All of lore.kernel.org
 help / color / mirror / Atom feed
From: Baolin Wang <baolin.wang@linux.alibaba.com>
To: akpm@linux-foundation.org
Cc: baolin.wang@linux.alibaba.com, linux-mm@kvack.org,
	linux-kernel@vger.kernel.org
Subject: [RFC PATCH 1/3] mm: Factor out the pagetable pages account into new helper function
Date: Sat,  4 Jun 2022 09:32:29 +0800	[thread overview]
Message-ID: <809544e284d35caf72aa66bf7214a1ef006cad40.1654271618.git.baolin.wang@linux.alibaba.com> (raw)
In-Reply-To: <cover.1654271618.git.baolin.wang@linux.alibaba.com>
In-Reply-To: <cover.1654271618.git.baolin.wang@linux.alibaba.com>

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 <baolin.wang@linux.alibaba.com>
---
 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 8a96197..1ce3366 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -2358,20 +2358,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)	\
@@ -2457,16 +2467,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


  reply	other threads:[~2022-06-04  1:32 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-04  1:32 [RFC PATCH 0/3] Add PUD and kernel PTE level pagetable account Baolin Wang
2022-06-04  1:32 ` Baolin Wang [this message]
2022-06-04  1:32 ` [RFC PATCH 2/3] mm: Add PUD " Baolin Wang
2022-06-04  1:32 ` [RFC PATCH 3/3] mm: Add kernel PTE level pagetable pages account Baolin Wang
2022-06-08 14:38   ` [mm] 9b12e49e9b: BUG:Bad_page_state_in_process kernel test robot
2022-06-08 14:38     ` kernel test robot
2022-06-08 14:38     ` kernel test robot
2022-06-08 15:07     ` Matthew Wilcox
2022-06-08 15:07       ` Matthew Wilcox
2022-06-08 15:07       ` Matthew Wilcox
2022-06-09  4:45       ` Baolin Wang
2022-06-09  4:45         ` Baolin Wang
2022-06-09  4:45         ` Baolin Wang
2022-06-09  4:42     ` Baolin Wang
2022-06-09  4:42       ` Baolin Wang
2022-06-09  4:42       ` Baolin Wang
2022-06-09 12:18       ` Matthew Wilcox
2022-06-09 12:18         ` Matthew Wilcox
2022-06-09 12:18         ` Matthew Wilcox
2022-06-10  3:58         ` Baolin Wang
2022-06-10  3:58           ` Baolin Wang
2022-06-10  3:58           ` Baolin Wang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=809544e284d35caf72aa66bf7214a1ef006cad40.1654271618.git.baolin.wang@linux.alibaba.com \
    --to=baolin.wang@linux.alibaba.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.