From patchwork Fri Nov 3 14:01:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13444563 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 0E048C4332F for ; Fri, 3 Nov 2023 14:03:55 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id F325728001E; Fri, 3 Nov 2023 10:03:53 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id F096328000F; Fri, 3 Nov 2023 10:03:53 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D0E2A28001E; Fri, 3 Nov 2023 10:03:53 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id C1E6F28000F for ; Fri, 3 Nov 2023 10:03:53 -0400 (EDT) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 04A931A0E32 for ; Fri, 3 Nov 2023 14:03:52 +0000 (UTC) X-FDA: 81416811546.12.C835C0A Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf29.hostedemail.com (Postfix) with ESMTP id 493A8120027 for ; Fri, 3 Nov 2023 14:03:48 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf29.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1699020229; a=rsa-sha256; cv=none; b=NC6vcl8+VpunQgqm9A03ClbTNgFzYH5vHGachM/r+tiGA8vVzoVBtoP2VB+AoKPcyfnHTw m+J2FiokOOLzjPSI9ZKSSGRhKtyKXLWUibrUhmgjTPZ8u3JlAt5AXo93ESXYTgFZ7+xWoK m8zr4n/QfENldBM1OUUKHl9fQPQKjGw= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf29.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1699020229; 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-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=8+J3qRxOBK8DBKSlvlbT9kzwQm4rIUsyVkkfO9bjcqY=; b=lJVggbaMfA8uGaJAtzDLyYn4h53zug3uq0TGAH5h94+ryhI7bNtQIHt48hDn8csBZzcoxv Op3Dv3tEtv1958knm6dhfIuTxdapJJDlZ+UIMGQbsKj4OOntIirPUHPkMIqvTNBzeFg/kb QJJ0Kx3reFQj21W/SHnaVoCQKG8jaME= Received: from dggpemm100001.china.huawei.com (unknown [172.30.72.54]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4SMMsk23mLzVkbd; Fri, 3 Nov 2023 22:03:38 +0800 (CST) Received: from localhost.localdomain (10.175.112.125) by dggpemm100001.china.huawei.com (7.185.36.93) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.31; Fri, 3 Nov 2023 22:03:43 +0800 From: Kefeng Wang To: Andrew Morton CC: , , Matthew Wilcox , David Hildenbrand , , Kefeng Wang Subject: [PATCH 01/18] mm: add mm_counter_folio() and mm_counter_file_folio() Date: Fri, 3 Nov 2023 22:01:02 +0800 Message-ID: <20231103140119.2306578-2-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20231103140119.2306578-1-wangkefeng.wang@huawei.com> References: <20231103140119.2306578-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggpemm100001.china.huawei.com (7.185.36.93) X-CFilter-Loop: Reflected X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 493A8120027 X-Stat-Signature: obu8icwhbg38b4rrwoa6dzamww37pnzb X-Rspam-User: X-HE-Tag: 1699020228-657259 X-HE-Meta: U2FsdGVkX188f9rn0JDOQTD3tWHjoJfd238itw/Xtw5jkBW00jTpF615p/b2SD+jfrsbkqjRczX05T1HeFfBmBS7FO3pXDQz9+SNz//z5bVsj60vRm1ozSaT+N5cPtDdOM37lfhNJGdMpqGJHAlHPWl0VIiaV48C3bWPSZzKg+yuRoffMr0itMAgjw5OKTxANg/iZ17xWOO13rQsFgTyaIBFxzTc/nWrCZjG45aWyiNwllRddOMFM7UJfeGi/UM9tQjmbxvk/oLi5SDINCYwrAZn+kC6iCbWBapMotBZxWy5qjtOvf42tbbqVmsreMc9cbEoFN68KNz3OB7SZK5F3bbriMScIsnDbsBJ+naQdvT8KRkEkycWCKfT8po3LdkSuWJXaOA0J5syTVwHvMIIdc79W/nBxtUBkAte17SD0vQ368xyvVkJgTRy3RR5Nknp/4eyvY2f+pfetLL9xOzSPQx6GFX0pY2+juJaw0OhQMLaqimCC4kUNOjjmhDXleGeqk/M/nhMN43Kt71DwkPnnmtmHTa7lkitSIQVLvyyJjgmwH010/rJGHGwnADtsKZ7XRJPtXL+0NPho+pk+T5A3BcaSUCkRzyd5muJA92xTnRBD3Dg6g2xKxZ2a3gU1zfXZAZIQEeSHWnXDB1ZHAov/ZsiP6EzVwA1ahsVt1+fYGKIVfnyjYsZZ1fvpjrmTu6vw47KMYuvWh2gW5rtSgwb8oRMqtIsDkdPlL0H4yo9GrFz1Ad6TV+Hp71wLgiOc9PAJhK5Cppns9EYYFHKLp3lGDeGOMR1bnytX81gwOfdHaWd7Lk+5Kg4rrOWrb7uukqeNcylzexmX4MFQvC+Yxf64Qwkkvb9Og8HoZo3GqvIwwE1xvZRMPCITrE7ZJNt1pvKdX4kexswgTw3dlQXoYRyAcFhlJcQ4KLZMxYXk6MOK1/hRr6NV2r4OpLpLO1OPskuYSlwYZW0LrKYPt3Gl2c eQTmhmCa lkU7CuOwMwCPyNBO+zytzPb5AAnNs/qNi75dW3TVQYe7LgcKakrhip4fJTyttrwJGZKRHBYRmols/pWvm4MciPct5QHzVHM5XbvPQYjhrBQbJXS7ixH/S0TC2/BqHhcCC1ZDIXvpXSRE29Ti/e3EgKyfeQ4qTh2J5Mjd/tdWkyeoV9kME/fh3bqErZZnl7by0UmJy 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: Introduce two mm counter folio functions mm_counter_folio() and mm_counter_file_folio(), will be used folio conversion, and it saves a compound_head() in mm_counter(). Signed-off-by: Kefeng Wang --- include/linux/mm.h | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/include/linux/mm.h b/include/linux/mm.h index caf13e94260e..f5f76504b212 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -2583,19 +2583,29 @@ static inline void dec_mm_counter(struct mm_struct *mm, int member) mm_trace_rss_stat(mm, member); } -/* Optimized variant when page is already known not to be PageAnon */ -static inline int mm_counter_file(struct page *page) +static inline int mm_counter_file_folio(struct folio *folio) { - if (PageSwapBacked(page)) + if (folio_test_swapbacked(folio)) return MM_SHMEMPAGES; return MM_FILEPAGES; } -static inline int mm_counter(struct page *page) +/* Optimized variant when page is already known not to be PageAnon */ +static inline int mm_counter_file(struct page *page) +{ + return mm_counter_file_folio(page_folio(page)); +} + +static inline int mm_counter_folio(struct folio *folio) { - if (PageAnon(page)) + if (folio_test_anon(folio)) return MM_ANONPAGES; - return mm_counter_file(page); + return mm_counter_file_folio(folio); +} + +static inline int mm_counter(struct page *page) +{ + return mm_counter_folio(page_folio(page)); } static inline unsigned long get_mm_rss(struct mm_struct *mm)