From patchwork Wed Jun 22 08:58:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baolin Wang X-Patchwork-Id: 12890324 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 8D81BC433EF for ; Wed, 22 Jun 2022 08:59:33 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1058B8E00A0; Wed, 22 Jun 2022 04:59:33 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 08F918E008A; Wed, 22 Jun 2022 04:59:33 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E99898E00A0; Wed, 22 Jun 2022 04:59:32 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id D46DD8E008A for ; Wed, 22 Jun 2022 04:59:32 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 7F35B21418 for ; Wed, 22 Jun 2022 08:59:32 +0000 (UTC) X-FDA: 79605273384.16.3F1F845 Received: from out30-45.freemail.mail.aliyun.com (out30-45.freemail.mail.aliyun.com [115.124.30.45]) by imf26.hostedemail.com (Postfix) with ESMTP id A9DAF1400BA for ; Wed, 22 Jun 2022 08:59:26 +0000 (UTC) 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: ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1655888372; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:in-reply-to:in-reply-to: references:references:references; bh=7YXhTi/3nPAbv/D37EtgqnZnexmlrpjb9zjbPV8w/FU=; b=VsL6xBqCUQLhwHGWLVlfdeZyX1b3JhscTzhGIbuS+t52IZIeM+Wzl80ZydqYoimFfc37zr ou0cmwM/063MosfTCrcy5XtihlP6G4endEdybmd+pCtsJdXYyDEITky3C0uz3jox4QjeQ4 U/ihiDaEMGYOh5o0DavYhwgjO+hSYKU= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1655888372; a=rsa-sha256; cv=none; b=GEdMPnphmfaUM6sFF4VSkbUaV2/s0DU9A8S9j5GjS0+Ic3iuXNOIWDhiHrCvxaNkHo4WOt aNzruPbFGFvemvvS/i1+8UBgficZc3i7tEoZHP/t4KSQx7yPerYWeGwh9/AgkvULKfT8B+ nV1s+BPZ2gH6jrvqHuOj8VfmyUap6zI= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=none; dmarc=temperror reason="SPF/DKIM temp error" header.from=alibaba.com (policy=temperror); spf=temperror (imf26.hostedemail.com: error in processing during lookup of baolin.wang@linux.alibaba.com: DNS error) smtp.mailfrom=baolin.wang@linux.alibaba.com X-Stat-Signature: 8j5zm7s4wg85o6fzwazeenzwsrds7c5z X-Rspamd-Queue-Id: A9DAF1400BA Authentication-Results: imf26.hostedemail.com; dkim=none; dmarc=temperror reason="SPF/DKIM temp error" header.from=alibaba.com (policy=temperror); spf=temperror (imf26.hostedemail.com: error in processing during lookup of baolin.wang@linux.alibaba.com: DNS error) smtp.mailfrom=baolin.wang@linux.alibaba.com X-Rspamd-Server: rspam02 X-Rspam-User: X-HE-Tag: 1655888366-165433 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: 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); } /*