From: Michal Hocko <mhocko@kernel.org>
To: Waiman Long <longman@redhat.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Mel Gorman <mgorman@suse.de>,
Johannes Weiner <hannes@cmpxchg.org>,
Roman Gushchin <guro@fb.com>, Vlastimil Babka <vbabka@suse.cz>,
Konstantin Khlebnikov <khlebnikov@yandex-team.ru>,
Jann Horn <jannh@google.com>, Song Liu <songliubraving@fb.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Rafael Aquini <aquini@redhat.com>,
linux-mm@kvack.org, LKML <linux-kernel@vger.kernel.org>
Subject: Re: [RFC PATCH 2/2] mm, vmstat: reduce zone->lock holding time by /proc/pagetypeinfo
Date: Wed, 23 Oct 2019 18:10:29 +0200 [thread overview]
Message-ID: <20191023161029.GK17610@dhcp22.suse.cz> (raw)
In-Reply-To: <a3510617-fd23-9f90-3c40-700bcb0f353c@redhat.com>
On Wed 23-10-19 10:56:30, Waiman Long wrote:
> On 10/23/19 6:27 AM, Michal Hocko wrote:
> > From: Michal Hocko <mhocko@suse.com>
> >
> > pagetypeinfo_showfree_print is called by zone->lock held in irq mode.
> > This is not really nice because it blocks both any interrupts on that
> > cpu and the page allocator. On large machines this might even trigger
> > the hard lockup detector.
> >
> > Considering the pagetypeinfo is a debugging tool we do not really need
> > exact numbers here. The primary reason to look at the outuput is to see
> > how pageblocks are spread among different migratetypes therefore putting
> > a bound on the number of pages on the free_list sounds like a reasonable
> > tradeoff.
> >
> > The new output will simply tell
> > [...]
> > Node 6, zone Normal, type Movable >100000 >100000 >100000 >100000 41019 31560 23996 10054 3229 983 648
> >
> > instead of
> > Node 6, zone Normal, type Movable 399568 294127 221558 102119 41019 31560 23996 10054 3229 983 648
> >
> > The limit has been chosen arbitrary and it is a subject of a future
> > change should there be a need for that.
> >
> > Suggested-by: Andrew Morton <akpm@linux-foundation.org>
> > Signed-off-by: Michal Hocko <mhocko@suse.com>
> > ---
> > mm/vmstat.c | 19 ++++++++++++++++++-
> > 1 file changed, 18 insertions(+), 1 deletion(-)
> >
> > diff --git a/mm/vmstat.c b/mm/vmstat.c
> > index 4e885ecd44d1..762034fc3b83 100644
> > --- a/mm/vmstat.c
> > +++ b/mm/vmstat.c
> > @@ -1386,8 +1386,25 @@ static void pagetypeinfo_showfree_print(struct seq_file *m,
> >
> > area = &(zone->free_area[order]);
> >
> > - list_for_each(curr, &area->free_list[mtype])
> > + list_for_each(curr, &area->free_list[mtype]) {
> > freecount++;
> > + /*
> > + * Cap the free_list iteration because it might
> > + * be really large and we are under a spinlock
> > + * so a long time spent here could trigger a
> > + * hard lockup detector. Anyway this is a
> > + * debugging tool so knowing there is a handful
> > + * of pages in this order should be more than
> > + * sufficient
> > + */
> > + if (freecount > 100000) {
> > + seq_printf(m, ">%6lu ", freecount);
> > + spin_unlock_irq(&zone->lock);
> > + cond_resched();
> > + spin_lock_irq(&zone->lock);
> > + continue;
> list_for_each() is a for loop. The continue statement will just iterate
> the rests with the possibility that curr will be stale. Should we use
> goto to jump after the seq_print() below?
You are right. Kinda brown paper back material. Sorry about that. What
about this on top?
---
diff --git a/mm/vmstat.c b/mm/vmstat.c
index 762034fc3b83..c156ce24a322 100644
--- a/mm/vmstat.c
+++ b/mm/vmstat.c
@@ -1383,11 +1383,11 @@ static void pagetypeinfo_showfree_print(struct seq_file *m,
unsigned long freecount = 0;
struct free_area *area;
struct list_head *curr;
+ bool overflow = false;
area = &(zone->free_area[order]);
list_for_each(curr, &area->free_list[mtype]) {
- freecount++;
/*
* Cap the free_list iteration because it might
* be really large and we are under a spinlock
@@ -1397,15 +1397,15 @@ static void pagetypeinfo_showfree_print(struct seq_file *m,
* of pages in this order should be more than
* sufficient
*/
- if (freecount > 100000) {
- seq_printf(m, ">%6lu ", freecount);
+ if (++freecount >= 100000) {
+ overflow = true;
spin_unlock_irq(&zone->lock);
cond_resched();
spin_lock_irq(&zone->lock);
- continue;
+ break;
}
}
- seq_printf(m, "%6lu ", freecount);
+ seq_printf(m, "%s%6lu ", overflow ? ">" : "", freecount);
}
seq_putc(m, '\n');
}
--
Michal Hocko
SUSE Labs
next prev parent reply other threads:[~2019-10-23 16:10 UTC|newest]
Thread overview: 62+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-22 16:21 [PATCH] mm/vmstat: Reduce zone lock hold time when reading /proc/pagetypeinfo Waiman Long
2019-10-22 16:57 ` Michal Hocko
2019-10-22 18:00 ` Waiman Long
2019-10-22 18:40 ` Waiman Long
2019-10-23 0:52 ` David Rientjes
2019-10-23 8:31 ` Mel Gorman
2019-10-23 9:04 ` Michal Hocko
2019-10-23 9:56 ` Mel Gorman
2019-10-23 10:27 ` [RFC PATCH 0/2] " Michal Hocko
2019-10-23 10:27 ` [RFC PATCH 1/2] mm, vmstat: hide /proc/pagetypeinfo from normal users Michal Hocko
2019-10-23 13:13 ` Mel Gorman
2019-10-23 13:27 ` Vlastimil Babka
2019-10-23 14:52 ` Waiman Long
2019-10-23 15:10 ` Rafael Aquini
2019-10-23 16:15 ` Vlastimil Babka
2019-10-24 19:01 ` David Rientjes
2019-10-23 10:27 ` [RFC PATCH 2/2] mm, vmstat: reduce zone->lock holding time by /proc/pagetypeinfo Michal Hocko
2019-10-23 13:15 ` Mel Gorman
2019-10-23 13:32 ` Vlastimil Babka
2019-10-23 13:37 ` Michal Hocko
2019-10-23 13:48 ` Vlastimil Babka
2019-10-23 14:31 ` Michal Hocko
2019-10-23 16:20 ` Vlastimil Babka
2019-10-23 13:46 ` Rafael Aquini
2019-10-23 14:56 ` Waiman Long
2019-10-23 15:21 ` Waiman Long
2019-10-23 16:10 ` Michal Hocko [this message]
2019-10-23 16:17 ` Waiman Long
2019-10-23 16:21 ` Waiman Long
2019-10-23 16:15 ` Vlastimil Babka
2019-10-23 16:41 ` Michal Hocko
2019-10-23 16:47 ` Waiman Long
2019-10-23 17:34 ` [PATCH 1/2] mm, vmstat: Release zone lock more frequently when reading /proc/pagetypeinfo Waiman Long
2019-10-23 18:01 ` Michal Hocko
2019-10-23 18:14 ` Waiman Long
2019-10-23 20:02 ` Michal Hocko
2019-10-23 17:34 ` [PATCH 2/2] mm, vmstat: List total free blocks for each order in /proc/pagetypeinfo Waiman Long
2019-10-23 18:02 ` Michal Hocko
2019-10-23 18:07 ` Waiman Long
2019-10-24 8:20 ` [RFC PATCH 0/2] mm/vmstat: Reduce zone lock hold time when reading /proc/pagetypeinfo Michal Hocko
2019-10-24 16:16 ` Waiman Long
2019-10-23 12:42 ` [PATCH] " Qian Cai
2019-10-23 13:25 ` Vlastimil Babka
2019-10-22 21:59 ` Andrew Morton
2019-10-23 6:15 ` Michal Hocko
2019-10-23 14:30 ` Waiman Long
2019-10-23 14:48 ` Qian Cai
2019-10-23 15:01 ` Waiman Long
2019-10-23 15:05 ` Qian Cai
2019-10-23 22:30 ` Andrew Morton
2019-10-24 5:33 ` Qian Cai
2019-10-24 7:42 ` Michal Hocko
2019-10-24 11:11 ` Qian Cai
2019-10-24 13:38 ` Michal Hocko
2019-10-24 14:55 ` Qian Cai
2019-10-24 3:33 ` Feng Tang
2019-10-24 4:34 ` Qian Cai
2019-10-24 5:34 ` Feng Tang
2019-10-24 10:51 ` Qian Cai
2019-10-25 1:38 ` Feng Tang
2019-10-23 15:03 ` Rafael Aquini
2019-10-23 15:51 ` Qian Cai
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=20191023161029.GK17610@dhcp22.suse.cz \
--to=mhocko@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=aquini@redhat.com \
--cc=gregkh@linuxfoundation.org \
--cc=guro@fb.com \
--cc=hannes@cmpxchg.org \
--cc=jannh@google.com \
--cc=khlebnikov@yandex-team.ru \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=longman@redhat.com \
--cc=mgorman@suse.de \
--cc=songliubraving@fb.com \
--cc=vbabka@suse.cz \
/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;
as well as URLs for NNTP newsgroup(s).