From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Subject: Re: [PATCH v10 00/62] Convert page cache to XArray To: Matthew Wilcox Cc: linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, Matthew Wilcox , Jan Kara , Jeff Layton , Lukas Czerner , Ross Zwisler , Christoph Hellwig , Goldwyn Rodrigues , Nicholas Piggin , Ryusuke Konishi , linux-nilfs@vger.kernel.org, Jaegeuk Kim , Chao Yu , linux-f2fs-devel@lists.sourceforge.net, Oleg Drokin , Andreas Dilger , James Simmons References: <20180330034245.10462-1-willy@infradead.org> <20180405035200.GE9301@bombadil.infradead.org> From: Mike Kravetz Message-ID: Date: Thu, 5 Apr 2018 11:33:29 -0700 MIME-Version: 1.0 In-Reply-To: <20180405035200.GE9301@bombadil.infradead.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: owner-linux-mm@kvack.org List-ID: On 04/04/2018 08:52 PM, Matthew Wilcox wrote: > On Wed, Apr 04, 2018 at 09:35:46AM -0700, Mike Kravetz wrote: >> Running with this XArray series on top of next-20180329 consistently 'hangs' >> on shutdown looping (?forever?) in tag_pages_for_writeback/xas_for_each_tag. >> All I have to do is make sure there is some activity on the ext4 fs before >> shutdown. Not sure if this is a 'next-20180329' issue or XArray issue. >> But the fact that we are looping in xas_for_each_tag looks suspicious. > > Thanks for your help debugging this! Particularly collecting the xa_dump. > I got bit by the undefined behaviour of shifting by BITS_PER_LONG, > but of course it was subtle. > > The userspace testing framework wasn't catching this for a couple of > reasons; I'll work on making sure it catches this kind of thing in > the future. > > I'll fold this in and post a v11 later this week or early next week. Nice! Added patch and it solves the hangs I observed. -- Mike Kravetz > > diff --git a/include/linux/xarray.h b/include/linux/xarray.h > index eac04922eba2..f5b7e507a86f 100644 > --- a/include/linux/xarray.h > +++ b/include/linux/xarray.h > @@ -904,9 +929,12 @@ static inline unsigned int xas_find_chunk(struct xa_state *xas, bool advance, > if (advance) > offset++; > if (XA_CHUNK_SIZE == BITS_PER_LONG) { > - unsigned long data = *addr & (~0UL << offset); > - if (data) > - return __ffs(data); > + if (offset < XA_CHUNK_SIZE) { > + unsigned long data = *addr & (~0UL << offset); > + > + if (data) > + return __ffs(data); > + } > return XA_CHUNK_SIZE; > } > >