Skip to contentSkip to conversation

mm/memcg: update page struct member in comments

PATCH In review Alex Shi 3 participants 4 messages Nov 6, 2020 – Nov 7, 2020

Subsystems (3)
lore
Share & tools
lore

Alex Shi

author
#0 lore raw

PATCH 1/1 mm/memcg: update page struct member in comments

The page->mem_cgroup member is replaced by memcg_data, and add a helper page_memcg() for it. Need to update comments to avoid confusing.

---
 mm/memcontrol.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
mm/memcontrol.c +2 -2
index b2aa3b73ab82..8a8debea34fc 100644
@@ -1310,7 +1310,7 @@ int mem_cgroup_scan_tasks(struct mem_cgroup *memcg,
  * @page: the page
  * @pgdat: pgdat of the page
  *
- * This function relies on page->mem_cgroup being stable - see the
+ * This function relies on page_memcg(page) being stable - see the
  * access rules in commit_charge().
  */
 struct lruvec *mem_cgroup_page_lruvec(struct page *page, struct pglist_data *pgdat)
@@ -2862,7 +2862,7 @@ static void commit_charge(struct page *page, struct mem_cgroup *memcg)
 {
 	VM_BUG_ON_PAGE(page_memcg(page), page);
 	/*
-	 * Any of the following ensures page->mem_cgroup stability:
+	 * Any of the following ensures page_memcg(page) stability:
 	 *
 	 * - the page lock
 	 * - LRU isolation
Signature · 1 line
1.8.3.1
#1 lore raw
Quoted 2 lines · Alex Shi

The page->mem_cgroup member is replaced by memcg_data, and add a helper page_memcg() for it. Need to update comments to avoid confusing.

I'm not an expert in this code but IMO the pointer manipulation of page->mem_cgroup could be thought of as local to the code in mm/memcontrol.c. As such the detail of the member of the page struct that the code depends on is a valuable part of the comment. Having to look at page_memcg() to find out this information is kind of annoying.

Ira

Quoted 38 lines
---
 mm/memcontrol.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
mm/memcontrol.c +2 -2
index b2aa3b73ab82..8a8debea34fc 100644
@@ -1310,7 +1310,7 @@ int mem_cgroup_scan_tasks(struct mem_cgroup *memcg,
  * @page: the page
  * @pgdat: pgdat of the page
  *
- * This function relies on page->mem_cgroup being stable - see the
+ * This function relies on page_memcg(page) being stable - see the
  * access rules in commit_charge().
  */
 struct lruvec *mem_cgroup_page_lruvec(struct page *page, struct pglist_data *pgdat)
@@ -2862,7 +2862,7 @@ static void commit_charge(struct page *page, struct mem_cgroup *memcg)
 {
 	VM_BUG_ON_PAGE(page_memcg(page), page);
 	/*
-	 * Any of the following ensures page->mem_cgroup stability:
+	 * Any of the following ensures page_memcg(page) stability:
 	 *
 	 * - the page lock
 	 * - LRU isolation
Signature · 1 line
1.8.3.1
Acked-by on v1 1/1
#2 lore raw
In reply to Alex Shi
Quoted 2 lines · Alex Shi

The page->mem_cgroup member is replaced by memcg_data, and add a helper page_memcg() for it. Need to update comments to avoid confusing.

Hi Alex,

thank you for bringing it in!
I definitely missed those.

Quoted 18 lines
---
 mm/memcontrol.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
mm/memcontrol.c +0 -0
index b2aa3b73ab82..8a8debea34fc 100644

mm/memcontrol.c int mem_cgroup_scan_tasks(struct mem_cgroup *memcg, · line 1314

Quoted 6 lines
mm/memcontrol.c +1 -1
@@ -1310,7 +1310,7 @@ int mem_cgroup_scan_tasks(struct mem_cgroup *memcg,
  * @page: the page
  * @pgdat: pgdat of the page
  *
- * This function relies on page->mem_cgroup being stable - see the
+ * This function relies on page_memcg(page) being stable - see the
  * access rules in commit_charge().

There are "page and memcg binding" and "page's memcg" used in similar cases, I think it's more obvious than "page_memcg(page) being stable".

Maybe it helps to address Ira's comment.

Anyway, please feel free to add:

Thanks!

author Acked-by Roman Gushchin
#3 lore raw

ÔÚ 2020/11/7 ÉÏÎç4:51, Roman Gushchin дµÀ:

Quoted 9 lines

There are "page and memcg binding" and "page's memcg" used in similar cases, I think it's more obvious than "page_memcg(page) being stable".

Maybe it helps to address Ira's comment.

Anyway, please feel free to add:

Thanks!

Thanks a lot! Roman.
here is the updated patch with your suggestion and ack.

From 0db2bd8f3833ec5e58c6978f771b05e4902e5156 Mon Sep 17 00:00:00 2001
From: Alex Shi <alex.shi-KPsoFbNs7GizrGE5bRqYAgC/[email protected]>
Date: Fri, 6 Nov 2020 19:33:33 +0800
Subject: [PATCH v2] mm/memcg: update page struct member in comments

The page->mem_cgroup member is replaced by memcg_data, and add a helper page_memcg() for it. Need to update comments to avoid confusing.

---
 mm/memcontrol.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
mm/memcontrol.c +2 -2
index 7657f16cf992..b6560ab1adc4 100644
@@ -1330,7 +1330,7 @@ void lruvec_memcg_debug(struct lruvec *lruvec, struct page *page)
  * @page: the page
  * @pgdat: pgdat of the page
  *
- * This function relies on page->mem_cgroup being stable - see the
+ * This function relies on page's memcg being stable - see the
  * access rules in commit_charge().
  */
 struct lruvec *mem_cgroup_page_lruvec(struct page *page, struct pglist_data *pgdat)
@@ -2942,7 +2942,7 @@ static void commit_charge(struct page *page, struct mem_cgroup *memcg)
 {
 	VM_BUG_ON_PAGE(page_memcg(page), page);
 	/*
-	 * Any of the following ensures page->mem_cgroup stability:
+	 * Any of the following ensures page's memcg stability:
 	 *
 	 * - the page lock
 	 * - LRU isolation
Signature · 1 line
1.8.3.1