From: Muchun Song <songmuchun-EC8Uxl6Npydl57MIdRCFDg@public.gmane.org>
To: akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org,
hannes-druUgvl0LCNAfugRpC6u6w@public.gmane.org,
longman-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org,
mhocko-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org,
roman.gushchin-fxUVXftIFDnyG1zEObXtfA@public.gmane.org,
shakeelb-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org
Cc: cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
duanxiongchun-EC8Uxl6Npydl57MIdRCFDg@public.gmane.org,
linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-mm-Bw31MaZKKs3YtjvyW6yDsg@public.gmane.org,
Muchun Song <songmuchun-EC8Uxl6Npydl57MIdRCFDg@public.gmane.org>
Subject: [PATCH v6 10/11] mm: lru: add VM_WARN_ON_ONCE_FOLIO to lru maintenance function
Date: Tue, 21 Jun 2022 20:56:57 +0800 [thread overview]
Message-ID: <20220621125658.64935-11-songmuchun@bytedance.com> (raw)
In-Reply-To: <20220621125658.64935-1-songmuchun-EC8Uxl6Npydl57MIdRCFDg@public.gmane.org>
We need to make sure that the page is deleted from or added to the
correct lruvec list. So add a VM_WARN_ON_ONCE_FOLIO() to catch
invalid users. Then the VM_BUG_ON_PAGE() in move_pages_to_lru()
could be removed since add_page_to_lru_list() will check that.
Signed-off-by: Muchun Song <songmuchun-EC8Uxl6Npydl57MIdRCFDg@public.gmane.org>
Acked-by: Roman Gushchin <roman.gushchin-fxUVXftIFDnyG1zEObXtfA@public.gmane.org>
---
include/linux/mm_inline.h | 6 ++++++
mm/vmscan.c | 1 -
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/include/linux/mm_inline.h b/include/linux/mm_inline.h
index 7b25b53c474a..6585198b19e2 100644
--- a/include/linux/mm_inline.h
+++ b/include/linux/mm_inline.h
@@ -99,6 +99,8 @@ void lruvec_add_folio(struct lruvec *lruvec, struct folio *folio)
{
enum lru_list lru = folio_lru_list(folio);
+ VM_WARN_ON_ONCE_FOLIO(!folio_matches_lruvec(folio, lruvec), folio);
+
update_lru_size(lruvec, lru, folio_zonenum(folio),
folio_nr_pages(folio));
if (lru != LRU_UNEVICTABLE)
@@ -116,6 +118,8 @@ void lruvec_add_folio_tail(struct lruvec *lruvec, struct folio *folio)
{
enum lru_list lru = folio_lru_list(folio);
+ VM_WARN_ON_ONCE_FOLIO(!folio_matches_lruvec(folio, lruvec), folio);
+
update_lru_size(lruvec, lru, folio_zonenum(folio),
folio_nr_pages(folio));
/* This is not expected to be used on LRU_UNEVICTABLE */
@@ -133,6 +137,8 @@ void lruvec_del_folio(struct lruvec *lruvec, struct folio *folio)
{
enum lru_list lru = folio_lru_list(folio);
+ VM_WARN_ON_ONCE_FOLIO(!folio_matches_lruvec(folio, lruvec), folio);
+
if (lru != LRU_UNEVICTABLE)
list_del(&folio->lru);
update_lru_size(lruvec, lru, folio_zonenum(folio),
diff --git a/mm/vmscan.c b/mm/vmscan.c
index 697656151431..51b1607c81e4 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -2361,7 +2361,6 @@ static unsigned int move_pages_to_lru(struct list_head *list)
continue;
}
- VM_BUG_ON_FOLIO(!folio_matches_lruvec(folio, lruvec), folio);
lruvec_add_folio(lruvec, folio);
nr_pages = folio_nr_pages(folio);
nr_moved += nr_pages;
--
2.11.0
next prev parent reply other threads:[~2022-06-21 12:56 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-21 12:56 [PATCH v6 00/11] Use obj_cgroup APIs to charge the LRU pages Muchun Song
2022-06-21 12:56 ` [PATCH v6 01/11] mm: memcontrol: remove dead code and comments Muchun Song
2022-06-21 12:56 ` [PATCH v6 02/11] mm: rename unlock_page_lruvec{_irq, _irqrestore} to lruvec_unlock{_irq, _irqrestore} Muchun Song
[not found] ` <20220621125658.64935-1-songmuchun-EC8Uxl6Npydl57MIdRCFDg@public.gmane.org>
2022-06-21 12:56 ` [PATCH v6 03/11] mm: memcontrol: prepare objcg API for non-kmem usage Muchun Song
2022-06-21 12:56 ` [PATCH v6 04/11] mm: memcontrol: make lruvec lock safe when LRU pages are reparented Muchun Song
2022-06-21 12:56 ` [PATCH v6 05/11] mm: vmscan: rework move_pages_to_lru() Muchun Song
2022-06-21 12:56 ` [PATCH v6 06/11] mm: thp: make split queue lock safe when LRU pages are reparented Muchun Song
2022-06-21 12:56 ` [PATCH v6 07/11] mm: memcontrol: make all the callers of {folio,page}_memcg() safe Muchun Song
2022-06-21 12:56 ` [PATCH v6 09/11] mm: memcontrol: use obj_cgroup APIs to charge the LRU pages Muchun Song
2022-06-21 12:56 ` Muchun Song [this message]
2022-06-21 12:56 ` [PATCH v6 11/11] mm: lru: use lruvec lock to serialize memcg changes Muchun Song
2022-06-26 10:32 ` [PATCH v6 00/11] Use obj_cgroup APIs to charge the LRU pages Yosry Ahmed
[not found] ` <CAJD7tkbeTtkMcVri9vzKHATjxAVZfC_vPNfApJiyRxY53c8pZQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2022-06-27 7:11 ` Muchun Song
[not found] ` <YrlYG0ecJyzFTVVz-t1y1lxtqHnnw2QbUemf3bixXY32XiHfO@public.gmane.org>
2022-06-27 8:05 ` Yosry Ahmed
[not found] ` <CAJD7tkbubDhpJV81qkXqRE5-yvvcjKrtPnZnECenafz+to=3_Q-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2022-06-27 10:13 ` Muchun Song
2022-06-27 16:46 ` Yosry Ahmed
2022-06-28 1:24 ` Roman Gushchin
2022-06-28 1:31 ` Yosry Ahmed
[not found] ` <CAJD7tkaOJoZ-8S5RaefDKtD_+aCGVa-RJ3hR23EHOZqT_wf+ew-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2022-06-28 1:37 ` Roman Gushchin
2022-06-28 1:45 ` Yosry Ahmed
2022-06-27 10:43 ` Mika Penttilä
[not found] ` <e96f0885-16dc-3d2a-7220-2ff5e7a37737-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2022-06-27 16:49 ` Yosry Ahmed
2022-07-07 22:14 ` Yosry Ahmed
[not found] ` <CAJD7tkbk-E+Skkj3xxELuGFHet940DovKi0z8NxPqePzXa-Wug-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2022-07-08 6:52 ` Muchun Song
[not found] ` <YsfUIpM5NlWZhUDT-t1y1lxtqHnnw2QbUemf3bixXY32XiHfO@public.gmane.org>
2022-07-08 9:26 ` Yosry Ahmed
2022-07-09 5:51 ` Muchun Song
[not found] ` <YskXXlUAB1YZikkG-t1y1lxtqHnnw2QbUemf3bixXY32XiHfO@public.gmane.org>
2022-07-09 9:23 ` Yosry Ahmed
2022-07-03 23:23 ` Andrew Morton
2022-06-21 12:56 ` [PATCH v6 08/11] mm: memcontrol: introduce memcg_reparent_ops Muchun Song
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=20220621125658.64935-11-songmuchun@bytedance.com \
--to=songmuchun-ec8uxl6npydl57midrcfdg@public.gmane.org \
--cc=akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org \
--cc=cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=duanxiongchun-EC8Uxl6Npydl57MIdRCFDg@public.gmane.org \
--cc=hannes-druUgvl0LCNAfugRpC6u6w@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-mm-Bw31MaZKKs3YtjvyW6yDsg@public.gmane.org \
--cc=longman-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
--cc=mhocko-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
--cc=roman.gushchin-fxUVXftIFDnyG1zEObXtfA@public.gmane.org \
--cc=shakeelb-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox