lkml.org 
[lkml]   [2012]   [Mar]   [6]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] cpuset: mm: Reduce large amounts of memory barrier related damage v2
On Tue, 6 Mar 2012 22:42:01 +0000
Mel Gorman <mgorman@suse.de> wrote:

> /*
> * get_mems_allowed is required when making decisions involving mems_allowed
> * such as during page allocation. mems_allowed can be updated in parallel
> * and depending on the new value an operation can fail potentially causing
> * process failure. A retry loop with get_mems_allowed and put_mems_allowed
> * prevents these artificial failures.
> */
> static inline unsigned int get_mems_allowed(void)
> {
> return read_seqcount_begin(&current->mems_allowed_seq);
> }
>
> /*
> * If this returns false, the operation that took place after get_mems_allowed
> * may have failed. It is up to the caller to retry the operation if
> * appropriate.
> */
> static inline bool put_mems_allowed(unsigned int seq)
> {
> return !read_seqcount_retry(&current->mems_allowed_seq, seq);
> }
>
> ?

lgtm ;)

> > > -static inline void put_mems_allowed(void)
> > > +/*
> > > + * If this returns false, the operation that took place after get_mems_allowed
> > > + * may have failed. It is up to the caller to retry the operation if
> > > + * appropriate
> > > + */
> > > +static inline bool put_mems_allowed(unsigned int seq)
> > > {
> > > - /*
> > > - * ensure that reading mems_allowed and mempolicy before reducing
> > > - * mems_allowed_change_disable.
> > > - *
> > > - * the write-side task will know that the read-side task is still
> > > - * reading mems_allowed or mempolicy, don't clears old bits in the
> > > - * nodemask.
> > > - */
> > > - smp_mb();
> > > - --ACCESS_ONCE(current->mems_allowed_change_disable);
> > > + return !read_seqcount_retry(&current->mems_allowed_seq, seq);
> > > }
> > >
> > > static inline void set_mems_allowed(nodemask_t nodemask)
> >
> > How come set_mems_allowed() still uses task_lock()?
> >
>
> Consistency.
>
> The task_lock is taken by kernel/cpuset.c when updating
> mems_allowed so it is taken here. That said, it is unnecessary to take
> as the two places where set_mems_allowed is used are not going to be
> racing. In the unlikely event that set_mems_allowed() gets another user,
> there is no harm is leaving the task_lock as it is. It's not in a hot
> path of any description.

But shouldn't set_mems_allowed() bump mems_allowed_seq?


\
 
 \ /
  Last update: 2012-03-06 23:57    [W:0.052 / U:2.328 seconds]
©2003-2017 Jasper Spaans. hosted at Digital OceanAdvertise on this site