All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Revert "isolcpus: Affine unbound kernel threads to housekeeping cpus"
@ 2021-05-07 16:57 Marcelo Tosatti
  2021-05-07 20:16 ` Frederic Weisbecker
  0 siblings, 1 reply; 3+ messages in thread
From: Marcelo Tosatti @ 2021-05-07 16:57 UTC (permalink / raw)
  To: linux-kernel; +Cc: Frederic Weisbecker, Phil Auld, Peter Zijlstra



commit 9cc5b8656892a72438ee7deb introduced a new housekeeping flag,
HK_FLAG_KTHREAD, that when enabled sets the CPU affinity for the 
kthreadd process (therefore all unbounded kernel threads created
from that point on will use the housekeeping cpumask).

This is not necessary, since its possible to control placement of
kthreadd from userspace:

# taskset -c -p 0 `pgrep kthreadd`
pid 2's current affinity list: 1
pid 2's new affinity list: 0

Unbounded kernel threads started from that point on will inherit
the kthreadd cpumask.

Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>

Index: linux-2.6/include/linux/sched/isolation.h
===================================================================
--- linux-2.6.orig/include/linux/sched/isolation.h
+++ linux-2.6/include/linux/sched/isolation.h
@@ -14,7 +14,6 @@ enum hk_flags {
 	HK_FLAG_DOMAIN		= (1 << 5),
 	HK_FLAG_WQ		= (1 << 6),
 	HK_FLAG_MANAGED_IRQ	= (1 << 7),
-	HK_FLAG_KTHREAD		= (1 << 8),
 };
 
 #ifdef CONFIG_CPU_ISOLATION
Index: linux-2.6/kernel/kthread.c
===================================================================
--- linux-2.6.orig/kernel/kthread.c
+++ linux-2.6/kernel/kthread.c
@@ -27,7 +27,6 @@
 #include <linux/ptrace.h>
 #include <linux/uaccess.h>
 #include <linux/numa.h>
-#include <linux/sched/isolation.h>
 #include <trace/events/sched.h>
 
 
@@ -405,8 +404,7 @@ struct task_struct *__kthread_create_on_
 		 * The kernel thread should not inherit these properties.
 		 */
 		sched_setscheduler_nocheck(task, SCHED_NORMAL, &param);
-		set_cpus_allowed_ptr(task,
-				     housekeeping_cpumask(HK_FLAG_KTHREAD));
+		set_cpus_allowed_ptr(task, cpu_possible_mask);
 	}
 	kfree(create);
 	return task;
@@ -655,7 +653,7 @@ int kthreadd(void *unused)
 	/* Setup a clean context for our children to inherit. */
 	set_task_comm(tsk, "kthreadd");
 	ignore_signals(tsk);
-	set_cpus_allowed_ptr(tsk, housekeeping_cpumask(HK_FLAG_KTHREAD));
+	set_cpus_allowed_ptr(tsk, cpu_possible_mask);
 	set_mems_allowed(node_states[N_MEMORY]);
 
 	current->flags |= PF_NOFREEZE;
Index: linux-2.6/kernel/sched/isolation.c
===================================================================
--- linux-2.6.orig/kernel/sched/isolation.c
+++ linux-2.6/kernel/sched/isolation.c
@@ -140,8 +140,7 @@ static int __init housekeeping_nohz_full
 {
 	unsigned int flags;
 
-	flags = HK_FLAG_TICK | HK_FLAG_WQ | HK_FLAG_TIMER | HK_FLAG_RCU |
-		HK_FLAG_MISC | HK_FLAG_KTHREAD;
+	flags = HK_FLAG_TICK | HK_FLAG_WQ | HK_FLAG_TIMER | HK_FLAG_RCU | HK_FLAG_MISC;
 
 	return housekeeping_setup(str, flags);
 }


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Revert "isolcpus: Affine unbound kernel threads to housekeeping cpus"
  2021-05-07 16:57 [PATCH] Revert "isolcpus: Affine unbound kernel threads to housekeeping cpus" Marcelo Tosatti
@ 2021-05-07 20:16 ` Frederic Weisbecker
  2021-05-07 22:09   ` Marcelo Tosatti
  0 siblings, 1 reply; 3+ messages in thread
From: Frederic Weisbecker @ 2021-05-07 20:16 UTC (permalink / raw)
  To: Marcelo Tosatti; +Cc: linux-kernel, Phil Auld, Peter Zijlstra

On Fri, May 07, 2021 at 01:57:10PM -0300, Marcelo Tosatti wrote:
> 
> 
> commit 9cc5b8656892a72438ee7deb introduced a new housekeeping flag,
> HK_FLAG_KTHREAD, that when enabled sets the CPU affinity for the 
> kthreadd process (therefore all unbounded kernel threads created
> from that point on will use the housekeeping cpumask).
> 
> This is not necessary, since its possible to control placement of
> kthreadd from userspace:
> 
> # taskset -c -p 0 `pgrep kthreadd`
> pid 2's current affinity list: 1
> pid 2's new affinity list: 0
> 
> Unbounded kernel threads started from that point on will inherit
> the kthreadd cpumask.

Hmm, but look below:

> @@ -405,8 +404,7 @@ struct task_struct *__kthread_create_on_
>  		 * The kernel thread should not inherit these properties.
>  		 */
>  		sched_setscheduler_nocheck(task, SCHED_NORMAL, &param);
> -		set_cpus_allowed_ptr(task,
> -				     housekeeping_cpumask(HK_FLAG_KTHREAD));
> +		set_cpus_allowed_ptr(task, cpu_possible_mask);

That inheritance is then overriden, right?

Thanks.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Revert "isolcpus: Affine unbound kernel threads to housekeeping cpus"
  2021-05-07 20:16 ` Frederic Weisbecker
@ 2021-05-07 22:09   ` Marcelo Tosatti
  0 siblings, 0 replies; 3+ messages in thread
From: Marcelo Tosatti @ 2021-05-07 22:09 UTC (permalink / raw)
  To: Frederic Weisbecker; +Cc: linux-kernel, Phil Auld, Peter Zijlstra

On Fri, May 07, 2021 at 10:16:00PM +0200, Frederic Weisbecker wrote:
> On Fri, May 07, 2021 at 01:57:10PM -0300, Marcelo Tosatti wrote:
> > 
> > 
> > commit 9cc5b8656892a72438ee7deb introduced a new housekeeping flag,
> > HK_FLAG_KTHREAD, that when enabled sets the CPU affinity for the 
> > kthreadd process (therefore all unbounded kernel threads created
> > from that point on will use the housekeeping cpumask).
> > 
> > This is not necessary, since its possible to control placement of
> > kthreadd from userspace:
> > 
> > # taskset -c -p 0 `pgrep kthreadd`
> > pid 2's current affinity list: 1
> > pid 2's new affinity list: 0
> > 
> > Unbounded kernel threads started from that point on will inherit
> > the kthreadd cpumask.
> 
> Hmm, but look below:
> 
> > @@ -405,8 +404,7 @@ struct task_struct *__kthread_create_on_
> >  		 * The kernel thread should not inherit these properties.
> >  		 */
> >  		sched_setscheduler_nocheck(task, SCHED_NORMAL, &param);
> > -		set_cpus_allowed_ptr(task,
> > -				     housekeeping_cpumask(HK_FLAG_KTHREAD));
> > +		set_cpus_allowed_ptr(task, cpu_possible_mask);
> 
> That inheritance is then overriden, right?
> 
> Thanks.

Hi Frederic,

Doh, yes, ignore me.



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-05-10 16:23 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-07 16:57 [PATCH] Revert "isolcpus: Affine unbound kernel threads to housekeeping cpus" Marcelo Tosatti
2021-05-07 20:16 ` Frederic Weisbecker
2021-05-07 22:09   ` Marcelo Tosatti

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.