linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Nicholas Piggin <npiggin@gmail.com>
To: Christophe Leroy <christophe.leroy@csgroup.eu>,
	linuxppc-dev@lists.ozlabs.org
Subject: Re: [PATCH] powerpc/64s: power4 nap fixup in C
Date: Tue, 16 Mar 2021 18:11:42 +1000	[thread overview]
Message-ID: <1615882185.2o1zpw54nt.astroid@bobo.none> (raw)
In-Reply-To: <6ab2073b-dd10-ef2c-375d-1300f071ae1a@csgroup.eu>

Excerpts from Christophe Leroy's message of March 16, 2021 5:16 pm:
> 
> 
> Le 12/03/2021 à 02:20, Nicholas Piggin a écrit :
>> There is no need for this to be in asm, use the new intrrupt entry wrapper.
>> 
>> Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
>> ---
>> Hopefully this works on a real G5 now, but I couldn't reproduce the
>> problem with QEMU.
>> 
>> Thanks,
>> Nick
>> 
>>   arch/powerpc/include/asm/interrupt.h   | 19 +++++++++++
>>   arch/powerpc/include/asm/processor.h   |  1 +
>>   arch/powerpc/include/asm/thread_info.h |  6 ++++
>>   arch/powerpc/kernel/exceptions-64s.S   | 45 --------------------------
>>   arch/powerpc/kernel/idle_book3s.S      |  4 +++
>>   5 files changed, 30 insertions(+), 45 deletions(-)
>> 
>> diff --git a/arch/powerpc/include/asm/interrupt.h b/arch/powerpc/include/asm/interrupt.h
>> index aedfba29e43a..ef015d3b5e39 100644
>> --- a/arch/powerpc/include/asm/interrupt.h
>> +++ b/arch/powerpc/include/asm/interrupt.h
>> @@ -9,6 +9,17 @@
>>   #include <asm/kprobes.h>
>>   #include <asm/runlatch.h>
>>   
>> +static inline void nap_adjust_return(struct pt_regs *regs)
>> +{
>> +#ifdef CONFIG_PPC_970_NAP
>> +	if (unlikely(test_thread_local_flags(_TLF_NAPPING))) {
>> +		/* Can avoid a test-and-clear because NMIs do not call this */
>> +		clear_thread_local_flags(_TLF_NAPPING);
>> +		regs->nip = (unsigned long)power4_idle_nap_return;
> 
> Why don't you do regs->nip = regs->link like PPC32 instead of going via an intermediate symbol that 
> does nothing else than branching to LR ?

It is supposed to keep the return branch predictor balanced.

I don't know if these CPUs have one, if it gets lost during nap, or if 
nap latency is so high it really doesn't matter. But I think it is good
practice to make a habit of keeping things balanced.

Thanks,
Nick

  reply	other threads:[~2021-03-16  8:12 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-12  1:20 [PATCH] powerpc/64s: power4 nap fixup in C Nicholas Piggin
2021-03-16  7:16 ` Christophe Leroy
2021-03-16  8:11   ` Nicholas Piggin [this message]
2021-03-29  4:40 ` Michael Ellerman
2021-03-29  8:33 ` Benjamin Herrenschmidt
2021-03-29  9:04   ` Christophe Leroy
     [not found]   ` <236a67a4-1609-5fec-3c68-41db02cd1a4c__18973.8760514714$1617008745$gmane$org@csgroup.eu>
2021-03-29 11:56     ` Andreas Schwab
     [not found]     ` <87czvikwb7.fsf__13924.9042653077$1617019017$gmane$org@igel.home>
2021-03-29 16:51       ` Andreas Schwab
     [not found] ` <87y2e6fu7v.fsf__9754.75274478725$1616992871$gmane$org@mpe.ellerman.id.au>
2021-03-29 15:30   ` Andreas Schwab
     [not found]   ` <87v99aj7tr.fsf__47134.2879392736$1617031867$gmane$org@igel.home>
2021-03-29 16:23     ` Andreas Schwab
2021-04-01  7:36       ` Nicholas Piggin
2021-04-05 12:56         ` Nicholas Piggin
2021-04-05 16:40           ` Andreas Schwab
2021-04-06  2:45             ` Nicholas Piggin
2021-04-10 14:28 ` Michael Ellerman
2021-04-19  5:16   ` Michael Ellerman

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=1615882185.2o1zpw54nt.astroid@bobo.none \
    --to=npiggin@gmail.com \
    --cc=christophe.leroy@csgroup.eu \
    --cc=linuxppc-dev@lists.ozlabs.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).