public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Ingo Molnar <mingo@kernel.org>
To: Thomas Gleixner <tglx@linutronix.de>
Cc: LKML <linux-kernel@vger.kernel.org>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Peter Anvin <hpa@zytor.com>,
	Borislav Petkov <borislav.petkov@amd.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Mike Travis <travis@sgi.com>,
	Daniel J Blueman <daniel@numascale.com>
Subject: Re: [patch 02/14] x86/apic: Implement single target IPI function for x2apic_cluster
Date: Thu, 5 Nov 2015 07:38:13 +0100	[thread overview]
Message-ID: <20151105063813.GA12730@gmail.com> (raw)
In-Reply-To: <20151104220848.817975597@linutronix.de>


* Thomas Gleixner <tglx@linutronix.de> wrote:

> From: Linus Torvalds <torvalds@linux-foundation.org>
> 
> [ tglx: Split it out from the patch which provides the new callback
>   	and wrapped it into local_irq_save/restore ]
> 
> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
> ---
>  arch/x86/kernel/apic/x2apic_cluster.c |   12 ++++++++++++
>  1 file changed, 12 insertions(+)
> 
> Index: linux/arch/x86/kernel/apic/x2apic_cluster.c
> ===================================================================
> --- linux.orig/arch/x86/kernel/apic/x2apic_cluster.c
> +++ linux/arch/x86/kernel/apic/x2apic_cluster.c
> @@ -23,6 +23,17 @@ static inline u32 x2apic_cluster(int cpu
>  	return per_cpu(x86_cpu_to_logical_apicid, cpu) >> 16;
>  }
>  
> +static void x2apic_send_IPI(int cpu, int vector)
> +{
> +	u32 dest = per_cpu(x86_cpu_to_logical_apicid, cpu);
> +	unsigned long flags;
> +
> +	x2apic_wrmsr_fence();
> +	local_irq_save(flags);
> +	__x2apic_send_IPI_dest(dest, vector, APIC_DEST_LOGICAL);
> +	local_irq_restore(flags);
> +}

So the series looks good to me:

  Reviewed-by: Ingo Molnar <mingo@kernel.org>

but in the above sequence I think we can do even better: we don't need the 
local_irq_save()/restore() I think.

The reason, this is how __x2apic_send_IPI_dest() looks like:

        unsigned long cfg = __prepare_ICR(0, vector, dest);
        native_x2apic_icr_write(cfg, apicid);

__prepare_ICR(), which is a confusing misnomer as it does not prepare anything 
about the ICR register, it just pre-calculates some values, is obviously 
interrupt-safe:

static inline unsigned int __prepare_ICR(unsigned int shortcut, int vector,
                                         unsigned int dest)
{
        unsigned int icr = shortcut | dest;

        switch (vector) {
        default:
                icr |= APIC_DM_FIXED | vector;
                break;
        case NMI_VECTOR:
                icr |= APIC_DM_NMI;
                break;
        }
        return icr;
}

and native_x2apic_icr_write() is a single WRMSR:

static inline void native_x2apic_icr_write(u32 low, u32 id)
{
        wrmsrl(APIC_BASE_MSR + (APIC_ICR >> 4), ((__u64) id) << 32 | low);
}

which is interrupt-safe as well.

So we can save another 10-20 cycles of CLI/POPF overhead from this hotpath.

I'd do it as a patch on top, to keep the series simpler - something like the 
below. (Completely untested: may the Force be with you.)

Thanks,

	Ingo

Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 arch/x86/kernel/apic/x2apic_cluster.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/arch/x86/kernel/apic/x2apic_cluster.c b/arch/x86/kernel/apic/x2apic_cluster.c
index 3329dab47efc..aca8b75c1552 100644
--- a/arch/x86/kernel/apic/x2apic_cluster.c
+++ b/arch/x86/kernel/apic/x2apic_cluster.c
@@ -26,12 +26,9 @@ static inline u32 x2apic_cluster(int cpu)
 static void x2apic_send_IPI(int cpu, int vector)
 {
 	u32 dest = per_cpu(x86_cpu_to_logical_apicid, cpu);
-	unsigned long flags;
 
 	x2apic_wrmsr_fence();
-	local_irq_save(flags);
 	__x2apic_send_IPI_dest(dest, vector, APIC_DEST_LOGICAL);
-	local_irq_restore(flags);
 }
 
 static void

  reply	other threads:[~2015-11-05  6:38 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-04 22:56 [patch 00/14] x86/apic: Implement single target IPI callback Thomas Gleixner
2015-11-04 22:57 ` [patch 01/14] x86/apic: Add a single-target IPI function to the apic Thomas Gleixner
2015-11-05 14:42   ` [tip:x86/apic] " tip-bot for Linus Torvalds
2015-11-04 22:57 ` [patch 02/14] x86/apic: Implement single target IPI function for x2apic_cluster Thomas Gleixner
2015-11-05  6:38   ` Ingo Molnar [this message]
2015-11-05  6:46     ` Linus Torvalds
2015-11-05  8:04       ` Thomas Gleixner
2015-11-05 14:43   ` [tip:x86/apic] " tip-bot for Linus Torvalds
2015-11-04 22:57 ` [patch 03/14] x86/apic: Implement default single target IPI function Thomas Gleixner
2015-11-05 14:43   ` [tip:x86/apic] " tip-bot for Thomas Gleixner
2015-11-04 22:57 ` [patch 04/14] x86/apic: Remove pointless indirections from apic_physflat Thomas Gleixner
2015-11-05 14:43   ` [tip:x86/apic] " tip-bot for Thomas Gleixner
2015-11-04 22:57 ` [patch 05/14] x86/apic: Wire up single IPI for apic_physflat Thomas Gleixner
2015-11-05 14:44   ` [tip:x86/apic] " tip-bot for Thomas Gleixner
2015-11-04 22:57 ` [patch 06/14] x86/apic: Remove pointless indirections from bigsmp_apic Thomas Gleixner
2015-11-05 14:44   ` [tip:x86/apic] " tip-bot for Thomas Gleixner
2015-11-04 22:57 ` [patch 08/14] x86/apic: Implement single IPI for x2apic_phys Thomas Gleixner
2015-11-05 14:45   ` [tip:x86/apic] " tip-bot for Thomas Gleixner
2015-11-04 22:57 ` [patch 07/14] x86/apic: Wire up single IPI for bigsmp_apic Thomas Gleixner
2015-11-05 14:44   ` [tip:x86/apic] " tip-bot for Thomas Gleixner
2015-11-04 22:57 ` [patch 09/14] x86/apic: Wire up single IPI for x2apic_uv Thomas Gleixner
2015-11-05 14:45   ` [tip:x86/apic] " tip-bot for Thomas Gleixner
2015-11-04 22:57 ` [patch 10/14] x86/apic: Implement single IPI for apic_noop Thomas Gleixner
2015-11-05 14:46   ` [tip:x86/apic] " tip-bot for Thomas Gleixner
2015-11-04 22:57 ` [patch 11/14] x86/apic: Wire up single IPI for apic_numachip Thomas Gleixner
2015-11-05 14:45   ` [tip:x86/apic] " tip-bot for Thomas Gleixner
2015-11-04 22:57 ` [patch 12/14] x86/apic: Provide default send single IPI wrapper Thomas Gleixner
2015-11-05 14:46   ` [tip:x86/apic] " tip-bot for Thomas Gleixner
2015-11-04 22:57 ` [patch 13/14] x86/apic: Use " Thomas Gleixner
2015-11-05 14:46   ` [tip:x86/apic] " tip-bot for Thomas Gleixner
2015-11-04 22:57 ` [patch 14/14] x86/smp: Remove " Thomas Gleixner
2015-11-05 14:47   ` [tip:x86/apic] " tip-bot for Thomas Gleixner
2015-11-04 22:59 ` [patch 00/14] x86/apic: Implement single target IPI callback Linus Torvalds
2015-11-05  8:17   ` 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=20151105063813.GA12730@gmail.com \
    --to=mingo@kernel.org \
    --cc=borislav.petkov@amd.com \
    --cc=daniel@numascale.com \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    --cc=torvalds@linux-foundation.org \
    --cc=travis@sgi.com \
    /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