Re: [PATCH] powerpc/kvm/booke: Fix build break due to stack frame size warning

2013-12-10 Thread Alexander Graf

On 11.12.2013, at 00:11, Scott Wood  wrote:

> On Tue, 2013-12-10 at 03:05 +0100, Alexander Graf wrote:
>> On 09.12.2013, at 22:18, Scott Wood  wrote:
>> 
>>> On Mon, 2013-11-25 at 04:26 -0600, Bharat Bhushan wrote:
 
> -Original Message-
> From: Wood Scott-B07421
> Sent: Saturday, November 23, 2013 3:22 AM
> To: Alexander Graf
> Cc: kvm-ppc@vger.kernel.org; k...@vger.kernel.org; Wood Scott-B07421; 
> Bhushan
> Bharat-R65777
> Subject: [PATCH] powerpc/kvm/booke: Fix build break due to stack frame 
> size
> warning
> 
> Commit ce11e48b7fdd256ec68b932a89b397a790566031 ("KVM: PPC: E500: Add
> userspace debug stub support") added "struct thread_struct" to the
> stack of kvmppc_vcpu_run().  thread_struct is 1152 bytes on my build,
> compared to 48 bytes for the recently-introduced "struct debug_reg".
> Use the latter instead.
> 
> This fixes the following error:
> 
> cc1: warnings being treated as errors
> arch/powerpc/kvm/booke.c: In function 'kvmppc_vcpu_run':
> arch/powerpc/kvm/booke.c:760:1: error: the frame size of 1424 bytes is 
> larger
> than 1024 bytes
> make[2]: *** [arch/powerpc/kvm/booke.o] Error 1
> make[1]: *** [arch/powerpc/kvm] Error 2
> make[1]: *** Waiting for unfinished jobs
> 
> Signed-off-by: Scott Wood 
> Cc: Bharat Bhushan 
> ---
> Build tested only.  Bharat, please test.
 
 Tested with qemu debug stub; It works fine
 
 -Bharat
>>> 
>>> Alex, are you going to take this through your tree?
>> 
>> Sure. Do you want this for 3.13 or 3.14? Since I don't see the breakage
>> with my compilers I'd queue it for 3.14, but whatever works for you
>> works for me.
> 
> 3.13 please.  All I need to do to trigger the build break is enable KVM
> with corenet64_smp_defconfig with GCC 4.5.

Thanks, applied to the for-3.13 branch.


Alex

--
To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] powerpc/kvm/booke: Fix build break due to stack frame size warning

2013-12-10 Thread Alexander Graf

On 11.12.2013, at 00:11, Scott Wood  wrote:

> On Tue, 2013-12-10 at 03:05 +0100, Alexander Graf wrote:
>> On 09.12.2013, at 22:18, Scott Wood  wrote:
>> 
>>> On Mon, 2013-11-25 at 04:26 -0600, Bharat Bhushan wrote:
 
> -Original Message-
> From: Wood Scott-B07421
> Sent: Saturday, November 23, 2013 3:22 AM
> To: Alexander Graf
> Cc: kvm-ppc@vger.kernel.org; k...@vger.kernel.org; Wood Scott-B07421; 
> Bhushan
> Bharat-R65777
> Subject: [PATCH] powerpc/kvm/booke: Fix build break due to stack frame 
> size
> warning
> 
> Commit ce11e48b7fdd256ec68b932a89b397a790566031 ("KVM: PPC: E500: Add
> userspace debug stub support") added "struct thread_struct" to the
> stack of kvmppc_vcpu_run().  thread_struct is 1152 bytes on my build,
> compared to 48 bytes for the recently-introduced "struct debug_reg".
> Use the latter instead.
> 
> This fixes the following error:
> 
> cc1: warnings being treated as errors
> arch/powerpc/kvm/booke.c: In function 'kvmppc_vcpu_run':
> arch/powerpc/kvm/booke.c:760:1: error: the frame size of 1424 bytes is 
> larger
> than 1024 bytes
> make[2]: *** [arch/powerpc/kvm/booke.o] Error 1
> make[1]: *** [arch/powerpc/kvm] Error 2
> make[1]: *** Waiting for unfinished jobs
> 
> Signed-off-by: Scott Wood 
> Cc: Bharat Bhushan 
> ---
> Build tested only.  Bharat, please test.
 
 Tested with qemu debug stub; It works fine
 
 -Bharat
>>> 
>>> Alex, are you going to take this through your tree?
>> 
>> Sure. Do you want this for 3.13 or 3.14? Since I don't see the breakage
>> with my compilers I'd queue it for 3.14, but whatever works for you
>> works for me.
> 
> 3.13 please.  All I need to do to trigger the build break is enable KVM
> with corenet64_smp_defconfig with GCC 4.5.

Thanks, applied to the for-3.13 branch.


Alex

--
To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] powerpc/kvm/booke: Fix build break due to stack frame size warning

2013-12-10 Thread Scott Wood
On Tue, 2013-12-10 at 03:05 +0100, Alexander Graf wrote:
> On 09.12.2013, at 22:18, Scott Wood  wrote:
> 
> > On Mon, 2013-11-25 at 04:26 -0600, Bharat Bhushan wrote:
> >> 
> >>> -Original Message-
> >>> From: Wood Scott-B07421
> >>> Sent: Saturday, November 23, 2013 3:22 AM
> >>> To: Alexander Graf
> >>> Cc: kvm-ppc@vger.kernel.org; k...@vger.kernel.org; Wood Scott-B07421; 
> >>> Bhushan
> >>> Bharat-R65777
> >>> Subject: [PATCH] powerpc/kvm/booke: Fix build break due to stack frame 
> >>> size
> >>> warning
> >>> 
> >>> Commit ce11e48b7fdd256ec68b932a89b397a790566031 ("KVM: PPC: E500: Add
> >>> userspace debug stub support") added "struct thread_struct" to the
> >>> stack of kvmppc_vcpu_run().  thread_struct is 1152 bytes on my build,
> >>> compared to 48 bytes for the recently-introduced "struct debug_reg".
> >>> Use the latter instead.
> >>> 
> >>> This fixes the following error:
> >>> 
> >>> cc1: warnings being treated as errors
> >>> arch/powerpc/kvm/booke.c: In function 'kvmppc_vcpu_run':
> >>> arch/powerpc/kvm/booke.c:760:1: error: the frame size of 1424 bytes is 
> >>> larger
> >>> than 1024 bytes
> >>> make[2]: *** [arch/powerpc/kvm/booke.o] Error 1
> >>> make[1]: *** [arch/powerpc/kvm] Error 2
> >>> make[1]: *** Waiting for unfinished jobs
> >>> 
> >>> Signed-off-by: Scott Wood 
> >>> Cc: Bharat Bhushan 
> >>> ---
> >>> Build tested only.  Bharat, please test.
> >> 
> >> Tested with qemu debug stub; It works fine
> >> 
> >> -Bharat
> > 
> > Alex, are you going to take this through your tree?
> 
> Sure. Do you want this for 3.13 or 3.14? Since I don't see the breakage
> with my compilers I'd queue it for 3.14, but whatever works for you
> works for me.

3.13 please.  All I need to do to trigger the build break is enable KVM
with corenet64_smp_defconfig with GCC 4.5.

Oddly, I don't see it with newer GCCs (4.7.3 or 4.8.0).  It looks like
it may be a bug in the stack frame warning in those newer versions.
This is the code from 4.8.0:

0e8c <.kvmppc_vcpu_run>:
.kvmppc_vcpu_run():
/home/scott/fsl/git/linux/upstream/arch/powerpc/kvm/booke.c:682
 e8c:   7c 08 02 a6 mflrr0
 e90:   fb 41 ff d0 std r26,-48(r1)
 e94:   7c 7a 1b 78 mr  r26,r3
 e98:   fb a1 ff e8 std r29,-24(r1)
 e9c:   fb c1 ff f0 std r30,-16(r1)
 ea0:   7c 9e 23 78 mr  r30,r4
 ea4:   fb e1 ff f8 std r31,-8(r1)
 ea8:   f8 01 00 10 std r0,16(r1)
 eac:   fb 21 ff c8 std r25,-56(r1)
 eb0:   fb 61 ff d8 std r27,-40(r1)
 eb4:   fb 81 ff e0 std r28,-32(r1)
 eb8:   f8 21 fe 41 stdur1,-448(r1)
/home/scott/fsl/git/linux/upstream/arch/powerpc/kvm/booke.c:690
 ebc:   89 44 08 a9 lbz r10,2217(r4)
/home/scott/fsl/git/linux/upstream/arch/powerpc/kvm/booke.c:682
 ec0:   7c 3f 0b 78 mr  r31,r1
 ec4:   e9 21 00 00 ld  r9,0(r1)
/home/scott/fsl/git/linux/upstream/arch/powerpc/kvm/booke.c:690
 ec8:   2f 8a 00 00 cmpwi   cr7,r10,0
/home/scott/fsl/git/linux/upstream/arch/powerpc/kvm/booke.c:682
 ecc:   f9 21 fb 41 stdur9,-1216(r1)
 ed0:   3b a1 00 af addir29,r1,175  
 ed4:   7b bd 06 64 rldicr  r29,r29,0,57

The instruction at 0xecc expands the stack by 1216 bytes, on top of the
already allocated stack frame of 448 bytes.  I'm not sure why it's
creating a secondary stack frame in this odd way.

GCC 4.5, which produces the warning, does this instead:

0eb8 <.kvmppc_vcpu_run>:
kvmppc_vcpu_run():
/home/scott/fsl/git/linux/upstream/arch/powerpc/kvm/booke.c:682
 eb8:   7c 08 02 a6 mflrr0
 ebc:   fb 61 ff d8 std r27,-40(r1)
 ec0:   7c 7b 1b 78 mr  r27,r3
 ec4:   fb e1 ff f8 std r31,-8(r1)
 ec8:   7c 9f 23 78 mr  r31,r4
 ecc:   f8 01 00 10 std r0,16(r1)
 ed0:   fb 41 ff d0 std r26,-48(r1)
 ed4:   fb 81 ff e0 std r28,-32(r1)
 ed8:   fb a1 ff e8 std r29,-24(r1)
 edc:   f8 21 f9 d1 stdur1,-1584(r1)

-Scott



--
To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] KVM: PPC: Use schedule instead of cond_resched

2013-12-10 Thread Benjamin Herrenschmidt
On Tue, 2013-12-10 at 23:48 +0100, Peter Zijlstra wrote:
> 
> Yeah, I went on holidays and the patch just sat there. I'll prod Ingo
> into merging it.

Thanks !

Cheers,
Ben.


--
To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] KVM: PPC: Use schedule instead of cond_resched

2013-12-10 Thread Peter Zijlstra
On Wed, Dec 11, 2013 at 07:52:51AM +1100, Benjamin Herrenschmidt wrote:
> On Tue, 2013-12-10 at 15:40 +0100, Alexander Graf wrote:
> > On 10.12.2013, at 15:21, Aneesh Kumar K.V  
> > wrote:
> > 
> > > From: "Aneesh Kumar K.V" 
> > > 
> > > We already checked need_resched. So we can call schedule directly
> > > 
> > > Signed-off-by: Aneesh Kumar K.V 
> > 
> > The real fix for the issue you're seeing is
> > 
> >   https://lkml.org/lkml/2013/11/28/241
> > 
> 
> And is still not upstream Peter ?

Yeah, I went on holidays and the patch just sat there. I'll prod Ingo
into merging it.
--
To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] KVM: PPC: Use schedule instead of cond_resched

2013-12-10 Thread Benjamin Herrenschmidt
On Tue, 2013-12-10 at 15:40 +0100, Alexander Graf wrote:
> On 10.12.2013, at 15:21, Aneesh Kumar K.V  
> wrote:
> 
> > From: "Aneesh Kumar K.V" 
> > 
> > We already checked need_resched. So we can call schedule directly
> > 
> > Signed-off-by: Aneesh Kumar K.V 
> 
> The real fix for the issue you're seeing is
> 
>   https://lkml.org/lkml/2013/11/28/241
> 

And is still not upstream Peter ?

Cheers,
Ben.


--
To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] KVM: PPC: Use schedule instead of cond_resched

2013-12-10 Thread Alexander Graf

On 10.12.2013, at 17:08, Aneesh Kumar K.V  
wrote:

> Alexander Graf  writes:
> 
>> On 10.12.2013, at 15:21, Aneesh Kumar K.V  
>> wrote:
>> 
>>> From: "Aneesh Kumar K.V" 
>>> 
>>> We already checked need_resched. So we can call schedule directly
>>> 
>>> Signed-off-by: Aneesh Kumar K.V 
>> 
>> The real fix for the issue you're seeing is
>> 
>>  https://lkml.org/lkml/2013/11/28/241
> 
> True, I mentioned that in the thread
> 
> https://lkml.org/lkml/2013/12/9/64
> 
> But do we need to do cond_resched after we checked for need_resched() ?

This is really just copying the logic from kvm_resched() from 
virt/kvm/kvm_main.c. And I'd prefer not to diverge from that. I do agree that 
there's a good chance we don't need it, as it seems to predate preempt 
notifiers:

  
https://git.kernel.org/cgit/virt/kvm/kvm.git/commit/?id=3fca03653010b8c5fa63b99fc94c78cbfb433d00

But this is a discussion that should occur on the non-ppc specific code first 
:).


Alex

--
To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] KVM: PPC: Use schedule instead of cond_resched

2013-12-10 Thread Aneesh Kumar K.V
Alexander Graf  writes:

> On 10.12.2013, at 15:21, Aneesh Kumar K.V  
> wrote:
>
>> From: "Aneesh Kumar K.V" 
>> 
>> We already checked need_resched. So we can call schedule directly
>> 
>> Signed-off-by: Aneesh Kumar K.V 
>
> The real fix for the issue you're seeing is
>
>   https://lkml.org/lkml/2013/11/28/241

True, I mentioned that in the thread

https://lkml.org/lkml/2013/12/9/64

But do we need to do cond_resched after we checked for need_resched() ?

-aneesh

--
To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] KVM: PPC: Use schedule instead of cond_resched

2013-12-10 Thread Alexander Graf

On 10.12.2013, at 15:21, Aneesh Kumar K.V  
wrote:

> From: "Aneesh Kumar K.V" 
> 
> We already checked need_resched. So we can call schedule directly
> 
> Signed-off-by: Aneesh Kumar K.V 

The real fix for the issue you're seeing is

  https://lkml.org/lkml/2013/11/28/241


Alex

--
To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] KVM: PPC: Use schedule instead of cond_resched

2013-12-10 Thread Aneesh Kumar K.V
From: "Aneesh Kumar K.V" 

We already checked need_resched. So we can call schedule directly

Signed-off-by: Aneesh Kumar K.V 
---

NOTE: This patch also work around a regression upstream w.r.t PR KVM

 BUG: soft lockup - CPU#0 stuck for 23s! [qemu-system-ppc:4394]
 Modules linked in:
 CPU: 0 PID: 4394 Comm: qemu-system-ppc Not tainted 3.13.0-rc3+ #98
 task: c001d0788400 ti: c001dca0 task.ti: c001dca0
 NIP: c082dd80 LR: c0081ae0 CTR: c0062ba0
 REGS: c001dca02f70 TRAP: 0901   Not tainted  (3.13.0-rc3+)
 MSR: 80009032   CR: 24822024  XER: 
 CFAR: c0081adc SOFTE: 1
 GPR00: c0081ae0 c001dca031f0 c0d67ab0 0001
 GPR04: 7102 0001 0189a0d786b7 018c
 GPR08: 0001   c0da
 GPR12: 0c00 cfef
 NIP [c082dd80] ._cond_resched+0x0/0x40
 LR [c0081ae0] .kvmppc_prepare_to_enter+0x2a0/0x2e0
 Call Trace:
 [c001dca031f0] [c0081ae0] .kvmppc_prepare_to_enter+0x2a0/0x2e0 
(unreliable)
 [c001dca03290] [c008f2cc] .kvmppc_handle_exit_pr+0xec/0xa40
 [c001dca03340] [c00918c4] kvm_start_lightweight+0xac/0xbc
 [c001dca03510] [c008efe0] .kvmppc_vcpu_run_pr+0x130/0x2a0
 [c001dca039e0] [c00855bc] .kvmppc_vcpu_run+0x2c/0x40
 [c001dca03a50] [c0082c94] .kvm_arch_vcpu_ioctl_run+0x54/0x1b0
 [c001dca03ae0] [c007d5f8] .kvm_vcpu_ioctl+0x478/0x740
 [c001dca03ca0] [c0218864] .do_vfs_ioctl+0x4a4/0x760
 [c001dca03d80] [c0218b78] .SyS_ioctl+0x58/0xb0
 [c001dca03e30] [c0009e58] syscall_exit+0x0/0x98
 Instruction dump:
 e92d0260 e94911c0 812a0004 5529f07e 5529103e 912a0004 38210080 e8010010
 ebc1fff0 ebe1fff8 7c0803a6 4e800020 <7c0802a6> 3860 f8010010 f821ff91 

 arch/powerpc/kvm/powerpc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/powerpc/kvm/powerpc.c b/arch/powerpc/kvm/powerpc.c
index e4d511c8b38b..6a49b23a3276 100644
--- a/arch/powerpc/kvm/powerpc.c
+++ b/arch/powerpc/kvm/powerpc.c
@@ -74,7 +74,7 @@ int kvmppc_prepare_to_enter(struct kvm_vcpu *vcpu)
while (true) {
if (need_resched()) {
local_irq_enable();
-   cond_resched();
+   schedule();
local_irq_disable();
continue;
}
-- 
1.8.3.2

--
To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html