keys: Add cond_resched to key_gc_unused_keys()
Subsystems (2)
PATCH 1/1 keys: Add cond_resched to key_gc_unused_keys()
From: MengEn Sun <[email protected]>
When running the follow test:
while :
do
stress-ng --key=64 --key-ops=1000
done
We used the bcc tools funclatency to measure the execution latency of key_gc_unused_keys(), and the results are as follows:
funclatency key_gc_unused_keys.constprop.5 -i 1 -m
msecs : count
0 -> 1 : 0
2 -> 3 : 0
4 -> 7 : 0
8 -> 15 : 0
16 -> 31 : 0
32 -> 63 : 0
64 -> 127 : 1It seems that key_gc_unused_keys() takes a long time to execute, and there are no scheduling points in this function, which may harm latency-sensitive services.
Therefore, we have added a scheduling point to this function.
--- security/keys/gc.c | 1 + 1 file changed, 1 insertion(+)
security/keys/gc.c +1 -0
@@ -165,6 +165,7 @@ static noinline void key_gc_unused_keys(struct list_head *keys)memzero_explicit (key,sizeof (*key));kmem_cache_free (key_jar, key); +cond_resched (); } }
Signature · 1 line
1.8.3.1
Jarkko Sakkinen
maintainerQuoted 39 lines · On Wed Nov 27, 2024 at 5:52 AM EET, mengensun88 wrote:
From: MengEn Sun <[email protected]>
When running the follow test:
while :
dostress-ng --key=64 --key-ops=1000done
We used the bcc tools funclatency to measure the execution latency of
key_gc_unused_keys(), and the results are as follows:funclatency key_gc_unused_keys.constprop.5 -i 1 -m
msecs : count 0 -> 1 : 0 2 -> 3 : 0 4 -> 7 : 0 8 -> 15 : 0 16 -> 31 : 0 32 -> 63 : 0 64 -> 127 : 1It seems that
key_gc_unused_keys()takes a long time to execute, and there are no scheduling points in this function, which may harm latency-sensitive services.Therefore, we have added a scheduling point to this function.
Reviewed-by YueHong Wu <[email protected]>Signed-off-by MengEn Sun <[email protected]>--- security/keys/gc.c | 1 + 1 file changed, 1 insertion(+)security/keys/gc.c +0
-0
security/keys/gc.c static noinline void key_gc_unused_keys(struct list_head *keys) · line 171
Quoted 7 lines
security/keys/gc.c +1
-0@@ -165,6 +165,7 @@ static noinline void key_gc_unused_keys(struct list_head *keys)memzero_explicit (key,sizeof (*key));kmem_cache_free (key_jar, key); +cond_resched (); } }
This really needs ack from David.
Get the idea tho.
BR, Jarkko
Hi, David
Quoted 42 lines · On Sat, 30 Nov 2024 04:46:35 +0200 Jarkko Sakkinen wrote:
From: [email protected]
Quoted 40 lines · On Wed Nov 27, 2024 at 5:52 AM EET, mengensun88 wrote:
From: MengEn Sun <[email protected]>
When running the follow test:
while :
dostress-ng --key=64 --key-ops=1000done
We used the bcc tools funclatency to measure the execution latency of
key_gc_unused_keys(), and the results are as follows:funclatency key_gc_unused_keys.constprop.5 -i 1 -m
msecs : count 0 -> 1 : 0 2 -> 3 : 0 4 -> 7 : 0 8 -> 15 : 0 16 -> 31 : 0 32 -> 63 : 0 64 -> 127 : 1It seems that
key_gc_unused_keys()takes a long time to execute, and there are no scheduling points in this function, which may harm latency-sensitive services.Therefore, we have added a scheduling point to this function.
Reviewed-by YueHong Wu <[email protected]>Signed-off-by MengEn Sun <[email protected]>--- security/keys/gc.c | 1 + 1 file changed, 1 insertion(+)security/keys/gc.c +0
-0@@ -165,6 +165,7 @@ static noinline void key_gc_unused_keys(struct list_head *keys)
Quoted 9 lines
security/keys/gc.c static noinline void key_gc_unused_keys(struct list_head *keys) · line 171
Quoted 6 lines
security/keys/gc.c +1
-0memzero_explicit (key,sizeof (*key));kmem_cache_free (key_jar, key); +cond_resched (); } }This really needs ack from David.
Could you please provide me with some valuable suggestions? That way, I can make adjustments for a version 2 based on your advice. Thank you very much!
Quoted 4 lines
Get the idea tho.
BR, Jarkko
Regards
Meng En