Received: by 10.223.185.116 with SMTP id b49csp6162997wrg; Thu, 8 Mar 2018 02:56:16 -0800 (PST) X-Google-Smtp-Source: AG47ELs+IYsxgI4RUwlK7QLeBP8RlBYOV4idQVffrpbV8f1gM8Fl2lNNZMLv+jOb4r4a4U6GjjPA X-Received: by 2002:a17:902:9306:: with SMTP id bc6-v6mr13298301plb.133.1520506576793; Thu, 08 Mar 2018 02:56:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520506576; cv=none; d=google.com; s=arc-20160816; b=o1qMPxN0/f1h6WQUw+q/c7+NmSkzH/7JFJVvFC99p0Xm1brNZ+bpOz/e5ZY4n1udgT 9gTHTaD1QBbhxFr5+iFhtZbmtQystYA4bQUzjVphTXNEmsEJYQfVCTTBbxtox+9BeZK8 SqFlU73bapLKbPSkU4jEodnpeIgN6Djp0aTJltKEbVlxYcHxHWZSvF4dRlkFwiAS0JLN 8BBYr4RAwueOChML0Mu7eATzI1XkCbIwyuLTM9ckiW6Nw0SU7yqn17Nr9dGp3s6bRT38 oE8Lmw5gPTzz9RacZr09DEfwL86cnTFIZOisj/kP1nPnrHTA5eg2a57XZiEgAlLapUFj mHsA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=jflVP0DM23H1dnWvQE4UOMgF8JLUSvI8t3JGcsh8cvY=; b=U1w7zb5tqhvrizqPlWu7TbgGtuaC/28kUzP3ADAKZ/utaxIIn9Hn1CKlmZUXAvNI8g Bs1YvhWfK6VgIBsIRO9HCYLMKi9h3FGT2b14v4rXjxRe2tGnGrFnanl7GYn2WXA+s0VH +JjyEdws98ug0njlXRHSTO105C8Z1Vi4APbfcXH6Y8CQ/KKWk7weRRRitXHSJaoo7xXM wHHGs/UtRYpAtIed5wmgxmFJ2HfnE7u0KyMQJM69T5XIxTSMzaR75TTBLtCp+Xmt+C/M a/NXcwayib9K8jyahD7lmjs+oBcfORE85SEr47HCcYvJ1mr01FOEw6Bp5xM/W6qnx8e8 ThMA== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n3-v6si14410232plb.817.2018.03.08.02.56.02; Thu, 08 Mar 2018 02:56:16 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S966183AbeCHKyu (ORCPT + 99 others); Thu, 8 Mar 2018 05:54:50 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:48182 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S934907AbeCHKys (ORCPT ); Thu, 8 Mar 2018 05:54:48 -0500 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 mx1.redhat.com (Postfix) with ESMTPS id 0F7B44023BB3; Thu, 8 Mar 2018 10:54:48 +0000 (UTC) Received: from localhost (ovpn-12-72.pek2.redhat.com [10.72.12.72]) by smtp.corp.redhat.com (Postfix) with ESMTP id A160E2023227; Thu, 8 Mar 2018 10:54:40 +0000 (UTC) From: Ming Lei To: Jens Axboe , Christoph Hellwig , Thomas Gleixner , linux-kernel@vger.kernel.org Cc: linux-block@vger.kernel.org, Laurence Oberman , Ming Lei Subject: [PATCH V3 3/4] genirq/affinity: support to do irq vectors spread starting from any vector Date: Thu, 8 Mar 2018 18:53:57 +0800 Message-Id: <20180308105358.1506-4-ming.lei@redhat.com> In-Reply-To: <20180308105358.1506-1-ming.lei@redhat.com> References: <20180308105358.1506-1-ming.lei@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Thu, 08 Mar 2018 10:54:48 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Thu, 08 Mar 2018 10:54:48 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'ming.lei@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Now two parameters(start_vec, affv) are introduced to irq_build_affinity_masks(), then this helper can build the affinity of each irq vector starting from the irq vector of 'start_vec', and handle at most 'affv' vectors. This way is required to do 2-stages irq vectors spread among all possible CPUs. Cc: Thomas Gleixner Reviewed-by: Christoph Hellwig Signed-off-by: Ming Lei --- kernel/irq/affinity.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/kernel/irq/affinity.c b/kernel/irq/affinity.c index e119e86bed48..616f040c5d02 100644 --- a/kernel/irq/affinity.c +++ b/kernel/irq/affinity.c @@ -94,17 +94,17 @@ static int get_nodes_in_cpumask(cpumask_var_t *node_to_cpumask, return nodes; } -static int irq_build_affinity_masks(int nvecs, const struct irq_affinity *affd, +static int irq_build_affinity_masks(const struct irq_affinity *affd, + int start_vec, int affv, cpumask_var_t *node_to_cpumask, const struct cpumask *cpu_mask, struct cpumask *nmsk, struct cpumask *masks) { - int affv = nvecs - affd->pre_vectors - affd->post_vectors; int last_affv = affv + affd->pre_vectors; - int curvec = affd->pre_vectors; + int curvec = start_vec; nodemask_t nodemsk = NODE_MASK_NONE; - int n, nodes, cpus_per_vec, extra_vecs; + int n, nodes, cpus_per_vec, extra_vecs, done = 0; nodes = get_nodes_in_cpumask(node_to_cpumask, cpu_mask, &nodemsk); @@ -116,8 +116,10 @@ static int irq_build_affinity_masks(int nvecs, const struct irq_affinity *affd, for_each_node_mask(n, nodemsk) { cpumask_copy(masks + curvec, node_to_cpumask[n]); - if (++curvec == last_affv) + if (++done == affv) break; + if (++curvec == last_affv) + curvec = affd->pre_vectors; } goto out; } @@ -150,13 +152,16 @@ static int irq_build_affinity_masks(int nvecs, const struct irq_affinity *affd, irq_spread_init_one(masks + curvec, nmsk, cpus_per_vec); } - if (curvec >= last_affv) + done += v; + if (done >= affv) break; + if (curvec >= last_affv) + curvec = affd->pre_vectors; --nodes; } out: - return curvec - affd->pre_vectors; + return done; } /** @@ -169,6 +174,7 @@ static int irq_build_affinity_masks(int nvecs, const struct irq_affinity *affd, struct cpumask * irq_create_affinity_masks(int nvecs, const struct irq_affinity *affd) { + int affv = nvecs - affd->pre_vectors - affd->post_vectors; int curvec; struct cpumask *masks; cpumask_var_t nmsk, *node_to_cpumask; @@ -198,7 +204,8 @@ irq_create_affinity_masks(int nvecs, const struct irq_affinity *affd) /* Stabilize the cpumasks */ get_online_cpus(); build_node_to_cpumask(node_to_cpumask); - curvec += irq_build_affinity_masks(nvecs, affd, node_to_cpumask, + curvec += irq_build_affinity_masks(affd, curvec, affv, + node_to_cpumask, cpu_possible_mask, nmsk, masks); put_online_cpus(); -- 2.9.5