lkml.org 
[lkml]   [2015]   [Apr]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 1/3] sched, timer: Remove usages of ACCESS_ONCE in the scheduler

* Jason Low <jason.low2@hp.com> wrote:

> On Thu, 2015-04-16 at 20:24 +0200, Ingo Molnar wrote:
> > Would it make sense to add a few comments to the seq field definition
> > site(s), about how it's supposed to be accessed - or to the
> > READ_ONCE()/WRITE_ONCE() sites, to keep people from wondering?
>
> How about this:
>
> ---
> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> index 5a44371..63fa87f 100644
> --- a/kernel/sched/fair.c
> +++ b/kernel/sched/fair.c
> @@ -1794,6 +1794,11 @@ static void task_numa_placement(struct task_struct *p)
> u64 runtime, period;
> spinlock_t *group_lock = NULL;
>
> + /*
> + * The p->mm->numa_scan_seq gets updated without
> + * exclusive access. Use READ_ONCE() here to ensure
> + * that the field is read in a single access.
> + */
> seq = READ_ONCE(p->mm->numa_scan_seq);
> if (p->numa_scan_seq == seq)
> return;
> @@ -2107,6 +2112,13 @@ void task_numa_fault(int last_cpupid, int mem_node, int pages, int flags)
>
> static void reset_ptenuma_scan(struct task_struct *p)
> {
> + /*
> + * We only did a read acquisition of the mmap sem, so
> + * p->mm->numa_scan_seq is written to without exclusive access.
> + * That's not much of an issue though, since this is just used
> + * for statistical sampling. Use WRITE_ONCE and READ_ONCE, which
> + * are not expensive, to avoid load/store tearing.
> + */
> WRITE_ONCE(p->mm->numa_scan_seq, READ_ONCE(p->mm->numa_scan_seq) + 1);
> p->mm->numa_scan_offset = 0;
> }

Perfect! It just needs a changelog and a SOB.

Thanks,

Ingo


\
 
 \ /
  Last update: 2015-04-17 11:01    [W:0.072 / U:1.324 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site