From patchwork Thu Dec 8 20:35:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 13068865 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id A3032C4332F for ; Thu, 8 Dec 2022 20:35:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 449068E0006; Thu, 8 Dec 2022 15:35:11 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 3FA7A8E0001; Thu, 8 Dec 2022 15:35:11 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 189B48E0006; Thu, 8 Dec 2022 15:35:11 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 018458E0001 for ; Thu, 8 Dec 2022 15:35:10 -0500 (EST) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id C75E71A0207 for ; Thu, 8 Dec 2022 20:35:10 +0000 (UTC) X-FDA: 80220293580.21.B3FEAEF Received: from mail-pl1-f172.google.com (mail-pl1-f172.google.com [209.85.214.172]) by imf18.hostedemail.com (Postfix) with ESMTP id 2C6931C0009 for ; Thu, 8 Dec 2022 20:35:08 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=fvvYF98h; spf=pass (imf18.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.214.172 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1670531709; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=YC6lmTEI2DddOWPjuQmefmlclj4ZLY2oiewxsoGP1Vs=; b=hzdTHohW/mIeJm2qcs/ZsCvcLw2ltYJaRCH4v6J6Jr/Xv3hyb47ty2GYmznlZ6fqHNBF+s bCAiOzS/5qy7BcBVrJW5vurz6ADlIa886AUnCCKBDhR5v+vaGGnjG1S6Ej3t4j4m756Bpe YecjSJjm0X3a24m59JWcsAWZWKLf+4U= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=fvvYF98h; spf=pass (imf18.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.214.172 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1670531709; a=rsa-sha256; cv=none; b=yr5sKu9KtXlOULW6cbzZyBw6C7NURBZ+KEtKjVoVOTg5ldTx2005yMIL42xMpORHwg5MCX Tz54y3kwIHEmpYpQ/kgS4YXzF4TxPOdiA3MNVg2rLYNnehEzQtPTdM+jjx0FJ3ajRjvF+f /c50vo7iVLlbJe4oeJCEsebD0U3Plek= Received: by mail-pl1-f172.google.com with SMTP id m4so2684822pls.4 for ; Thu, 08 Dec 2022 12:35:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=YC6lmTEI2DddOWPjuQmefmlclj4ZLY2oiewxsoGP1Vs=; b=fvvYF98hTiJGOMFMCMtIoAJFjddR3ZNFHwcDPozFhzpj20s5sT2JGxRa4/JsoWeSxR 27O4Hyx3dB8flhxlRct4WhUwoyuhQ4DZa0fBQViceKnlJwnt1M4STuay8S1ELwivT4W5 JnFuebtJ/6heRA7futibraynFvgPzx5EmJuSPiVNpscBAw1y+0HX2KpqZedNdKX+q9A2 G7EH4P2kHgqJ2MivIeUQpAIzYMbDFn5k7YjhM+D7xCoV9xRpKYOEzznz3w9NL3P1rsBw zHlmiEQdjCjKY6pWfRpw9uokV7ZAai9Fv9pxWmVWIiS+vtmSBZa5JyP1KGX34V0TBLnw 9lhw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=YC6lmTEI2DddOWPjuQmefmlclj4ZLY2oiewxsoGP1Vs=; b=4mvsVZKRgxLd2KM52KJlcgVMV+svcaool5eFu+zVREIu5+FzqyYQ0119fcJl8Wjr9h YF5pj/AKmI2PRieAqwBIX8zun84VBJ0uBIpdFpCdvmb8N5qXSEgnvq66GuE+nPblNDWV CF4y+DmECfwPOcBJor3YvwFJCZeSV32ph6LzLRjJHq8O95ijdnECF7QJeONzRENrYVZr vDqwR3eaBIcK96kJmhcPRxn3vc26CZgbvYS1nsYnFA+IuQZrQAgO6DdEn49ZNN6izxyI PIZFUC5YmBC7VNsfHpwlbP3i7C6oHP8LAdLj4LRilfvxPUIwwF6xXwzE8zs/aI7ijwmP G+Tw== X-Gm-Message-State: ANoB5pmr7USvHzGNtK7vuTjz+65vCXJRRykfZkbnDGju6wHNOYgLR7dA WHSLOawcn40EGcFQNc39+9fV3G/AO14= X-Google-Smtp-Source: AA0mqf5DoA93piz5CVF9XnFBz7DCsU5iv2lttlOp9VDYowFUmIgZu7ivcuR8M/O6WoSa+05bardiCQ== X-Received: by 2002:a17:902:6a8b:b0:186:fb8d:f4d3 with SMTP id n11-20020a1709026a8b00b00186fb8df4d3mr3201464plk.5.1670531707818; Thu, 08 Dec 2022 12:35:07 -0800 (PST) Received: from fedora.hsd1.ca.comcast.net ([2601:644:8002:1c20::2c6b]) by smtp.googlemail.com with ESMTPSA id f5-20020a170902860500b00189951514c4sm16954349plo.206.2022.12.08.12.35.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Dec 2022 12:35:07 -0800 (PST) From: "Vishal Moola (Oracle)" To: linux-mm@kvack.org Cc: damon@lists.linux.dev, linux-kernel@vger.kernel.org, akpm@linux-foundation.org, sj@kernel.org, "Vishal Moola (Oracle)" Subject: [PATCH v3 1/4] mm/memory: Add vm_normal_folio() Date: Thu, 8 Dec 2022 12:35:00 -0800 Message-Id: <20221208203503.20665-2-vishal.moola@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221208203503.20665-1-vishal.moola@gmail.com> References: <20221208203503.20665-1-vishal.moola@gmail.com> MIME-Version: 1.0 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 2C6931C0009 X-Rspam-User: X-Stat-Signature: b956yh6wmkz6ajd3gcdxqreyr61a9ux6 X-HE-Tag: 1670531708-49841 X-HE-Meta: U2FsdGVkX1+Ete83Fg+NafLHqW9BXN0JNbwuqOHb+nftEueLW9btIQhn2PQhm5lQAFl1IsPXIFT51PzUf1fCoKnMwQAgxGdOOd9F6alBF9k5YOLAH8GOg7ykgcH2/Th8pkZ2RF0TtKzeLRpK/SEseNKWbvqM9PXgxLAtB/h0eEHzhE7Q/81AekSryEnJs1Ha+FxzfdUmbYCybULRQU1cjuncvpRsSonoHOBHakkO43I+EJG+Ja9KYjEhHEOqhao5V8VlgVoi+EDzBDVgseyILE0SkKgFDPijVZchRj0cmsZ8LiJTT4MoDbyKawPe1v0uVw7V+ASD/y3pheoTsw00goGDOPziRrwYQ7P0IuGiA1jd5jjJvxd2tsrnRXri6sA39nOEp2lGySWQX4HFVUXq5kJoIIMnn3GND+7S3hJLQ52AFrxK2chmD0A5cv9pqMvFTCZOptgUmK+1Ri5FICBjfuqWd5cGAH9Zv0qyzB0QzrZbsLzg31im04a0ojorNkf+6mhdogM+BginGi3KPVjukzm0PswBXUr44b5pgLqPvdR8xyHmjDPnzGrn5L3AdZZyZosWqudm28GT0rPcqBWyyJCPhodpMxiluVxBQyxet47ALwBu5Nb0/fb6zmYeyXXXQ+BGVG2+mJWHAG9AwJ8Nyo3dobmQo5VRIbtUn2v0EFz12GWtW2oFLkryuviFNvfhrcpaeFcFRy6ANHHBQF0BiFAM/KtUTstjewK1X0ChEYYOChWUZ2lxNaH5j/c5IPe5eplMFo7rVQhbUQxWCVavWFd9muWNY8yTOUx6XcYT79wcVW/u+oVefM0CN0xx9/+eoNk7+Ys8w46gNKl53TWIvCOPdLd0BBlkokul0e7i8fj1Yg1phyEcvZsGoQGozZnM+A4+ICG0zkIe4W/WFAAf6R9bm/2zUJ0ymuXbaeHnkwbEkDInfTg3bB/4g9l7wgVD0qWvtlhEuzoJCfrWcip SC04n0an 1h9xztOn46ymnEHNaZ5rjvPznV4G7BmwcD59MUkREXZSf8ZcKQqPIi2HL1JSo9LgbUQ/dX3/LAJCkGkvKhbbyRJv9/Jkzj632si3IChfn1K1UXVMwdG9B/AkiwyQpjtU1VpdmThBQi+979M3jsiSdF7WC5vUCzobKR/q0DrOyZPmqQ4erbw/6jAI6o+uNCx3oVFiEStcyeZ/AjAQDDQ8dXx70QGXUp6nsz7All5Iw2zVDnX8Jp4o46zo1xG1ThM/bZZShgiKzSMOb9UCMaEYI4aoXtA== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Introduce a wrapper function called vm_normal_folio(). This function calls vm_normal_page() and returns the folio of the page found, or null if no page is found. This function allows callers to get a folio from a pte, which will eventually allow them to completely replace their struct page variables with struct folio instead. Signed-off-by: Vishal Moola (Oracle) Reviewed-by: Matthew Wilcox (Oracle) --- include/linux/mm.h | 2 ++ mm/memory.c | 10 ++++++++++ 2 files changed, 12 insertions(+) diff --git a/include/linux/mm.h b/include/linux/mm.h index 8bbcccbc5565..626ae0757bd3 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -1860,6 +1860,8 @@ static inline bool can_do_mlock(void) { return false; } extern int user_shm_lock(size_t, struct ucounts *); extern void user_shm_unlock(size_t, struct ucounts *); +struct folio *vm_normal_folio(struct vm_area_struct *vma, unsigned long addr, + pte_t pte); struct page *vm_normal_page(struct vm_area_struct *vma, unsigned long addr, pte_t pte); struct page *vm_normal_page_pmd(struct vm_area_struct *vma, unsigned long addr, diff --git a/mm/memory.c b/mm/memory.c index f88c351aecd4..1247c19c516c 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -672,6 +672,16 @@ struct page *vm_normal_page(struct vm_area_struct *vma, unsigned long addr, return pfn_to_page(pfn); } +struct folio *vm_normal_folio(struct vm_area_struct *vma, unsigned long addr, + pte_t pte) +{ + struct page *page = vm_normal_page(vma, addr, pte); + + if (page) + return page_folio(page); + return NULL; +} + #ifdef CONFIG_TRANSPARENT_HUGEPAGE struct page *vm_normal_page_pmd(struct vm_area_struct *vma, unsigned long addr, pmd_t pmd) From patchwork Thu Dec 8 20:35:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 13068866 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id C49ADC001B2 for ; Thu, 8 Dec 2022 20:35:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 50EED8E0007; Thu, 8 Dec 2022 15:35:12 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 448A78E0001; Thu, 8 Dec 2022 15:35:12 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2C39C8E0007; Thu, 8 Dec 2022 15:35:12 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 1E6F78E0001 for ; Thu, 8 Dec 2022 15:35:12 -0500 (EST) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id E54E5120F97 for ; Thu, 8 Dec 2022 20:35:11 +0000 (UTC) X-FDA: 80220293622.12.1C1963B Received: from mail-pl1-f178.google.com (mail-pl1-f178.google.com [209.85.214.178]) by imf18.hostedemail.com (Postfix) with ESMTP id 3A74C1C0016 for ; Thu, 8 Dec 2022 20:35:10 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=NEepa2sC; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf18.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.214.178 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1670531710; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=wHUznzZJR/+2eFOYGxPgX5SObHA9uL1BQ/OTB3xHgrA=; b=ZhJiXYkk/bYm93ry0kPu8GMNPN+p+MIkkwbdw5/0LDVt7OrDWCWsNkly/Sr9xmQ20C3Kuh BsCdgm9zjUqqeFknzBQN0cU+ILg8RURdIE/iiEXCDqHeijKMDhIZV0Nw1+lh70SNA0lXdz jOSuMoWEaOcUS6/WnK0TSbpX9iGXOpo= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=NEepa2sC; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf18.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.214.178 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1670531710; a=rsa-sha256; cv=none; b=hyrZYImuhvKR0zzljlihz5wvrtvl1mHKCktCNBkw4RL5WRTkAIrOI/qJSFXPJDxwePwPLe YhGNPG9O5+642342IzfJ1DmWe4CgH7WOL4qGBV9r5usmVXtsQ1N7cq3+94IEBEuO2o+sOr c170f+Ujn4U7v3JmYhQ7/7sJDqziM/g= Received: by mail-pl1-f178.google.com with SMTP id s7so2680595plk.5 for ; Thu, 08 Dec 2022 12:35:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=wHUznzZJR/+2eFOYGxPgX5SObHA9uL1BQ/OTB3xHgrA=; b=NEepa2sCfJJvgnX3ejRFOGPrjMYmgXnKRjN5unAOsJ/tE/BFewdxSNeEpPh1ad1sGm sIvarvzBcw9Q3fQ8zNawaQb5T7z+NwATAYhUr1/Zzfia5k8LSv8jP7nLAWj12z2ly+ZT f1GUI5W5sCMhxUsXXmc3IaXRX1EDRvErMLIqll3a5CVIKNBy+z+Ps/lbk08QQ9KaT7Xk XnMYibTX66/3+am1vVR/kGAVRT7Ww4h9duW2iIIY993dThq5e7aPSkAMZ/4u08o/kpj9 hMuvayRPzWZ61DFZfjIkSk7CofF4B5i1NolYOU2OWLJeiOsFr0kMvqfSPwlc83/zYe2K Aagw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=wHUznzZJR/+2eFOYGxPgX5SObHA9uL1BQ/OTB3xHgrA=; b=QpPuF2jsLXwVQyh3ecQHSxXqfS63x6hv00j8ELsFNOrCaSdgJGB5W08k6pFBKHHyR5 u1qdt5WT5vYsEL4QG0pibtVusOnRa+2Xk5v6R/ieYYJSa6iSqdxLV/YrGqDxS3pjHNAQ qT72mFU7zWrQOWb98LDixdt4yfFUcrnnbkTgohvTXop8m59ZeBuTceuSzq7nH4v3fnU3 BK9muRJ9jUM7IG+YSZoKHGHO4teJGQADIlVsgy1DmDUqb5nRFNSkWsVA8m1fNy/B9vUh smaR4LD6frTDuHdKEmDJRxKSTk0Y+XQlh1POe07SK89X/GMNGrok51/2j4whwAzE1sAY Gv7A== X-Gm-Message-State: ANoB5pm8/VQRgZ59E/9hCGCOT5ifJTDoMxeZRY29Ge3dOFJ9ylzm+RT6 U0LJrFt4xvdhd6to85X8QL4wRM55tac= X-Google-Smtp-Source: AA0mqf5+O1BZXrE1YEC4dz/Cxj4pggZ4XHVB3Kve73sA6I4CTYSn6JfKCq6XbOm2qlu7J9B/7TW1zQ== X-Received: by 2002:a17:902:d58a:b0:189:a11e:9995 with SMTP id k10-20020a170902d58a00b00189a11e9995mr3527512plh.13.1670531708818; Thu, 08 Dec 2022 12:35:08 -0800 (PST) Received: from fedora.hsd1.ca.comcast.net ([2601:644:8002:1c20::2c6b]) by smtp.googlemail.com with ESMTPSA id f5-20020a170902860500b00189951514c4sm16954349plo.206.2022.12.08.12.35.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Dec 2022 12:35:08 -0800 (PST) From: "Vishal Moola (Oracle)" To: linux-mm@kvack.org Cc: damon@lists.linux.dev, linux-kernel@vger.kernel.org, akpm@linux-foundation.org, sj@kernel.org, "Vishal Moola (Oracle)" Subject: [PATCH v3 2/4] madvise: Convert madvise_cold_or_pageout_pte_range() to use folios Date: Thu, 8 Dec 2022 12:35:01 -0800 Message-Id: <20221208203503.20665-3-vishal.moola@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221208203503.20665-1-vishal.moola@gmail.com> References: <20221208203503.20665-1-vishal.moola@gmail.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: 3A74C1C0016 X-Rspamd-Server: rspam09 X-Rspam-User: X-Stat-Signature: iio7y77rehp1q6zcuo4kxm7bcdktgfu4 X-HE-Tag: 1670531710-766526 X-HE-Meta: U2FsdGVkX1/P1laHjfSzD148d5gG/JERtsAztoCU9VZkLIKRDVFy1sOJHy/UgWnY2Sce+p9Kwzb9kwf+FnrslN6nYRbAKp1vCJaoE9S8Ri/TvmPyDWW12QJ3SwLMgNb4ArEVHC2oKnXmk9Ma3nEp/tx8oFpcD87xgY3HXNfElknBKkCChAw/CaaS9DTzZsVVXSe5qX9H7Dj8pr6mwVO1cw0d6U6LMHh3AWl7U12vfA1uPHwL6YlyvYE63uOY+HQ2Fc16lGaIH/QXmRNZV6i9ilcCPqtaHZMH5oTJtEsLq7lO2rFrO6xM8+g86hpA34FYQ355k9PaRN9VQ+j8SyqUbOztPRcXQzT3YLnLaiO2bao+fs+kJGbiyLV8MA+0Xa+jadZUAQYwcdm0XeZqICpKZ0eP6/22exoX5ceNZsovbyb866KxA6SC64h3gmsqECnOphlj3CWtzwm95fpE/np1GXVIXkxyZzddHywNxMfyzr1KPUhwqnL/az1AAezzhXX8LkZbETkkbkbL0EeRHV8DM6Y/VZGORFVI9DWMkL1oybSnQ5gUf18Z6vBFUqa3jYh9i1vOd4Qw0F675Jjlf7NwVrwAsK72c5WNBVkWDpaHwgzOKL1Cq55GVytOvyyNBQ+rnnzBCZmbiiyKE4pL0Y9GqT28vwhFfe0rx4snltBHIePdp0dZ9hM/KAxoXducfKdErFQaJcFu9+VlaSa1dnx0wekewaLwHkMM7b6ZSvY1KGq0Op75N25LFK8AC7NFAwEQ7N+DQUpWRXmUdbdM4nIrtGnO3HQZvHln3QnchIpfuQxmruu50ldYnt8xuiZg98WrBWNRmmWWJYLM0GnbwMsuRBqvUz1gbXNOLF1JPSr6VfgYPEQR2pvTpNv1Z11bwk7hp5/EBn1ODa6YpErGeV/g8ISS3gGM0k/tSNVkP0Tt+bBypL2VVbUN7Wv594XQs2FQJd8bb8PBDgtSnwJ56Pz Th6tp7j7 t02k9LbpM9BO4VRhel04sYLxw1aEaPT1vulaxJn15uJN+CWmzC+Q5oii0duNcPew7f0eeOiyc6RFn2cPgb3PNEOTQTbfuGL/iuwdhdCp8ReTHD+hM8rR8OLm/gI5CuoYRT4RDlP3/g5f7f/zP24yEwBXd8U2AnAHiKlVTumXed3vV5JKEZi71xBni4NzMrXWRzIkkrLeEYV+AgnFT+p0FMzLQQBfXKrXJC4eaHD0v6h5prDID/+Xi7QCgnAO4U9xL/8dWizhmhSj7ATvt44G3UFgh7A== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: This change removes a number of calls to compound_head(), and saves 1319 bytes of kernel text. Signed-off-by: Vishal Moola (Oracle) Reviewed-by: Matthew Wilcox (Oracle) --- mm/madvise.c | 92 ++++++++++++++++++++++++++-------------------------- 1 file changed, 46 insertions(+), 46 deletions(-) diff --git a/mm/madvise.c b/mm/madvise.c index 2baa93ca2310..2a84b5dfbb4c 100644 --- a/mm/madvise.c +++ b/mm/madvise.c @@ -332,8 +332,8 @@ static int madvise_cold_or_pageout_pte_range(pmd_t *pmd, struct vm_area_struct *vma = walk->vma; pte_t *orig_pte, *pte, ptent; spinlock_t *ptl; - struct page *page = NULL; - LIST_HEAD(page_list); + struct folio *folio = NULL; + LIST_HEAD(folio_list); if (fatal_signal_pending(current)) return -EINTR; @@ -358,23 +358,23 @@ static int madvise_cold_or_pageout_pte_range(pmd_t *pmd, goto huge_unlock; } - page = pmd_page(orig_pmd); + folio = pfn_folio(pmd_pfn(orig_pmd)); - /* Do not interfere with other mappings of this page */ - if (page_mapcount(page) != 1) + /* Do not interfere with other mappings of this folio */ + if (folio_mapcount(folio) != 1) goto huge_unlock; if (next - addr != HPAGE_PMD_SIZE) { int err; - get_page(page); + folio_get(folio); spin_unlock(ptl); - lock_page(page); - err = split_huge_page(page); - unlock_page(page); - put_page(page); + folio_lock(folio); + err = split_folio(folio); + folio_unlock(folio); + folio_put(folio); if (!err) - goto regular_page; + goto regular_folio; return 0; } @@ -386,25 +386,25 @@ static int madvise_cold_or_pageout_pte_range(pmd_t *pmd, tlb_remove_pmd_tlb_entry(tlb, pmd, addr); } - ClearPageReferenced(page); - test_and_clear_page_young(page); + folio_clear_referenced(folio); + folio_test_clear_young(folio); if (pageout) { - if (!isolate_lru_page(page)) { - if (PageUnevictable(page)) - putback_lru_page(page); + if (!folio_isolate_lru(folio)) { + if (folio_test_unevictable(folio)) + folio_putback_lru(folio); else - list_add(&page->lru, &page_list); + list_add(&folio->lru, &folio_list); } } else - deactivate_page(page); + deactivate_page(&folio->page); huge_unlock: spin_unlock(ptl); if (pageout) - reclaim_pages(&page_list); + reclaim_pages(&folio_list); return 0; } -regular_page: +regular_folio: if (pmd_trans_unstable(pmd)) return 0; #endif @@ -421,31 +421,31 @@ static int madvise_cold_or_pageout_pte_range(pmd_t *pmd, if (!pte_present(ptent)) continue; - page = vm_normal_page(vma, addr, ptent); - if (!page || is_zone_device_page(page)) + folio = vm_normal_folio(vma, addr, ptent); + if (!folio || folio_is_zone_device(folio)) continue; /* * Creating a THP page is expensive so split it only if we * are sure it's worth. Split it if we are only owner. */ - if (PageTransCompound(page)) { - if (page_mapcount(page) != 1) + if (folio_test_large(folio)) { + if (folio_mapcount(folio) != 1) break; - get_page(page); - if (!trylock_page(page)) { - put_page(page); + folio_get(folio); + if (!folio_trylock(folio)) { + folio_put(folio); break; } pte_unmap_unlock(orig_pte, ptl); - if (split_huge_page(page)) { - unlock_page(page); - put_page(page); + if (split_folio(folio)) { + folio_unlock(folio); + folio_put(folio); orig_pte = pte_offset_map_lock(mm, pmd, addr, &ptl); break; } - unlock_page(page); - put_page(page); + folio_unlock(folio); + folio_put(folio); orig_pte = pte = pte_offset_map_lock(mm, pmd, addr, &ptl); pte--; addr -= PAGE_SIZE; @@ -453,13 +453,13 @@ static int madvise_cold_or_pageout_pte_range(pmd_t *pmd, } /* - * Do not interfere with other mappings of this page and - * non-LRU page. + * Do not interfere with other mappings of this folio and + * non-LRU folio. */ - if (!PageLRU(page) || page_mapcount(page) != 1) + if (!folio_test_lru(folio) || folio_mapcount(folio) != 1) continue; - VM_BUG_ON_PAGE(PageTransCompound(page), page); + VM_BUG_ON_FOLIO(folio_test_large(folio), folio); if (pte_young(ptent)) { ptent = ptep_get_and_clear_full(mm, addr, pte, @@ -470,28 +470,28 @@ static int madvise_cold_or_pageout_pte_range(pmd_t *pmd, } /* - * We are deactivating a page for accelerating reclaiming. - * VM couldn't reclaim the page unless we clear PG_young. + * We are deactivating a folio for accelerating reclaiming. + * VM couldn't reclaim the folio unless we clear PG_young. * As a side effect, it makes confuse idle-page tracking * because they will miss recent referenced history. */ - ClearPageReferenced(page); - test_and_clear_page_young(page); + folio_clear_referenced(folio); + folio_test_clear_young(folio); if (pageout) { - if (!isolate_lru_page(page)) { - if (PageUnevictable(page)) - putback_lru_page(page); + if (!folio_isolate_lru(folio)) { + if (folio_test_unevictable(folio)) + folio_putback_lru(folio); else - list_add(&page->lru, &page_list); + list_add(&folio->lru, &folio_list); } } else - deactivate_page(page); + deactivate_page(&folio->page); } arch_leave_lazy_mmu_mode(); pte_unmap_unlock(orig_pte, ptl); if (pageout) - reclaim_pages(&page_list); + reclaim_pages(&folio_list); cond_resched(); return 0; From patchwork Thu Dec 8 20:35:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 13068867 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6F947C4332F for ; Thu, 8 Dec 2022 20:35:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3D76E8E0008; Thu, 8 Dec 2022 15:35:13 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 310BD8E0001; Thu, 8 Dec 2022 15:35:13 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 162188E0008; Thu, 8 Dec 2022 15:35:13 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 076408E0001 for ; Thu, 8 Dec 2022 15:35:13 -0500 (EST) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id DD6A2140B94 for ; Thu, 8 Dec 2022 20:35:12 +0000 (UTC) X-FDA: 80220293664.30.6E49CAD Received: from mail-pj1-f44.google.com (mail-pj1-f44.google.com [209.85.216.44]) by imf08.hostedemail.com (Postfix) with ESMTP id 1CC8C160007 for ; Thu, 8 Dec 2022 20:35:10 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=Ii3vt0qJ; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf08.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.216.44 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1670531711; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=Ihy8jPmuCwZF2NUxckyF8mvKKJAfgGLMAeVZly3BYIQ=; b=UCmW1PLP+yHFTTBEUPTjM+8m8yai+L9mReEJOYHPKpWtk57c5k866vGV9G8hVeEt0JllIP uyscD8W+rtNh4X5yRmzSq26RsX5RMg9CmJrqv6S47d+TS04mCWWPEx+k/l8kobqlrCHLdx K74Xr5SFlEeQkFDP+IUeEnicV7Nt2/o= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=Ii3vt0qJ; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf08.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.216.44 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1670531711; a=rsa-sha256; cv=none; b=Bvrx5K9SKXjky0lUDdk76GpqNXGICuWxL8VyQxLbnogWgV/CtmdFZo7aMF2HtjOoRzokV9 C6Vs5Gb0zaCbwdEd8CilqWIJa/bBH0Gl9eiArxJmvZFv0az8pJu4yJc2wDvdT5CFTGzNVr QYn4g+NXxriTK8Og71/QA7DbTvas94A= Received: by mail-pj1-f44.google.com with SMTP id v13-20020a17090a6b0d00b00219c3be9830so2728961pjj.4 for ; Thu, 08 Dec 2022 12:35:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Ihy8jPmuCwZF2NUxckyF8mvKKJAfgGLMAeVZly3BYIQ=; b=Ii3vt0qJdv0V25/feuGUMH7PzkflNrD7g8L2x6z6/EYO9gzRto4zD8ZTJENpqeU8XP gLmydlYQJhHXfGq9y5BeriBDQ11jeq2TYMS4ysPrNZ9lPX61JatrrzxhNPq8b43OY+1j ptjf++BriBBDjvyJBWStE5HuQ96Co+07MfQnvCs2OW/l8Fnd4dMK7S3wmVg9uQ10eoQe daaPLy51OxzLCvTwyZhN2Miw3T/m5LTvMPAIzD6bUUY+4EQQU/bJ69w/ZA8Q6XpK5xLy SxVqHOiUx+drkxy5pADNtrFlAQV+RXgMmv1emA5DGz0XXWcWdkZMZTar5/QzNUuvgqaX Bdxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Ihy8jPmuCwZF2NUxckyF8mvKKJAfgGLMAeVZly3BYIQ=; b=6w9tVGT3Q14rPr+qPQiufFzvpgWZ9GiPUFpIqSwLgg5z39YwIyHa7JExQIXJExnAwV 5gxLqTJTRsCi/9fH5TwOJXthKV9V4EjB2IdYx2H7815Py7GcGDXz7BLgCRM14VYIEnLP 4kT63KZnpFlEmtf8vShHncrqw9ZCoOJKAxf0InzPG5ah0BbpbM4HRAjdkW0ywfJBfRwI Lm0GuGXm/RVbIiGUbpNiS5Azt/BYTSDKS0XTt7Ifab4YWb45ZiJS/y98QOA85LFe+8bK VxaURwVsSVZIpE+unv0pNCn5mHm2+BUePn3OxsKjgH3jeSBEjVSHTWg6yHQJtsfBxkeS fXNw== X-Gm-Message-State: ANoB5pnwPqHJF2aaQyegImwB1ZWwjvsLdqb74jQx5kozCmq27BF+FvoK WyznXjpL60QEK82N5lsbcmMupx2XY+g= X-Google-Smtp-Source: AA0mqf4+5Zv1Qu99xU00p+xkeABzV897h+Xfstc+913jbdXvjz2pIi2b+ZYYSdFCNInv+po5xPqf2w== X-Received: by 2002:a17:902:e806:b0:185:4421:72e5 with SMTP id u6-20020a170902e80600b00185442172e5mr3989355plg.42.1670531709851; Thu, 08 Dec 2022 12:35:09 -0800 (PST) Received: from fedora.hsd1.ca.comcast.net ([2601:644:8002:1c20::2c6b]) by smtp.googlemail.com with ESMTPSA id f5-20020a170902860500b00189951514c4sm16954349plo.206.2022.12.08.12.35.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Dec 2022 12:35:09 -0800 (PST) From: "Vishal Moola (Oracle)" To: linux-mm@kvack.org Cc: damon@lists.linux.dev, linux-kernel@vger.kernel.org, akpm@linux-foundation.org, sj@kernel.org, "Vishal Moola (Oracle)" Subject: [PATCH v3 3/4] mm/damon: Convert damon_pa_mark_accessed_or_deactivate() to use folios Date: Thu, 8 Dec 2022 12:35:02 -0800 Message-Id: <20221208203503.20665-4-vishal.moola@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221208203503.20665-1-vishal.moola@gmail.com> References: <20221208203503.20665-1-vishal.moola@gmail.com> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 1CC8C160007 X-Stat-Signature: 6xuekrt6rxu7hineyiurydnp8kwyqsqh X-HE-Tag: 1670531710-367000 X-HE-Meta: U2FsdGVkX19UlkaSLgX7udvNp/9v5vTBDnZDN6gDB/4v1AIqqZtU17f11cbdgpduLKm2wiA9KNC9HbTgk+Q3gIYz1CMTBhjzIHf0G8h/JsAYUmGbum1ZS8nGrvhglChdzm8OAO8ex0S1G8dBG+Mv7n29AxYyHOkXmYWSGz9zbLg0lnv3RRF8vbdXYdvL4SmL8SXDbV/dJnUyKp5vGpipMj+gDH6SYg7GSI6CQr/n5TCNzPsmp0ZcyHt6Ri2QQDSO873+zjsBnv75EW9almT+Saey9gnOuMS5Yh3UJwdBw2ujCDY++UcyjrTmXomw7FgoIK69Y/l4YX7bvDvJ8yOd+NWy/vLp4YbJazP/c06nE6QRf9i8oQiXLvvOx8baPQY8zHsFir1kf80xfbc9zRSOGFtIkgv3soymXT0VHneKoi8m+IPIViET9UC/oio7O/Fw6RQzj04tsfpFhKhlSvQ+uKOZqIHNCeWYIM+5SHBB+Fgq/ixEpWQ+OSHl00agatcOe6UThAA2E+221FwjkDCxlPyAdCt4fogg5MK62HVReiVq1b+7KkMfnTm/dt6btyv5yf4b8zidTfHWBEt2QQvGKwTneRU8/dHSy7Yz5R51AJs8bBPHk5UnydJHq8WeV4sENspqf+1P6MydyTIiKzbw06wjZRaRA3LgaTTppc2PL/9dZKL3eld0ORmklYK8wMXUpZ4UpMOkoRYz/UgoVTjoFEVZnyG4E7w4J8ZOa2rtwtduILSmVjhAuUipo+1NatzOmb5ZKJwsP3gfidGHKgLsDAVzRBMbXS0reeW2CM4wZ5eIDtNh0yPnLF7KGjcvtMhB4J4ZDw0E/DZPGPzn8pdG3a3dvUCcs0B1jK9vjeEVGVMHFjeUyp6BGR/m1Sa275PyzEBhGxsriuDNp6WVMeCDQCw82crP+lAvncx3LxWMJYNlPHYDtIqtQCLnRDYAmN4aWYd/lmcX4e0Y3r0KRRj vyp2RRzB Hoam/myVSJ2tBaRxQcW+VXRSbvQesu30EN+0gcciNwD4AWaCW5aMymxE8ojcEsTJ0TpSFTeNTrZC+3tJDazGbekLRFq/7PCxfhvqy41z440fCszP4Arg5Qfp4EJ85vgxxiRhsDmA/ZQtrTTZ5qvcGBdn5wBfbPfHkUoVUFJmYtzyQfhuRLMSqjvCd4FSed+CEYub7f2zhLu4kvPgCsOjpJQmQlZriuoVAEp98RbilUhGPuelCt6XU6oReaflkV+dOxZnNKhw8QSqxEP/WGPBTKeRs3w== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000011, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: This change replaces 2 calls to compound_head() with one. This is in preparation for the conversion of deactivate_page() to folio_deactivate(). Signed-off-by: Vishal Moola (Oracle) Reviewed-by: Matthew Wilcox (Oracle) Reviewed-by: SeongJae Park --- mm/damon/paddr.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/mm/damon/paddr.c b/mm/damon/paddr.c index e1a4315c4be6..73548bc82297 100644 --- a/mm/damon/paddr.c +++ b/mm/damon/paddr.c @@ -238,15 +238,18 @@ static inline unsigned long damon_pa_mark_accessed_or_deactivate( for (addr = r->ar.start; addr < r->ar.end; addr += PAGE_SIZE) { struct page *page = damon_get_page(PHYS_PFN(addr)); + struct folio *folio; if (!page) continue; + folio = page_folio(page); + if (mark_accessed) - mark_page_accessed(page); + folio_mark_accessed(folio); else - deactivate_page(page); - put_page(page); - applied++; + deactivate_page(&folio->page); + folio_put(folio); + applied += folio_nr_pages(folio); } return applied * PAGE_SIZE; } From patchwork Thu Dec 8 20:35:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 13068868 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 914A1C4167B for ; Thu, 8 Dec 2022 20:35:15 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 890988E0009; Thu, 8 Dec 2022 15:35:14 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 840738E0001; Thu, 8 Dec 2022 15:35:14 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 61E228E0009; Thu, 8 Dec 2022 15:35:14 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 4D8A68E0001 for ; Thu, 8 Dec 2022 15:35:14 -0500 (EST) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 1E499AB6C3 for ; Thu, 8 Dec 2022 20:35:14 +0000 (UTC) X-FDA: 80220293748.22.0C4EA30 Received: from mail-pj1-f53.google.com (mail-pj1-f53.google.com [209.85.216.53]) by imf10.hostedemail.com (Postfix) with ESMTP id 64C55C0014 for ; Thu, 8 Dec 2022 20:35:12 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=iWudK4xr; spf=pass (imf10.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.216.53 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1670531712; a=rsa-sha256; cv=none; b=F1APTdjWxnR1wJ+OXWfBejwsWKg5Cu/A4X9L9ktWNU8aNPtBOLR6Wrgb59E5lZSdBxL/xC qaaoRuUz8GBm2Cm0dAJhb0hsMrUrf2t62iNGBeLAXeG40FdVAYsOLvzUsNjRaaY2nhwMHu dOuFC998E08C+4jWwvITHb8qT8M96Uw= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=iWudK4xr; spf=pass (imf10.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.216.53 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1670531712; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=IgIdh8nt+mq77dQQNk9/S7rfV6TiIO4QqyG3Sqp+yaY=; b=YoT7oMPYGHTDQ4YmosYm8GCmlzp1aCXlwwMZTHxuZkNuLUA4Vr43QKzmmjRitj9VpSvn7l xmLbV1p7T5cCgoM+SjjYA8pV8wGwsAs3AKglH0QktJUZiiP1fsDyIA3yiUxM8EzcAxNO2Q Hh1sp0h+GCcIPiEXRWvs/Cq/bvVOcIU= Received: by mail-pj1-f53.google.com with SMTP id q17-20020a17090aa01100b002194cba32e9so5878528pjp.1 for ; Thu, 08 Dec 2022 12:35:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=IgIdh8nt+mq77dQQNk9/S7rfV6TiIO4QqyG3Sqp+yaY=; b=iWudK4xr8eyn/01wdfoGvrxyUZ3k1Zp/c9SZe2LcNl4BOQDgNz1rrGJo+5CwWhbxsB ekFj/Vx5q+l+Er2zXRcjiwwJ7Org396Wm7q4Qi1iKNkG/8p8agHenkkce3pEZ2WWcyJv HWDgSY5KjyzddNWRNvF5+ItpMrECfjvrPJdosOTLsMFYLgac6nNGyRFOwiYuGbaC2MoE dbZNnKV4+iKB3vUXa9waapqdDgJkv+WDMARouAaHEBewwulZ+Bj8Q56TL7piK4KIKDcW C3m6/Gz0ZDe4U3xG2q8ctJWNYAp/WE2rQqaalZBdrEiETAX6nj01t2ihO7VPs3yUYnGw tn4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=IgIdh8nt+mq77dQQNk9/S7rfV6TiIO4QqyG3Sqp+yaY=; b=1nMEcu5UzicGNV58aFDrT83JXe4kNSba4Cs+QrxqRPdwC30sFQti5QQJMXJMgZW0JH YyiUjSC6blLWUlFAuOxnRhT8v+0qstl/YO/D4P5GV4AKumBsrbDVTqwrrCdzDEf8u+I4 JHXCWUal1+g0cC2Lc3Tgg9Mks9qqDsLLA4Ibl8JJ0pRj/fuJBt5XtrmfLST8KGPSnofH tryErC+dhaSEcu7CdsbR5R/t4wL0tnJ/80pJfBVfTeZ9YDjKVK791dFYlRnnCxHNXBz2 yoURYARwF1yCX5Abpb1RoE0JzxJfRWjJrMP5oI/KzsNdLx+3kqmvkjt7nhW8dIKszeZO H+2g== X-Gm-Message-State: ANoB5pkVtDQFZP/q+v/HJoeTHj42d8JDJ3lQ8kKI7o5mXpeH0R5Y7uFM UwycsD01UWAP/ye8m0SsKEbo6lCho4A= X-Google-Smtp-Source: AA0mqf5LuEF6hw5v4QfYtY1YTYCQswEq2LvxbAKaP13F6C+lHoQVP968dI3AQN2b+rJ2dSyg/9P1qA== X-Received: by 2002:a17:902:b289:b0:189:70c1:4ff5 with SMTP id u9-20020a170902b28900b0018970c14ff5mr3560139plr.37.1670531711111; Thu, 08 Dec 2022 12:35:11 -0800 (PST) Received: from fedora.hsd1.ca.comcast.net ([2601:644:8002:1c20::2c6b]) by smtp.googlemail.com with ESMTPSA id f5-20020a170902860500b00189951514c4sm16954349plo.206.2022.12.08.12.35.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Dec 2022 12:35:10 -0800 (PST) From: "Vishal Moola (Oracle)" To: linux-mm@kvack.org Cc: damon@lists.linux.dev, linux-kernel@vger.kernel.org, akpm@linux-foundation.org, sj@kernel.org, "Vishal Moola (Oracle)" Subject: [PATCH v3 4/4] mm/swap: Convert deactivate_page() to folio_deactivate() Date: Thu, 8 Dec 2022 12:35:03 -0800 Message-Id: <20221208203503.20665-5-vishal.moola@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221208203503.20665-1-vishal.moola@gmail.com> References: <20221208203503.20665-1-vishal.moola@gmail.com> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 64C55C0014 X-Stat-Signature: j1es8g18dccncoppngtkp3s36i6y493t X-HE-Tag: 1670531712-376688 X-HE-Meta: U2FsdGVkX1/BMLBFM5Ybkwf1f5cU5ljCh8Zh5MHVImDltm21wXOIREdQUilAqlbEOJnYpuuVm6gKsJhXG92ImoaiudgiHdQjkBvb3cQrk4ByRIBYj8c499U/IHOU5fKXtXAg81qK/g7iq8lhUeygmVFb9jIVa6/AZINeKPIdax1Dry6fLxJNmCnvZ1bQ1yQaNK5JhNovp0lektirUNkgQqzrLtKgFkHogJVDX1SGRpahpQno/5LOn3ZCKGE+1f4zfTNfoZzmNFx2Oo/QKwbNZeFOUmzUzNksL5yUIKlvW6tpPDBNXYeA3KniLe/aPdPk/UHx2/jKcrOGmDdPBegGlBK+COmH4RDHcRan8khhP7cLelTcrgWowmzDZdMPkp+3RbM7DK0VqRBLI+DUKaiz+eOPCPHGmWyuRvRaQwlHUWC+ttV2nKU9tEC++rIW+qUWoFKJoEulPYsWnGzrzfAAghPx8iXWjMxsBoWEu8vinllwesnDmZ/vPwpFoKi0D2n12O6Gqfv4cGl+FuhAQYL9hNZJY9vK8LqP4/FapCA+S5+sBj4GqV68NXZThOUD7tdrQp5N26bp7E5d0X+nGSO1PGMpGd1USv5tCFlhS6+39VBquZo5vxBr7LNiROtW0Ck3GXcnylHrAm4Zcw/N+Ze7hdO3dh0iDULSPOX5kers5oFum0AKU5AWfP2dPMHIm+tsClM9C/bgY6t27F5uCdsZ4r435CpqmUSGGqpDRDS+YzUZW4eyYj4NQV8hkswpnJ90Oz4259A0wxkbKV1hdKi+KqY1uRdwbl9+Fhnq2xR9qjZcB/fryfagZBh3w0quRrVVmYE7nIjxLxPz73/2p5QP4IDF66Au9u470erqEvNovxanfPHc8zk7543TgTJt+dtDKahiTAiuEvc+v/nL2dmIPRsQmF5mZ7jvcIjcWNKTC27cbwM3K3U5bLxpKIfp4Br+eon3pEuB/N0QJjkhI1Q vBCMBVNX hj/MhzLwQM3liTD9IT3KzOoakHWHQIQ3fx0p+GhXeuf+5BMUtCVgcKWCYQnMUrKClmK4ba2/Q3Qlj75IrsZkhOsBvcjJeeA4tDm/6wHkIMudrMxyr4KefJw2EGFlU6aQxHatp9q9IhXTMcJXwWRm26P9XfYE99+AGkzZEIDAN7Dbh0KuD2RTZxxsW9pnY6FUvtaqVLKh3snEEBx0hZoU+9StqfQ4e3l5YBWeDHw6TdZjeDPHg4Plie65AhxeA6ixzuJgUTL4xjDZ/3AuYpULrlpAsBQ== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Deactivate_page() has already been converted to use folios, this change converts it to take in a folio argument instead of calling page_folio(). It also renames the function folio_deactivate() to be more consistent with other folio functions. Signed-off-by: Vishal Moola (Oracle) Reviewed-by: Matthew Wilcox (Oracle) Reviewed-by: SeongJae Park --- include/linux/swap.h | 2 +- mm/damon/paddr.c | 2 +- mm/madvise.c | 4 ++-- mm/swap.c | 14 ++++++-------- 4 files changed, 10 insertions(+), 12 deletions(-) diff --git a/include/linux/swap.h b/include/linux/swap.h index a18cf4b7c724..6427b3af30c3 100644 --- a/include/linux/swap.h +++ b/include/linux/swap.h @@ -409,7 +409,7 @@ extern void lru_add_drain(void); extern void lru_add_drain_cpu(int cpu); extern void lru_add_drain_cpu_zone(struct zone *zone); extern void lru_add_drain_all(void); -extern void deactivate_page(struct page *page); +void folio_deactivate(struct folio *folio); extern void mark_page_lazyfree(struct page *page); extern void swap_setup(void); diff --git a/mm/damon/paddr.c b/mm/damon/paddr.c index 73548bc82297..6b36de1396a4 100644 --- a/mm/damon/paddr.c +++ b/mm/damon/paddr.c @@ -247,7 +247,7 @@ static inline unsigned long damon_pa_mark_accessed_or_deactivate( if (mark_accessed) folio_mark_accessed(folio); else - deactivate_page(&folio->page); + folio_deactivate(folio); folio_put(folio); applied += folio_nr_pages(folio); } diff --git a/mm/madvise.c b/mm/madvise.c index 2a84b5dfbb4c..1ab293019862 100644 --- a/mm/madvise.c +++ b/mm/madvise.c @@ -396,7 +396,7 @@ static int madvise_cold_or_pageout_pte_range(pmd_t *pmd, list_add(&folio->lru, &folio_list); } } else - deactivate_page(&folio->page); + folio_deactivate(folio); huge_unlock: spin_unlock(ptl); if (pageout) @@ -485,7 +485,7 @@ static int madvise_cold_or_pageout_pte_range(pmd_t *pmd, list_add(&folio->lru, &folio_list); } } else - deactivate_page(&folio->page); + folio_deactivate(folio); } arch_leave_lazy_mmu_mode(); diff --git a/mm/swap.c b/mm/swap.c index 955930f41d20..9cc8215acdbb 100644 --- a/mm/swap.c +++ b/mm/swap.c @@ -720,17 +720,15 @@ void deactivate_file_folio(struct folio *folio) } /* - * deactivate_page - deactivate a page - * @page: page to deactivate + * folio_deactivate - deactivate a folio + * @folio: folio to deactivate * - * deactivate_page() moves @page to the inactive list if @page was on the active - * list and was not an unevictable page. This is done to accelerate the reclaim - * of @page. + * folio_deactivate() moves @folio to the inactive list if @folio was on the + * active list and was not unevictable. This is done to accelerate the + * reclaim of @folio. */ -void deactivate_page(struct page *page) +void folio_deactivate(struct folio *folio) { - struct folio *folio = page_folio(page); - if (folio_test_lru(folio) && !folio_test_unevictable(folio) && (folio_test_active(folio) || lru_gen_enabled())) { struct folio_batch *fbatch;