From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1,USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4B7B4CA9EA0 for ; Fri, 25 Oct 2019 21:08:57 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id E51E621D7B for ; Fri, 25 Oct 2019 21:08:56 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="XaiGMHIY" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E51E621D7B Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 59C686B0003; Fri, 25 Oct 2019 17:08:56 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 54D906B0006; Fri, 25 Oct 2019 17:08:56 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 43B2C6B0007; Fri, 25 Oct 2019 17:08:56 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0225.hostedemail.com [216.40.44.225]) by kanga.kvack.org (Postfix) with ESMTP id 1C9A66B0003 for ; Fri, 25 Oct 2019 17:08:56 -0400 (EDT) Received: from smtpin27.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with SMTP id BA5E1180890BC for ; Fri, 25 Oct 2019 21:08:55 +0000 (UTC) X-FDA: 76083546630.27.dog28_6b01a02c7eb4e X-HE-Tag: dog28_6b01a02c7eb4e X-Filterd-Recvd-Size: 6593 Received: from mail-pg1-f194.google.com (mail-pg1-f194.google.com [209.85.215.194]) by imf10.hostedemail.com (Postfix) with ESMTP for ; Fri, 25 Oct 2019 21:08:55 +0000 (UTC) Received: by mail-pg1-f194.google.com with SMTP id u23so2350055pgo.0 for ; Fri, 25 Oct 2019 14:08:55 -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=eTmq1ZotaAKKXafZKbOtdelfYNDu7s70GlRUl/zzJchC8kyiTMrZwLK4PnAv2gY7zm amvteuWgGctjNd1r06sdd+lJbxXGyTjKw+Ma+U2fWfV3feryry+s2ypPfIL6LW8G7FGa 24u2suHPgP10DSg+Wdll1FBq7Y9PeW9kgo7+s4JQJfzN5vqYas7tMRBDmnEHib0rV+p8 uH9UotN3fjbNMHLezPnOUBxyUK9gz63azKKxZwbstw5KOUarnYGXK5EMqu+mXNSLYHfq ci4fYPjAHf5vuxYfAY8vgX0+TMk5iSdHe68Y0r4c6+8vSjcxN0CWj9ANe3wUD2YiGVzQ 9Gog== X-Gm-Message-State: APjAAAXhc7nf3PCRu5F9VSZezhRHqmCxwNxBE2VNAWuFomAc3Etxjlf3 lSFmAcj3/0cAqHzF5uPC3wrlZQ== X-Google-Smtp-Source: APXvYqzqO0iRM2YfCDmg6tFvM3zUERjScrLgQ+IHqgTKuIgMxweznsy90HYJlCJ4SBIWEJjlDbpkQA== 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 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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'); > }