Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1437120 > unrolled thread

Re: [PATCH 3/3] xen: support runqueue steal time on xen

Started byStefano Stabellini <sstabellini@kernel.org>
First post2016-07-05 17:30 +0200
Last post2016-07-06 06:30 +0200
Articles 2 — 2 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: [PATCH 3/3] xen: support runqueue steal time on xen Stefano Stabellini <sstabellini@kernel.org> - 2016-07-05 17:30 +0200
    Re: [PATCH 3/3] xen: support runqueue steal time on xen Juergen Gross <jgross@suse.com> - 2016-07-06 06:30 +0200

#1437120 — Re: [PATCH 3/3] xen: support runqueue steal time on xen

FromStefano Stabellini <sstabellini@kernel.org>
Date2016-07-05 17:30 +0200
SubjectRe: [PATCH 3/3] xen: support runqueue steal time on xen
Message-ID<rRAsp-4Ci-5@gated-at.bofh.it>
On Wed, 22 Jun 2016, Juergen Gross wrote:
> Up to now reading the stolen time of a remote cpu was not possible in a
> performant way under Xen. This made support of runqueue steal time via
> paravirt_steal_rq_enabled impossible.
> 
> With the addition of an appropriate hypervisor interface this is now
> possible, so add the support.
> 
> Signed-off-by: Juergen Gross <jgross@suse.com>
> ---
>  drivers/xen/time.c | 42 +++++++++++++++++++++++++-----------------
>  1 file changed, 25 insertions(+), 17 deletions(-)
> 
> diff --git a/drivers/xen/time.c b/drivers/xen/time.c
> index 2257b66..65afbe9 100644
> --- a/drivers/xen/time.c
> +++ b/drivers/xen/time.c
> @@ -19,6 +19,9 @@
>  /* runstate info updated by Xen */
>  static DEFINE_PER_CPU(struct vcpu_runstate_info, xen_runstate);
>  
> +/* runstate info of remote cpu accessible */
> +static bool xen_runstate_remote;

Honestly I would rather have one global variable less if it means only
dropping one BUG_ON.


>  /* return an consistent snapshot of 64-bit time/counter value */
>  static u64 get64(const u64 *p)
>  {
> @@ -47,27 +50,31 @@ static u64 get64(const u64 *p)
>  	return ret;
>  }
>  
> -/*
> - * Runstate accounting
> - */
> -void xen_get_runstate_snapshot(struct vcpu_runstate_info *res)
> +static void xen_get_runstate_snapshot_cpu(struct vcpu_runstate_info *res,
> +					  unsigned int cpu)
>  {
>  	u64 state_time;
>  	struct vcpu_runstate_info *state;
>  
>  	BUG_ON(preemptible());
>  
> -	state = this_cpu_ptr(&xen_runstate);
> +	state = per_cpu_ptr(&xen_runstate, cpu);
>  
> -	/*
> -	 * The runstate info is always updated by the hypervisor on
> -	 * the current CPU, so there's no need to use anything
> -	 * stronger than a compiler barrier when fetching it.
> -	 */
>  	do {
>  		state_time = get64(&state->state_entry_time);
> +		rmb();	/* Hypervisor might update data. */
>  		*res = READ_ONCE(*state);
> -	} while (get64(&state->state_entry_time) != state_time);
> +		rmb();	/* Hypervisor might update data. */
> +	} while (get64(&state->state_entry_time) != state_time ||
> +		 (state_time & XEN_RUNSTATE_UPDATE));
> +}
> +
> +/*
> + * Runstate accounting
> + */
> +void xen_get_runstate_snapshot(struct vcpu_runstate_info *res)
> +{
> +	xen_get_runstate_snapshot_cpu(res, smp_processor_id());
>  }
>  
>  /* return true when a vcpu could run but has no real cpu to run on */
> @@ -80,8 +87,8 @@ static u64 xen_steal_clock(int cpu)
>  {
>  	struct vcpu_runstate_info state;
>  
> -	BUG_ON(cpu != smp_processor_id());
> -	xen_get_runstate_snapshot(&state);
> +	BUG_ON(!xen_runstate_remote && cpu != smp_processor_id());
> +	xen_get_runstate_snapshot_cpu(&state, cpu);
>  	return state.time[RUNSTATE_runnable] + state.time[RUNSTATE_offline];
>  }
>  
> @@ -98,11 +105,12 @@ void xen_setup_runstate_info(int cpu)
>  
>  void __init xen_time_setup_guest(void)
>  {
> +	xen_runstate_remote = !HYPERVISOR_vm_assist(VMASST_CMD_enable,
> +					VMASST_TYPE_runstate_update_flag);
> +
>  	pv_time_ops.steal_clock = xen_steal_clock;
>  
>  	static_key_slow_inc(&paravirt_steal_enabled);
> -	/*
> -	 * We can't set paravirt_steal_rq_enabled as this would require the
> -	 * capability to read another cpu's runstate info.
> -	 */
> +	if (xen_runstate_remote)
> +		static_key_slow_inc(&paravirt_steal_rq_enabled);
>  }

[toc] | [next] | [standalone]


#1437402

FromJuergen Gross <jgross@suse.com>
Date2016-07-06 06:30 +0200
Message-ID<rRMDf-4rp-1@gated-at.bofh.it>
In reply to#1437120
On 05/07/16 17:23, Stefano Stabellini wrote:
> On Wed, 22 Jun 2016, Juergen Gross wrote:
>> Up to now reading the stolen time of a remote cpu was not possible in a
>> performant way under Xen. This made support of runqueue steal time via
>> paravirt_steal_rq_enabled impossible.
>>
>> With the addition of an appropriate hypervisor interface this is now
>> possible, so add the support.
>>
>> Signed-off-by: Juergen Gross <jgross@suse.com>
>> ---
>>  drivers/xen/time.c | 42 +++++++++++++++++++++++++-----------------
>>  1 file changed, 25 insertions(+), 17 deletions(-)
>>
>> diff --git a/drivers/xen/time.c b/drivers/xen/time.c
>> index 2257b66..65afbe9 100644
>> --- a/drivers/xen/time.c
>> +++ b/drivers/xen/time.c
>> @@ -19,6 +19,9 @@
>>  /* runstate info updated by Xen */
>>  static DEFINE_PER_CPU(struct vcpu_runstate_info, xen_runstate);
>>  
>> +/* runstate info of remote cpu accessible */
>> +static bool xen_runstate_remote;
> 
> Honestly I would rather have one global variable less if it means only
> dropping one BUG_ON.

Okay, I'll remove it.


Juergen

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web