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


Groups > linux.kernel > #1369073

Re: [PATCH v3 5/6] virt, sched: add cpu pinning to smp_call_sync_on_phys_cpu()

From Peter Zijlstra <peterz@infradead.org>
Newsgroups linux.kernel
Subject Re: [PATCH v3 5/6] virt, sched: add cpu pinning to smp_call_sync_on_phys_cpu()
Date 2016-04-01 09:50 +0200
Message-ID <rj20a-189-21@gated-at.bofh.it> (permalink)
References <rj1x7-Xr-7@gated-at.bofh.it> <rj1x8-Xr-17@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Fri, Apr 01, 2016 at 09:14:33AM +0200, Juergen Gross wrote:
> --- a/kernel/smp.c
> +++ b/kernel/smp.c
> @@ -14,6 +14,7 @@
>  #include <linux/smp.h>
>  #include <linux/cpu.h>
>  #include <linux/sched.h>
> +#include <linux/hypervisor.h>
>  
>  #include "smpboot.h"
>  
> @@ -758,9 +759,14 @@ struct smp_sync_call_struct {
>  static void smp_call_sync_callback(struct work_struct *work)
>  {
>  	struct smp_sync_call_struct *sscs;
> +	unsigned int cpu;
>  
>  	sscs = container_of(work, struct smp_sync_call_struct, work);
> +	cpu = get_cpu();
> +	hypervisor_pin_vcpu(cpu);
>  	sscs->ret = sscs->func(sscs->data);
> +	hypervisor_pin_vcpu(-1);
> +	put_cpu();
>  
>  	complete(&sscs->done);
>  }

So I don't really like this; it adds the requirement that the function
cannot schedule, which greatly limits the utility of the construct. At
this point you might as well use the regular IPI stuff.

You can easily avoid this constraint by using:

	hypervisor_pin_vcpu(smp_processor_id());

Also, for the vpinning stuff, the UP version below is sufficient, even
on SMP systems (with the current !preempt constraint). Which seems to
suggest we're not having the right interface for this.

So I would propose you add:

	smp_call_on_cpu()

As per patch 2. No promises about physical or anything. This means it
can be used freely by anyone that wants to run a function on another
cpu -- a much more useful thing.

And then build a phys variant on top.


> diff --git a/kernel/up.c b/kernel/up.c
> index afd395c..725ec44 100644
> --- a/kernel/up.c
> +++ b/kernel/up.c
> @@ -6,6 +6,7 @@
>  #include <linux/kernel.h>
>  #include <linux/export.h>
>  #include <linux/smp.h>
> +#include <linux/hypervisor.h>
>  
>  int smp_call_function_single(int cpu, void (*func) (void *info), void *info,
>  				int wait)
> @@ -85,9 +86,17 @@ EXPORT_SYMBOL(on_each_cpu_cond);
>  
>  int smp_call_sync_on_phys_cpu(unsigned int cpu, int (*func)(void *), void *par)
>  {
> +	int ret;
> +
>  	if (cpu != 0)
>  		return -EINVAL;
>  
> -	return func(par);
> +	preempt_disable();
> +	hypervisor_pin_vcpu(0);
> +	ret = func(par);
> +	hypervisor_pin_vcpu(-1);
> +	preempt_enable();
> +
> +	return ret;
>  }
>  EXPORT_SYMBOL_GPL(smp_call_sync_on_phys_cpu);
> -- 
> 2.6.2
> 

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH v3 0/6] Support calling functions on dedicated physical cpu Juergen Gross <jgross@suse.com> - 2016-04-01 09:20 +0200
  [PATCH v3 6/6] xen: add xen_pin_vcpu() to support calling functions on a dedicated pcpu Juergen Gross <jgross@suse.com> - 2016-04-01 09:20 +0200
  [PATCH v3 1/6] xen: sync xen header Juergen Gross <jgross@suse.com> - 2016-04-01 09:20 +0200
  [PATCH v3 5/6] virt, sched: add cpu pinning to smp_call_sync_on_phys_cpu() Juergen Gross <jgross@suse.com> - 2016-04-01 09:20 +0200
    Re: [PATCH v3 5/6] virt, sched: add cpu pinning to  smp_call_sync_on_phys_cpu() Peter Zijlstra <peterz@infradead.org> - 2016-04-01 09:50 +0200
      Re: [PATCH v3 5/6] virt, sched: add cpu pinning to  smp_call_sync_on_phys_cpu() Juergen Gross <jgross@suse.com> - 2016-04-01 10:40 +0200
        Re: [PATCH v3 5/6] virt, sched: add cpu pinning to  smp_call_sync_on_phys_cpu() Peter Zijlstra <peterz@infradead.org> - 2016-04-01 10:50 +0200
          Re: [PATCH v3 5/6] virt, sched: add cpu pinning to  smp_call_sync_on_phys_cpu() Juergen Gross <jgross@suse.com> - 2016-04-01 11:10 +0200
            Re: [PATCH v3 5/6] virt, sched: add cpu pinning to  smp_call_sync_on_phys_cpu() Peter Zijlstra <peterz@infradead.org> - 2016-04-01 11:20 +0200
              Re: [PATCH v3 5/6] virt, sched: add cpu pinning to  smp_call_sync_on_phys_cpu() Juergen Gross <jgross@suse.com> - 2016-04-01 11:30 +0200
  [PATCH v3 4/6] hwmon: use smp_call_sync_on_phys_cpu() for dell-smm i8k Juergen Gross <jgross@suse.com> - 2016-04-01 09:20 +0200

csiph-web