Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp2090727ybg; Thu, 24 Oct 2019 04:42:26 -0700 (PDT) X-Google-Smtp-Source: APXvYqz7BLEOrXojvCWpx+qemogHX8L0PR2FOLxVPNCrpK3Cf/4zikbMBB7bbfa9Ki/AJzmPRwZp X-Received: by 2002:a17:906:f90c:: with SMTP id lc12mr23844704ejb.208.1571917346142; Thu, 24 Oct 2019 04:42:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571917346; cv=none; d=google.com; s=arc-20160816; b=nZEK7hO9UT67W0SdNcxj15AlBi5FIbhhFEcYuHPmG2gY+Z5LE0+4yt9cINAFRjKZ/X sd7+BLGBS6ym7QVEV8frVb7fkkc6xhfSz7xSbGrZQDmIk6eEQC2gM5U7DdnoMZelB7NH UsPRt9HTlr8syhClFg8mFpknA19Afgytqj7AQcf+I6XaknykHgJhHkHyE9PjQKk7D8OZ s+7bZxggOWnQDq/GaD8xhyzzCCkqqnKIa8JgecTndxpgF1mjHomeYFLwrPcUbrUzeVr9 5qndzzPKudbAMTbjGJ3V9H52K/njFpgfU4/fpGHYsGAwPCxXXga56QlCQqGPkzWLSwSl HB3Q== 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=VqYcBib9jdP78l6/Jj+bAwp/d6P0E9oqY7laA0s64Mg=; b=BUso48IgpE91q/lxiA841imMOjydjJrfxwhsEwR/E0tggjnbSokw8nJLx1KsE2R1wr x+OkO93yLU10UDwn30L2ILMLwzpLe5/WYwrWhYK2TYSztL52pGkmFNxPTuoBXcicmsx2 rCl2HfeyY/fqr/m8CGl0CPfJKpUAkioS9dNGNKisRPuDBWf7UmP0dk23RBsvEi0WZoS4 SceRbdt40sQf0aNt2zBgCl6b2/JEnDByy2We80U1IXvOe4S6ILAv61GGJz3uMtfvIhxC fLttgXx123Qq2Nkud4WlSRepXaSccL614C4acTI8O7fL3lbjGE5GenaL0m3nr3AfldyC ua3w== 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 og20si8392823ejb.29.2019.10.24.04.42.01; Thu, 24 Oct 2019 04:42:26 -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 S2407322AbfJWQls (ORCPT + 99 others); Wed, 23 Oct 2019 12:41:48 -0400 Received: from mx2.suse.de ([195.135.220.15]:54694 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1730796AbfJWQls (ORCPT ); Wed, 23 Oct 2019 12:41:48 -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 9DA1EAC84; Wed, 23 Oct 2019 16:41:46 +0000 (UTC) Date: Wed, 23 Oct 2019 18:41:45 +0200 From: Michal Hocko To: Andrew Morton , Mel Gorman , Waiman Long Cc: 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: <20191023164145.GL17610@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: <20191023102737.32274-3-mhocko@kernel.org> 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 With a brown paper bag bug fixed. I have also added a note about low number of pages being more important as per Vlastimil's feedback From 0282f604144a5c06fdf3cf0bb2df532411e7f8c9 Mon Sep 17 00:00:00 2001 From: Michal Hocko Date: Wed, 23 Oct 2019 12:13:02 +0200 Subject: [PATCH] mm, vmstat: reduce zone->lock holding time by /proc/pagetypeinfo 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. Suggested-by: Andrew Morton Acked-by: Mel Gorman Signed-off-by: Michal Hocko --- mm/vmstat.c | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/mm/vmstat.c b/mm/vmstat.c index 4e885ecd44d1..c156ce24a322 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) { + overflow = true; + spin_unlock_irq(&zone->lock); + cond_resched(); + spin_lock_irq(&zone->lock); + break; + } + } + seq_printf(m, "%s%6lu ", overflow ? ">" : "", freecount); } seq_putc(m, '\n'); } -- 2.20.1 -- Michal Hocko SUSE Labs