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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 87C9EC433EF for ; Thu, 28 Apr 2022 00:20:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 940D46B0071; Wed, 27 Apr 2022 20:20:05 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8C94F6B0073; Wed, 27 Apr 2022 20:20:05 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 742B66B0074; Wed, 27 Apr 2022 20:20:05 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.hostedemail.com [64.99.140.25]) by kanga.kvack.org (Postfix) with ESMTP id 63F4F6B0071 for ; Wed, 27 Apr 2022 20:20:05 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 3212F61B70 for ; Thu, 28 Apr 2022 00:20:05 +0000 (UTC) X-FDA: 79404380370.29.863DB44 Received: from mail-lf1-f42.google.com (mail-lf1-f42.google.com [209.85.167.42]) by imf08.hostedemail.com (Postfix) with ESMTP id 78793160053 for ; Thu, 28 Apr 2022 00:19:58 +0000 (UTC) Received: by mail-lf1-f42.google.com with SMTP id p10so5813429lfa.12 for ; Wed, 27 Apr 2022 17:20:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=qNZjVSOl3+SKxT0abGlcYzEnmnW7jx9+eRVJWTFACx4=; b=Q7FqlTONWgOWGuUufc1hiL3Tz+ke7VXv4mrclHLUpuR/BN+MLAo7FdYp4S9lhZb0rz vFIgg0BdCrdKYfKuD1T2vxzY7AyNCbvaFguWaA+/xaHBhrP7Oajhktw7JECcojhMPe8D oQ+Yh9J9Op5DNOrPgVE9qhonDahy8WtnHMYM9seTjUgrCs6OL5iWuIaxFhvINxzUlXLN MU3GLUHBSBrk+AsPO1EojQ03OKOvGl2gYawRq723OVuL2C1JXxh8JrThsfZxZr2MLrEt N1ghy+OlJ3Xe3bLM4FcSFlhkio0rQ3Zyewm3TjSNlc44sAKYTAF+L/hxSW2PgsM7esub IApw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=qNZjVSOl3+SKxT0abGlcYzEnmnW7jx9+eRVJWTFACx4=; b=yc8SFkIIynTh9lfYcl5qzs3h8lzOt8zFu/E2MTciSpGUvcDiHM1aVabDhgJIotDOjj R5jDmAuivir9XV4kngM2ZLU1/XdW2EAKMYDPkdCCHxmH73oQcBdTMh3XgG4UOM2cyMGO Vix2fxvMOyXLAaVWFBVbtaD1CoqDGnyMUSzvVIrtA5m8OQGaW4VIi6+UtyCG2W2z3r7J AGVybkHZTn0LNBsC8ClOt9cZof32mov9JtZEPWLuQ77JhqSqwCg/R07hpHaU2QUteC6w UxcZQ/5/wM5vGKFA+oUi3VRXNVbThSTx+vsm304AeK+V4oym8PQEzZjKXbG4yHZBZyff 369A== X-Gm-Message-State: AOAM531V8TX6+gwdH4KudKukWddPR21rACh2aE9N/jKedwW46tamlnrf hq+OHuA9oCOeFb6GeD2qSPBlEnRHXg3MWg4LuSKeEQ== X-Google-Smtp-Source: ABdhPJxmpOjmVVQTFFAq6JV/YtG/wgcjbvxWDJ6cG3nn/fehZU4gUpSePwenM4DUSL70zkBmXaRHpPrRIWVNEwi6NAA= X-Received: by 2002:a05:6512:131b:b0:44b:75d:e3d0 with SMTP id x27-20020a056512131b00b0044b075de3d0mr21842066lfu.685.1651105202571; Wed, 27 Apr 2022 17:20:02 -0700 (PDT) MIME-Version: 1.0 References: <20220426144412.742113-1-zokeefe@google.com> <20220426144412.742113-3-zokeefe@google.com> In-Reply-To: From: "Zach O'Keefe" Date: Wed, 27 Apr 2022 17:19:25 -0700 Message-ID: Subject: Re: [PATCH v3 02/12] mm/khugepaged: add struct collapse_control To: Peter Xu Cc: Alex Shi , David Hildenbrand , David Rientjes , Matthew Wilcox , Michal Hocko , Pasha Tatashin , SeongJae Park , Song Liu , Vlastimil Babka , Yang Shi , Zi Yan , linux-mm@kvack.org, Andrea Arcangeli , Andrew Morton , Arnd Bergmann , Axel Rasmussen , Chris Kennelly , Chris Zankel , Helge Deller , Hugh Dickins , Ivan Kokshaysky , "James E.J. Bottomley" , Jens Axboe , "Kirill A. Shutemov" , Matt Turner , Max Filippov , Miaohe Lin , Minchan Kim , Patrick Xia , Pavel Begunkov , Thomas Bogendoerfer Content-Type: text/plain; charset="UTF-8" X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 78793160053 X-Stat-Signature: htgmsw348456wehydu8x4k734g5xz4pn X-Rspam-User: Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=Q7FqlTON; spf=pass (imf08.hostedemail.com: domain of zokeefe@google.com designates 209.85.167.42 as permitted sender) smtp.mailfrom=zokeefe@google.com; dmarc=pass (policy=reject) header.from=google.com X-HE-Tag: 1651105198-789975 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, Apr 27, 2022 at 12:49 PM Peter Xu wrote: > > On Tue, Apr 26, 2022 at 07:44:02AM -0700, Zach O'Keefe wrote: > > Modularize hugepage collapse by introducing struct collapse_control. > > This structure serves to describe the properties of the requested > > collapse, as well as serve as a local scratch pad to use during the > > collapse itself. > > Reasonable, but IMHO worth mentioning that "we're introducing the context > by first moving the per-node statistics into ...", or something like that. > Sounds good to me. Updated. > > > > Signed-off-by: Zach O'Keefe > > --- > > mm/khugepaged.c | 79 ++++++++++++++++++++++++++++--------------------- > > 1 file changed, 46 insertions(+), 33 deletions(-) > > > > diff --git a/mm/khugepaged.c b/mm/khugepaged.c > > index 2933b13fc975..9d42fa330812 100644 > > --- a/mm/khugepaged.c > > +++ b/mm/khugepaged.c > > @@ -86,6 +86,14 @@ static struct kmem_cache *mm_slot_cache __read_mostly; > > > > #define MAX_PTE_MAPPED_THP 8 > > > > +struct collapse_control { > > + /* Num pages scanned per node */ > > + int node_load[MAX_NUMNODES]; > > + > > + /* Last target selected in khugepaged_find_target_node() for this scan */ > > Not really important, but.. iiuc this is not only for this scan but for all > scans of the khugepaged thread. > Thanks for catching this. I've removed the "for this scan" bit to avoid confusion. > > + int last_target_node; > > +}; > > [...] > > > @@ -829,28 +835,28 @@ static inline gfp_t alloc_hugepage_khugepaged_gfpmask(void) > > } > > > > #ifdef CONFIG_NUMA > > -static int khugepaged_find_target_node(void) > > +static int khugepaged_find_target_node(struct collapse_control *cc) > > { > > - static int last_khugepaged_target_node = NUMA_NO_NODE; > > int nid, target_node = 0, max_value = 0; > > > > /* find first node with max normal pages hit */ > > for (nid = 0; nid < MAX_NUMNODES; nid++) > > - if (khugepaged_node_load[nid] > max_value) { > > - max_value = khugepaged_node_load[nid]; > > + if (cc->node_load[nid] > max_value) { > > + max_value = cc->node_load[nid]; > > target_node = nid; > > } > > > > /* do some balance if several nodes have the same hit record */ > > - if (target_node <= last_khugepaged_target_node) > > - for (nid = last_khugepaged_target_node + 1; nid < MAX_NUMNODES; > > - nid++) > > - if (max_value == khugepaged_node_load[nid]) { > > + if (target_node <= cc->last_target_node) > > + for (nid = cc->last_target_node + 1; nid < MAX_NUMNODES; > > + nid++) { > > + if (max_value == cc->node_load[nid]) { > > target_node = nid; > > break; > > } > > + } > > I'm not sure what's the coding style for this case, but IIUC we could > either add both (to both outer "if" and "for") or none; adding one pair of > brackets seems a bit odd. > Sorry about that - remnant of a change that was (partially) reverted. I've removed the extra brackets to keep change minimal. Thank you. > > > > - last_khugepaged_target_node = target_node; > > + cc->last_target_node = target_node; > > return target_node; > > } > > -- > Peter Xu >