Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp4627832iog; Wed, 22 Jun 2022 02:39:15 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tv980FhO6i1e/g5G5/5H6kJVGnVwyfkbFNCB1oDz2AcFG1tzOzFprNHDPbjedzpwHqbcwJ X-Received: by 2002:a17:90a:e7c8:b0:1ea:e6fd:4a4a with SMTP id kb8-20020a17090ae7c800b001eae6fd4a4amr2820271pjb.234.1655890755562; Wed, 22 Jun 2022 02:39:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655890755; cv=none; d=google.com; s=arc-20160816; b=VO3ZZrS2BYkhTS2+1WiZWiZkfoE8HTi6P3xwi0d0XNOhJ8rZiZzo61MUs12hzYLSEw U+cBZu1yo8ZcC9hLgMJEzbeg1GSsRvH/so6YNBnpRMTdQ18HYfZHAVaqe4yppdgZ5U9k EZlSVTMQ4WFa++DK0v42NID0aQrl7ijfZsxp4v5aiVFQ1ZXXC3AVNYwLnSTJTdI1qjSV HGQUBXa5j4WHXttnta+MKbBtwE/OtUMnH+nwG8RWeJqIkm7TtlRAg8w2+ZSUzhW1Wbcq qpYk/LucVpRcjAle6uGTPSSs8yJBOs+wkQZe+4Fe4f+Ol6ttidfjhRr0ur4Mq4B6TGB0 ywQg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:references:in-reply-to :message-id:date:subject:cc:to:from; bh=7YXhTi/3nPAbv/D37EtgqnZnexmlrpjb9zjbPV8w/FU=; b=fsl6/aXF3Gphn7X+cY5a2tuGYrf2HP4HgFXDufzoqbG20lM9HpuFfLp5ydFeN0hyAg mVWx0C7HZywoyAeEgXXupflPiQsBTVItRMQpCLQVD4cHzWZyWlXpVZXXRmHWwKj8ETbA 9AjSZizjOk2RWEAVd9Chsq3u9yK5IPR362U1arEGNzwbnbVPxsApsxQeTvFCcywfxALw Cti29sJmB6lc9kNba79O2C40JsxhTM9pt7xqVn9uoansBW1o16SLgkW7SCMS2WKAa265 d2+L/g8Ta/iWGUoRzcMO8+tYqbQVjzIfKtzE9icwyCYsl2OGqKWEZzeSWxSh0fKrgF3a yv/w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u4-20020a6540c4000000b0040d1e48659asi2702871pgp.239.2022.06.22.02.39.03; Wed, 22 Jun 2022 02:39:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1356789AbiFVI72 (ORCPT + 99 others); Wed, 22 Jun 2022 04:59:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54486 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356396AbiFVI7J (ORCPT ); Wed, 22 Jun 2022 04:59:09 -0400 Received: from out30-44.freemail.mail.aliyun.com (out30-44.freemail.mail.aliyun.com [115.124.30.44]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B5F1C55B8 for ; Wed, 22 Jun 2022 01:59:08 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R111e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018046060;MF=baolin.wang@linux.alibaba.com;NM=1;PH=DS;RN=6;SR=0;TI=SMTPD_---0VH5BRmX_1655888343; Received: from localhost(mailfrom:baolin.wang@linux.alibaba.com fp:SMTPD_---0VH5BRmX_1655888343) by smtp.aliyun-inc.com; Wed, 22 Jun 2022 16:59:04 +0800 From: Baolin Wang To: akpm@linux-foundation.org Cc: rppt@linux.ibm.com, willy@infradead.org, baolin.wang@linux.alibaba.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [RFC PATCH v2 1/3] mm: Factor out the pagetable pages account into new helper function Date: Wed, 22 Jun 2022 16:58:52 +0800 Message-Id: X-Mailer: git-send-email 1.8.3.1 In-Reply-To: References: In-Reply-To: References: X-Spam-Status: No, score=-9.9 required=5.0 tests=BAYES_00, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,UNPARSEABLE_RELAY,USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Factor out the pagetable pages account into new helper functions to avoid duplicated code. Meanwhile these helper functions also will be used to account pagetable pages which do not need split pagetale lock. Signed-off-by: Baolin Wang --- include/linux/mm.h | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/include/linux/mm.h b/include/linux/mm.h index 6d4e9ce1..6da6634 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -2377,20 +2377,30 @@ static inline void pgtable_init(void) pgtable_cache_init(); } +static inline void pgtable_set_and_inc(struct page *page) +{ + __SetPageTable(page); + inc_lruvec_page_state(page, NR_PAGETABLE); +} + +static inline void pgtable_clear_and_dec(struct page *page) +{ + __ClearPageTable(page); + dec_lruvec_page_state(page, NR_PAGETABLE); +} + static inline bool pgtable_pte_page_ctor(struct page *page) { if (!ptlock_init(page)) return false; - __SetPageTable(page); - inc_lruvec_page_state(page, NR_PAGETABLE); + pgtable_set_and_inc(page); return true; } static inline void pgtable_pte_page_dtor(struct page *page) { ptlock_free(page); - __ClearPageTable(page); - dec_lruvec_page_state(page, NR_PAGETABLE); + pgtable_clear_and_dec(page); } #define pte_offset_map_lock(mm, pmd, address, ptlp) \ @@ -2476,16 +2486,14 @@ static inline bool pgtable_pmd_page_ctor(struct page *page) { if (!pmd_ptlock_init(page)) return false; - __SetPageTable(page); - inc_lruvec_page_state(page, NR_PAGETABLE); + pgtable_set_and_inc(page); return true; } static inline void pgtable_pmd_page_dtor(struct page *page) { pmd_ptlock_free(page); - __ClearPageTable(page); - dec_lruvec_page_state(page, NR_PAGETABLE); + pgtable_clear_and_dec(page); } /* -- 1.8.3.1