From nobody Wed Dec 31 13:04:48 2025 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C31CBC41535 for ; Fri, 3 Nov 2023 14:03:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377782AbjKCODx (ORCPT ); Fri, 3 Nov 2023 10:03:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37128 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233366AbjKCODt (ORCPT ); Fri, 3 Nov 2023 10:03:49 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1B5D2D4F; Fri, 3 Nov 2023 07:03:45 -0700 (PDT) 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 Content-Transfer-Encoding: quoted-printable 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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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); } =20 -/* 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; } =20 -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)); } =20 static inline unsigned long get_mm_rss(struct mm_struct *mm) --=20 2.27.0