Re: [RFC] Heuristic for inode/dentry fragmentation prevention

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@xxxxxxxxx";> email@xxxxxxxxx </a>



[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]
  Powered by Linux