From patchwork Sat Jul 15 04:23:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13314376 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 E0EDEEB64DC for ; Sat, 15 Jul 2023 04:24:01 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 623E86B0075; Sat, 15 Jul 2023 00:24:01 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5D3DA6B0078; Sat, 15 Jul 2023 00:24:01 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4C5656B007B; Sat, 15 Jul 2023 00:24:01 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 3EBA86B0075 for ; Sat, 15 Jul 2023 00:24:01 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 104F3A0101 for ; Sat, 15 Jul 2023 04:24:01 +0000 (UTC) X-FDA: 81012553482.26.8011E96 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf14.hostedemail.com (Postfix) with ESMTP id 73825100012 for ; Sat, 15 Jul 2023 04:23:59 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=iY960qup; dmarc=none; spf=none (imf14.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1689395039; 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=7FLmcjaPLpEGscatrzN5qp/wg/vDvmkauQ9Fg4Em8sE=; b=b/6kp13z+22Itf184HuobdhhFT0AtPYtGJ0aiEJvm7fOVD0JNef33tZD1uLQKXl253fM6h 7vRnAsPqSbpdiSsdfxKMbDDe0OOxd55RR4yVyfiJe4Oxhv5Ea7telUmF8/i2m+i9QQ9/R1 jkils5vIDgR2VIK3XLzay4qyQ2ODCps= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=iY960qup; dmarc=none; spf=none (imf14.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1689395039; a=rsa-sha256; cv=none; b=8EeB8qW2Iklrki6J8/wnDsGlvfS5W5+/Q2V/sk1I7AYjBsSpVJemLDFkzgfm2jxgUz+gyr 7jQ6omWuMI+6F30towY/PjZtTy3Vxjbss1iWiSzNiaumDeD2I22n+6RoDub0+Ag9p1CDRK khlY/oEMRz896nT5uc2qfy4ZsV7yUNk= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=7FLmcjaPLpEGscatrzN5qp/wg/vDvmkauQ9Fg4Em8sE=; b=iY960qup3GgE02Qc8hTQi0rsqK 1ig2TdspYQRUVHvoQt0nYZglzQb8SzK09LJYGooF+YhYJNMDQfkdNavbCcUqjtON2iqPn2rTz8wvB 7KuwGjoADJqAgCESw9WNyWlZIgqcucnRFkF9WP9FiDf4+JvcqeDxSDFmo7AC3nsFFvRkrzZONP3// KTyRt7nwOQkqoKa1gdOzKn7fWbA15RC45913fcCB6Rm2VvPZzeoyj2Zw6Ao44b2+uHnoijdO9txwe uSbSfquHsw7enKXdBl8oSCYKtQFN5vU2Ve9v1r3lr+yC+tFwCpMLrh4Lia4dF0C1WlSJJY7Ep1D5w 8PnT856A==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1qKWos-001p3s-GU; Sat, 15 Jul 2023 04:23:46 +0000 From: "Matthew Wilcox (Oracle)" To: Johannes Weiner Cc: "Matthew Wilcox (Oracle)" , linux-mm@kvack.org, linux-kernel@vger.kernel.org, vitaly.wool@konsulko.com, cerasuolodomenico@gmail.com, nphamcs@gmail.com, hch@infradead.org, yosryahmed@google.com, akpm@linux-foundation.org Subject: [PATCH 3/5] memcg: Convert get_obj_cgroup_from_page to get_obj_cgroup_from_folio Date: Sat, 15 Jul 2023 05:23:41 +0100 Message-Id: <20230715042343.434588-4-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20230715042343.434588-1-willy@infradead.org> References: <20230714194610.828210-1-hannes@cmpxchg.org> <20230715042343.434588-1-willy@infradead.org> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 73825100012 X-Stat-Signature: qqzbk6zbh7akza7d91674kujs1ton8is X-HE-Tag: 1689395039-547898 X-HE-Meta: U2FsdGVkX1827yITsMf4YHaylW9HrgSgRO9S2TuLa6HoIyHSMxJ/Fp+ameb6243VApx0SuGZ+a+tUJeXlSnidKn/va5NlpnSil5HVqm/nxsZxdWRORWdUMxV7YfADdUbl8bA5Q2hEil5mzof9lBxTF9j4fGQrbYQsNioVqd0MH+HhML1Ri/de+N1HoALDk8PT0NaJ87Z+TfIZMxW4Y1tkSS9lAfBz/YoPgd3WSQhMqSGmr0NXfy5kEt/MlMlelVe26cxdRNFdFXFmsUlnZwwmHtN6CnMYdARznBmXkW0VkIC4V+mESsogpmX5+RmP5khuOdZ5afJ+/QYE9qvRgUHXwx3BJpYDf24JYMmHLlEU1lYCvsmw3chsQbaVo/OcSCrvfgr0BuIL3ym7kNspta/FQgDrWjNvMTKMrT9DHsyU/r8Eny/iGQXqRhdIAM4UF6lNvG5elilfhg0ZJM6NJcZ87H+++ko3Namy7UO2qaVpRk7+Jcuu30K9LycsuT0WkCDZd4XdJIDCLGK5/WTRkO8xWZlxGBPt/6PDtJxHZjHmtd9sQt84CQ7TptSp3TllWvj2rbU5qZJyy9gd/UftDLmjWBlME9QB6Q++EQk8K88Q7PHkaTOKh3CsDgRMtArZmHUSdFP96Ed9eamXGTkQGQIRPJWoiqmx3oz+bX51Zo5fXGTuEyf9ZfXnNluXiRLBDeTu3i6RVFxmm6LAv+5PNzzK461ewUf7kJAXzHpdtlyYRrD9b3tlz9pwgmAJaaAw5TR0xUIzhBd0oVgIgd2/LnpUtxwgUyVhecx9qqAJoNkppdcmclClVhiNACdHLYsjjE3WojBEpuRhxKXZ9iAOhl1IckSSVR3ZnqqJ63wUH8YuedAXV1+JmVYyoeG42vVABJby7rIL86Gy9L+e25T/ksAhsp5bIWV1BM+de1OAO8XSq8qegETFejpn92GaCLB9itCPEKnLlQwReCww1s5aB8 UNe/AXHq MWdf4KQ3ZSeGVSDBnjTZylFyIngUvfU2FHSPvXvMrc4A/abB0/Dhxnv0N4bxqJK7A5cbiID2C1CK7Ej9aZFbOpOYPpI1ghhIBkL4lDpQiECS/rU5B6SYNpD2oKqKwEFTuaweplOlvd/ImCqNcXfd4nFofG9bXs+gA53tLJ+eY5NzB0f+Lc7W747HxLcuTaSm4GxKanKXSjm+8Fi3NvcQtKAL2LGuK7330zocu 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: As the one caller now has a folio, pass it in and use it. Removes three calls to compound_head(). Signed-off-by: Matthew Wilcox (Oracle) --- include/linux/memcontrol.h | 4 ++-- mm/memcontrol.c | 8 ++++---- mm/zswap.c | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h index 5818af8eca5a..7b676752f474 100644 --- a/include/linux/memcontrol.h +++ b/include/linux/memcontrol.h @@ -1761,7 +1761,7 @@ int __memcg_kmem_charge_page(struct page *page, gfp_t gfp, int order); void __memcg_kmem_uncharge_page(struct page *page, int order); struct obj_cgroup *get_obj_cgroup_from_current(void); -struct obj_cgroup *get_obj_cgroup_from_page(struct page *page); +struct obj_cgroup *get_obj_cgroup_from_folio(struct folio *folio); int obj_cgroup_charge(struct obj_cgroup *objcg, gfp_t gfp, size_t size); void obj_cgroup_uncharge(struct obj_cgroup *objcg, size_t size); @@ -1845,7 +1845,7 @@ static inline void __memcg_kmem_uncharge_page(struct page *page, int order) { } -static inline struct obj_cgroup *get_obj_cgroup_from_page(struct page *page) +static inline struct obj_cgroup *get_obj_cgroup_from_folio(struct folio *folio) { return NULL; } diff --git a/mm/memcontrol.c b/mm/memcontrol.c index e8ca4bdcb03c..acc9acb0c9a1 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -3036,21 +3036,21 @@ __always_inline struct obj_cgroup *get_obj_cgroup_from_current(void) return objcg; } -struct obj_cgroup *get_obj_cgroup_from_page(struct page *page) +struct obj_cgroup *get_obj_cgroup_from_folio(struct folio *folio) { struct obj_cgroup *objcg; if (!memcg_kmem_online()) return NULL; - if (PageMemcgKmem(page)) { - objcg = __folio_objcg(page_folio(page)); + if (folio_memcg_kmem(folio)) { + objcg = __folio_objcg(folio); obj_cgroup_get(objcg); } else { struct mem_cgroup *memcg; rcu_read_lock(); - memcg = __folio_memcg(page_folio(page)); + memcg = __folio_memcg(folio); if (memcg) objcg = __get_obj_cgroup_from_memcg(memcg); else diff --git a/mm/zswap.c b/mm/zswap.c index ba50b186ee27..69d097d14255 100644 --- a/mm/zswap.c +++ b/mm/zswap.c @@ -1235,7 +1235,7 @@ bool zswap_store(struct folio *folio) * cgroup-aware entry LRU, we will push out entries system-wide based on * local cgroup limits. */ - objcg = get_obj_cgroup_from_page(page); + objcg = get_obj_cgroup_from_folio(folio); if (objcg && !obj_cgroup_may_zswap(objcg)) goto reject;