[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20210514204947.g5nznqwo6gnt2vnu@oracle.com>
Date: Fri, 14 May 2021 16:49:47 -0400
From: Daniel Jordan <daniel.m.jordan@...cle.com>
To: "Huang, Ying" <ying.huang@...el.com>
Cc: Peter Zijlstra <peterz@...radead.org>,
Andrew Morton <akpm@...ux-foundation.org>, linux-mm@...ck.org,
linux-kernel@...r.kernel.org,
Dan Carpenter <dan.carpenter@...cle.com>,
Andrea Parri <andrea.parri@...rulasolutions.com>,
Andi Kleen <ak@...ux.intel.com>,
Dave Hansen <dave.hansen@...ux.intel.com>,
Omar Sandoval <osandov@...com>,
Paul McKenney <paulmck@...nel.org>, Tejun Heo <tj@...nel.org>,
Will Deacon <will.deacon@....com>,
Miaohe Lin <linmiaohe@...wei.com>
Subject: Re: [PATCH] mm, swap: Remove unnecessary smp_rmb() in
swap_type_to_swap_info()
On Fri, May 14, 2021 at 12:02:05PM +0800, Huang, Ying wrote:
> Daniel Jordan <daniel.m.jordan@...cle.com> writes:
> > Yes, this does help, I didn't understand why smp_wmb stayed around in
> > the original post.
> >
> > I think the only access smp_store_release() orders is p->type. Wouldn't
> > it be kinda inconsistent to only initialize that one field before
> > publishing when many others would be done at the end of
> > alloc_swap_info() after the fact?
>
> In addition to p->type, *p is zeroed via kvzalloc().
So it is, good point.
> > p->type doesn't seem special. For
> > instance, get_swap_page_of_type() touches si->lock soon after it calls
> > swap_type_to_swap_info(), so there could be a small window where there's
> > a non-NULL si with an uninitialized lock.
>
> We usually check the state of swap_info_struct before other operations.
> For example, we check si->swap_map in swap_start().
Yes, we usually do.
> > It's not as if this is likely to be a problem in practice, it would just
> > make it harder to understand why smp_store_release is there. Maybe all
> > we need is a WRITE_ONCE, or if it's really necessary for certain fields
> > to be set before publication then move them up and explain?
>
> I think we have initialized all fields before publication :-).
Probably all the ones that matter in practice, yes :-)
Still feeling slightly uneasy about the theoretical p->lock, but that
was possible before this change too so it's out of scope.
A comment explaining the pairing and that we care mostly about the zero
init would be nice.
Powered by blists - more mailing lists