mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Xavier  <xavier_qy@163.com>
To: tglx@linutronix.de
Cc: anna-maria@linutronix.de, frederic@kernel.org,
	j.granados@samsung.com,  kees@kernel.org,
	linux-kernel@vger.kernel.org, linux@weissschuh.net,
	 mcgrof@kernel.org
Subject: Re:[PATCH v2] Ucount: Optimize the ucount code
Date: Fri, 23 Aug 2024 10:28:25 +0800 (CST)	[thread overview]
Message-ID: <2dd8a8ef.27d5.1917d104930.Coremail.xavier_qy@163.com> (raw)
In-Reply-To: <20240812084823.563277-1-xavier_qy@163.com>

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@163.com> wrote:
>Optimize the memory release operation by placing it outside of the
>spin lock in alloc_ucounts.
>
>Signed-off-by: Xavier <xavier_qy@163.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

      reply	other threads:[~2024-08-23  2:29 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-09 12:17 [PATCH v1] Namespace: Optimize the namespace code Xavier
2024-08-10  8:53 ` Thomas Gleixner
2024-08-12  8:48   ` [PATCH v2] Ucount: Optimize the ucount code Xavier
2024-08-23  2:28     ` Xavier [this message]

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=2dd8a8ef.27d5.1917d104930.Coremail.xavier_qy@163.com \
    --to=xavier_qy@163.com \
    --cc=anna-maria@linutronix.de \
    --cc=frederic@kernel.org \
    --cc=j.granados@samsung.com \
    --cc=kees@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@weissschuh.net \
    --cc=mcgrof@kernel.org \
    --cc=tglx@linutronix.de \
    /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

all inboxes | Powered by JetHome®