Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp1821555ybg; Thu, 24 Oct 2019 00:08:37 -0700 (PDT) X-Google-Smtp-Source: APXvYqwWLtMam+hnbpDCLyAYuFymASoCog7tlL4nnLrkFr93SsJw4VSMecNn6p3ciazXlI81GH12 X-Received: by 2002:a17:906:22cc:: with SMTP id q12mr22762875eja.131.1571900917124; Thu, 24 Oct 2019 00:08:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571900917; cv=none; d=google.com; s=arc-20160816; b=S6O2bPLIYyNIOhIHXiw1Sj+OTReqtc5O4p0yPNRY7osuaiDdYYLD07y+DkEHKGto4e 9VwiL3hA4DHcAYiJJ7q7MhQFNk989HqdFHMYiJpL83AD0xwBWHx7eoYk7PELrES5/g55 ClHoqk1K5sWSpJcPfrDoKBY45t6wYfaEKgPefCKfXQWI6QzVhVjbjXagoi/GgqcSwajl zp6VPDzqAoAZplb89Mq21zKWobR7WyQc/VIkevXCq78cM8wdLOpLUmeraEge3WTivqNv uNHrz3zAe2nw3LMeEbb87T2fULkareXpt72f3Ai3ppSi830+qGnwSNNM69tCyCqGWCbC d99A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=Pa0RfGTUV5fyDVXVpounn78QyCo2okhLWzEAbYRdoe4=; b=D6zYWjfYlZUH+bW0c812xGsK9tvJofEeZGqMOf1hvny2/RgHULlVn0onfcGHH++aqt dQthvTVsBMj0Yl2h/Lz+vRnjLesMM5FHfbS5fKeqQ8ofym56YQa6Ve0ZXT7nMhjISike V7EVuUw9CScPaXqePkdffx7+e7Gwq9xPgprEYvZ5tyTVxNyJ2bo3CT6CMv1m+KGjirMR +gBVwHKjZiZSg/936fMexEO+K/xoe9J7ZiRwopR2ABzqteoHDnuQndqt0u0+QTasNvlS kSQW270Egl2wSXTzs+jFNF/rMbaEm0++ZfKXWhmbnbBufSzpuKpyDZwIrvPS2QV+Dg63 sm6A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h50si16105899ede.423.2019.10.24.00.07.36; Thu, 24 Oct 2019 00:08:37 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2407054AbfJWQKd (ORCPT + 99 others); Wed, 23 Oct 2019 12:10:33 -0400 Received: from mx2.suse.de ([195.135.220.15]:37366 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2404582AbfJWQKd (ORCPT ); Wed, 23 Oct 2019 12:10:33 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 0F75BB1C1; Wed, 23 Oct 2019 16:10:31 +0000 (UTC) Date: Wed, 23 Oct 2019 18:10:29 +0200 From: Michal Hocko To: Waiman Long Cc: Andrew Morton , Mel Gorman , Johannes Weiner , Roman Gushchin , Vlastimil Babka , Konstantin Khlebnikov , Jann Horn , Song Liu , Greg Kroah-Hartman , Rafael Aquini , linux-mm@kvack.org, LKML Subject: Re: [RFC PATCH 2/2] mm, vmstat: reduce zone->lock holding time by /proc/pagetypeinfo Message-ID: <20191023161029.GK17610@dhcp22.suse.cz> References: <20191023095607.GE3016@techsingularity.net> <20191023102737.32274-1-mhocko@kernel.org> <20191023102737.32274-3-mhocko@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed 23-10-19 10:56:30, Waiman Long wrote: > On 10/23/19 6:27 AM, Michal Hocko wrote: > > From: Michal Hocko > > > > 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 > > Signed-off-by: Michal Hocko > > --- > > 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