lkml.org 
[lkml]   [2014]   [May]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] mm: filemap: Avoid unnecessary barries and waitqueue lookups in unlock_page fastpath v5
On Wed, May 21, 2014 at 04:33:57PM +0100, Mel Gorman wrote:
> > > +__prepare_to_wait(wait_queue_head_t *q, wait_queue_t *wait,
> > > + struct page *page, int state, bool exclusive)
> > > {
> > > unsigned long flags;
> > >
> > > + if (page && !PageWaiters(page))
> > > + SetPageWaiters(page);
> > > + if (list_empty(&wait->task_list)) {
> > > + if (exclusive) {
> > > + wait->flags |= WQ_FLAG_EXCLUSIVE;
> > > + __add_wait_queue_tail(q, wait);
> > > + } else {
> >
> > I'm fairly sure we've just initialized the wait thing to 0, so clearing
> > the bit would be superfluous.
> >
>
> I assume you mean the clearing of WQ_FLAG_EXCLUSIVE. It may or may not be
> superflous. If it's an on-stack wait_queue_t initialised with DEFINE_WAIT()
> then it's redundant. If it's a wait_queue_t that is being reused and
> sometimes used for exclusive waits and other times for non-exclusive
> waits then it's required. The API allows this to happen so I see no harm
> is clearing the flag like the old code did. Am I missing your point?

Yeah, I'm not aware of any other users except the on-stack kind, but
you're right.

Maybe we should stick an object_is_on_stack() test in there to see if
anything falls out, something for a rainy afternoon perhaps..

> > > +void __wake_up_page_bit(wait_queue_head_t *wqh, struct page *page, void *word, int bit)
> > > +{
> > > + struct wait_bit_key key = __WAIT_BIT_KEY_INITIALIZER(word, bit);
> > > + unsigned long flags;
> > > +
> > > + spin_lock_irqsave(&wqh->lock, flags);
> > > + if (waitqueue_active(wqh))
> > > + __wake_up_common(wqh, TASK_NORMAL, 1, 0, &key);
> > > + else
> > > + ClearPageWaiters(page);
> > > + spin_unlock_irqrestore(&wqh->lock, flags);
> > > +}
> >
> > Seeing how word is always going to be &page->flags, might it make sense
> > to remove that argument?
> >
>
> The wait_queue was defined on-stack with DEFINE_WAIT_BIT which uses
> wake_bit_function() as a wakeup function and that thing consumes both the
> page->flags and the bit number it's interested in. This is used for both
> PG_writeback and PG_locked so assumptions cannot really be made about
> the value.

Well, both PG_flags come from the same &page->flags word, right? But
yeah, if we ever decide to grow the page frame with another flags word
we'd be in trouble :-)

In any case I don't feel too strongly about either of these points.


\
 
 \ /
  Last update: 2014-05-21 18:41    [W:0.073 / U:2.284 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site