mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Waiman Long <longman@redhat.com>
To: Miaohe Lin <linmiaohe@huawei.com>,
	tj@kernel.org, hannes@cmpxchg.org, lizefan.x@bytedance.com
Cc: cgroups@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] cgroup/cpuset: avoid unneeded cpuset_mutex re-lock
Date: Tue, 4 Jul 2023 23:10:01 -0400	[thread overview]
Message-ID: <974a48a8-7402-6303-10e8-9d5fe475bb42@redhat.com> (raw)
In-Reply-To: <20230704120352.1226787-1-linmiaohe@huawei.com>

On 7/4/23 08:03, Miaohe Lin wrote:
> cpuset_mutex unlock and lock pair is only needed when transferring tasks
> out of empty cpuset. Avoid unneeded cpuset_mutex re-lock when !is_empty
> to save cpu cycles.
>
> Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
> ---
>   kernel/cgroup/cpuset.c | 9 ++++-----
>   1 file changed, 4 insertions(+), 5 deletions(-)
>
> diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c
> index 601c40da8e03..e136269c152c 100644
> --- a/kernel/cgroup/cpuset.c
> +++ b/kernel/cgroup/cpuset.c
> @@ -3521,17 +3521,16 @@ hotplug_update_tasks_legacy(struct cpuset *cs,
>   	is_empty = cpumask_empty(cs->cpus_allowed) ||
>   		   nodes_empty(cs->mems_allowed);
>   
> -	mutex_unlock(&cpuset_mutex);
> -
>   	/*
>   	 * Move tasks to the nearest ancestor with execution resources,
>   	 * This is full cgroup operation which will also call back into
>   	 * cpuset. Should be done outside any lock.
>   	 */
> -	if (is_empty)
> +	if (is_empty) {
> +		mutex_unlock(&cpuset_mutex);
>   		remove_tasks_in_empty_cpuset(cs);
> -
> -	mutex_lock(&cpuset_mutex);
> +		mutex_lock(&cpuset_mutex);
> +	}
>   }
>   
>   static void
Reviewed-by: Waiman Long <longman@redhat.com>


  reply	other threads:[~2023-07-05  3:11 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-04 12:03 Miaohe Lin
2023-07-05  3:10 ` Waiman Long [this message]
2023-07-10 20:26 ` Tejun Heo

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=974a48a8-7402-6303-10e8-9d5fe475bb42@redhat.com \
    --to=longman@redhat.com \
    --cc=cgroups@vger.kernel.org \
    --cc=hannes@cmpxchg.org \
    --cc=linmiaohe@huawei.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lizefan.x@bytedance.com \
    --cc=tj@kernel.org \
    /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®