lkml.org 
[lkml]   [2018]   [Jul]   [23]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v2 13/19] mm/migrate: Use xchg instead of spinlock
On Mon, Jul 23, 2018 at 04:20:32AM -0700, Srikar Dronamraju wrote:
> > If you maybe write that like:
> >
> > if (time_after(jiffies, next_window) &&
> > xchg(&pgdat->numabalancing_migrate_nr_pages, 0UL)) {
> >
> > do {
> > next_window += interval;
> > } while (unlikely(time_after(jiffies, next_window)));
> >
> > WRITE_ONCE(pgdat->numabalancing_migrate_next_window, next_window);
> > }
> >
> > Then you avoid an indent level and line-wrap, resulting imo easier to
> > read code.
> >
>
> Okay will do.

FWIW, that code seems to rely on @nr_pages != 0, otherwise you can have
the xchg fail even though time_after is true.

Probably not a problem, but it is a semantic change vs the spinlock.
Also, the spinlock thing could probably have changed to a trylock and
you'd have seens similar 'gains' I suppose.

Another difference vs the lock+unlock is that you lost the release
ordering. Again, probably not a big deal, but it does make the whole
things a little dodgy.

\
 
 \ /
  Last update: 2018-07-23 16:05    [W:0.164 / U:3.708 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site