[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <2dd8a8ef.27d5.1917d104930.Coremail.xavier_qy@163.com>
Date: Fri, 23 Aug 2024 10:28:25 +0800 (CST)
From: Xavier <xavier_qy@....com>
To: tglx@...utronix.de
Cc: anna-maria@...utronix.de, frederic@...nel.org, j.granados@...sung.com,
kees@...nel.org, linux-kernel@...r.kernel.org, linux@...ssschuh.net,
mcgrof@...nel.org
Subject: Re:[PATCH v2] Ucount: Optimize the ucount code
Hi,
Just a reminder, does anyone have any comments or feedback on the patch?
--
Thanks,
Xavier
At 2024-08-12 16:48:23, "Xavier" <xavier_qy@....com> wrote:
>Optimize the memory release operation by placing it outside of the
>spin lock in alloc_ucounts.
>
>Signed-off-by: Xavier <xavier_qy@....com>
>---
> kernel/ucount.c | 9 +++++----
> 1 file changed, 5 insertions(+), 4 deletions(-)
>
>diff --git a/kernel/ucount.c b/kernel/ucount.c
>index 8c07714ff27d..87a773e6ff15 100644
>--- a/kernel/ucount.c
>+++ b/kernel/ucount.c
>@@ -164,7 +164,7 @@ struct ucounts *get_ucounts(struct ucounts *ucounts)
> struct ucounts *alloc_ucounts(struct user_namespace *ns, kuid_t uid)
> {
> struct hlist_head *hashent = ucounts_hashentry(ns, uid);
>- struct ucounts *ucounts, *new;
>+ struct ucounts *ucounts, *new = NULL;
> bool wrapped;
>
> spin_lock_irq(&ucounts_lock);
>@@ -182,9 +182,7 @@ struct ucounts *alloc_ucounts(struct user_namespace *ns, kuid_t uid)
>
> spin_lock_irq(&ucounts_lock);
> ucounts = find_ucounts(ns, uid, hashent);
>- if (ucounts) {
>- kfree(new);
>- } else {
>+ if (!ucounts) {
> hlist_add_head(&new->node, hashent);
> get_user_ns(new->ns);
> spin_unlock_irq(&ucounts_lock);
>@@ -193,6 +191,9 @@ struct ucounts *alloc_ucounts(struct user_namespace *ns, kuid_t uid)
> }
> wrapped = !get_ucounts_or_wrap(ucounts);
> spin_unlock_irq(&ucounts_lock);
>+ if (new)
>+ kfree(new);
>+
> if (wrapped) {
> put_ucounts(ucounts);
> return NULL;
>--
>2.45.2
Powered by blists - more mailing lists