[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20171205232326.GH26021@bombadil.infradead.org>
Date: Tue, 5 Dec 2017 15:23:26 -0800
From: Matthew Wilcox <willy@...radead.org>
To: Thiago Rafael Becker <thiago.becker@...il.com>
Cc: NeilBrown <neilb@...e.com>, bfields@...ldses.org,
linux-nfs@...r.kernel.org, linux-fsdevel@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH 2/3, V2] kernel: Move groups_sort to the caller of
set_groups.
On Tue, Dec 05, 2017 at 09:03:02PM -0200, Thiago Rafael Becker wrote:
> On Tue, 5 Dec 2017, Matthew Wilcox wrote:
> > It must be relatively common to sort an already-sorted array. I wonder
> > if something like this patch would be worthwhile?
>
> The bug happens when two threads enter sort_groups for the same group info
> in parallel, and one thread starts overwriting values that another thread
> may already have "heapified" or sorted.
>
> Thread A Thread B
> Enter groups_sort
> Enter groups_sort
> .
> .
> .
> Return from groups_sort
> .
> .
> .
> Return from groups_sort
>
> Wouldn't this patch just make both threads see the structure as unsorted and
> sort them?
I'm sorry, I wasn't clear. I wasn't commenting on the original bug (and
I believe your analysis to be correct unless there's some locking which
prevents two calls to group_sort from happening at the same time).
I was wondering about whether our sort() implementation is the best that
it could possibly be, and whether having the trait of not modifying an
already-sorted array is worthwhile (eg it would not cause cachelines to
enter the dirty state if they were already clean).
Powered by blists - more mailing lists