From: Nadav Amit <namit@vmware.com>
To: Thomas Gleixner <tglx@linutronix.de>
Cc: LKML <linux-kernel@vger.kernel.org>,
the arch/x86 maintainers <x86@kernel.org>,
Ricardo Neri <ricardo.neri-calderon@linux.intel.com>,
Stephane Eranian <eranian@google.com>,
Feng Tang <feng.tang@intel.com>
Subject: Re: [patch V2 21/25] x86/smp: Enhance native_send_call_func_ipi()
Date: Fri, 5 Jul 2019 01:26:10 +0000 [thread overview]
Message-ID: <C77F4C58-9CA3-4784-AE98-A9D6EDD4A788@vmware.com> (raw)
In-Reply-To: <20190704155610.325211809@linutronix.de>
> On Jul 4, 2019, at 8:52 AM, Thomas Gleixner <tglx@linutronix.de> wrote:
>
> Nadav noticed that the cpumask allocations in native_send_call_func_ipi()
> are noticeable in microbenchmarks.
>
> Use the new cpumask_or_equal() function to simplify the decision whether
> the supplied target CPU mask is either equal to cpu_online_mask or equal to
> cpu_online_mask except for the CPU on which the function is invoked.
>
> cpumask_or_equal() or's the target mask and the cpumask of the current CPU
> together and compares it to cpu_online_mask.
>
> If the result is false, use the mask based IPI function, otherwise check
> whether the current CPU is set in the target mask and invoke either the
> send_IPI_all() or the send_IPI_allbutselt() APIC callback.
>
> Make the shorthand decision also depend on the static key which enables
> shorthand mode. That allows to remove the extra cpumask comparison with
> cpu_callout_mask.
>
> Reported-by: Nadav Amit <namit@vmware.com>
> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
> ---
> V2: New patch
> ---
> arch/x86/kernel/apic/ipi.c | 24 +++++++++++-------------
> 1 file changed, 11 insertions(+), 13 deletions(-)
>
> --- a/arch/x86/kernel/apic/ipi.c
> +++ b/arch/x86/kernel/apic/ipi.c
> @@ -83,23 +83,21 @@ void native_send_call_func_single_ipi(in
>
> void native_send_call_func_ipi(const struct cpumask *mask)
> {
> - cpumask_var_t allbutself;
> + if (static_branch_likely(&apic_use_ipi_shorthand)) {
> + unsigned int cpu = smp_processor_id();
>
> - if (!alloc_cpumask_var(&allbutself, GFP_ATOMIC)) {
> - apic->send_IPI_mask(mask, CALL_FUNCTION_VECTOR);
> + if (!cpumask_or_equal(mask, cpumask_of(cpu), cpu_online_mask))
> + goto sendmask;
> +
> + if (cpumask_test_cpu(cpu, mask))
> + apic->send_IPI_all(CALL_FUNCTION_VECTOR);
> + else if (num_online_cpus() > 1)
> + apic->send_IPI_allbutself(CALL_FUNCTION_VECTOR);
> return;
> }
>
> - cpumask_copy(allbutself, cpu_online_mask);
> - cpumask_clear_cpu(smp_processor_id(), allbutself);
> -
> - if (cpumask_equal(mask, allbutself) &&
> - cpumask_equal(cpu_online_mask, cpu_callout_mask))
> - apic->send_IPI_allbutself(CALL_FUNCTION_VECTOR);
> - else
> - apic->send_IPI_mask(mask, CALL_FUNCTION_VECTOR);
> -
> - free_cpumask_var(allbutself);
> +sendmask:
> + apic->send_IPI_mask(mask, CALL_FUNCTION_VECTOR);
> }
>
> #endif /* CONFIG_SMP */
It does look better and simpler than my solution.
next prev parent reply other threads:[~2019-07-05 1:26 UTC|newest]
Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-04 15:51 [patch V2 00/25] x86/apic: Support for IPI shorthands Thomas Gleixner
2019-07-04 15:51 ` [patch V2 01/25] x86/kgbd: Use NMI_VECTOR not APIC_DM_NMI Thomas Gleixner
2019-07-05 21:43 ` Thomas Gleixner
2019-07-04 15:51 ` [patch V2 02/25] x86/apic: Invoke perf_events_lapic_init() after enabling APIC Thomas Gleixner
2019-07-04 15:51 ` [patch V2 03/25] x86/apic: Soft disable APIC before initializing it Thomas Gleixner
2019-07-04 15:51 ` [patch V2 04/25] x86/apic: Make apic_pending_intr_clear() more robust Thomas Gleixner
2019-07-05 15:47 ` Andrew Cooper
2019-07-05 19:06 ` Andy Lutomirski
2019-07-05 20:17 ` Andrew Cooper
2019-07-05 20:36 ` Thomas Gleixner
2019-07-05 20:39 ` Andy Lutomirski
2019-07-07 8:27 ` Thomas Gleixner
2019-07-05 19:19 ` Nadav Amit
2019-07-05 20:47 ` Andrew Cooper
2019-07-05 20:25 ` Thomas Gleixner
2019-07-05 20:37 ` Andy Lutomirski
2019-07-05 20:49 ` Paolo Bonzini
2019-07-05 21:16 ` Andrew Cooper
2019-07-07 8:37 ` Thomas Gleixner
2019-07-09 14:43 ` Thomas Gleixner
2019-07-04 15:51 ` [patch V2 05/25] x86/apic: Move IPI inlines into ipi.c Thomas Gleixner
2019-07-04 15:51 ` [patch V2 06/25] x86/apic: Cleanup the include maze Thomas Gleixner
2019-07-04 15:51 ` [patch V2 07/25] x86/apic: Move ipi header into apic directory Thomas Gleixner
2019-07-04 15:51 ` [patch V2 08/25] x86/apic: Move apic_flat_64 " Thomas Gleixner
2019-07-04 15:51 ` [patch V2 09/25] x86/apic: Consolidate the apic local headers Thomas Gleixner
2019-07-04 15:51 ` [patch V2 10/25] x86/apic/uv: Make x2apic_extra_bits static Thomas Gleixner
2019-07-04 15:51 ` [patch V2 11/25] smp/hotplug: Track booted once CPUs in a cpumask Thomas Gleixner
2019-07-04 15:51 ` [patch V2 12/25] x86/cpu: Move arch_smt_update() to a neutral place Thomas Gleixner
2019-07-04 15:51 ` [patch V2 13/25] x86/hotplug: Silence APIC and NMI when CPU is dead Thomas Gleixner
2019-07-04 15:51 ` [patch V2 14/25] x86/apic: Remove dest argument from __default_send_IPI_shortcut() Thomas Gleixner
2019-07-04 15:52 ` [patch V2 15/25] x86/apic: Add NMI_VECTOR wait to IPI shorthand Thomas Gleixner
2019-07-04 15:52 ` [patch V2 16/25] x86/apic: Move no_ipi_broadcast() out of 32bit Thomas Gleixner
2019-07-04 15:52 ` [patch V2 17/25] x86/apic: Add static key to Control IPI shorthands Thomas Gleixner
2019-07-04 15:52 ` [patch V2 18/25] x86/apic: Provide and use helper for send_IPI_allbutself() Thomas Gleixner
2019-07-04 15:52 ` [patch V2 19/25] cpumask: Implement cpumask_or_equal() Thomas Gleixner
2019-07-04 15:52 ` [patch V2 20/25] x86/smp: Move smp_function_call implementations into IPI code Thomas Gleixner
2019-07-04 15:52 ` [patch V2 21/25] x86/smp: Enhance native_send_call_func_ipi() Thomas Gleixner
2019-07-05 1:26 ` Nadav Amit [this message]
2019-07-04 15:52 ` [patch V2 22/25] x86/apic: Remove the shorthand decision logic Thomas Gleixner
2019-07-04 15:52 ` [patch V2 23/25] x86/apic: Share common IPI helpers Thomas Gleixner
2019-07-04 15:52 ` [patch V2 24/25] x86/apic/flat64: Remove the IPI shorthand decision logic Thomas Gleixner
2019-07-04 15:52 ` [patch V2 25/25] x86/apic/x2apic: Implement IPI shorthands support Thomas Gleixner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=C77F4C58-9CA3-4784-AE98-A9D6EDD4A788@vmware.com \
--to=namit@vmware.com \
--cc=eranian@google.com \
--cc=feng.tang@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=ricardo.neri-calderon@linux.intel.com \
--cc=tglx@linutronix.de \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).