Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp906192ybl; Fri, 9 Aug 2019 16:07:12 -0700 (PDT) X-Google-Smtp-Source: APXvYqwOTZVN+EHrpLGpW/N6T6NDjpjIAU9bgVlKDnJfS8yTsaX4bb/6PfDxY1LRXj+UzdxKEGJV X-Received: by 2002:a63:5a0a:: with SMTP id o10mr19834926pgb.282.1565392032735; Fri, 09 Aug 2019 16:07:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565392032; cv=none; d=google.com; s=arc-20160816; b=h495B3kX+WkL5DU64MpWVz47On+48OXPyTceI1l8ftyiDhwkvOFOoNCrd8nxcNbyrV 1O/SZSEW/Qr/8nK1FqA5WUG8P86AMvacCQpXfHT4BJ2CEfVq5lueh7sfm56Vr9FgnnzA moorOqP3tnL63mHK6WE8WUhoiQIjMDRic/Qcs6fpK5MN2mjFaIIAxrX/NKYChNqV266t /Gqh1AaEUHuM/ClB26lZyS4BSCoZDrqxXeHl97f5Zq6ENsiqjnhxY7H3b0nzYAsy8rbj z+jPMxWnyeAq1pBSSCeEE4T+/Wjrjv/Y0d1Et8OX2sc4fXLR9yuxGpwmpUglpiUXbzb8 ekWw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=1VwyOAXo7eohMBN8xZNUOLTE4Y6Up/vz30c30b2901o=; b=ZU0wbdcXd6+a3fFfDh10gWelj7YqctFMWc1LYjXcMe/v7BFn9kBGjFQR2YuJS6ncB0 aoZ1ocn+4oJ2nmyBd4/lFfcrpEnoMCQaJulONRcvl7UK4ZgsOfJri/UOu9Co+wGWF2nc yBiJ2h1/RCnDW1wq5TJD1NT1e9iR72FoLx02OgBESOKRt0obnq9gDDnTuRWy22X7Nb3v Oq2AItlaK29XUvCd4VEiuJJxK4RG1sLGuMcq/PoTIn7PhDGEuOaLXEafhwl+w0bI03kT hWEPsUFKzciGFySYrwomfBtxl8Xw4r8Pdn1U3QkjV/A57o3zvrgbwPzK9ieOaBFazrvO JwJg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="mWeeK/dI"; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c13si7663490pfr.36.2019.08.09.16.06.57; Fri, 09 Aug 2019 16:07:12 -0700 (PDT) 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=@gmail.com header.s=20161025 header.b="mWeeK/dI"; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726972AbfHIXFv (ORCPT + 99 others); Fri, 9 Aug 2019 19:05:51 -0400 Received: from mail-wm1-f68.google.com ([209.85.128.68]:39835 "EHLO mail-wm1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726053AbfHIXFu (ORCPT ); Fri, 9 Aug 2019 19:05:50 -0400 Received: by mail-wm1-f68.google.com with SMTP id u25so6886603wmc.4 for ; Fri, 09 Aug 2019 16:05:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=1VwyOAXo7eohMBN8xZNUOLTE4Y6Up/vz30c30b2901o=; b=mWeeK/dI7isF36qGFvVF6s8fzsuKm/X9kRrS0TRtB+fNCmtNJGRZMcHSGY/ib1FnIA UY1m7UVvnn1hGBSuYxwSRwze4J00e/39Z8hoJzIXsTzT6nTO0DATxXN2xNqmKBAo1fMp Y//GS5xG2Jd4Yb7nw3MbzZrnEzCoDulkPLQwZSHxbAGYYoK+qV/Uf6CQGwU+bVlDZfie 2mJ84c3HB0fu7y0LUMvtLJJrMnjcQ76pkDy3oi45FO2917t7CXEKcdYTCE2lYtMkf652 iVQiV15A17GXvulm4iHxskvIlR94Vl+KH3iB2ABI8G2yzjcRTDmJAju6RNUQFnF+b0Ir atbQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=1VwyOAXo7eohMBN8xZNUOLTE4Y6Up/vz30c30b2901o=; b=WHReFdsUzHloWIZaGWVr5LwiNONylw3mwKkPggW6q5FBXhgrF1ZtmjGo8DRtI23iz7 XFx/6siyDwaqnhaI5WIOUCsC28K/VFS6AGO/CAJq71L0Zd5w6daIqgPBtM/b5nOfL8Xn ZuXpksowyjyjB3GV2ntvEy7dc0WB0bi3tZ47eiZoqquvJsxdpeKYsG1DYPNGToMaCs3z pduDxLx7m7MNJU8z1mmNCjZOnDw4zJpLbgTyzLYSwxITDVu7bMlddCL4QmsWlyLqZmcW I/VyQDuiSm8rg+ogeQFDQ9sziVPZpTcg7jagKfzn6HAhu0bGcFdnVxE8ljhvC86gSebq fAMA== X-Gm-Message-State: APjAAAVgecqsyYXmvO+4O+Zg40VJMWTDJtUh8SOMhNw/dG+bVlpcXV5B pepa73NvTRMY6ayh34d51ZMWKg+oqAJV5i/G4mc2R2Jkj33Alw== X-Received: by 2002:a05:600c:2144:: with SMTP id v4mr11735016wml.146.1565391948663; Fri, 09 Aug 2019 16:05:48 -0700 (PDT) MIME-Version: 1.0 References: <20190809102310.27246-1-ming.lei@redhat.com> <20190809102310.27246-2-ming.lei@redhat.com> <20190809144204.GA28515@localhost.localdomain> In-Reply-To: <20190809144204.GA28515@localhost.localdomain> From: Ming Lei Date: Sat, 10 Aug 2019 07:05:32 +0800 Message-ID: Subject: Re: [PATCH 1/2] genirq/affinity: improve __irq_build_affinity_masks() To: Keith Busch Cc: Ming Lei , Thomas Gleixner , Jon Derrick , Linux Kernel Mailing List , linux-nvme , Christoph Hellwig Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Aug 9, 2019 at 10:44 PM Keith Busch wrote: > > On Fri, Aug 09, 2019 at 06:23:09PM +0800, Ming Lei wrote: > > One invariant of __irq_build_affinity_masks() is that all CPUs in the > > specified masks( cpu_mask AND node_to_cpumask for each node) should be > > covered during the spread. Even though all requested vectors have been > > reached, we still need to spread vectors among left CPUs. The similar > > policy has been taken in case of 'numvecs <= nodes'. > > > > So remove the following check inside the loop: > > > > if (done >= numvecs) > > break; > > > > Meantime assign at least 1 vector for left nodes if 'numvecs' vectors > > have been spread. > > > > Also, if the specified cpumask for one numa node is empty, simply not > > spread vectors on this node. > > > > Cc: Christoph Hellwig > > Cc: Keith Busch > > Cc: linux-nvme@lists.infradead.org, > > Cc: Jon Derrick > > Signed-off-by: Ming Lei > > --- > > kernel/irq/affinity.c | 33 +++++++++++++++++++++------------ > > 1 file changed, 21 insertions(+), 12 deletions(-) > > > > diff --git a/kernel/irq/affinity.c b/kernel/irq/affinity.c > > index 6fef48033f96..bc3652a2c61b 100644 > > --- a/kernel/irq/affinity.c > > +++ b/kernel/irq/affinity.c > > @@ -129,21 +129,32 @@ static int __irq_build_affinity_masks(unsigned int startvec, > > for_each_node_mask(n, nodemsk) { > > unsigned int ncpus, v, vecs_to_assign, vecs_per_node; > > > > - /* Spread the vectors per node */ > > - vecs_per_node = (numvecs - (curvec - firstvec)) / nodes; > > - > > /* Get the cpus on this node which are in the mask */ > > cpumask_and(nmsk, cpu_mask, node_to_cpumask[n]); > > - > > - /* Calculate the number of cpus per vector */ > > ncpus = cpumask_weight(nmsk); > > + if (!ncpus) > > + continue; > > This shouldn't be possible, right? The nodemsk we're looping wouldn't > have had that node set if no CPUs intersect the node_to_cpu_mask for > that node, so the resulting cpumask should always have a non-zero weight. cpumask_and(nmsk, cpu_mask, node_to_cpumask[n]); It is often true, see the following cases: 1) all CPUs in one node are not present OR 2) all CPUs in one node are present > > > @@ -153,16 +164,14 @@ static int __irq_build_affinity_masks(unsigned int startvec, > > } > > irq_spread_init_one(&masks[curvec].mask, nmsk, > > cpus_per_vec); > > + if (++curvec >= last_affv) > > + curvec = firstvec; > > I'm not so sure about wrapping the vector to share it across nodes. We The wrapping is always there, not added by this patch. Most time it won't happen since we spread vectors on remaining (un-assigned)nodes. And it only happens when there is remaining nodes not spread. We have to make sure all nodes are spread. And the similar policy is applied on the branch of 'numvecs <= nodes' too. > have enough vectors in this path to ensure each compute node can have > a unique one, and it's much cheaper to share these within nodes than > across them. The patch just moves the wrapping from loop outside into the loop, then all 'extra_vecs' can be covered because it is always < 'vecs_to_assign'. What matters is that the following check is removed: if (done >= numvecs) break; then all nodes can be covered. Thanks, Ming Lei