From mboxrd@z Thu Jan 1 00:00:00 1970 From: "tiejun.chen" Subject: Re: [v1][PATCH 1/1] KVM: PPC: disable preemption when using hard_irq_disable() Date: Fri, 12 Jul 2013 12:54:34 +0800 Message-ID: <51DF8C0A.6070608@windriver.com> References: <1373436139-27998-1-git-send-email-tiejun.chen@windriver.com> <62E2724C-EC17-4E36-AC9E-C9FFEDF5C5B7@suse.de> <51DE1CE9.7060406@windriver.com> <1373545684.19894.80.camel@pasglop> <3B36D92F-CD11-49A0-A0F5-CD3E49BD6793@suse.de> <1373547293.19894.99.camel@pasglop> <1373588345.19894.126.camel@pasglop> <51DF6653.7010902@windriver.com> <1373601460.19894.135.camel@pasglop> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit Cc: Alexander Graf , "" , " list" To: Benjamin Herrenschmidt Return-path: In-Reply-To: <1373601460.19894.135.camel@pasglop> Sender: kvm-ppc-owner@vger.kernel.org List-Id: kvm.vger.kernel.org On 07/12/2013 11:57 AM, Benjamin Herrenschmidt wrote: > On Fri, 2013-07-12 at 10:13 +0800, tiejun.chen wrote: >>> #define hard_irq_disable() do { \ >>> u8 _was_enabled = get_paca()->soft_enabled; \ >> >> Current problem I met is issued from the above line. >> >>> __hard_irq_disable(); \ >>> - get_paca()->soft_enabled = 0; \ >> >> Not here. >> >> If I'm misunderstanding what you guys means, please correct me since this is a >> long discussion thread. I have to reread that carefully. > > Then make it > u8 _was_enabled; > __hard_irq_disable(); > was_enabled = local_paca->.... > > Once you have hard disabled, using local_paca directly *should* be safe > (minus that gcc problem I mentioned). Is the following fine? powerpc: to access local paca after hard irq disabled We can access paca directly after hard interrupt disabled, and this can avoid accessing wrong paca when using get_paca() in preempt case. Signed-off-by: Tiejun Chen --- arch/powerpc/include/asm/hw_irq.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/arch/powerpc/include/asm/hw_irq.h b/arch/powerpc/include/asm/hw_irq.h index ba713f1..10be1dd 100644 --- a/arch/powerpc/include/asm/hw_irq.h +++ b/arch/powerpc/include/asm/hw_irq.h @@ -96,10 +96,11 @@ static inline bool arch_irqs_disabled(void) #endif #define hard_irq_disable() do { \ - u8 _was_enabled = get_paca()->soft_enabled; \ + u8 _was_enabled; \ __hard_irq_disable(); \ - get_paca()->soft_enabled = 0; \ - get_paca()->irq_happened |= PACA_IRQ_HARD_DIS; \ + _was_enabled = local_paca->soft_enabled; \ + local_paca->soft_enabled = 0; \ + local_paca->irq_happened |= PACA_IRQ_HARD_DIS; \ if (_was_enabled) \ trace_hardirqs_off(); \ } while(0) -- 1.7.9.5 Or what about that change to call SOFT_DISABLE_INTS only in KVM scenario? Which better? Then I can send to review? Thanks, Tiejun