[PATCH net-next 11/12] jump_label: export static_key_slow_{inc,dec}_cpuslocked()

Alexander Lobakin posted 12 patches 1 year ago
[PATCH net-next 11/12] jump_label: export static_key_slow_{inc,dec}_cpuslocked()
Posted by Alexander Lobakin 1 year ago
Sometimes, there's a need to modify a lot of static keys or modify the
same key multiple times in a loop. In that case, it seems more optimal
to lock cpu_read_lock once and then call _cpuslocked() variants.
The enable/disable functions are already exported, the refcounted
counterparts however are not. Fix that to allow modules to save some
cycles.

Signed-off-by: Alexander Lobakin <aleksander.lobakin@intel.com>
---
 kernel/jump_label.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/kernel/jump_label.c b/kernel/jump_label.c
index 93a822d3c468..1034c0348995 100644
--- a/kernel/jump_label.c
+++ b/kernel/jump_label.c
@@ -182,6 +182,7 @@ bool static_key_slow_inc_cpuslocked(struct static_key *key)
 	}
 	return true;
 }
+EXPORT_SYMBOL_GPL(static_key_slow_inc_cpuslocked);
 
 bool static_key_slow_inc(struct static_key *key)
 {
@@ -342,6 +343,7 @@ void static_key_slow_dec_cpuslocked(struct static_key *key)
 	STATIC_KEY_CHECK_USE(key);
 	__static_key_slow_dec_cpuslocked(key);
 }
+EXPORT_SYMBOL_GPL(static_key_slow_dec_cpuslocked);
 
 void __static_key_slow_dec_deferred(struct static_key *key,
 				    struct delayed_work *work,
-- 
2.47.1
Re: [PATCH net-next 11/12] jump_label: export static_key_slow_{inc,dec}_cpuslocked()
Posted by Josh Poimboeuf 1 year ago
On Wed, Dec 11, 2024 at 06:26:48PM +0100, Alexander Lobakin wrote:
> Sometimes, there's a need to modify a lot of static keys or modify the
> same key multiple times in a loop. In that case, it seems more optimal
> to lock cpu_read_lock once and then call _cpuslocked() variants.
> The enable/disable functions are already exported, the refcounted
> counterparts however are not. Fix that to allow modules to save some
> cycles.
> 
> Signed-off-by: Alexander Lobakin <aleksander.lobakin@intel.com>
> ---
>  kernel/jump_label.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/kernel/jump_label.c b/kernel/jump_label.c
> index 93a822d3c468..1034c0348995 100644
> --- a/kernel/jump_label.c
> +++ b/kernel/jump_label.c
> @@ -182,6 +182,7 @@ bool static_key_slow_inc_cpuslocked(struct static_key *key)
>  	}
>  	return true;
>  }
> +EXPORT_SYMBOL_GPL(static_key_slow_inc_cpuslocked);
>  
>  bool static_key_slow_inc(struct static_key *key)
>  {
> @@ -342,6 +343,7 @@ void static_key_slow_dec_cpuslocked(struct static_key *key)
>  	STATIC_KEY_CHECK_USE(key);
>  	__static_key_slow_dec_cpuslocked(key);
>  }
> +EXPORT_SYMBOL_GPL(static_key_slow_dec_cpuslocked);

Where's the code which uses this?

-- 
Josh
Re: [PATCH net-next 11/12] jump_label: export static_key_slow_{inc,dec}_cpuslocked()
Posted by Alexander Lobakin 1 year ago
From: Josh Poimboeuf <jpoimboe@kernel.org>
Date: Wed, 11 Dec 2024 09:40:00 -0800

> On Wed, Dec 11, 2024 at 06:26:48PM +0100, Alexander Lobakin wrote:
>> Sometimes, there's a need to modify a lot of static keys or modify the
>> same key multiple times in a loop. In that case, it seems more optimal
>> to lock cpu_read_lock once and then call _cpuslocked() variants.
>> The enable/disable functions are already exported, the refcounted
>> counterparts however are not. Fix that to allow modules to save some
>> cycles.
>>
>> Signed-off-by: Alexander Lobakin <aleksander.lobakin@intel.com>
>> ---
>>  kernel/jump_label.c | 2 ++
>>  1 file changed, 2 insertions(+)
>>
>> diff --git a/kernel/jump_label.c b/kernel/jump_label.c
>> index 93a822d3c468..1034c0348995 100644
>> --- a/kernel/jump_label.c
>> +++ b/kernel/jump_label.c
>> @@ -182,6 +182,7 @@ bool static_key_slow_inc_cpuslocked(struct static_key *key)
>>  	}
>>  	return true;
>>  }
>> +EXPORT_SYMBOL_GPL(static_key_slow_inc_cpuslocked);
>>  
>>  bool static_key_slow_inc(struct static_key *key)
>>  {
>> @@ -342,6 +343,7 @@ void static_key_slow_dec_cpuslocked(struct static_key *key)
>>  	STATIC_KEY_CHECK_USE(key);
>>  	__static_key_slow_dec_cpuslocked(key);
>>  }
>> +EXPORT_SYMBOL_GPL(static_key_slow_dec_cpuslocked);
> 
> Where's the code which uses this?

It's not in this series -- the initial one was too large, so it was split.

Thanks,
Olek
Re: [PATCH net-next 11/12] jump_label: export static_key_slow_{inc,dec}_cpuslocked()
Posted by Josh Poimboeuf 1 year ago
On Fri, Dec 13, 2024 at 06:22:51PM +0100, Alexander Lobakin wrote:
> From: Josh Poimboeuf <jpoimboe@kernel.org>
> >> +EXPORT_SYMBOL_GPL(static_key_slow_dec_cpuslocked);
> > 
> > Where's the code which uses this?
> 
> It's not in this series -- the initial one was too large, so it was split.

It's best to put the patch exporting the symbol adjacent to (or squashed
with) the patch using it so the justification for exporting it can be
reviewed at the same time.

-- 
Josh
Re: [PATCH net-next 11/12] jump_label: export static_key_slow_{inc,dec}_cpuslocked()
Posted by Alexander Lobakin 12 months ago
From: Josh Poimboeuf <jpoimboe@kernel.org>
Date: Fri, 13 Dec 2024 19:24:31 -0800

> On Fri, Dec 13, 2024 at 06:22:51PM +0100, Alexander Lobakin wrote:
>> From: Josh Poimboeuf <jpoimboe@kernel.org>
>>>> +EXPORT_SYMBOL_GPL(static_key_slow_dec_cpuslocked);
>>>
>>> Where's the code which uses this?
>>
>> It's not in this series -- the initial one was too large, so it was split.
> 
> It's best to put the patch exporting the symbol adjacent to (or squashed
> with) the patch using it so the justification for exporting it can be
> reviewed at the same time.

Sure, I'll move this one to the next series.

Thanks,
Olek