lkml.org 
[lkml]   [2018]   [Jul]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 3/6] bdi: Use refcount_t for reference counting instead atomic_t
On 2018-07-16 15:57:16 [-0700], Andrew Morton wrote:
> > --- a/mm/backing-dev.c
> > +++ b/mm/backing-dev.c
> > @@ -438,10 +438,10 @@ wb_congested_get_create(struct backing_dev_info *bdi, int blkcg_id, gfp_t gfp)
> > if (new_congested) {
> > /* !found and storage for new one already allocated, insert */
> > congested = new_congested;
> > - new_congested = NULL;
> > rb_link_node(&congested->rb_node, parent, node);
> > rb_insert_color(&congested->rb_node, &bdi->cgwb_congested_tree);
> > - goto found;
> > + spin_unlock_irqrestore(&cgwb_lock, flags);
> > + return congested;
> > }
> >
> > spin_unlock_irqrestore(&cgwb_lock, flags);
> > @@ -451,13 +451,13 @@ wb_congested_get_create(struct backing_dev_info *bdi, int blkcg_id, gfp_t gfp)
> > if (!new_congested)
> > return NULL;
> >
> > - atomic_set(&new_congested->refcnt, 0);
> > + refcount_set(&new_congested->refcnt, 1);
> > new_congested->__bdi = bdi;
> > new_congested->blkcg_id = blkcg_id;
> > goto retry;
> >
> > found:
> > - atomic_inc(&congested->refcnt);
> > + refcount_inc(&congested->refcnt);
> > spin_unlock_irqrestore(&cgwb_lock, flags);
> > kfree(new_congested);
> > return congested;
> >
> > ...
> >
>
> I'm not sure that the restructuring of wb_congested_get_create() was
> desirable and it does make the patch harder to review. But it looks
> OK to me.

By `restructuring' you mean the addition of return statement instead
using the goto label in the first hunk? If so, then you would have

refcount_set(&new_congested->refcnt, 0);
refcount_inc(&congested->refcnt);

which is a 0 -> 1 transition and is forbidden by refcount_t. So I had to
avoid this one.

Thank you applying the patches!

You applied the bdi and userns switch from atomic_t to refcount_t.
There were also the patches
[PATCH 4/6] bdi: Use irqsave variant of refcount_dec_and_lock()
[PATCH 6/6] userns: Use irqsave variant of refcount_dec_and_lock()

in the series which make use the irqsave version of
refcount_dec_and_lock(). Did you miss them by chance or skipped them on
purpose?

Sebastian

\
 
 \ /
  Last update: 2018-07-17 17:56    [W:0.125 / U:0.160 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site