From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753674AbdFVRIu (ORCPT ); Thu, 22 Jun 2017 13:08:50 -0400 Received: from terminus.zytor.com ([65.50.211.136]:55581 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753561AbdFVRIr (ORCPT ); Thu, 22 Jun 2017 13:08:47 -0400 Date: Thu, 22 Jun 2017 10:03:35 -0700 From: tip-bot for Thomas Gleixner Message-ID: Cc: linux-kernel@vger.kernel.org, axboe@kernel.dk, peterz@infradead.org, marc.zyngier@arm.com, tglx@linutronix.de, mpe@ellerman.id.au, mingo@kernel.org, keith.busch@intel.com, hpa@zytor.com, hch@lst.de Reply-To: linux-kernel@vger.kernel.org, axboe@kernel.dk, peterz@infradead.org, marc.zyngier@arm.com, mingo@kernel.org, keith.busch@intel.com, hpa@zytor.com, hch@lst.de, tglx@linutronix.de, mpe@ellerman.id.au In-Reply-To: <20170619235446.560868224@linutronix.de> References: <20170619235446.560868224@linutronix.de> To: linux-tip-commits@vger.kernel.org Subject: [tip:irq/core] x86/apic: Move online masking to core code Git-Commit-ID: 52b166af40faec9813cd5ac26d6ba9adec2e3a9d X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 52b166af40faec9813cd5ac26d6ba9adec2e3a9d Gitweb: http://git.kernel.org/tip/52b166af40faec9813cd5ac26d6ba9adec2e3a9d Author: Thomas Gleixner AuthorDate: Tue, 20 Jun 2017 01:37:42 +0200 Committer: Thomas Gleixner CommitDate: Thu, 22 Jun 2017 18:21:21 +0200 x86/apic: Move online masking to core code All implementations of apic->cpu_mask_to_apicid_and() mask out the offline cpus. The callsite already has a mask available, which has the offline CPUs removed. Use that and remove the extra bits. Signed-off-by: Thomas Gleixner Cc: Jens Axboe Cc: Marc Zyngier Cc: Michael Ellerman Cc: Keith Busch Cc: Peter Zijlstra Cc: Christoph Hellwig Link: http://lkml.kernel.org/r/20170619235446.560868224@linutronix.de --- arch/x86/kernel/apic/apic.c | 27 +++++++++------------------ arch/x86/kernel/apic/vector.c | 5 ++++- arch/x86/kernel/apic/x2apic_cluster.c | 25 +++++++++---------------- 3 files changed, 22 insertions(+), 35 deletions(-) diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c index e9b322f..8a0bde3 100644 --- a/arch/x86/kernel/apic/apic.c +++ b/arch/x86/kernel/apic/apic.c @@ -2205,19 +2205,12 @@ int default_cpu_mask_to_apicid_and(const struct cpumask *cpumask, const struct cpumask *andmask, unsigned int *apicid) { - unsigned int cpu; + unsigned int cpu = cpumask_first_and(cpumask, andmask); - for_each_cpu_and(cpu, cpumask, andmask) { - if (cpumask_test_cpu(cpu, cpu_online_mask)) - break; - } - - if (likely(cpu < nr_cpu_ids)) { - *apicid = per_cpu(x86_cpu_to_apicid, cpu); - return 0; - } - - return -EINVAL; + if (cpu >= nr_cpu_ids) + return -EINVAL; + *apicid = per_cpu(x86_cpu_to_apicid, cpu); + return 0; } int flat_cpu_mask_to_apicid_and(const struct cpumask *cpumask, @@ -2226,14 +2219,12 @@ int flat_cpu_mask_to_apicid_and(const struct cpumask *cpumask, { unsigned long cpu_mask = cpumask_bits(cpumask)[0] & cpumask_bits(andmask)[0] & - cpumask_bits(cpu_online_mask)[0] & APIC_ALL_CPUS; - if (likely(cpu_mask)) { - *apicid = (unsigned int)cpu_mask; - return 0; - } - return -EINVAL; + if (!cpu_mask) + return -EINVAL; + *apicid = (unsigned int)cpu_mask; + return 0; } /* diff --git a/arch/x86/kernel/apic/vector.c b/arch/x86/kernel/apic/vector.c index 47c5d01..0f94ddb 100644 --- a/arch/x86/kernel/apic/vector.c +++ b/arch/x86/kernel/apic/vector.c @@ -221,8 +221,11 @@ success: * Cache destination APIC IDs into cfg->dest_apicid. This cannot fail * as we already established, that mask & d->domain & cpu_online_mask * is not empty. + * + * vector_searchmask is a subset of d->domain and has the offline + * cpus masked out. */ - BUG_ON(apic->cpu_mask_to_apicid_and(mask, d->domain, + BUG_ON(apic->cpu_mask_to_apicid_and(mask, vector_searchmask, &d->cfg.dest_apicid)); return 0; } diff --git a/arch/x86/kernel/apic/x2apic_cluster.c b/arch/x86/kernel/apic/x2apic_cluster.c index 5a35f20..d73baa8 100644 --- a/arch/x86/kernel/apic/x2apic_cluster.c +++ b/arch/x86/kernel/apic/x2apic_cluster.c @@ -108,31 +108,24 @@ x2apic_cpu_mask_to_apicid_and(const struct cpumask *cpumask, const struct cpumask *andmask, unsigned int *apicid) { + unsigned int cpu; u32 dest = 0; u16 cluster; - int i; - - for_each_cpu_and(i, cpumask, andmask) { - if (!cpumask_test_cpu(i, cpu_online_mask)) - continue; - dest = per_cpu(x86_cpu_to_logical_apicid, i); - cluster = x2apic_cluster(i); - break; - } - if (!dest) + cpu = cpumask_first_and(cpumask, andmask); + if (cpu >= nr_cpu_ids) return -EINVAL; - for_each_cpu_and(i, cpumask, andmask) { - if (!cpumask_test_cpu(i, cpu_online_mask)) - continue; - if (cluster != x2apic_cluster(i)) + dest = per_cpu(x86_cpu_to_logical_apicid, cpu); + cluster = x2apic_cluster(cpu); + + for_each_cpu_and(cpu, cpumask, andmask) { + if (cluster != x2apic_cluster(cpu)) continue; - dest |= per_cpu(x86_cpu_to_logical_apicid, i); + dest |= per_cpu(x86_cpu_to_logical_apicid, cpu); } *apicid = dest; - return 0; }