From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Date: Wed, 4 Apr 2018 20:52:00 -0700 From: Matthew Wilcox To: Mike Kravetz 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 Subject: Re: [PATCH v10 00/62] Convert page cache to XArray Message-ID: <20180405035200.GE9301@bombadil.infradead.org> References: <20180330034245.10462-1-willy@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: owner-linux-mm@kvack.org List-ID: 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. 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; }