From patchwork Wed Oct 23 10:27:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Hocko X-Patchwork-Id: 11206289 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 65F9C1951 for ; Wed, 23 Oct 2019 10:27:55 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 3CA7C20659 for ; Wed, 23 Oct 2019 10:27:55 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3CA7C20659 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 7B8146B000C; Wed, 23 Oct 2019 06:27:53 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 741006B000D; Wed, 23 Oct 2019 06:27:53 -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 62EEB6B000E; Wed, 23 Oct 2019 06:27:53 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0192.hostedemail.com [216.40.44.192]) by kanga.kvack.org (Postfix) with ESMTP id 3E76E6B000C for ; Wed, 23 Oct 2019 06:27:53 -0400 (EDT) Received: from smtpin15.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with SMTP id E85305841 for ; Wed, 23 Oct 2019 10:27:52 +0000 (UTC) X-FDA: 76074673584.15.car83_44c3e8ca28951 X-Spam-Summary: 2,0,0,4a2bc4e052fb1ea7,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:1437:1515:1534:1541:1711:1730:1747:1777:1792:2196:2199:2393:2559:2562:3138:3139:3140:3141:3142:3352:3865:3867:3868:3871:3872:3874:4321:4385:5007:6119:6120: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:14721:21067:21080:21444:21451:21627:30045:30054,0,RBL:209.85.128.67:@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:neutral,Custom_rules:0:0:0,LFtime:25,LUA_SUMMARY:n one X-HE-Tag: car83_44c3e8ca28951 X-Filterd-Recvd-Size: 4002 Received: from mail-wm1-f67.google.com (mail-wm1-f67.google.com [209.85.128.67]) by imf15.hostedemail.com (Postfix) with ESMTP for ; Wed, 23 Oct 2019 10:27:52 +0000 (UTC) Received: by mail-wm1-f67.google.com with SMTP id g24so11431764wmh.5 for ; Wed, 23 Oct 2019 03:27:52 -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=TsLzXYwYLSB8hHF4vHJgIrxG5rx+YZo4hwBqQCis9kU=; b=qtgmDbXy2Y/j79hyRWaEErbIFuI8ba+aUyCox+WyS1kUpdHeGTclhJB+MVppZZP5zS udQLYxJYUAdkNkyXZhEUavjcvz4kShX/G5n0+YuMZ3KFOCYKpgcPx7E86PtNNLqbcC3h BGYFuZlSGhmTi/R9Unoqh81kSdW2wPr0MZr5ZmnuQL0QP3vA+n6/e69uTcOSPQvrwjb4 OWMGeAI4z+LS007HB7MrCQNIKwCvnZza2xbselHX+nbNtOp5MJUaLXwEbOxLUjwaibjo xnA7DCP5UIIZeAItWLVpilaf7oY/ZBFcf+7qXoYFWxTflSTbz8b9SnFXcKi6ddRysO81 VzYw== X-Gm-Message-State: APjAAAVyyeso7cklNPn+mPXKV186/PZYoQiGd4d4Vip2wj1z4xy1rTqW WuAfpQDfIOACub55FvK45Hc= X-Google-Smtp-Source: APXvYqzP6Mht+wSNTC2Mtl2i9OMjpIr9618QNI6FunUy6TCvoivmzg9pmKUkUO33dVax3Omo1X3Haw== X-Received: by 2002:a1c:1d41:: with SMTP id d62mr7091015wmd.32.1571826471365; Wed, 23 Oct 2019 03:27:51 -0700 (PDT) Received: from tiehlicka.suse.cz (ip-37-188-173-3.eurotel.cz. [37.188.173.3]) by smtp.gmail.com with ESMTPSA id u21sm18234122wmu.27.2019.10.23.03.27.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Oct 2019 03:27:50 -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: [RFC PATCH 1/2] mm, vmstat: hide /proc/pagetypeinfo from normal users Date: Wed, 23 Oct 2019 12:27:36 +0200 Message-Id: <20191023102737.32274-2-mhocko@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191023102737.32274-1-mhocko@kernel.org> References: <20191023095607.GE3016@techsingularity.net> <20191023102737.32274-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 Signed-off-by: Michal Hocko Acked-by: Mel Gorman Acked-by: Vlastimil Babka Acked-by: Waiman Long Acked-by: Rafael Aquini Acked-by: David Rientjes --- 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 Wed Oct 23 10:27:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Hocko X-Patchwork-Id: 11206293 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 6F0F01515 for ; Wed, 23 Oct 2019 10:27:57 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 3BB5721872 for ; Wed, 23 Oct 2019 10:27:57 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3BB5721872 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 76CA96B000D; Wed, 23 Oct 2019 06:27:55 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 62EBE6B000E; Wed, 23 Oct 2019 06:27:55 -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 4D0706B0010; Wed, 23 Oct 2019 06:27:55 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0051.hostedemail.com [216.40.44.51]) by kanga.kvack.org (Postfix) with ESMTP id 27BFB6B000D for ; Wed, 23 Oct 2019 06:27:55 -0400 (EDT) Received: from smtpin12.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with SMTP id C5688181AC9BF for ; Wed, 23 Oct 2019 10:27:54 +0000 (UTC) X-FDA: 76074673668.12.legs81_45096624ff942 X-Spam-Summary: 2,0,0,8299d49c00af93cd,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:1534:1542:1711:1730:1747:1777:1792:2196:2198:2199:2200:2393:2559:2562:2693:2731:2898:3138:3139:3140:3141:3142:3354:3865:3866:3867:3868:3870:3871:3872:3874:4321:4385:4605:5007:6120:6261:6742:7576:7901:7903:10004:11026:11658:11914:12043:12296:12297:12438:12517:12519:12555:12679:12895:12986:13149:13161:13229:13230:13255:13894:14181:14721:21080:21444:21451:21627:21939:30034:30054:30070,0,RBL:209.85.221.66:@gmail.com:.lbl8.mailshell.net-62.18.175.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:neu tral,Cus X-HE-Tag: legs81_45096624ff942 X-Filterd-Recvd-Size: 4906 Received: from mail-wr1-f66.google.com (mail-wr1-f66.google.com [209.85.221.66]) by imf17.hostedemail.com (Postfix) with ESMTP for ; Wed, 23 Oct 2019 10:27:54 +0000 (UTC) Received: by mail-wr1-f66.google.com with SMTP id c2so16227331wrr.10 for ; Wed, 23 Oct 2019 03:27:54 -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=HogpH9E/f0iRGMXfxCc+U7lRJjZn9ahpkT4ZsQUlsRA=; b=QkIwrFbRf/9bpKIBVMU3h8i5HUAzn72QEitgmOJTk7gz1OmDTZwpdUpJaxTnVCq3qm Cl3AxEKnxsqUMOyOL1czz9p0TeCBfYRuEp1yxBpx9NOjS2D7qWWSZkuutT7txlXLKJ9A wHS4y8BhpwAFRmP5n9BPj8MiyFcgNk7JdFTlWGqNrojEFHcAFu/GlgS3I84tDqbLfMSo g7HaZb4Nsweq/nkaIWY8JWgd31j3s1Xl9jENlY0/28Yoi/GcN4mZ5EVvW+2mDXwhZM5R gd6SAQ4O+Sip4Q5DxxKyhM3Z9Z7AMwVVhPGDk+16O0IpgKxBIX/eXlG1HMj/H1e2I0Hj b73w== X-Gm-Message-State: APjAAAWec8h7ErtZg+C1W32Nn7GkGJWlVeLvTc3gbv/PIINCLwTxDTRQ GaQrg1TRV5xGS6iUQOLoBVY= X-Google-Smtp-Source: APXvYqxgZBZbWr+ZaAPWcVFpHB2ZDTH3/EHAddQJLlI72Frxl1clvXwGfNlUONV6WKYAB5Vnp2ejpw== X-Received: by 2002:adf:f685:: with SMTP id v5mr7993017wrp.246.1571826473245; Wed, 23 Oct 2019 03:27:53 -0700 (PDT) Received: from tiehlicka.suse.cz (ip-37-188-173-3.eurotel.cz. [37.188.173.3]) by smtp.gmail.com with ESMTPSA id u21sm18234122wmu.27.2019.10.23.03.27.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Oct 2019 03:27:52 -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: [RFC PATCH 2/2] mm, vmstat: reduce zone->lock holding time by /proc/pagetypeinfo Date: Wed, 23 Oct 2019 12:27:37 +0200 Message-Id: <20191023102737.32274-3-mhocko@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191023102737.32274-1-mhocko@kernel.org> References: <20191023095607.GE3016@techsingularity.net> <20191023102737.32274-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 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 Signed-off-by: Michal Hocko Acked-by: Mel Gorman Acked-by: Mel Gorman Signed-off-by: Michal Hocko Reviewed-by: Waiman Long --- mm/vmstat.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/mm/vmstat.c b/mm/vmstat.c index 4e885ecd44d1..762034fc3b83 100644 --- a/mm/vmstat.c +++ b/mm/vmstat.c @@ -1386,8 +1386,25 @@ static void pagetypeinfo_showfree_print(struct seq_file *m, area = &(zone->free_area[order]); - list_for_each(curr, &area->free_list[mtype]) + list_for_each(curr, &area->free_list[mtype]) { freecount++; + /* + * 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) { + seq_printf(m, ">%6lu ", freecount); + spin_unlock_irq(&zone->lock); + cond_resched(); + spin_lock_irq(&zone->lock); + continue; + } + } seq_printf(m, "%6lu ", freecount); } seq_putc(m, '\n');