Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp4153060ybg; Fri, 25 Oct 2019 14:10:44 -0700 (PDT) X-Google-Smtp-Source: APXvYqwC7wemMtugPoD6KgkqZQ/b1sCbzSN2Khuzd/2kwZNqpij9TqlW+V1H6Xs4MQLVuqJw6MZm X-Received: by 2002:a17:906:22c8:: with SMTP id q8mr5413316eja.19.1572037844488; Fri, 25 Oct 2019 14:10:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572037844; cv=none; d=google.com; s=arc-20160816; b=vKeywRjcWTgPyA4BhnnbD/ngNQ1We4dbgTGzDxBDmU5XJCDNDKs4Gkvw2t39oZ8r3J z+bSDQJvZ5TAYXgNHVcILX0xI3bqofdJIGdggTOjxA/vPxZtvbxNE1y0kExF3X15tXcE OosM+4KyQAOUFoCSiNb84hqBb9NwoXLojUtmstm+jnJw1flTDlGIPapyQyzUKbgKNjlx Cj/8qZFgZR70YcMj9ZrRYz2hhfQjIv5Ye/6YnKVwvy+/GjdKrOlenRg15iRnwwvhxhcC t4jpbpGi0Q7I9Pw1UrG3fiiEd8sjNwAj/yBmmtILy/JE67jijzAGL/uLEzscUWzwm6ER LdPQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date:dkim-signature; bh=dTwx/JjKBwPW6sZ06ysYvFl3kZ/YdB0UaChMs4crqCs=; b=rUo05wthyhCe7zDfHACd95f1O7nCsQuS9mr7mpS4LHpRFLjfA1tya9tabT+jVjvi+v DgHMWb2N6TlGxY7zf+hYxJOHnr6kHyJGShFQj9hoLcBVjAs447rG0JWhJcBq2p4VNu8+ /pwV4ZFKmpMDz1FDNSwPNwH86G/AIRZ7L7xAku+OQBJjHP5YpubKKfn85oODGMxli6cy ts2rYCmqZ8bOC1OZUmyslpGIKVUBnMC8ytv2hMpXOK10aEUWGLeSNfgVs7utlMFocdi8 h7bPmuyMOkRbE9er+Ze2lOh60EB9YdwdUikzBBmWLd+GLjct5Z8zEPFMwz7wACNLZQWf 3rXQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=XaiGMHIY; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e1si1980662ejf.28.2019.10.25.14.10.19; Fri, 25 Oct 2019 14:10:44 -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; dkim=pass header.i=@google.com header.s=20161025 header.b=XaiGMHIY; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725899AbfJYVI4 (ORCPT + 99 others); Fri, 25 Oct 2019 17:08:56 -0400 Received: from mail-pg1-f196.google.com ([209.85.215.196]:36549 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725283AbfJYVI4 (ORCPT ); Fri, 25 Oct 2019 17:08:56 -0400 Received: by mail-pg1-f196.google.com with SMTP id 23so2338911pgk.3 for ; Fri, 25 Oct 2019 14:08:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:in-reply-to:message-id:references :user-agent:mime-version; bh=dTwx/JjKBwPW6sZ06ysYvFl3kZ/YdB0UaChMs4crqCs=; b=XaiGMHIYXGHoCAEZDWHURZfURQ54T0lzfOD4OkWbsntZbjBQ+4AGzqHjvoAweZpl7T 6NtcpZFyUkEQhxSG+DB5XyUtlNarXPU2yeGak/RzJndqXahGDP6VCkcQDGvho64htRmV QVuuVjsjhAcRQu6TcoIaj7DxWNOHC8zfkgB22d+559KsdhR8kpufB81E/t0zC7WYKC1W yqfXubNU3ivU4B4WpIFH+vsXx11XMovXAy75r1c1a1+c6+HLE6O2fQIySoFnqGE3oeZV eiZc7jeoMM7UE8zDhDC5fWCRsxBcCwsT5u/ToRHU58pY6LOPgMvRDiRAJnwFe+VT4PjF quFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:in-reply-to:message-id :references:user-agent:mime-version; bh=dTwx/JjKBwPW6sZ06ysYvFl3kZ/YdB0UaChMs4crqCs=; b=Wqo3h3SqKqRKTBjb/NrPzHvdhxiJeYijvMLs8V3P+2jeKgGd5DMFpnZxDPA/LfG1oP 1pyE2gt764zRjzItBIM6IL6e+ym+80bwIkB7d+zi5pgQxsAiAqqRJr7si7Qvk8ZinSEQ mWjq5JCoJVapdSPpDF0PZ6bUA8N5QwnUSDpqD4Nq6i2WfUUIzjk0sLTAMSFxQgXPeEis OKJQO66P+mXIxq3TDurMpPLjc/Nu/kXw+wuGwLHbvllzfPWYeUSuoYlGrqznR8rlN79f fEFD9+0x02zVQePHjz0HGUgTD3GmKMbI01bwIOfFEBQp6rNVkdVVLHLafCfHlVSADgPW 2ySg== X-Gm-Message-State: APjAAAX9F+m2udhHX29T7n2DAAQboOLFmyOZjY+W4I3EEhVd8kt+ZNrh tcgCOYYm4l/AYEBZBUwrnXEK6Q== X-Received: by 2002:a63:4902:: with SMTP id w2mr6691954pga.77.1572037733679; Fri, 25 Oct 2019 14:08:53 -0700 (PDT) Received: from [2620:15c:17:3:3a5:23a7:5e32:4598] ([2620:15c:17:3:3a5:23a7:5e32:4598]) by smtp.gmail.com with ESMTPSA id u36sm4208041pgn.29.2019.10.25.14.08.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Oct 2019 14:08:51 -0700 (PDT) Date: Fri, 25 Oct 2019 14:08:50 -0700 (PDT) From: David Rientjes X-X-Sender: rientjes@chino.kir.corp.google.com To: Michal Hocko cc: Andrew Morton , Mel Gorman , Waiman Long , Johannes Weiner , Roman Gushchin , Vlastimil Babka , Konstantin Khlebnikov , Jann Horn , Song Liu , Greg Kroah-Hartman , Rafael Aquini , linux-mm@kvack.org, LKML , Michal Hocko Subject: Re: [PATCH 2/2] mm, vmstat: reduce zone->lock holding time by /proc/pagetypeinfo In-Reply-To: <20191025072610.18526-3-mhocko@kernel.org> Message-ID: References: <20191025072610.18526-1-mhocko@kernel.org> <20191025072610.18526-3-mhocko@kernel.org> User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 25 Oct 2019, 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 and low number of > pages is much more interesting 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. > > While we are at it, also drop the zone lock after each free_list > iteration which will help with the IRQ and page allocator responsiveness > even further as the IRQ lock held time is always bound to those 100k > pages. > > Suggested-by: Andrew Morton > Reviewed-by: Waiman Long > Signed-off-by: Michal Hocko I think 100k is a very reasonable threshold. Acked-by: David Rientjes > --- > mm/vmstat.c | 23 ++++++++++++++++++++--- > 1 file changed, 20 insertions(+), 3 deletions(-) > > diff --git a/mm/vmstat.c b/mm/vmstat.c > index 4e885ecd44d1..ddb89f4e0486 100644 > --- a/mm/vmstat.c > +++ b/mm/vmstat.c > @@ -1383,12 +1383,29 @@ 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++; > - seq_printf(m, "%6lu ", freecount); > + list_for_each(curr, &area->free_list[mtype]) { > + /* > + * 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) { I suppose it's most precise to check freecount > 1000000 to print >100000, but I doubt anybody cares :) > + overflow = true; > + break; > + } > + } > + seq_printf(m, "%s%6lu ", overflow ? ">" : "", freecount); > + spin_unlock_irq(&zone->lock); > + cond_resched(); > + spin_lock_irq(&zone->lock); > } > seq_putc(m, '\n'); > }