From patchwork Wed Oct 23 10:27:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Hocko X-Patchwork-Id: 11206291 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 490F5112B for ; Wed, 23 Oct 2019 10:27:53 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 156FF21872 for ; Wed, 23 Oct 2019 10:27:53 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 156FF21872 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 4A7836B000A; Wed, 23 Oct 2019 06:27:52 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 459746B000C; Wed, 23 Oct 2019 06:27:52 -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 36EFF6B000D; Wed, 23 Oct 2019 06:27:52 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0077.hostedemail.com [216.40.44.77]) by kanga.kvack.org (Postfix) with ESMTP id 1669B6B000A for ; Wed, 23 Oct 2019 06:27:52 -0400 (EDT) Received: from smtpin22.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with SMTP id A6DCC582B for ; Wed, 23 Oct 2019 10:27:51 +0000 (UTC) X-FDA: 76074673542.22.floor46_4490004acd760 X-Spam-Summary: 2,0,0,375d61053c98cbd1,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,RULES_HIT:41:355:379:541:960:966:968:973:988:989:1260:1311:1314:1345:1359:1437:1515:1535:1543:1605:1711:1730:1747:1777:1792:2194:2196:2198:2199:2200:2201:2393:2553:2559:2562:2689:2693:2731:2740:2892:2894:2898:2912:3138:3139:3140:3141:3142:3865:3866:3867:3868:3870:3871:3872:3873:3874:4117:4321:4385:5007:6120:6248:6261:7875:7903:9010:10004:11026:11232:11289:11658:11914:12296:12297:12438:12517:12519:12555:12663:12740:12895:13146:13230:13255:13894:14093:14096:14721:21080:21324:21433:21444:21450:21627:21819:21972:30003:30022:30034:30054:30070:30075:30090:30091,0,RBL:209.85.221.65:@gmail.com:.lbl8.mailshell.net-62.18.175.100 66.100.201.100,CacheIP:none,Bayesian:0.5, 0.5,0.5, X-HE-Tag: floor46_4490004acd760 X-Filterd-Recvd-Size: 6298 Received: from mail-wr1-f65.google.com (mail-wr1-f65.google.com [209.85.221.65]) by imf32.hostedemail.com (Postfix) with ESMTP for ; Wed, 23 Oct 2019 10:27:50 +0000 (UTC) Received: by mail-wr1-f65.google.com with SMTP id p4so21469431wrm.8 for ; Wed, 23 Oct 2019 03:27:50 -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=WB7/i5uuRwyukis66Pg18JvXY3b0KiEPdqkT6P2Dv5I=; b=D+pNCOeYaBZMbtn8cfAEW7S6e0mMsZdjnmCo25Rtycc2326ExrjODvJ/UuF/YIxwXB MXJTZ8H12zsdL4g9TOypc4g4GIIbp1P4XRdygxvqjNaGjB97YwnTtJaBHu6T0WfsQkNy /JyFtmLs4FLZVw3/YbbdDWLvqObFF1DncHKiHVaoNUZfJwxr56Q/LDP5WFNeLy6jRU8F xygStekBY6yrFVOkHjE23ePKuHvICqoQZcxCpnPoQgWgtre4emwEbOPlSUqYEdAwLWj9 yGLDM+iCGsV5ZQP5jaI/KT7vpivdeN1aQizsI4UQZMICUL68rjVR4nROyfdfgj8w+6mU YLMQ== X-Gm-Message-State: APjAAAWf5CmiQ5dqSfsl9Mf1ji1Du9Hb/46GH6gO25vYfWAd3CSTrNm7 QW74edxEqjL4MbOg3oO/Ciw= X-Google-Smtp-Source: APXvYqxhanNo7P+GGioOseTpZYeqbU9Rk+Vt1EErh5XE4tuQ07F4oXbDPsz/GAFPh2pt4bzO8TH5xA== X-Received: by 2002:adf:9b9d:: with SMTP id d29mr7760523wrc.293.1571826469733; Wed, 23 Oct 2019 03:27:49 -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.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Oct 2019 03:27:48 -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 Subject: [RFC PATCH 0/2] mm/vmstat: Reduce zone lock hold time when reading /proc/pagetypeinfo Date: Wed, 23 Oct 2019 12:27:35 +0200 Message-Id: <20191023102737.32274-1-mhocko@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191023095607.GE3016@techsingularity.net> References: <20191023095607.GE3016@techsingularity.net> 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: On Wed 23-10-19 10:56:08, Mel Gorman wrote: > On Wed, Oct 23, 2019 at 11:04:22AM +0200, Michal Hocko wrote: > > So can we go with this to address the security aspect of this and have > > something trivial to backport. > > > > Yes. Ok, patch 1 in reply to this email. > > > > > There is a free_area structure associated with each page order. There > > > > > is also a nr_free count within the free_area for all the different > > > > > migration types combined. Tracking the number of free list entries > > > > > for each migration type will probably add some overhead to the fast > > > > > paths like moving pages from one migration type to another which may > > > > > not be desirable. > > > > > > > > Have you tried to measure that overhead? > > > > > > > > > > I would prefer this option not be taken. It would increase the cost of > > > watermark calculations which is a relatively fast path. > > > > Is the change for the wmark check going to require more than > > diff --git a/mm/page_alloc.c b/mm/page_alloc.c > > index c0b2e0306720..5d95313ba4a5 100644 > > --- a/mm/page_alloc.c > > +++ b/mm/page_alloc.c > > @@ -3448,9 +3448,6 @@ bool __zone_watermark_ok(struct zone *z, unsigned int order, unsigned long mark, > > struct free_area *area = &z->free_area[o]; > > int mt; > > > > - if (!area->nr_free) > > - continue; > > - > > for (mt = 0; mt < MIGRATE_PCPTYPES; mt++) { > > if (!free_area_empty(area, mt)) > > return true; > > > > Is this really going to be visible in practice? Sure we are going to do > > more checks but most orders tend to have at least some memory in a > > reasonably balanced system and we can hardly expect an optimal > > allocation path on those that are not. > > > > You also have to iterate over them all later in the same function. The the > free counts are per migrate type then they would have to be iterated over > every time. > > Similarly, there would be multiple places where all the counters would > have to be iterated -- find_suitable_fallback, show_free_areas, > fast_isolate_freepages, fill_contig_page_info, zone_init_free_lists etc. > > It'd be a small cost but given that it's aimed at fixing a problem with > reading pagetypeinfo, is it really worth it? I don't think so. Fair enough. [...] > > As pointed out in other email. The problem with this patch is that it > > hasn't really removed the iteration over the whole free_list which is > > the primary problem. So I think that we should either consider this a > > non-issue and make it "admin knows this is potentially expensive" or do > > something like Andrew was suggesting if we do not want to change the > > nr_free accounting. > > > > Again, the cost is when reading a proc file. From what Andrew said, > the lock is necessary to safely walk the list but if anything. I would > be ok with limiting the length of the walk but honestly, I would also > be ok with simply deleting the proc file. The utility for debugging a > problem with it is limited now (it was more important when fragmentation > avoidance was first introduced) and there is little an admin can do with > the information. I can't remember the last time I asked for the contents > of the file when trying to debug a problem. There is a possibility that > someone will complain but I'm not aware of any utility that reads the > information and does something useful with it. In the unlikely event > something breaks, the file can be re-added with a limited walk. I went with a bound to the pages iteratred over in the free_list. See patch 2.