From patchwork Tue Jan 17 17:54:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: tip-bot2 for Thomas Gleixner X-Patchwork-Id: 44774 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1911362wrn; Tue, 17 Jan 2023 10:21:24 -0800 (PST) X-Google-Smtp-Source: AMrXdXtME4ytFmXm59RZUrcVTx5uQTloH0cMXBfbXx6trmGaQB+Hyeu0FajUl3l7ucf5jmz6loBb X-Received: by 2002:a05:6a20:8c24:b0:9d:efbe:a0f1 with SMTP id j36-20020a056a208c2400b0009defbea0f1mr4024671pzh.1.1673979683829; Tue, 17 Jan 2023 10:21:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673979683; cv=none; d=google.com; s=arc-20160816; b=ckX8/YS6M2AMRamRAI4zsuqJ0uLBpjvM6fxcF447eCzKujGCcZavicE4YhkZCGsCa1 GWM89JgPeQaUgrYIs0dViZTD2Xpf0oR56+ajOkIiM7hHq16ehNLsV2fnVrxft8tvMD/B TG3YVgB/cqT3yYvOPC5GyywsSH1qIBJUCz/3oPz56JcHHd9AvQSaFgWglIyirWn17xMT RZMUQVjxLweFuRU1Zzw1kqmQguND+rTs75WNLocb3I/5j1QeXfvkkps0X4lY5VSkEIMc 2qP47T8dALaTSYDpWcaKIm6keihf0AYLjnfv/BqrrA4Vedc8/vcBiCdjFMaYfUP1vm0C k0Bw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:references:in-reply-to:cc:subject :to:reply-to:sender:from:dkim-signature:dkim-signature:date; bh=aCfuJ7iY9K8A4IP3bR9jcsWCiPX2EhlumxfAD9wtaNY=; b=JWLTMqB4IiKgoXDmokKeJDYgpecbxke8+QkzyLTafSgyQNnXTdTWMu/jN5HrAeGyXz nfvcDx+y2fRu/HiBMPXfB/1w5ujSg0NImXQoiRyTBJc6T+fZWH/Tdf07qH1rX+G4ws48 o5xiuNKTEtAGXnYjlk5jbtwPpqURXeRqKHJnp914DHZ1Xu2xYTyxc8x7DXzJeqctN4re EvBWmUavXi1dRVIuCpthOInOhqup8eLRUrL3DFeEEZMOR2ySZwV/No3LIRo4iTmoZ8yl q+lANU5VSrZoi/6OZbON4tM6Cr+6CKp4skWK84wxpXIa5y5WgBJQvfjzthwfbjBElv2O vCZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=RzgB4hEM; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=WGhmFmFj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f207-20020a6238d8000000b00588c0ea133dsi25737168pfa.140.2023.01.17.10.21.11; Tue, 17 Jan 2023 10:21:23 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=RzgB4hEM; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=WGhmFmFj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229863AbjAQSRT (ORCPT + 99 others); Tue, 17 Jan 2023 13:17:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47242 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233191AbjAQSOE (ORCPT ); Tue, 17 Jan 2023 13:14:04 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 312FB59E44; Tue, 17 Jan 2023 09:55:00 -0800 (PST) Date: Tue, 17 Jan 2023 17:54:57 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1673978098; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=aCfuJ7iY9K8A4IP3bR9jcsWCiPX2EhlumxfAD9wtaNY=; b=RzgB4hEMfo/ODTuoRpsluG+xNh219w5CMXlwXGxmhlmCA1jdFqZKCwfuFbPjHSctNVyAMN MDsxU7NeidnKQFeB+z4GlJrIUYiAE8XgbrLWdxmeI0tatv7X8cZY9KQc9Ipmi37IqJXwL0 4wiLQ5mZuXUZU+e5qcARgzy+vFyip0ykWDnhDLCoeXaULzbexjFjD+xSYsdXVhWsEkmmhi UsFepEo3mLZytKVHpBHHxT3h7/hBzQSxmC/oYV/reoqiej2R1Cv3J5Uw2fxp/KQekSLzww sdJWX3Zh7IudScsFaz4SI2yjsizUAw5Swj89/4jfiNS6Mytr+msuoZ2Z0D+QSA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1673978098; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=aCfuJ7iY9K8A4IP3bR9jcsWCiPX2EhlumxfAD9wtaNY=; b=WGhmFmFjz7NDC7dawj+8rgwiGI27lrHGOyEuBpX6/7nJi5kZKLKeDS/iMYJI5CBy32sfMS Zr0kFA46sXifFnCg== From: "tip-bot2 for Ming Lei" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: irq/core] genirq/affinity: Pass affinity managed mask array to irq_build_affinity_masks Cc: Ming Lei , Thomas Gleixner , Christoph Hellwig , John Garry , Jens Axboe , x86@kernel.org, linux-kernel@vger.kernel.org, maz@kernel.org In-Reply-To: <20221227022905.352674-3-ming.lei@redhat.com> References: <20221227022905.352674-3-ming.lei@redhat.com> MIME-Version: 1.0 Message-ID: <167397809793.4906.10094526787624204112.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1753332578955715344?= X-GMAIL-MSGID: =?utf-8?q?1755294920864725213?= The following commit has been merged into the irq/core branch of tip: Commit-ID: 1f962d91a15af54301c63febb8ac2ba07aa3654f Gitweb: https://git.kernel.org/tip/1f962d91a15af54301c63febb8ac2ba07aa3654f Author: Ming Lei AuthorDate: Tue, 27 Dec 2022 10:29:01 +08:00 Committer: Thomas Gleixner CommitterDate: Tue, 17 Jan 2023 18:50:06 +01:00 genirq/affinity: Pass affinity managed mask array to irq_build_affinity_masks Pass affinity managed mask array to irq_build_affinity_masks() so that the index of the first affinity managed vector is always zero. This allows to simplify the implementation a bit. Signed-off-by: Ming Lei Signed-off-by: Thomas Gleixner Reviewed-by: Christoph Hellwig Reviewed-by: John Garry Reviewed-by: Jens Axboe Link: https://lore.kernel.org/r/20221227022905.352674-3-ming.lei@redhat.com --- kernel/irq/affinity.c | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/kernel/irq/affinity.c b/kernel/irq/affinity.c index 3361e36..da6379c 100644 --- a/kernel/irq/affinity.c +++ b/kernel/irq/affinity.c @@ -246,14 +246,13 @@ static void alloc_nodes_vectors(unsigned int numvecs, static int __irq_build_affinity_masks(unsigned int startvec, unsigned int numvecs, - unsigned int firstvec, cpumask_var_t *node_to_cpumask, const struct cpumask *cpu_mask, struct cpumask *nmsk, struct irq_affinity_desc *masks) { unsigned int i, n, nodes, cpus_per_vec, extra_vecs, done = 0; - unsigned int last_affv = firstvec + numvecs; + unsigned int last_affv = numvecs; unsigned int curvec = startvec; nodemask_t nodemsk = NODE_MASK_NONE; struct node_vectors *node_vectors; @@ -273,7 +272,7 @@ static int __irq_build_affinity_masks(unsigned int startvec, cpumask_and(nmsk, cpu_mask, node_to_cpumask[n]); cpumask_or(&masks[curvec].mask, &masks[curvec].mask, nmsk); if (++curvec == last_affv) - curvec = firstvec; + curvec = 0; } return numvecs; } @@ -321,7 +320,7 @@ static int __irq_build_affinity_masks(unsigned int startvec, * may start anywhere */ if (curvec >= last_affv) - curvec = firstvec; + curvec = 0; irq_spread_init_one(&masks[curvec].mask, nmsk, cpus_per_vec); } @@ -336,11 +335,10 @@ static int __irq_build_affinity_masks(unsigned int startvec, * 1) spread present CPU on these vectors * 2) spread other possible CPUs on these vectors */ -static int irq_build_affinity_masks(unsigned int startvec, unsigned int numvecs, +static int irq_build_affinity_masks(unsigned int numvecs, struct irq_affinity_desc *masks) { - unsigned int curvec = startvec, nr_present = 0, nr_others = 0; - unsigned int firstvec = startvec; + unsigned int curvec = 0, nr_present = 0, nr_others = 0; cpumask_var_t *node_to_cpumask; cpumask_var_t nmsk, npresmsk; int ret = -ENOMEM; @@ -360,9 +358,8 @@ static int irq_build_affinity_masks(unsigned int startvec, unsigned int numvecs, build_node_to_cpumask(node_to_cpumask); /* Spread on present CPUs starting from affd->pre_vectors */ - ret = __irq_build_affinity_masks(curvec, numvecs, firstvec, - node_to_cpumask, cpu_present_mask, - nmsk, masks); + ret = __irq_build_affinity_masks(curvec, numvecs, node_to_cpumask, + cpu_present_mask, nmsk, masks); if (ret < 0) goto fail_build_affinity; nr_present = ret; @@ -374,13 +371,12 @@ static int irq_build_affinity_masks(unsigned int startvec, unsigned int numvecs, * out vectors. */ if (nr_present >= numvecs) - curvec = firstvec; + curvec = 0; else - curvec = firstvec + nr_present; + curvec = nr_present; cpumask_andnot(npresmsk, cpu_possible_mask, cpu_present_mask); - ret = __irq_build_affinity_masks(curvec, numvecs, firstvec, - node_to_cpumask, npresmsk, nmsk, - masks); + ret = __irq_build_affinity_masks(curvec, numvecs, node_to_cpumask, + npresmsk, nmsk, masks); if (ret >= 0) nr_others = ret; @@ -463,7 +459,7 @@ irq_create_affinity_masks(unsigned int nvecs, struct irq_affinity *affd) unsigned int this_vecs = affd->set_size[i]; int ret; - ret = irq_build_affinity_masks(curvec, this_vecs, masks); + ret = irq_build_affinity_masks(this_vecs, &masks[curvec]); if (ret) { kfree(masks); return NULL;