Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp4039480ybg; Fri, 25 Oct 2019 12:26:45 -0700 (PDT) X-Google-Smtp-Source: APXvYqxxNlpnekxcFh/bFqsjwZ77OfqKokOHPfyku2baZERebL5wl69rlloW2gurP2J1SMr1UNUV X-Received: by 2002:a05:6402:2d4:: with SMTP id b20mr3498100edx.103.1572031605296; Fri, 25 Oct 2019 12:26:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572031605; cv=none; d=google.com; s=arc-20160816; b=MmG0jq78kuagEceQMiEcAPfC+Gt0p6Q+kx2mN2Ob69g+uf/Lbj3PkNWeAplOioYKB6 pUp7Kiv88HMse+uvGNMsPGAWbLbJXiPkXZL+Eqhh/TkS17IHRaB5HZiPAeniZtnaE5rv ElD/bpkWioZ5arioUD2U+drFyj5wiEVOavVqjnInbDe2BwCEAqYoyeFjewDP90wTm7Qi mK2hUZZ7j+vOahuv6NJUTOJ+lMB0Cb1a29wdCPDMxWRmkQnFtt45dsLF1xkFlthZfkER J6q8bJ7UGkv47GSsltsSh+SwSDgsY7eE/7+ubLo7voG9mNNjGf9aaf38LTGBkC2DARtB DYXw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=6pRXYeWKUORo8utPtv70wDXbv/nqcWSG3JUe6r/PfEI=; b=NZCNp9Xp51JIGd0pujv/qOMBXjQj6Vr0gPssXtPRTRdAsCLmownfQu+ZOMJw09u1d9 aRUx8w5YhxIdgOTl+l/Ma9yEh/sD4JgDkBG5OprN6br/JZ/qTY/bhvuFicoFhK7nWblM TcWZpDmIU/dudGwxKOTOUbloHpAOiqCsaPYyUrobzYHHvVEWgdzoijl7gUWV1c+jAO6y vOzSBoKL1ap2O3xKPynUlMLQwG+E1jBkpvzrf288e67tlqtbP++O951mKCyquS0enWHD hUajnykZhou+Brv4UV1CdkXSfQ4nPKkT4fdeZLRrNOLbHnHdEa2beFfpcCurPSVAoh9L O3Bw== 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 s21si1928238edm.311.2019.10.25.12.26.20; Fri, 25 Oct 2019 12:26:45 -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 S2436564AbfJYH0d (ORCPT + 99 others); Fri, 25 Oct 2019 03:26:33 -0400 Received: from mail-wm1-f66.google.com ([209.85.128.66]:51874 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2436532AbfJYH0c (ORCPT ); Fri, 25 Oct 2019 03:26:32 -0400 Received: by mail-wm1-f66.google.com with SMTP id q70so905073wme.1 for ; Fri, 25 Oct 2019 00:26:29 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=6pRXYeWKUORo8utPtv70wDXbv/nqcWSG3JUe6r/PfEI=; b=YYlLYoDROqbWwUtfTPNjepxcl8HiTTjq5OIslAlcY4i1JtM2Veu/FyZJRtpqTpSiMe 1TleEkPufyv41ZtdooikuHD97vptVcZ1YyUYgasNn7hQ9VNXoTzP5084+6yF74jSe03l 5hYNuR1/n+QFteqaOoM0ohdoWkU7hMjdzRJcGokVDkC4imte9om91uKM36IJv2niDzlH GasMWrE5K1mC0iEJFe3zuy2tOCsO5ubGrB+xjajoIXhgqlCgl/OgvX733B6i+59wxksH jXVR96nxhkqAz2gU34tW180p00ElVE5geNNre8egTS21Mz8xPew3lmjpcLWR5AybSb02 8AQA== X-Gm-Message-State: APjAAAXDyRTVPNjGszozn2xUjQnZsgNGekYqbzER0LWway/AoM9519yG rBnb36kKWWMEgprSCjAZoZw= X-Received: by 2002:a7b:c925:: with SMTP id h5mr1832355wml.61.1571988389054; Fri, 25 Oct 2019 00:26:29 -0700 (PDT) Received: from tiehlicka.microfocus.com (prg-ext-pat.suse.com. [213.151.95.130]) by smtp.gmail.com with ESMTPSA id x21sm1482446wmj.42.2019.10.25.00.26.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Oct 2019 00:26:28 -0700 (PDT) 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 , , LKML , Michal Hocko Subject: [PATCH 2/2] mm, vmstat: reduce zone->lock holding time by /proc/pagetypeinfo Date: Fri, 25 Oct 2019 09:26:10 +0200 Message-Id: <20191025072610.18526-3-mhocko@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191025072610.18526-1-mhocko@kernel.org> References: <20191025072610.18526-1-mhocko@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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) { + 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'); } -- 2.20.1