From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pl0-f70.google.com (mail-pl0-f70.google.com [209.85.160.70]) by kanga.kvack.org (Postfix) with ESMTP id 383326B0384 for ; Wed, 3 Jan 2018 15:33:19 -0500 (EST) Received: by mail-pl0-f70.google.com with SMTP id x1so1400288plb.2 for ; Wed, 03 Jan 2018 12:33:19 -0800 (PST) Received: from bombadil.infradead.org (bombadil.infradead.org. [65.50.211.133]) by mx.google.com with ESMTPS id f3si1038950pgn.718.2018.01.03.12.33.17 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 03 Jan 2018 12:33:18 -0800 (PST) Date: Wed, 3 Jan 2018 12:33:03 -0800 From: Matthew Wilcox 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: To: Christopher Lameter Cc: Dave Chinner , linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, Christoph Hellwig , Mel Gorman , Pekka Enberg 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