From: mengensun88@gmail.com
To: dhowells@redhat.com
Cc: jarkko@kernel.org, jmorris@namei.org, keyrings@vger.kernel.org,
yuehongwu@tencent.com, MengEn Sun <mengensun@tencent.com>
Subject: [PATCH] keys: Add cond_resched to key_gc_unused_keys()
Date: Wed, 27 Nov 2024 11:52:41 +0800 [thread overview]
Message-ID: <1732679561-22967-1-git-send-email-mengensun@tencent.com> (raw)
From: MengEn Sun <mengensun@tencent.com>
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 : 1
It 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 <yuehongwu@tencent.com>
Signed-off-by: MengEn Sun <mengensun@tencent.com>
---
security/keys/gc.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/security/keys/gc.c b/security/keys/gc.c
index 7d687b0..14e4f1c 100644
--- a/security/keys/gc.c
+++ b/security/keys/gc.c
@@ -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();
}
}
--
1.8.3.1
next reply other threads:[~2024-11-27 3:52 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-27 3:52 mengensun88 [this message]
2024-11-30 2:46 ` [PATCH] keys: Add cond_resched to key_gc_unused_keys() Jarkko Sakkinen
2024-12-06 7:46 ` MengEn Sun
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1732679561-22967-1-git-send-email-mengensun@tencent.com \
--to=mengensun88@gmail.com \
--cc=dhowells@redhat.com \
--cc=jarkko@kernel.org \
--cc=jmorris@namei.org \
--cc=keyrings@vger.kernel.org \
--cc=mengensun@tencent.com \
--cc=yuehongwu@tencent.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).