From patchwork Tue Dec 27 02:29:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 36732 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp1189634wrt; Mon, 26 Dec 2022 18:30:49 -0800 (PST) X-Google-Smtp-Source: AMrXdXsmTbhJ677Qi2cha4/ykkbHAp5HLAKr43lQN57zfL0eN6OQyomSqRT/0iLyriH1t9C091HU X-Received: by 2002:a62:2741:0:b0:577:a0d:b091 with SMTP id n62-20020a622741000000b005770a0db091mr22424226pfn.14.1672108248862; Mon, 26 Dec 2022 18:30:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672108248; cv=none; d=google.com; s=arc-20160816; b=o3uTVshOA1etQr8ebu7pZPFl6iC2jwZ7MhgEfhsNZ3f4yn87qo4/76oUpZssGo43Cp MoimqsOTRkt84SGOFcWLpAigXTh0hMSKUvtqlUkQY9TcHvXkvppenqBnREfS/mnrbfCy W01WWjHY3UAVHycwaB26n1MuYnGrsGsZGGM4sCgGOLBItf+2nPtcdRGZJc49OB01EJi4 XefdNfDtcAZh8XAMaytN1oaFKrb05K2xIWuMf6Klug4MbkLcm9K5GolLjHL/q6sth/RP UCVyKY2FUq3R1+GtSuTBrJhRYI9Q3G9cUvF+O55KPMtSOcqG73gYSX3C8qNSYZGuylo4 peVg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=8s9N4odoxU9TLcs2ylQzubyo1NqVpZprjNLrRaHWiXo=; b=wU97ws75HGTj4cjaJpPLz7jZZghcsIv6zy2xlab8T0BiFjEryBfH1tDh2/v4uAGu7W GDyCY628scjStNwvia7EoROf5Y6FDC968/FXq8GoT23MBQiC9U1pFzPTcXunv9WTjgcI 7adzSpMVyYd+hhlJzxqWxJpkHC4WnCINzbKhRHp3GBtbMHroKKamaC7z0USalHEj10ps z91wml3u15TaK10vhgAt0vEz5NFjoLCF6Y1d3/W6H/0Ge/h+g36MHLb+1ps9LaRI77ZF AoEjYNAKE1ufVvgKQfFHCcPetrqU+j56StneAtj95Di2jC7lB8W6i5XNlHdkwxQbuyyt dNxw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=EGUUYsX3; 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=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m2-20020a625802000000b00572e6576462si12584825pfb.97.2022.12.26.18.30.36; Mon, 26 Dec 2022 18:30:48 -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=@redhat.com header.s=mimecast20190719 header.b=EGUUYsX3; 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=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232621AbiL0CaK (ORCPT + 99 others); Mon, 26 Dec 2022 21:30:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53624 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232279AbiL0CaH (ORCPT ); Mon, 26 Dec 2022 21:30:07 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5E62C6355 for ; Mon, 26 Dec 2022 18:29:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1672108166; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=8s9N4odoxU9TLcs2ylQzubyo1NqVpZprjNLrRaHWiXo=; b=EGUUYsX3VSfYiV0pBFHLQBbviqi2N7tv6RPuKMz39PSSpQFAe+ISL98SlNaPART04G+qbR TjrxmoUGAf09BIMxpRgvxUcKvFADqly50ZT/6Ym+eMUjezCb+QGB265IAEp0Vm6tvLgsVi ddku2FeHoYovb2WRVIVLpfwwm7ExKLM= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-541-oY-z5lflOfCpSRNfuXqwcQ-1; Mon, 26 Dec 2022 21:29:22 -0500 X-MC-Unique: oY-z5lflOfCpSRNfuXqwcQ-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 3DD2F811E6E; Tue, 27 Dec 2022 02:29:22 +0000 (UTC) Received: from localhost (ovpn-8-22.pek2.redhat.com [10.72.8.22]) by smtp.corp.redhat.com (Postfix) with ESMTP id 413732026D4B; Tue, 27 Dec 2022 02:29:20 +0000 (UTC) From: Ming Lei To: Thomas Gleixner , Jens Axboe Cc: linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, Christoph Hellwig , John Garry , Ming Lei Subject: [PATCH V4 2/6] genirq/affinity: Pass affinity managed mask array to irq_build_affinity_masks Date: Tue, 27 Dec 2022 10:29:01 +0800 Message-Id: <20221227022905.352674-3-ming.lei@redhat.com> In-Reply-To: <20221227022905.352674-1-ming.lei@redhat.com> References: <20221227022905.352674-1-ming.lei@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE 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?1753332578955715344?= Pass affinity managed mask array to irq_build_affinity_masks() so that index of the first affinity managed vector is always zero, then we can simplify the implementation a bit. Reviewed-by: Christoph Hellwig Signed-off-by: Ming Lei Reviewed-by: John Garry --- 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 3361e36ebaa1..da6379cd27fd 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;