Re: [PATCH v6 2/6] init_on_alloc: Optimize static branches

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

 



On Mon, Mar 15, 2021 at 11:02:25AM -0700, Kees Cook wrote:
> diff --git a/mm/slab.h b/mm/slab.h
> index 076582f58f68..b0977d525c06 100644
> --- a/mm/slab.h
> +++ b/mm/slab.h
> @@ -601,7 +601,8 @@ static inline void cache_random_seq_destroy(struct kmem_cache *cachep) { }
>  
>  static inline bool slab_want_init_on_alloc(gfp_t flags, struct kmem_cache *c)
>  {
> -	if (static_branch_unlikely(&init_on_alloc)) {
> +	if (static_branch_maybe(CONFIG_INIT_ON_FREE_DEFAULT_ON,

Gah, this should be CONFIG_INIT_ON_ALLOC_DEFAULT_ON.

I'll see if there are any more comments before sending a v7...

-Kees

> +				&init_on_alloc)) {
>  		if (c->ctor)
>  			return false;
>  		if (c->flags & (SLAB_TYPESAFE_BY_RCU | SLAB_POISON))
> @@ -613,7 +614,8 @@ static inline bool slab_want_init_on_alloc(gfp_t flags, struct kmem_cache *c)
>  
>  static inline bool slab_want_init_on_free(struct kmem_cache *c)
>  {
> -	if (static_branch_unlikely(&init_on_free))
> +	if (static_branch_maybe(CONFIG_INIT_ON_FREE_DEFAULT_ON,
> +				&init_on_free))
>  		return !(c->ctor ||
>  			 (c->flags & (SLAB_TYPESAFE_BY_RCU | SLAB_POISON)));
>  	return false;
> -- 
> 2.25.1
> 

-- 
Kees Cook



[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux