[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAPcyv4hDXWTEZC__3zK8PeJNStmsjwzAQb+CqDOUYjuLx0J9Ag@mail.gmail.com>
Date: Sat, 19 Oct 2019 16:27:24 -0700
From: Dan Williams <dan.j.williams@...el.com>
To: Matthew Wilcox <willy@...radead.org>
Cc: linux-fsdevel <linux-fsdevel@...r.kernel.org>,
Jeff Smits <jeff.smits@...el.com>,
Doug Nelson <doug.nelson@...el.com>,
stable <stable@...r.kernel.org>, Jan Kara <jack@...e.cz>,
linux-nvdimm <linux-nvdimm@...ts.01.org>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] fs/dax: Fix pmd vs pte conflict detection
On Sat, Oct 19, 2019 at 4:09 PM Dan Williams <dan.j.williams@...el.com> wrote:
>
> On Sat, Oct 19, 2019 at 1:50 PM Matthew Wilcox <willy@...radead.org> wrote:
> >
> > On Sat, Oct 19, 2019 at 09:26:19AM -0700, Dan Williams wrote:
> > > Check for NULL entries before checking the entry order, otherwise NULL
> > > is misinterpreted as a present pte conflict. The 'order' check needs to
> > > happen before the locked check as an unlocked entry at the wrong order
> > > must fallback to lookup the correct order.
> > >
> > > Reported-by: Jeff Smits <jeff.smits@...el.com>
> > > Reported-by: Doug Nelson <doug.nelson@...el.com>
> > > Cc: <stable@...r.kernel.org>
> > > Fixes: 23c84eb78375 ("dax: Fix missed wakeup with PMD faults")
> > > Cc: Jan Kara <jack@...e.cz>
> > > Cc: Matthew Wilcox (Oracle) <willy@...radead.org>
> > > Signed-off-by: Dan Williams <dan.j.williams@...el.com>
> > > ---
> > > fs/dax.c | 5 +++--
> > > 1 file changed, 3 insertions(+), 2 deletions(-)
> > >
> > > diff --git a/fs/dax.c b/fs/dax.c
> > > index a71881e77204..08160011d94c 100644
> > > --- a/fs/dax.c
> > > +++ b/fs/dax.c
> > > @@ -221,10 +221,11 @@ static void *get_unlocked_entry(struct xa_state *xas, unsigned int order)
> > >
> > > for (;;) {
> > > entry = xas_find_conflict(xas);
> > > + if (!entry || WARN_ON_ONCE(!xa_is_value(entry)))
> > > + return entry;
> > > if (dax_entry_order(entry) < order)
> > > return XA_RETRY_ENTRY;
> > > - if (!entry || WARN_ON_ONCE(!xa_is_value(entry)) ||
> > > - !dax_is_locked(entry))
> > > + if (!dax_is_locked(entry))
> > > return entry;
> >
> > Yes, I think this works. Should we also add:
> >
> > static unsigned int dax_entry_order(void *entry)
> > {
> > + BUG_ON(!xa_is_value(entry));
> > if (xa_to_value(entry) & DAX_PMD)
> > return PMD_ORDER;
> > return 0;
> > }
> >
> > which would have caught this logic error before it caused a performance
> > regression?
>
> Sounds good will add it to v2.
...except that there are multiple dax helpers that have the 'value'
entry assumption. I'd rather do all of them in a separate patch, or
none of them. It turns out that after this change all
dax_entry_order() invocations are now protected by a xa_is_value()
assert earlier in the calling function.
Powered by blists - more mailing lists