From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=3.0 tests=INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E14D1CA9EB6 for ; Wed, 23 Oct 2019 10:27:52 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id A003D20650 for ; Wed, 23 Oct 2019 10:27:52 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A003D20650 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) Received: by kanga.kvack.org (Postfix, from userid 40) id 459746B000C; Wed, 23 Oct 2019 06:27:52 -0400 (EDT) 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-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-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 Content-Transfer-Encoding: quoted-printable 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 hav= e > > something trivial to backport. > >=20 >=20 > 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 differ= ent > > > > > migration types combined. Tracking the number of free list entr= ies > > > > > for each migration type will probably add some overhead to the = fast > > > > > paths like moving pages from one migration type to another whic= h may > > > > > not be desirable. > > > >=20 > > > > Have you tried to measure that overhead? > > > > =20 > > >=20 > > > I would prefer this option not be taken. It would increase the cost= of > > > watermark calculations which is a relatively fast path. > >=20 > > 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, unsign= ed int order, unsigned long mark, > > struct free_area *area =3D &z->free_area[o]; > > int mt; > > =20 > > - if (!area->nr_free) > > - continue; > > - > > for (mt =3D 0; mt < MIGRATE_PCPTYPES; mt++) { > > if (!free_area_empty(area, mt)) > > return true; > >=20 > > 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. > > =20 >=20 > 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 ov= er > every time. >=20 > 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= . >=20 > 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. > >=20 >=20 > 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 fragmentatio= n > avoidance was first introduced) and there is little an admin can do wit= h > the information. I can't remember the last time I asked for the content= s > 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. --=20 Michal Hocko SUSE Labs