lkml.org 
[lkml]   [2016]   [Mar]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 2/6] sched: add function to execute a function synchronously on a physical cpu
On Fri, Mar 11, 2016 at 01:43:53PM +0100, Juergen Gross wrote:
> On 11/03/16 13:19, Peter Zijlstra wrote:
> > On Fri, Mar 11, 2016 at 12:59:30PM +0100, Juergen Gross wrote:
> >> +int call_sync_on_phys_cpu(unsigned cpu, int (*func)(void *), void *par)
> >> +{
> >> + cpumask_var_t old_mask;
> >> + int ret;
> >> +
> >> + if (cpu >= nr_cpu_ids)
> >> + return -EINVAL;
> >> +
> >> + if (!alloc_cpumask_var(&old_mask, GFP_KERNEL))
> >> + return -ENOMEM;
> >> +
> >> + cpumask_copy(old_mask, &current->cpus_allowed);
> >> + ret = set_cpus_allowed_ptr(current, cpumask_of(cpu));
> >> + if (ret)
> >> + goto out;
> >
> > So what happens if someone does sched_setaffinity() right about here?
>
> Aah, okay. Seems I should add preempt_disable() in this patch already
> and retry the set_cpus_allowed_ptr() in case cpus_allowed has changed.

Doesn't help, you should simply not _ever_ touch this for random tasks.

\
 
 \ /
  Last update: 2016-03-11 14:21    [W:0.045 / U:1.420 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site