From patchwork Thu Jan 11 18:12:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13517689 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 BB7E1C47258 for ; Thu, 11 Jan 2024 18:12:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 35C476B00A0; Thu, 11 Jan 2024 13:12:40 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 30E256B00A1; Thu, 11 Jan 2024 13:12:40 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 04D866B00A2; Thu, 11 Jan 2024 13:12:39 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id E92B26B00A0 for ; Thu, 11 Jan 2024 13:12:39 -0500 (EST) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id C80BA1C0E04 for ; Thu, 11 Jan 2024 18:12:39 +0000 (UTC) X-FDA: 81667825638.05.72B2F22 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf30.hostedemail.com (Postfix) with ESMTP id 1FC408001E for ; Thu, 11 Jan 2024 18:12:37 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b="V8/B94yi"; dmarc=none; spf=none (imf30.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=1704996758; 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=ckLkDfpTy5X71kCDKuO9wk6WU/1baQA9VkLceFKNXrc=; b=X2WE4SWwWQP/BivspxB3CAfyi9yYK6XvM6ZUjTcOHEBuLsHPx5w2JcwR3HK/2ZQLaHpIpS OaYEs2vBA8z8EP6bQdq5KGLL0C4EAFSo6fW6mTgjI7HkibRCVoKVDLWOfCo47OaSwWrjgb NNHxYTUb/sg1LwJ2N2VpKk5NZ3xrER4= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b="V8/B94yi"; dmarc=none; spf=none (imf30.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=1704996758; a=rsa-sha256; cv=none; b=QzI0Q6AsI2TB5OCfk5tboDVjjc6eregi9cGq7UxmSfmdei2QHebVRfDMQz3/UTO/gte8Jo skuP1poMPuAe6vTPIW5TBtTlsxISFgmSbCz701ipcaVJ7aWwM91BemIGBDE8flRAc1eAOD h10WAU13zz1xvk3NDYvL0AOpuH24KOs= 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=ckLkDfpTy5X71kCDKuO9wk6WU/1baQA9VkLceFKNXrc=; b=V8/B94yi0XWKJBeBSphEHnJnTP OPrAAc6rjc8oO7WITgFGTDrIkp0HsGBGgRO91ipoC07vwDNLDpLV2ml06fcYpqsaCFqDexdsbtM6Z vd+jcROAvdMoq045wg0zd7FjgflmQ0nvNj+HvVHo3lU/GzL6hAaQENEkYs2tIQbflrMb9oMsqdYif kC6jG0PMTfe/DF1zm3H5Ke2jeYCSWlNoVvRU3KcuX3yqc3q1Lh991huh5e4kmgoDPCgCXbWKv8BiN 8otdL6KQiHaqZfrDiYhSAKo0nYrnLoO2BemF1JCQ2EKJVuFkjviVrJcxJ3gXXRf3ITzpdinrjHfrm GPkj9dvw==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1rNzXR-00EWr0-Hx; Thu, 11 Jan 2024 18:12:21 +0000 From: "Matthew Wilcox (Oracle)" To: Andrew Morton Cc: "Matthew Wilcox (Oracle)" , Johannes Weiner , Michal Hocko , Roman Gushchin , Shakeel Butt , Muchun Song , cgroups@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 2/4] memcg: Return the folio in union mc_target Date: Thu, 11 Jan 2024 18:12:17 +0000 Message-Id: <20240111181219.3462852-3-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20240111181219.3462852-1-willy@infradead.org> References: <20240111181219.3462852-1-willy@infradead.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 1FC408001E X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: phq8uq4d9zn8cbuk1tzh4zen1fi6dw6r X-HE-Tag: 1704996757-505949 X-HE-Meta: U2FsdGVkX1+NUVyCwNvkFPZccbBd5s99jjCS3/N0190qPW997XBK/cEXDNGESLqT6WZzarTTn20dYaPhf479D9m/umr1QtEoAgv3P48GmctkbAFfkzeaHaGqGCxAm+cz5a/QsZunrxKr/lHnt/wPSA9xcmmYL2Fv4Jx3bGsrNMWpTLZFG/WbXcPdYtihUPw6+peKq46f9PPv5jnRwhI6YAuLe574ewYSrFo7RHeAxS+2VGE1S4M0lkPKmtxxhZsTQFkSAFp4wcfewm0CWEDuvX5JsfRGwYoRIbdlQneGySJhBZyhNGzHOywspPWVaxLTOMx8sHrgCtTsF87YEfPcrmTzILQpdsK3Ap3HOpiRaPY4rgaP6JbrAk0hh2Hz+0zRikA1HD0xDuV2252Tyn7qOkSTjHeI0fvckwMIk4prSaO+VddrWa3Zrh/95qauD+ns+pKhllZ2rVOIKeh/oQ7V97eNiXxFGbeiUyWODSNAERDZQ/2Hmg60m2xAodiCNCANCEvogfNw9i5l4e3/ONf+fSnQlqMZSGifyLHjIN7wzqTM6YOxc4sdoQlMFrjq58VSjpSxNAQ4i5IkSFuYTCM4+uM+pj7RVFnUlkCq4KBj34E2aExXJenWQv9/mzjD/bqA5Lq5QIVjxPV9UR1cjPTJbevsA8DhPePgqNB6WFCOi8haWI+/3E+xp2y79LXkNeqN2a6HnPYXkRvvV6LJ58ZPGC4UjaSNjQe08arpApuvom56FiKvZQLiiXebFvdLMCc94SmB1/AN1IW/jsHuMu0xALIaa9eq46TXai8sDYknntYGSO1OYpntgRgMTrCf+7YQpzVdljQ90PRSJ+06E8UBVEi8SM0z4izsU85K7glJRCSyfHM0sa1hoYrMW18DD6slvhBEr9TB0ghCSYtfDx2hdRO2mC0jG9rafdC/b+nagwiKOrf3ElnGPv/TjvS0z712Lfz0TDp6z6dmXU4csG1 gWu+PlS7 M4Z1DpUn2wVDuReQqWLrFpRQg8VVHGnbocQtXYWR0YYekhL51fTM7aIDUqere3z960lvR7nqB121gPi3JtqKThky9Aj0GpK/ScxuZavlPUCKvz5ud9XUITFaxilesHUmo78d5FDwa+0fgVVrCT8dvHRnqZFE5AdYoMXS/YdSRaAwbxTKCibOrJusrOwkU2EtanpSxCQC9Q9zVOO7pHet8/eJZsX2us0XyErIl 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: List-Subscribe: List-Unsubscribe: All users of target.page convert it to the folio, so we can just return the folio directly and save a few calls to compound_head(). Signed-off-by: Matthew Wilcox (Oracle) Reviewed-by: Muchun Song --- mm/memcontrol.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/mm/memcontrol.c b/mm/memcontrol.c index c04bda961165..d14fe0740b37 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -5840,7 +5840,7 @@ static int mem_cgroup_do_precharge(unsigned long count) } union mc_target { - struct page *page; + struct folio *folio; swp_entry_t ent; }; @@ -6062,7 +6062,7 @@ static int mem_cgroup_move_account(struct folio *folio, * Return: * * MC_TARGET_NONE - If the pte is not a target for move charge. * * MC_TARGET_PAGE - If the page corresponding to this pte is a target for - * move charge. If @target is not NULL, the page is stored in target->page + * move charge. If @target is not NULL, the folio is stored in target->folio * with extra refcnt taken (Caller should release it). * * MC_TARGET_SWAP - If the swap entry corresponding to this pte is a * target for charge migration. If @target is not NULL, the entry is @@ -6127,7 +6127,7 @@ static enum mc_target_type get_mctgt_type(struct vm_area_struct *vma, is_device_coherent_page(page)) ret = MC_TARGET_DEVICE; if (target) - target->page = page; + target->folio = page_folio(page); } if (!ret || !target) { if (target) @@ -6177,7 +6177,7 @@ static enum mc_target_type get_mctgt_type_thp(struct vm_area_struct *vma, put_page(page); return MC_TARGET_NONE; } - target->page = page; + target->folio = page_folio(page); } } return ret; @@ -6407,7 +6407,7 @@ static int mem_cgroup_move_charge_pte_range(pmd_t *pmd, } target_type = get_mctgt_type_thp(vma, addr, *pmd, &target); if (target_type == MC_TARGET_PAGE) { - folio = page_folio(target.page); + folio = target.folio; if (folio_isolate_lru(folio)) { if (!mem_cgroup_move_account(folio, true, mc.from, mc.to)) { @@ -6419,7 +6419,7 @@ static int mem_cgroup_move_charge_pte_range(pmd_t *pmd, folio_unlock(folio); folio_put(folio); } else if (target_type == MC_TARGET_DEVICE) { - folio = page_folio(target.page); + folio = target.folio; if (!mem_cgroup_move_account(folio, true, mc.from, mc.to)) { mc.precharge -= HPAGE_PMD_NR; @@ -6449,7 +6449,7 @@ static int mem_cgroup_move_charge_pte_range(pmd_t *pmd, device = true; fallthrough; case MC_TARGET_PAGE: - folio = page_folio(target.page); + folio = target.folio; /* * We can have a part of the split pmd here. Moving it * can be done but it would be too convoluted so simply