From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Date: Wed, 3 Jan 2018 12:33:03 -0800 From: Matthew Wilcox To: Christopher Lameter Cc: Dave Chinner , linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, Christoph Hellwig , Mel Gorman , Pekka Enberg Subject: Re: [RFC] Heuristic for inode/dentry fragmentation prevention Message-ID: <20180103203303.GA3228@bombadil.infradead.org> References: 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, Jan 03, 2018 at 01:39:27PM -0600, Christopher Lameter wrote: > +/* How many objects left in slab page */ > +unsigned kobjects_left_in_slab_page(const void *object) > +{ > + struct page *page; > + > + if (unlikely(ZERO_OR_NULL_PTR(object))) > + return 0; > + > + page = virt_to_head_page(object); > + > + if (unlikely(!PageSlab(page))) { > + WARN_ON(1); > + return 1; > + } I see this construct all over the kernel. Here's a better one: if (WARN_ON(!PageSlab(page))) return 1; There's a built-in unlikely() in the definition of WARN_ON, so this works nicely. -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org