From patchwork Wed Nov 6 05:16:44 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Morton X-Patchwork-Id: 11229309 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 842AB15AB for ; Wed, 6 Nov 2019 05:16:48 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 3CD1B217F5 for ; Wed, 6 Nov 2019 05:16:48 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="13AHPYdq" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3CD1B217F5 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linux-foundation.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 47D056B0270; Wed, 6 Nov 2019 00:16:47 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 42CC56B0271; Wed, 6 Nov 2019 00:16:47 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 343686B0272; Wed, 6 Nov 2019 00:16:47 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0040.hostedemail.com [216.40.44.40]) by kanga.kvack.org (Postfix) with ESMTP id 201A26B0270 for ; Wed, 6 Nov 2019 00:16:47 -0500 (EST) Received: from smtpin23.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with SMTP id D2E2E441E for ; Wed, 6 Nov 2019 05:16:46 +0000 (UTC) X-FDA: 76124692812.23.mine07_3b24fa18f5303 X-Spam-Summary: 2,0,0,643427dfa3096fc7,d41d8cd98f00b204,akpm@linux-foundation.org,:akpm@linux-foundation.org:aquini@redhat.com:david@redhat.com:gregkh@linuxfoundation.org:guro@fb.com:hannes@cmpxchg.org:jannh@google.com:khlebnikov@yandex-team.ru::longman@redhat.com:mgorman@suse.de:mhocko@suse.com:mm-commits@vger.kernel.org:rientjes@google.com:songliubraving@fb.com:torvalds@linux-foundation.org:vbabka@suse.cz,RULES_HIT:41:355:379:800:960:966:967:973:988:989:1260:1263:1345:1381:1431:1437:1534:1543:1711:1730:1747:1777:1792:2196:2198:2199:2200:2393:2525:2559:2563:2682:2685:2693:2731:2859:2902:2933:2937:2939:2942:2945:2947:2951:2954:3022:3138:3139:3140:3141:3142:3355:3865:3866:3867:3868:3870:3871:3872:3874:3934:3936:3938:3941:3944:3947:3950:3953:3956:3959:4250:4321:4385:4605:5007:6261:6653:6737:7576:7901:7903:8599:9025:9207:9545:10004:10128:10913:11026:11658:11914:12043:12048:12291:12296:12297:12438:12517:12519:12555:12679:12783:12986:13149:13161:13229:13230:13846:14181:14721:14849 :14915:2 X-HE-Tag: mine07_3b24fa18f5303 X-Filterd-Recvd-Size: 4940 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf07.hostedemail.com (Postfix) with ESMTP for ; Wed, 6 Nov 2019 05:16:46 +0000 (UTC) Received: from localhost.localdomain (c-73-231-172-41.hsd1.ca.comcast.net [73.231.172.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id B5F6921A49; Wed, 6 Nov 2019 05:16:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1573017405; bh=cg/Xg2ZYmhpNwCUnp1S84InZujsfKbhVvuJtA4z0YhQ=; h=Date:From:To:Subject:From; b=13AHPYdqEeiEn3a0VNXC+AlzS573K5YLd4pACG0C23VENveOHvYxRbVSI8z++PLI9 f2zOcji5DDqe3jcJPFS/atdO/Bu2blA5RSYhZOUE6ZrnD6mpJiCHtjFL+DFzDupE+b vL7kkrb5i3OywAObuJrUjs9VaYnI/bX+Udjgsk20= Date: Tue, 05 Nov 2019 21:16:44 -0800 From: akpm@linux-foundation.org To: akpm@linux-foundation.org, aquini@redhat.com, david@redhat.com, gregkh@linuxfoundation.org, guro@fb.com, hannes@cmpxchg.org, jannh@google.com, khlebnikov@yandex-team.ru, linux-mm@kvack.org, longman@redhat.com, mgorman@suse.de, mhocko@suse.com, mm-commits@vger.kernel.org, rientjes@google.com, songliubraving@fb.com, torvalds@linux-foundation.org, vbabka@suse.cz Subject: [patch 08/17] mm, vmstat: reduce zone->lock holding time by /proc/pagetypeinfo Message-ID: <20191106051644.jR9CWg6LN%akpm@linux-foundation.org> User-Agent: s-nail v14.8.16 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: From: Michal Hocko Subject: 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. 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. [akpm@linux-foundation.org: tweak comment text, per David Hildenbrand] Link: http://lkml.kernel.org/r/20191025072610.18526-3-mhocko@kernel.org Signed-off-by: Michal Hocko Suggested-by: Andrew Morton Reviewed-by: Waiman Long Acked-by: Vlastimil Babka Acked-by: David Hildenbrand Acked-by: Rafael Aquini Acked-by: David Rientjes Reviewed-by: Andrew Morton Cc: Greg Kroah-Hartman Cc: Jann Horn Cc: Johannes Weiner Cc: Konstantin Khlebnikov Cc: Mel Gorman Cc: Roman Gushchin Cc: Song Liu Signed-off-by: Andrew Morton --- mm/vmstat.c | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) --- a/mm/vmstat.c~mm-vmstat-reduce-zone-lock-holding-time-by-proc-pagetypeinfo +++ a/mm/vmstat.c @@ -1383,12 +1383,29 @@ static void pagetypeinfo_showfree_print( 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 of 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'); }