Re: [PATCH v2] slab, rust: extend kmalloc() alignment guarantees to remove Rust padding

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

 



On Wed, Jul 03, 2024 at 09:25:21AM +0200, Vlastimil Babka wrote:
> -	if (is_power_of_2(size))
> -		align = max(align, size);
> +	if (flags & SLAB_KMALLOC)
> +		align = max(align, 1U << (ffs(size) - 1));

hmm ... maybe this would be faster:

	if (flags & SLAB_KMALLOC) {
		u32 tmp = size & (size - 1);
		align = max(align, size - tmp);
	}

(if size is 2^n, tmp is 0.  otherwise, tmp is size with the lowest bit
clear, so size-tmp is the largest POT that divides size evenly)




[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