linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Matthew Wilcox <willy@infradead.org>
To: Christopher Lameter <cl@linux.com>
Cc: Dave Chinner <dchinner@redhat.com>,
	linux-mm@kvack.org, linux-fsdevel@vger.kernel.org,
	Christoph Hellwig <hch@lst.de>, Mel Gorman <mel@skynet.ie>,
	Pekka Enberg <penberg@cs.helsinki.fi>
Subject: Re: [RFC] Heuristic for inode/dentry fragmentation prevention
Date: Wed, 3 Jan 2018 12:33:03 -0800	[thread overview]
Message-ID: <20180103203303.GA3228@bombadil.infradead.org> (raw)
In-Reply-To: <alpine.DEB.2.20.1801031332230.10522@nuc-kabylake>

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: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

  reply	other threads:[~2018-01-03 20:33 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-03 19:39 Christopher Lameter
2018-01-03 20:33 ` Matthew Wilcox [this message]
2018-01-03 21:06 ` Matthew Wilcox
2018-01-04  0:08 ` Dave Chinner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180103203303.GA3228@bombadil.infradead.org \
    --to=willy@infradead.org \
    --cc=cl@linux.com \
    --cc=dchinner@redhat.com \
    --cc=hch@lst.de \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mel@skynet.ie \
    --cc=penberg@cs.helsinki.fi \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox