diff mbox series

[net-next,v2,01/18] jump_label: export static_key_slow_{inc,dec}_cpuslocked()

Message ID 20241015145350.4077765-2-aleksander.lobakin@intel.com (mailing list archive)
State Changes Requested
Delegated to: BPF
Headers show
Series idpf: XDP chapter III: core XDP changes (+libeth_xdp) | expand

Checks

Context Check Description
netdev/series_format fail Series longer than 15 patches
netdev/tree_selection success Clearly marked for net-next, async
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 5 this patch: 5
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers fail 5 maintainers not CCed: ardb@kernel.org jpoimboe@kernel.org jbaron@akamai.com rostedt@goodmis.org peterz@infradead.org
netdev/build_clang success Errors and warnings before: 3 this patch: 3
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 4 this patch: 4
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 14 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/contest success net-next-2024-10-16--12-00 (tests: 776)

Commit Message

Alexander Lobakin Oct. 15, 2024, 2:53 p.m. UTC
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(+)

Comments

Maciej Fijalkowski Oct. 17, 2024, 11:06 a.m. UTC | #1
On Tue, Oct 15, 2024 at 04:53:33PM +0200, 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.

Hi Olek,

can you explain how is this at all related to the patchset that it
contains? AFAIK I don't see it being used in later changes?

> 
> 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.46.2
>
Alexander Lobakin Oct. 21, 2024, 1:53 p.m. UTC | #2
From: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
Date: Thu, 17 Oct 2024 13:06:25 +0200

> On Tue, Oct 15, 2024 at 04:53:33PM +0200, 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.
> 
> Hi Olek,
> 
> can you explain how is this at all related to the patchset that it
> contains? AFAIK I don't see it being used in later changes?

See libeth/xdp.c in patch #18, it's used to enable XDPSQ sharing static key.

> 
>>
>> 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.46.2
>>

Thanks,
Olek
Maciej Fijalkowski Oct. 22, 2024, 12:52 p.m. UTC | #3
On Mon, Oct 21, 2024 at 03:53:40PM +0200, Alexander Lobakin wrote:
> From: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
> Date: Thu, 17 Oct 2024 13:06:25 +0200
> 
> > On Tue, Oct 15, 2024 at 04:53:33PM +0200, 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.
> > 
> > Hi Olek,
> > 
> > can you explain how is this at all related to the patchset that it
> > contains? AFAIK I don't see it being used in later changes?
> 
> See libeth/xdp.c in patch #18, it's used to enable XDPSQ sharing static key.

I got tricked by define in include/linux/jump_label.h  and I was directly
grepping for funcs being exported:)

Not sure who should ack it though.

> 
> > 
> >>
> >> 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.46.2
> >>
> 
> Thanks,
> Olek
diff mbox series

Patch

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,