Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp2942630ybl; Sun, 26 Jan 2020 14:49:36 -0800 (PST) X-Google-Smtp-Source: APXvYqyC2SjejpkSDe1qTeGgAmjp25ZXVFKGTJnHyKwBgV530/RZ/kDiSEGDL6k/WqFH0J4Sp4FD X-Received: by 2002:aca:ea46:: with SMTP id i67mr5604693oih.149.1580078976051; Sun, 26 Jan 2020 14:49:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580078976; cv=none; d=google.com; s=arc-20160816; b=Ajlxi597P1i6wvgNJfVy4YEIsWqtIMt2s8uvk2CFfCmXwSKqO4TWFIkvGZBMkytCE/ YxHNvXo4ASii/0fVASbw+77mFwDo5O2IEay4itQpA8FBOTVy3LQZ56WiuZzbuEgbaNk3 O+uxw4t4n45GdG4UAKlSfPOnk1Ql4cE2Jt1GBEGJg2xaTyYlvlhzwD1yAish5F4BIiWc ZSYoI7wSPTC9zf+hGDUe1r4J+1dyo9pKf+Dg1LWKgmXjRz0DGn58rgTtvz9VisB70hZE UCuj7cGhaYwCO6sb0vtbajacdV8dHY/ikUqvQc5Pzca4qHvW6m7w/KJu/ev0IgxMiVmB BS7Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date:dkim-signature; bh=TjEZMOqVvMiaHfNHrbmYpQxyaSRI+vukKCsubEmmQJg=; b=bUQ4UmlWRKQSKv/OnSif7bYa0JXEhNNpxyZhtV6h9BYi5hGSDnK3P4hmt2Wf69pCSr kBY4/2OgvUQmDQmWhLHo4p4gljWFfIvfdK1MyJPizt0XPtAqMj9ZnC4Hsle8HddRhi/n +uNVkvUIt5RJk/g58xWpmyStYQwsxh2zyMlbu7lojQaCYerdm2OEo2CUBONUrqdgIj8l xJ2u1b+Vk7SRGOo4OLxCjxuLdt2v26rZNazyQs71E5wmQaJAPbwcRHuRheFmoTkNMij8 /1pCimQ5gm7dsWDVQ0UAeE+MKUoOtfXCvhd8L6wnpf5evFUAPJHEuZRUZqMxli4XEUUm EKEA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=LiZhUOIe; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n14si6183139otk.179.2020.01.26.14.49.23; Sun, 26 Jan 2020 14:49:36 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=LiZhUOIe; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727586AbgAZWoe (ORCPT + 99 others); Sun, 26 Jan 2020 17:44:34 -0500 Received: from mail-pl1-f193.google.com ([209.85.214.193]:44500 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726144AbgAZWod (ORCPT ); Sun, 26 Jan 2020 17:44:33 -0500 Received: by mail-pl1-f193.google.com with SMTP id d9so3043192plo.11 for ; Sun, 26 Jan 2020 14:44:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:in-reply-to:message-id:references :user-agent:mime-version; bh=TjEZMOqVvMiaHfNHrbmYpQxyaSRI+vukKCsubEmmQJg=; b=LiZhUOIecHLFKlKOf5LwM4AY0QJraXq2Eq6Cz5mZp25Tz4Ct5naIHG+lpYNxphSzKQ 75RjI+ggnHay5WPKmLtXxy05GkRnAgPzrxeM2eTYq6HFEjrjOWJu/m9x6pbkqD7fQOMW cQ4RExcCIJA8/9chPkONZEGXG6KNC/8JxBPjt2Nyik+qLMoIZ4x6iaIjrjQ/0RxhUmnF PTHQ8GqWkAQFZXiv8jLRjP7JQrjC6qXzIpz/Xon+MgyOPWF77OpSYfWjtd7tziFvfUjT 3mrkaCVOJTlsSI5o3TZucd+TGTlTesn54wOY08+xPnAD5ROcAHy39E7pNY63xQDZ490F n8DA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:in-reply-to:message-id :references:user-agent:mime-version; bh=TjEZMOqVvMiaHfNHrbmYpQxyaSRI+vukKCsubEmmQJg=; b=iN3E+IsUwo+J+lBuZveP2siu/U/YP+dv2djJi75k1R3PTDqJAzQuF79CuIyzir20VZ eFIMp2FPLYwCAQlMF446R/X6F+tKrsV2bMvVWj5WoCf2PXDvtRqOkNtZtZnnOgIe2SGo YdBmoO35uF7F37kDueG06QRsA8UWxzKm6mQsr+C7zM0fHfH6dQBk/9dG3mB2ATEhUT5Y iZ4SQYGDjig+7VGwmCo9YrsjHngURoRwT3qzewwdOelwTc/weBqU8FseWeLcJoLmg0gp ygkhZBXeuMoZHu96uXYJdRYcLuRgxmTMRT+6jwSXHA7/z0o3/TG1iUncNGiiHFkUKDaK jtkw== X-Gm-Message-State: APjAAAUYaMSt7bEk5uvMzW6G7zAUPDFl2nca6Z1cL5JcJJVoszYwLL6N To/69HxpF9GygO4lGiXsa7XqSw== X-Received: by 2002:a17:90a:e2d4:: with SMTP id fr20mr11737424pjb.85.1580078672716; Sun, 26 Jan 2020 14:44:32 -0800 (PST) Received: from [2620:15c:17:3:3a5:23a7:5e32:4598] ([2620:15c:17:3:3a5:23a7:5e32:4598]) by smtp.gmail.com with ESMTPSA id q6sm13303717pgt.47.2020.01.26.14.44.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Jan 2020 14:44:31 -0800 (PST) Date: Sun, 26 Jan 2020 14:44:31 -0800 (PST) From: David Rientjes X-X-Sender: rientjes@chino.kir.corp.google.com To: Wei Yang cc: akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] mm/vmscan.c: only adjust related kswapd cpu affinity when online cpu In-Reply-To: <20200126132052.11921-1-richardw.yang@linux.intel.com> Message-ID: References: <20200126132052.11921-1-richardw.yang@linux.intel.com> User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, 26 Jan 2020, Wei Yang wrote: > When onlining a cpu, kswapd_cpu_online() is called to adjust kswapd cpu > affinity. > > Current routine does like this: > > * Iterate all the numa node > * Adjust cpu affinity when node has an online cpu > > Actually we could improve this by: > > * Just adjust the numa node to which current online cpu belongs > > Because we know which numa node the cpu belongs to and this cpu would > not affect other node. > Is there ever a situation where the cpu to be onlined would have appeared in the cpumask of another node and so a different kswapd's cpumask would now include an off-node cpu? > Signed-off-by: Wei Yang > --- > mm/vmscan.c | 19 ++++++++++--------- > 1 file changed, 10 insertions(+), 9 deletions(-) > > diff --git a/mm/vmscan.c b/mm/vmscan.c > index 572fb17c6273..19c92d35045c 100644 > --- a/mm/vmscan.c > +++ b/mm/vmscan.c > @@ -4049,18 +4049,19 @@ unsigned long shrink_all_memory(unsigned long nr_to_reclaim) > restore their cpu bindings. */ > static int kswapd_cpu_online(unsigned int cpu) > { > - int nid; > + int nid = cpu_to_node(cpu); > + pg_data_t *pgdat; > + const struct cpumask *mask; > > - for_each_node_state(nid, N_MEMORY) { > - pg_data_t *pgdat = NODE_DATA(nid); > - const struct cpumask *mask; > + if (!node_state(nid, N_MEMORY)) > + return 0; > > - mask = cpumask_of_node(pgdat->node_id); > + pgdat = NODE_DATA(nid); > + mask = cpumask_of_node(nid); > + > + /* One of our CPUs online: restore mask */ > + set_cpus_allowed_ptr(pgdat->kswapd, mask); > > - if (cpumask_any_and(cpu_online_mask, mask) < nr_cpu_ids) > - /* One of our CPUs online: restore mask */ > - set_cpus_allowed_ptr(pgdat->kswapd, mask); > - } > return 0; > } > > -- > 2.17.1 > > >