mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Waiman Long <llong@redhat.com>
To: Steven Rostedt <rostedt@goodmis.org>,
	LKML <linux-kernel@vger.kernel.org>
Cc: "Peter Zijlstra" <peterz@infradead.org>,
	"Ingo Molnar" <mingo@kernel.org>,
	"Juri Lelli" <juri.lelli@redhat.com>,
	"Vincent Guittot" <vincent.guittot@linaro.org>,
	"Tejun Heo" <tj@kernel.org>,
	"Johannes Weiner" <hannes@cmpxchg.org>,
	"Michal Koutný" <mkoutny@suse.com>,
	"Andrea Righi" <righi.andrea@gmail.com>,
	"Julia Lawall" <Julia.Lawall@inria.fr>,
	"Luis Claudio R. Goncalves" <lgoncalv@redhat.com>,
	"Joseph Salisbury" <joseph.salisbury@oracle.com>
Subject: Re: [PATCH] sched: cgroup: Move task_can_attach() to cpuset.c
Date: Fri, 3 Oct 2025 12:39:45 -0400	[thread overview]
Message-ID: <a29a1849-e7f7-4c96-85be-6d8041ea1e57@redhat.com> (raw)
In-Reply-To: <20251003121421.0cf4372d@gandalf.local.home>

On 10/3/25 12:14 PM, Steven Rostedt wrote:
> From: Steven Rostedt <rostedt@goodmis.org>
>
> At our monthly stable meeting, we were talking about documenting non
> static functions and randomly picked a function to look at. That was
> task_can_attach(). It was then noticed that it's only used by
> cgroup/cpuset.c and nothing else. It's a simple function that doesn't
> reference anything unique to sched/core.c, hence there's no reason that
> function should be there.
>
> Move it to cgroup/cpuset.c as that's the only place it is used. Also make
> it a static inline as it is so small.
>
> Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
> ---
>   include/linux/sched.h  |  1 -
>   kernel/cgroup/cpuset.c | 19 +++++++++++++++++++
>   kernel/sched/core.c    | 19 -------------------
>   3 files changed, 19 insertions(+), 20 deletions(-)
>
> diff --git a/include/linux/sched.h b/include/linux/sched.h
> index e4ce0a76831e..4ee4fa973eda 100644
> --- a/include/linux/sched.h
> +++ b/include/linux/sched.h
> @@ -1849,7 +1849,6 @@ current_restore_flags(unsigned long orig_flags, unsigned long flags)
>   }
>   
>   extern int cpuset_cpumask_can_shrink(const struct cpumask *cur, const struct cpumask *trial);
> -extern int task_can_attach(struct task_struct *p);
>   extern int dl_bw_alloc(int cpu, u64 dl_bw);
>   extern void dl_bw_free(int cpu, u64 dl_bw);
>   
> diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c
> index 27adb04df675..21fe872803e8 100644
> --- a/kernel/cgroup/cpuset.c
> +++ b/kernel/cgroup/cpuset.c
> @@ -3009,6 +3009,25 @@ static void reset_migrate_dl_data(struct cpuset *cs)
>   	cs->sum_migrate_dl_bw = 0;
>   }
>   
> +static inline int task_can_attach(struct task_struct *p)
> +{
> +	int ret = 0;
> +
> +	/*
> +	 * Kthreads which disallow setaffinity shouldn't be moved
> +	 * to a new cpuset; we don't want to change their CPU
> +	 * affinity and isolating such threads by their set of
> +	 * allowed nodes is unnecessary.  Thus, cpusets are not
> +	 * applicable for such threads.  This prevents checking for
> +	 * success of set_cpus_allowed_ptr() on all attached tasks
> +	 * before cpus_mask may be changed.
> +	 */
> +	if (p->flags & PF_NO_SETAFFINITY)
> +		ret = -EINVAL;
> +
> +	return ret;
> +}
> +
>   /* Called by cgroups to determine if a cpuset is usable; cpuset_mutex held */
>   static int cpuset_can_attach(struct cgroup_taskset *tset)
>   {
> diff --git a/kernel/sched/core.c b/kernel/sched/core.c
> index ccba6fc3c3fe..a195c4b25475 100644
> --- a/kernel/sched/core.c
> +++ b/kernel/sched/core.c
> @@ -8070,25 +8070,6 @@ int cpuset_cpumask_can_shrink(const struct cpumask *cur,
>   	return ret;
>   }
>   
> -int task_can_attach(struct task_struct *p)
> -{
> -	int ret = 0;
> -
> -	/*
> -	 * Kthreads which disallow setaffinity shouldn't be moved
> -	 * to a new cpuset; we don't want to change their CPU
> -	 * affinity and isolating such threads by their set of
> -	 * allowed nodes is unnecessary.  Thus, cpusets are not
> -	 * applicable for such threads.  This prevents checking for
> -	 * success of set_cpus_allowed_ptr() on all attached tasks
> -	 * before cpus_mask may be changed.
> -	 */
> -	if (p->flags & PF_NO_SETAFFINITY)
> -		ret = -EINVAL;
> -
> -	return ret;
> -}
> -
>   bool sched_smp_initialized __read_mostly;
>   
>   #ifdef CONFIG_NUMA_BALANCING
Acked-by: Waiman Long <longman@redhat.com>


  parent reply	other threads:[~2025-10-03 16:39 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-03 16:14 Steven Rostedt
2025-10-03 16:36 ` Andrea Righi
2025-10-03 16:43   ` Steven Rostedt
2025-10-03 16:53     ` Andrea Righi
2025-10-03 16:39 ` Waiman Long [this message]
2025-10-03 17:11 ` Luis Claudio R. Goncalves
2025-10-03 19:56 ` [External] : " Joseph Salisbury
2025-10-03 21:38 ` Tejun Heo
2025-10-06 18:31   ` Peter Zijlstra
2025-10-06 18:59     ` 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=a29a1849-e7f7-4c96-85be-6d8041ea1e57@redhat.com \
    --to=llong@redhat.com \
    --cc=Julia.Lawall@inria.fr \
    --cc=hannes@cmpxchg.org \
    --cc=joseph.salisbury@oracle.com \
    --cc=juri.lelli@redhat.com \
    --cc=lgoncalv@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=mkoutny@suse.com \
    --cc=peterz@infradead.org \
    --cc=righi.andrea@gmail.com \
    --cc=rostedt@goodmis.org \
    --cc=tj@kernel.org \
    --cc=vincent.guittot@linaro.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®