* [PATCH 0/2] xen/arm: vcpu_yield on WFE
@ 2014-07-23 12:04 Stefano Stabellini
2014-07-23 12:05 ` [PATCH 1/2] xen: export do_yield as vcpu_yield Stefano Stabellini
2014-07-23 12:05 ` [PATCH 2/2] xen/arm: call vcpu_yield on WFE trap Stefano Stabellini
0 siblings, 2 replies; 10+ messages in thread
From: Stefano Stabellini @ 2014-07-23 12:04 UTC (permalink / raw)
To: xen-devel
Cc: pranavkumar, julien.grall, Ian Campbell, anup.patel,
stefano.stabellini
Hi all,
the patches should be self-explanatory.
Stefano Stabellini (2):
xen: export do_yield as vcpu_yield
xen/arm: call vcpu_yield on WFE trap
xen/arch/arm/traps.c | 2 +-
xen/common/schedule.c | 10 +++++-----
xen/include/xen/sched.h | 1 +
3 files changed, 7 insertions(+), 6 deletions(-)
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 1/2] xen: export do_yield as vcpu_yield
2014-07-23 12:04 [PATCH 0/2] xen/arm: vcpu_yield on WFE Stefano Stabellini
@ 2014-07-23 12:05 ` Stefano Stabellini
2014-07-23 12:14 ` Ian Campbell
2014-07-23 12:58 ` George Dunlap
2014-07-23 12:05 ` [PATCH 2/2] xen/arm: call vcpu_yield on WFE trap Stefano Stabellini
1 sibling, 2 replies; 10+ messages in thread
From: Stefano Stabellini @ 2014-07-23 12:05 UTC (permalink / raw)
To: xen-devel
Cc: Ian.Campbell, anup.patel, stefano.stabellini, george.dunlap,
julien.grall, JBeulich, pranavkumar
Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
CC: george.dunlap@eu.citrix.com
CC: JBeulich@suse.com
---
xen/common/schedule.c | 10 +++++-----
xen/include/xen/sched.h | 1 +
2 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/xen/common/schedule.c b/xen/common/schedule.c
index e9eb0bc..6631dc8 100644
--- a/xen/common/schedule.c
+++ b/xen/common/schedule.c
@@ -795,9 +795,8 @@ static long do_poll(struct sched_poll *sched_poll)
}
/* Voluntarily yield the processor for this allocation. */
-static long do_yield(void)
+void vcpu_yield(struct vcpu *v)
{
- struct vcpu * v=current;
spinlock_t *lock = vcpu_schedule_lock_irq(v);
SCHED_OP(VCPU2OP(v), yield, v);
@@ -805,7 +804,6 @@ static long do_yield(void)
TRACE_2D(TRC_SCHED_YIELD, current->domain->domain_id, current->vcpu_id);
raise_softirq(SCHEDULE_SOFTIRQ);
- return 0;
}
static void domain_watchdog_timeout(void *data)
@@ -888,7 +886,8 @@ long do_sched_op_compat(int cmd, unsigned long arg)
{
case SCHEDOP_yield:
{
- ret = do_yield();
+ vcpu_yield(current);
+ ret = 0;
break;
}
@@ -925,7 +924,8 @@ ret_t do_sched_op(int cmd, XEN_GUEST_HANDLE_PARAM(void) arg)
{
case SCHEDOP_yield:
{
- ret = do_yield();
+ vcpu_yield(current);
+ ret = 0;
break;
}
diff --git a/xen/include/xen/sched.h b/xen/include/xen/sched.h
index 2f876f5..b99a8d3 100644
--- a/xen/include/xen/sched.h
+++ b/xen/include/xen/sched.h
@@ -634,6 +634,7 @@ int sched_id(void);
void sched_tick_suspend(void);
void sched_tick_resume(void);
void vcpu_wake(struct vcpu *v);
+void vcpu_yield(struct vcpu *v);
void vcpu_sleep_nosync(struct vcpu *v);
void vcpu_sleep_sync(struct vcpu *v);
--
1.7.10.4
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 2/2] xen/arm: call vcpu_yield on WFE trap
2014-07-23 12:04 [PATCH 0/2] xen/arm: vcpu_yield on WFE Stefano Stabellini
2014-07-23 12:05 ` [PATCH 1/2] xen: export do_yield as vcpu_yield Stefano Stabellini
@ 2014-07-23 12:05 ` Stefano Stabellini
2014-07-23 13:11 ` George Dunlap
1 sibling, 1 reply; 10+ messages in thread
From: Stefano Stabellini @ 2014-07-23 12:05 UTC (permalink / raw)
To: xen-devel
Cc: pranavkumar, julien.grall, Ian.Campbell, anup.patel,
stefano.stabellini
No need to call vcpu_force_reschedule, is too expensive.
Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
---
xen/arch/arm/traps.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/xen/arch/arm/traps.c b/xen/arch/arm/traps.c
index 3dfabd0..8cd06cc 100644
--- a/xen/arch/arm/traps.c
+++ b/xen/arch/arm/traps.c
@@ -1805,7 +1805,7 @@ asmlinkage void do_trap_hypervisor(struct cpu_user_regs *regs)
}
if ( hsr.wfi_wfe.ti ) {
/* Yield the VCPU for WFE */
- vcpu_force_reschedule(current);
+ vcpu_yield(current);
} else {
/* Block the VCPU for WFI */
vcpu_block_unless_event_pending(current);
--
1.7.10.4
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH 1/2] xen: export do_yield as vcpu_yield
2014-07-23 12:05 ` [PATCH 1/2] xen: export do_yield as vcpu_yield Stefano Stabellini
@ 2014-07-23 12:14 ` Ian Campbell
2014-07-23 12:58 ` George Dunlap
1 sibling, 0 replies; 10+ messages in thread
From: Ian Campbell @ 2014-07-23 12:14 UTC (permalink / raw)
To: Stefano Stabellini
Cc: anup.patel, george.dunlap, julien.grall, JBeulich, xen-devel,
pranavkumar
On Wed, 2014-07-23 at 13:05 +0100, Stefano Stabellini wrote:
> Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
> CC: george.dunlap@eu.citrix.com
> CC: JBeulich@suse.com
> ---
> xen/common/schedule.c | 10 +++++-----
> xen/include/xen/sched.h | 1 +
> 2 files changed, 6 insertions(+), 5 deletions(-)
>
> diff --git a/xen/common/schedule.c b/xen/common/schedule.c
> index e9eb0bc..6631dc8 100644
> --- a/xen/common/schedule.c
> +++ b/xen/common/schedule.c
> @@ -795,9 +795,8 @@ static long do_poll(struct sched_poll *sched_poll)
> }
>
> /* Voluntarily yield the processor for this allocation. */
> -static long do_yield(void)
> +void vcpu_yield(struct vcpu *v)
> {
> - struct vcpu * v=current;
Is it safe to yield another vcpu?
Ian.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 1/2] xen: export do_yield as vcpu_yield
2014-07-23 12:05 ` [PATCH 1/2] xen: export do_yield as vcpu_yield Stefano Stabellini
2014-07-23 12:14 ` Ian Campbell
@ 2014-07-23 12:58 ` George Dunlap
2014-07-23 13:04 ` Stefano Stabellini
1 sibling, 1 reply; 10+ messages in thread
From: George Dunlap @ 2014-07-23 12:58 UTC (permalink / raw)
To: Stefano Stabellini, xen-devel
Cc: JBeulich, julien.grall, Ian.Campbell, anup.patel, pranavkumar
On 07/23/2014 01:05 PM, Stefano Stabellini wrote:
> Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
> CC: george.dunlap@eu.citrix.com
> CC: JBeulich@suse.com
> ---
> xen/common/schedule.c | 10 +++++-----
> xen/include/xen/sched.h | 1 +
> 2 files changed, 6 insertions(+), 5 deletions(-)
>
> diff --git a/xen/common/schedule.c b/xen/common/schedule.c
> index e9eb0bc..6631dc8 100644
> --- a/xen/common/schedule.c
> +++ b/xen/common/schedule.c
> @@ -795,9 +795,8 @@ static long do_poll(struct sched_poll *sched_poll)
> }
>
> /* Voluntarily yield the processor for this allocation. */
> -static long do_yield(void)
> +void vcpu_yield(struct vcpu *v)
What are you actually trying to do here? Why do you add a vcpu struct,
when all the callers (including the one you add in 2/2) just pass current?
> {
> - struct vcpu * v=current;
> spinlock_t *lock = vcpu_schedule_lock_irq(v);
>
> SCHED_OP(VCPU2OP(v), yield, v);
> @@ -805,7 +804,6 @@ static long do_yield(void)
>
> TRACE_2D(TRC_SCHED_YIELD, current->domain->domain_id, current->vcpu_id);
> raise_softirq(SCHEDULE_SOFTIRQ);
This is broken: it's still tracing current instead of v, and you're
raising the schedule softirq on the current cpu rather than on the cpu
on which v is running. If v!=current, you have to go through force
reschedule for safety.
Just rename the function and make it non-static, leaving the arguments
and return value alone.
-George
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 1/2] xen: export do_yield as vcpu_yield
2014-07-23 12:58 ` George Dunlap
@ 2014-07-23 13:04 ` Stefano Stabellini
2014-07-23 13:07 ` George Dunlap
0 siblings, 1 reply; 10+ messages in thread
From: Stefano Stabellini @ 2014-07-23 13:04 UTC (permalink / raw)
To: George Dunlap
Cc: Ian.Campbell, anup.patel, Stefano Stabellini, julien.grall,
JBeulich, xen-devel, pranavkumar
On Wed, 23 Jul 2014, George Dunlap wrote:
> On 07/23/2014 01:05 PM, Stefano Stabellini wrote:
> > Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
> > CC: george.dunlap@eu.citrix.com
> > CC: JBeulich@suse.com
> > ---
> > xen/common/schedule.c | 10 +++++-----
> > xen/include/xen/sched.h | 1 +
> > 2 files changed, 6 insertions(+), 5 deletions(-)
> >
> > diff --git a/xen/common/schedule.c b/xen/common/schedule.c
> > index e9eb0bc..6631dc8 100644
> > --- a/xen/common/schedule.c
> > +++ b/xen/common/schedule.c
> > @@ -795,9 +795,8 @@ static long do_poll(struct sched_poll *sched_poll)
> > }
> > /* Voluntarily yield the processor for this allocation. */
> > -static long do_yield(void)
> > +void vcpu_yield(struct vcpu *v)
>
> What are you actually trying to do here? Why do you add a vcpu struct, when
> all the callers (including the one you add in 2/2) just pass current?
I was just trying to be coherent with the other vcpu_* functions in
sched.h.
> > {
> > - struct vcpu * v=current;
> > spinlock_t *lock = vcpu_schedule_lock_irq(v);
> > SCHED_OP(VCPU2OP(v), yield, v);
> > @@ -805,7 +804,6 @@ static long do_yield(void)
> > TRACE_2D(TRC_SCHED_YIELD, current->domain->domain_id,
> > current->vcpu_id);
> > raise_softirq(SCHEDULE_SOFTIRQ);
>
> This is broken: it's still tracing current instead of v, and you're raising
> the schedule softirq on the current cpu rather than on the cpu on which v is
> running. If v!=current, you have to go through force reschedule for safety.
>
> Just rename the function and make it non-static, leaving the arguments and
> return value alone.
OK
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 1/2] xen: export do_yield as vcpu_yield
2014-07-23 13:04 ` Stefano Stabellini
@ 2014-07-23 13:07 ` George Dunlap
0 siblings, 0 replies; 10+ messages in thread
From: George Dunlap @ 2014-07-23 13:07 UTC (permalink / raw)
To: Stefano Stabellini
Cc: Ian.Campbell, anup.patel, julien.grall, JBeulich, xen-devel,
pranavkumar
On 07/23/2014 02:04 PM, Stefano Stabellini wrote:
> On Wed, 23 Jul 2014, George Dunlap wrote:
>> On 07/23/2014 01:05 PM, Stefano Stabellini wrote:
>>> Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
>>> CC: george.dunlap@eu.citrix.com
>>> CC: JBeulich@suse.com
>>> ---
>>> xen/common/schedule.c | 10 +++++-----
>>> xen/include/xen/sched.h | 1 +
>>> 2 files changed, 6 insertions(+), 5 deletions(-)
>>>
>>> diff --git a/xen/common/schedule.c b/xen/common/schedule.c
>>> index e9eb0bc..6631dc8 100644
>>> --- a/xen/common/schedule.c
>>> +++ b/xen/common/schedule.c
>>> @@ -795,9 +795,8 @@ static long do_poll(struct sched_poll *sched_poll)
>>> }
>>> /* Voluntarily yield the processor for this allocation. */
>>> -static long do_yield(void)
>>> +void vcpu_yield(struct vcpu *v)
>> What are you actually trying to do here? Why do you add a vcpu struct, when
>> all the callers (including the one you add in 2/2) just pass current?
> I was just trying to be coherent with the other vcpu_* functions in
> sched.h.
I see. Yeah, I think even apart from the rest of it, "yield" implies
"myself"; you can't really yield someone else. :-)
-George
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 2/2] xen/arm: call vcpu_yield on WFE trap
2014-07-23 12:05 ` [PATCH 2/2] xen/arm: call vcpu_yield on WFE trap Stefano Stabellini
@ 2014-07-23 13:11 ` George Dunlap
2014-07-23 13:13 ` Stefano Stabellini
0 siblings, 1 reply; 10+ messages in thread
From: George Dunlap @ 2014-07-23 13:11 UTC (permalink / raw)
To: Stefano Stabellini
Cc: xen-devel, Julien Grall, Ian Campbell, Anup Patel,
Pranavkumar Sawargaonkar
On Wed, Jul 23, 2014 at 1:05 PM, Stefano Stabellini
<stefano.stabellini@eu.citrix.com> wrote:
> No need to call vcpu_force_reschedule, is too expensive.
>
> Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
> ---
> xen/arch/arm/traps.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/xen/arch/arm/traps.c b/xen/arch/arm/traps.c
> index 3dfabd0..8cd06cc 100644
> --- a/xen/arch/arm/traps.c
> +++ b/xen/arch/arm/traps.c
> @@ -1805,7 +1805,7 @@ asmlinkage void do_trap_hypervisor(struct cpu_user_regs *regs)
> }
> if ( hsr.wfi_wfe.ti ) {
> /* Yield the VCPU for WFE */
> - vcpu_force_reschedule(current);
> + vcpu_yield(current);
Actually, sorry -- why are you wanting to yield here?
At the moment "yield" is only initiated by the guest itself, and the
individual schedulers are notified that the guest has called "yield".
If what you want to do is yield for some other reason, it might be
better to have a slightly separate path for that.
-George
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 2/2] xen/arm: call vcpu_yield on WFE trap
2014-07-23 13:11 ` George Dunlap
@ 2014-07-23 13:13 ` Stefano Stabellini
2014-07-23 13:29 ` George Dunlap
0 siblings, 1 reply; 10+ messages in thread
From: Stefano Stabellini @ 2014-07-23 13:13 UTC (permalink / raw)
To: George Dunlap
Cc: Ian Campbell, Anup Patel, Stefano Stabellini, Julien Grall,
xen-devel, Pranavkumar Sawargaonkar
On Wed, 23 Jul 2014, George Dunlap wrote:
> On Wed, Jul 23, 2014 at 1:05 PM, Stefano Stabellini
> <stefano.stabellini@eu.citrix.com> wrote:
> > No need to call vcpu_force_reschedule, is too expensive.
> >
> > Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
> > ---
> > xen/arch/arm/traps.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/xen/arch/arm/traps.c b/xen/arch/arm/traps.c
> > index 3dfabd0..8cd06cc 100644
> > --- a/xen/arch/arm/traps.c
> > +++ b/xen/arch/arm/traps.c
> > @@ -1805,7 +1805,7 @@ asmlinkage void do_trap_hypervisor(struct cpu_user_regs *regs)
> > }
> > if ( hsr.wfi_wfe.ti ) {
> > /* Yield the VCPU for WFE */
> > - vcpu_force_reschedule(current);
> > + vcpu_yield(current);
>
> Actually, sorry -- why are you wanting to yield here?
>
> At the moment "yield" is only initiated by the guest itself, and the
> individual schedulers are notified that the guest has called "yield".
> If what you want to do is yield for some other reason, it might be
> better to have a slightly separate path for that.
It is a very similar situation: WFE means "wait for event" and it is
used in the implementation of spin_locks, for example.
I think that trapping the instruction and yielding is what we want.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 2/2] xen/arm: call vcpu_yield on WFE trap
2014-07-23 13:13 ` Stefano Stabellini
@ 2014-07-23 13:29 ` George Dunlap
0 siblings, 0 replies; 10+ messages in thread
From: George Dunlap @ 2014-07-23 13:29 UTC (permalink / raw)
To: Stefano Stabellini
Cc: xen-devel, Julien Grall, Ian Campbell, Anup Patel,
Pranavkumar Sawargaonkar
On 07/23/2014 02:13 PM, Stefano Stabellini wrote:
> On Wed, 23 Jul 2014, George Dunlap wrote:
>> On Wed, Jul 23, 2014 at 1:05 PM, Stefano Stabellini
>> <stefano.stabellini@eu.citrix.com> wrote:
>>> No need to call vcpu_force_reschedule, is too expensive.
>>>
>>> Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
>>> ---
>>> xen/arch/arm/traps.c | 2 +-
>>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>>
>>> diff --git a/xen/arch/arm/traps.c b/xen/arch/arm/traps.c
>>> index 3dfabd0..8cd06cc 100644
>>> --- a/xen/arch/arm/traps.c
>>> +++ b/xen/arch/arm/traps.c
>>> @@ -1805,7 +1805,7 @@ asmlinkage void do_trap_hypervisor(struct cpu_user_regs *regs)
>>> }
>>> if ( hsr.wfi_wfe.ti ) {
>>> /* Yield the VCPU for WFE */
>>> - vcpu_force_reschedule(current);
>>> + vcpu_yield(current);
>> Actually, sorry -- why are you wanting to yield here?
>>
>> At the moment "yield" is only initiated by the guest itself, and the
>> individual schedulers are notified that the guest has called "yield".
>> If what you want to do is yield for some other reason, it might be
>> better to have a slightly separate path for that.
>
> It is a very similar situation: WFE means "wait for event" and it is
> used in the implementation of spin_locks, for example.
> I think that trapping the instruction and yielding is what we want.
Right -- sounds good then.
-George
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2014-07-23 13:29 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-07-23 12:04 [PATCH 0/2] xen/arm: vcpu_yield on WFE Stefano Stabellini
2014-07-23 12:05 ` [PATCH 1/2] xen: export do_yield as vcpu_yield Stefano Stabellini
2014-07-23 12:14 ` Ian Campbell
2014-07-23 12:58 ` George Dunlap
2014-07-23 13:04 ` Stefano Stabellini
2014-07-23 13:07 ` George Dunlap
2014-07-23 12:05 ` [PATCH 2/2] xen/arm: call vcpu_yield on WFE trap Stefano Stabellini
2014-07-23 13:11 ` George Dunlap
2014-07-23 13:13 ` Stefano Stabellini
2014-07-23 13:29 ` George Dunlap
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).