From patchwork Fri Oct 25 07:26:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Hocko X-Patchwork-Id: 11211533 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 3D87213B1 for ; Fri, 25 Oct 2019 07:26:32 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 1409721D71 for ; Fri, 25 Oct 2019 07:26:32 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1409721D71 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 0DF6C6B0007; Fri, 25 Oct 2019 03:26:30 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 0693E6B0008; Fri, 25 Oct 2019 03:26:29 -0400 (EDT) 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 E4B5F6B000A; Fri, 25 Oct 2019 03:26:29 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0234.hostedemail.com [216.40.44.234]) by kanga.kvack.org (Postfix) with ESMTP id B5F146B0007 for ; Fri, 25 Oct 2019 03:26:29 -0400 (EDT) Received: from smtpin22.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with SMTP id 2F37418081D7E for ; Fri, 25 Oct 2019 07:26:29 +0000 (UTC) X-FDA: 76081474098.22.sand54_38954f9ccb61c X-Spam-Summary: 2,0,0,072fcf5caf262c9e,d41d8cd98f00b204,mstsxfx@gmail.com,:akpm@linux-foundation.org:mgorman@suse.de:longman@redhat.com:hannes@cmpxchg.org:guro@fb.com:vbabka@suse.cz:khlebnikov@yandex-team.ru:jannh@google.com:songliubraving@fb.com:gregkh@linuxfoundation.org:aquini@redhat.com::linux-kernel@vger.kernel.org:mhocko@suse.com:rientjes@google.com,RULES_HIT:41:355:379:541:800:960:966:973:988:989:1260:1311:1314:1345:1359:1431:1437:1515:1534:1541:1711:1730:1747:1777:1792:2196:2198:2199:2200:2393:2559:2562:3138:3139:3140:3141:3142:3352:3865:3867:3868:3870:3871:3872:3874:4321:4385:5007:6119:6261:6742:7576:7903:10004:11026:11473:11658:11914:12043:12296:12297:12517:12519:12555:12679:12895:13069:13221:13229:13311:13357:13894:14096:14181:14384:14394:14721:21067:21080:21444:21451:21627:30045:30054,0,RBL:209.85.128.68:@gmail.com:.lbl8.mailshell.net-62.18.0.100 66.100.201.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:none,Cust om_rules X-HE-Tag: sand54_38954f9ccb61c X-Filterd-Recvd-Size: 4322 Received: from mail-wm1-f68.google.com (mail-wm1-f68.google.com [209.85.128.68]) by imf06.hostedemail.com (Postfix) with ESMTP for ; Fri, 25 Oct 2019 07:26:28 +0000 (UTC) Received: by mail-wm1-f68.google.com with SMTP id w9so876041wmm.5 for ; Fri, 25 Oct 2019 00:26:28 -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=7W6FbSGYxJZDumQvlMVc5ne/04KsfBxl9tYdZk3V7Nw=; b=LVmXcKcvCmZxtje0m4nMDT8ZGX8Fqx+2oJXgzRWIhznMPJnau/55k7xgWPbIHqAUN4 TUWJd7TLwkkiniQmH7JPCbOKkvPTmA282c5wugsNL49ukDsIghqBXgxS/wN0jGtaOZTh mFtyjtKR2lPUb3LmGRUF03ZZvjHNw2USx/50P7JyfvzDxoqj7guon7KOPMP4YBmhkVm9 oOLfGZUJoW59jsWuheWC5v6TgijMzM6a8G11Ae4vBizlvvt8eggHiesGKW9HrkhigXhv k9CqK/9cKZby9eUrPAqtnAqDiGDeB44mGilmpTHUX8IqjKu4xh/hAoYbdoMl0m/vRmCv yYjA== X-Gm-Message-State: APjAAAUqwTKZqESXQUrZUeEzlQ8xDRpOCgWI7ZDkrnm7sxf0pA2asNyc o+wvwPkpcbs0iPFF0lB0uNQ= X-Google-Smtp-Source: APXvYqzlrOJMqwfNEekFRcsxH77kBxe3u0ROf9E7iGhcUHQQHJ0GCyAXn5S6NSbQ6DgpH57CuJdohQ== X-Received: by 2002:a05:600c:2293:: with SMTP id 19mr2010511wmf.9.1571988387773; Fri, 25 Oct 2019 00:26:27 -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.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Oct 2019 00:26:27 -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 , David Rientjes Subject: [PATCH 1/2] mm, vmstat: hide /proc/pagetypeinfo from normal users Date: Fri, 25 Oct 2019 09:26:09 +0200 Message-Id: <20191025072610.18526-2-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 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 /proc/pagetypeinfo is a debugging tool to examine internal page allocator state wrt to fragmentation. It is not very useful for any other use so normal users really do not need to read this file. Waiman Long has noticed that reading this file can have negative side effects because zone->lock is necessary for gathering data and that a) interferes with the page allocator and its users and b) can lead to hard lockups on large machines which have very long free_list. Reduce both issues by simply not exporting the file to regular users. Reported-by: Waiman Long Cc: stable Fixes: 467c996c1e19 ("Print out statistics in relation to fragmentation avoidance to /proc/pagetypeinfo") Acked-by: Mel Gorman Acked-by: Vlastimil Babka Acked-by: Waiman Long Acked-by: Rafael Aquini Acked-by: David Rientjes Signed-off-by: Michal Hocko --- mm/vmstat.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/vmstat.c b/mm/vmstat.c index 6afc892a148a..4e885ecd44d1 100644 --- a/mm/vmstat.c +++ b/mm/vmstat.c @@ -1972,7 +1972,7 @@ void __init init_mm_internals(void) #endif #ifdef CONFIG_PROC_FS proc_create_seq("buddyinfo", 0444, NULL, &fragmentation_op); - proc_create_seq("pagetypeinfo", 0444, NULL, &pagetypeinfo_op); + proc_create_seq("pagetypeinfo", 0400, NULL, &pagetypeinfo_op); proc_create_seq("vmstat", 0444, NULL, &vmstat_op); proc_create_seq("zoneinfo", 0444, NULL, &zoneinfo_op); #endif From patchwork Fri Oct 25 07:26:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Hocko X-Patchwork-Id: 11211535 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 6A21F112B for ; Fri, 25 Oct 2019 07:26:34 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 41564206DD for ; Fri, 25 Oct 2019 07:26:34 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 41564206DD Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 417226B0008; Fri, 25 Oct 2019 03:26:31 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 39FBB6B000A; Fri, 25 Oct 2019 03:26:31 -0400 (EDT) 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 28C886B000C; Fri, 25 Oct 2019 03:26:31 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0138.hostedemail.com [216.40.44.138]) by kanga.kvack.org (Postfix) with ESMTP id 0260C6B0008 for ; Fri, 25 Oct 2019 03:26:30 -0400 (EDT) Received: from smtpin03.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with SMTP id 890CA81FC for ; Fri, 25 Oct 2019 07:26:30 +0000 (UTC) X-FDA: 76081474140.03.work55_38c500e4fb003 X-Spam-Summary: 2,0,0,4eef0dcd7b09f61e,d41d8cd98f00b204,mstsxfx@gmail.com,:akpm@linux-foundation.org:mgorman@suse.de:longman@redhat.com:hannes@cmpxchg.org:guro@fb.com:vbabka@suse.cz:khlebnikov@yandex-team.ru:jannh@google.com:songliubraving@fb.com:gregkh@linuxfoundation.org:aquini@redhat.com::linux-kernel@vger.kernel.org:mhocko@suse.com,RULES_HIT:41:355:379:541:800:960:966:973:988:989:1260:1311:1314:1345:1359:1431:1437:1515:1535:1542:1711:1730:1747:1777:1792:2196:2198:2199:2200:2393:2559:2562:2693:2731:3138:3139:3140:3141:3142:3354:3865:3866:3867:3868:3870:3871:3872:3874:4250:4321:4385:4605:5007:6261:6742:7576:7901:7903:10004:10128:11026:11658:11914:12043:12291:12296:12297:12438:12517:12519:12555:12679:12895:12986:13149:13161:13229:13230:13894:14181:14394:14721:21080:21433:21444:21451:21627:21939:30034:30054:30070,0,RBL:209.85.128.65:@gmail.com:.lbl8.mailshell.net-62.50.0.100 66.100.201.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL: 0,DNSBL: X-HE-Tag: work55_38c500e4fb003 X-Filterd-Recvd-Size: 5343 Received: from mail-wm1-f65.google.com (mail-wm1-f65.google.com [209.85.128.65]) by imf38.hostedemail.com (Postfix) with ESMTP for ; Fri, 25 Oct 2019 07:26:29 +0000 (UTC) Received: by mail-wm1-f65.google.com with SMTP id 11so907518wmk.0 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=IuBRDlhvxvmrp1ScC1aKsP3tU7apvMmKAjkpLhxEN+7lSACUt+RC7ss9/uUz55dk+z 8S6D6asxNA7wVXekngem66Cy1lW6WfRFO1uBlJRY4+/GDGdPwF5/vNgp02THpMddpR3/ qe93VIwgc4+kjkQY6sqSlFrUpbXRgn8zB853y3Rq4yZ3Idx4vOs1hkLCec0wEl4fGYOp Mw+2X4KnzjfxnI92EF4BH03OHjbsBhtZG3WxEXNdnRFlvORZw5qfyAtHuYRD8T/YT7Nm cXpDaZQXqBTuXj7Cfp2AUg8XD1UkfaeRy33j6DLdSp3XiZBR1WnwcUjiZ2htbuxE8tJp yQlw== X-Gm-Message-State: APjAAAVHvaoQLMqun+MLOqSbzs9F6Od+IUUN1sqGCNPI8lUnA9CUobYV Ps+CoCiz0wtdIHzKKdYfQAYtwkhQ X-Google-Smtp-Source: APXvYqzgotUGDCUQZwM9Vsb9uUsTRPRHVKF/iMxe3DUbcp0XuhY2DFbbJPpjicLQ/VwOXq0aoTMlFw== 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 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 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 Acked-by: Vlastimil Babka Acked-by: David Hildenbrand Acked-by: Rafael Aquini 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) { + 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'); }