All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH][RFC] sched/isolation: allow isolcpus and nohz_full for different cpus
@ 2020-04-09  7:57 Li RongQing
  2020-04-09 11:33 ` kbuild test robot
  2020-04-09 11:40 ` kbuild test robot
  0 siblings, 2 replies; 3+ messages in thread
From: Li RongQing @ 2020-04-09  7:57 UTC (permalink / raw)
  To: peterz, frederic, tglx, mingo, linux-kernel

when both isolcpus and nohz_full are set, their cpus must be
same now, in fact isolcpus and nohz_full are not related, and
different cpus are expected for some cases, for example, some
cores for polling threads wants to isolcpus, and some cores for
dedicated threads, only nohz_full is expected

Signed-off-by: Li RongQing <lirongqing@baidu.com>
---
 kernel/sched/isolation.c | 79 ++++++++++++++++++++++++++++++++----------------
 1 file changed, 53 insertions(+), 26 deletions(-)

diff --git a/kernel/sched/isolation.c b/kernel/sched/isolation.c
index 008d6ac2342b..6e6be34bb796 100644
--- a/kernel/sched/isolation.c
+++ b/kernel/sched/isolation.c
@@ -11,7 +11,8 @@
 
 DEFINE_STATIC_KEY_FALSE(housekeeping_overridden);
 EXPORT_SYMBOL_GPL(housekeeping_overridden);
-static cpumask_var_t housekeeping_mask;
+static cpumask_var_t housekeeping_mask_isolcpus;
+static cpumask_var_t housekeeping_mask_nohz_full;
 static unsigned int housekeeping_flags;
 
 bool housekeeping_enabled(enum hk_flags flags)
@@ -20,12 +21,26 @@ bool housekeeping_enabled(enum hk_flags flags)
 }
 EXPORT_SYMBOL_GPL(housekeeping_enabled);
 
+static cpumask_var_t housekeeping_get_mask(enum hk_flags flags)
+{
+	if (flags & (HK_FLAG_DOMAIN | HK_FLAG_MANAGED_IRQ))
+		return housekeeping_mask_isolcpus;
+
+	/* set by isolcpus=nohz only */
+	if ((flags & HK_FLAG_TICK) && !(housekeeping_flags & HK_FLAG_RCU))
+		return housekeeping_mask_isolcpus;
+
+	return housekeeping_mask_nohz_full;
+}
+
 int housekeeping_any_cpu(enum hk_flags flags)
 {
+	cpumask_var_t housekeeping_mask;
 	int cpu;
 
 	if (static_branch_unlikely(&housekeeping_overridden)) {
 		if (housekeeping_flags & flags) {
+			housekeeping_mask = housekeeping_get_mask(flags);
 			cpu = sched_numa_find_closest(housekeeping_mask, smp_processor_id());
 			if (cpu < nr_cpu_ids)
 				return cpu;
@@ -41,7 +56,7 @@ const struct cpumask *housekeeping_cpumask(enum hk_flags flags)
 {
 	if (static_branch_unlikely(&housekeeping_overridden))
 		if (housekeeping_flags & flags)
-			return housekeeping_mask;
+			return housekeeping_get_mask(flags);
 	return cpu_possible_mask;
 }
 EXPORT_SYMBOL_GPL(housekeeping_cpumask);
@@ -49,16 +64,24 @@ EXPORT_SYMBOL_GPL(housekeeping_cpumask);
 void housekeeping_affine(struct task_struct *t, enum hk_flags flags)
 {
 	if (static_branch_unlikely(&housekeeping_overridden))
-		if (housekeeping_flags & flags)
+		if (housekeeping_flags & flags) {
+			cpumask_var_t housekeeping_mask;
+
+			housekeeping_mask = housekeeping_get_mask(flags);
 			set_cpus_allowed_ptr(t, housekeeping_mask);
+		}
 }
 EXPORT_SYMBOL_GPL(housekeeping_affine);
 
 bool housekeeping_test_cpu(int cpu, enum hk_flags flags)
 {
 	if (static_branch_unlikely(&housekeeping_overridden))
-		if (housekeeping_flags & flags)
+		if (housekeeping_flags & flags) {
+			cpumask_var_t housekeeping_mask;
+
+			housekeeping_mask = housekeeping_get_mask(flags);
 			return cpumask_test_cpu(cpu, housekeeping_mask);
+		}
 	return true;
 }
 EXPORT_SYMBOL_GPL(housekeeping_test_cpu);
@@ -74,10 +97,14 @@ void __init housekeeping_init(void)
 		sched_tick_offload_init();
 
 	/* We need at least one CPU to handle housekeeping work */
-	WARN_ON_ONCE(cpumask_empty(housekeeping_mask));
+	if (housekeeping_mask_isolcpus)
+		WARN_ON_ONCE(cpumask_empty(housekeeping_mask_isolcpus));
+	if (housekeeping_mask_nohz_full)
+		WARN_ON_ONCE(cpumask_empty(housekeeping_mask_nohz_full));
 }
 
-static int __init housekeeping_setup(char *str, enum hk_flags flags)
+static int __init housekeeping_setup(char *str, enum hk_flags flags,
+		cpumask_var_t *housekeeping_mask)
 {
 	cpumask_var_t non_housekeeping_mask;
 	cpumask_var_t tmp;
@@ -92,25 +119,25 @@ static int __init housekeeping_setup(char *str, enum hk_flags flags)
 	}
 
 	alloc_bootmem_cpumask_var(&tmp);
-	if (!housekeeping_flags) {
-		alloc_bootmem_cpumask_var(&housekeeping_mask);
-		cpumask_andnot(housekeeping_mask,
-			       cpu_possible_mask, non_housekeeping_mask);
-
-		cpumask_andnot(tmp, cpu_present_mask, non_housekeeping_mask);
-		if (cpumask_empty(tmp)) {
-			pr_warn("Housekeeping: must include one present CPU, "
+	alloc_bootmem_cpumask_var(housekeeping_mask);
+	cpumask_andnot(*housekeeping_mask,
+				   cpu_possible_mask, non_housekeeping_mask);
+
+	cpumask_andnot(tmp, cpu_present_mask, non_housekeeping_mask);
+	if (cpumask_empty(tmp)) {
+		pr_warn("Housekeeping: must include one present CPU, "
 				"using boot CPU:%d\n", smp_processor_id());
-			__cpumask_set_cpu(smp_processor_id(), housekeeping_mask);
-			__cpumask_clear_cpu(smp_processor_id(), non_housekeeping_mask);
-		}
-	} else {
-		cpumask_andnot(tmp, cpu_present_mask, non_housekeeping_mask);
-		if (cpumask_empty(tmp))
-			__cpumask_clear_cpu(smp_processor_id(), non_housekeeping_mask);
-		cpumask_andnot(tmp, cpu_possible_mask, non_housekeeping_mask);
-		if (!cpumask_equal(tmp, housekeeping_mask)) {
-			pr_warn("Housekeeping: nohz_full= must match isolcpus=\n");
+		__cpumask_set_cpu(smp_processor_id(), *housekeeping_mask);
+		__cpumask_clear_cpu(smp_processor_id(), non_housekeeping_mask);
+	}
+
+	/* cpus should match when both nohz_full and isolcpus
+	 * with nohz are passed into kernel
+	 */
+	if (housekeeping_flags & flags & HK_FLAG_TICK) {
+		if (!cpumask_equal(housekeeping_mask_nohz_full,
+					housekeeping_mask_isolcpus)) {
+			pr_warn("Housekeeping: nohz_full= must match isolcpus=nohz\n");
 			free_bootmem_cpumask_var(tmp);
 			free_bootmem_cpumask_var(non_housekeeping_mask);
 			return 0;
@@ -142,7 +169,7 @@ static int __init housekeeping_nohz_full_setup(char *str)
 
 	flags = HK_FLAG_TICK | HK_FLAG_WQ | HK_FLAG_TIMER | HK_FLAG_RCU | HK_FLAG_MISC;
 
-	return housekeeping_setup(str, flags);
+	return housekeeping_setup(str, flags, &housekeeping_mask_nohz_full);
 }
 __setup("nohz_full=", housekeeping_nohz_full_setup);
 
@@ -177,6 +204,6 @@ static int __init housekeeping_isolcpus_setup(char *str)
 	if (!flags)
 		flags |= HK_FLAG_DOMAIN;
 
-	return housekeeping_setup(str, flags);
+	return housekeeping_setup(str, flags, &housekeeping_mask_isolcpus);
 }
 __setup("isolcpus=", housekeeping_isolcpus_setup);
-- 
2.16.2


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

* Re: [PATCH][RFC] sched/isolation: allow isolcpus and nohz_full for different cpus
  2020-04-09  7:57 [PATCH][RFC] sched/isolation: allow isolcpus and nohz_full for different cpus Li RongQing
@ 2020-04-09 11:33 ` kbuild test robot
  2020-04-09 11:40 ` kbuild test robot
  1 sibling, 0 replies; 3+ messages in thread
From: kbuild test robot @ 2020-04-09 11:33 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 6429 bytes --]

Hi Li,

[FYI, it's a private test report for your RFC patch.]
[auto build test ERROR on tip/sched/core]
[also build test ERROR on v5.6 next-20200409]
[if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

url:    https://github.com/0day-ci/linux/commits/Li-RongQing/sched-isolation-allow-isolcpus-and-nohz_full-for-different-cpus/20200409-174606
base:   https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git 313f16e2e35abb833eab5bdebc6ae30699adca18
config: x86_64-defconfig (attached as .config)
compiler: gcc-7 (Ubuntu 7.5.0-6ubuntu2) 7.5.0
reproduce:
        # save the attached .config to linux build tree
        make ARCH=x86_64 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kbuild test robot <lkp@intel.com>

All error/warnings (new ones prefixed by >>):

>> kernel/sched/isolation.c:24:22: error: 'housekeeping_get_mask' declared as function returning an array
    static cpumask_var_t housekeeping_get_mask(enum hk_flags flags)
                         ^~~~~~~~~~~~~~~~~~~~~
   kernel/sched/isolation.c: In function 'housekeeping_get_mask':
>> kernel/sched/isolation.c:27:10: warning: return makes integer from pointer without a cast [-Wint-conversion]
      return housekeeping_mask_isolcpus;
             ^~~~~~~~~~~~~~~~~~~~~~~~~~
   kernel/sched/isolation.c:31:10: warning: return makes integer from pointer without a cast [-Wint-conversion]
      return housekeeping_mask_isolcpus;
             ^~~~~~~~~~~~~~~~~~~~~~~~~~
   kernel/sched/isolation.c:33:9: warning: return makes integer from pointer without a cast [-Wint-conversion]
     return housekeeping_mask_nohz_full;
            ^~~~~~~~~~~~~~~~~~~~~~~~~~~
   kernel/sched/isolation.c: In function 'housekeeping_any_cpu':
>> kernel/sched/isolation.c:43:22: error: assignment to expression with array type
       housekeeping_mask = housekeeping_get_mask(flags);
                         ^
   kernel/sched/isolation.c: In function 'housekeeping_cpumask':
>> kernel/sched/isolation.c:59:11: warning: return makes pointer from integer without a cast [-Wint-conversion]
       return housekeeping_get_mask(flags);
              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
   kernel/sched/isolation.c: In function 'housekeeping_affine':
   kernel/sched/isolation.c:70:22: error: assignment to expression with array type
       housekeeping_mask = housekeeping_get_mask(flags);
                         ^
   kernel/sched/isolation.c: In function 'housekeeping_test_cpu':
   kernel/sched/isolation.c:82:22: error: assignment to expression with array type
       housekeeping_mask = housekeeping_get_mask(flags);
                         ^
   kernel/sched/isolation.c: In function 'housekeeping_init':
>> kernel/sched/isolation.c:100:6: warning: the address of 'housekeeping_mask_isolcpus' will always evaluate as 'true' [-Waddress]
     if (housekeeping_mask_isolcpus)
         ^~~~~~~~~~~~~~~~~~~~~~~~~~
>> kernel/sched/isolation.c:102:6: warning: the address of 'housekeeping_mask_nohz_full' will always evaluate as 'true' [-Waddress]
     if (housekeeping_mask_nohz_full)
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~

vim +/housekeeping_get_mask +24 kernel/sched/isolation.c

    23	
  > 24	static cpumask_var_t housekeeping_get_mask(enum hk_flags flags)
    25	{
    26		if (flags & (HK_FLAG_DOMAIN | HK_FLAG_MANAGED_IRQ))
  > 27			return housekeeping_mask_isolcpus;
    28	
    29		/* set by isolcpus=nohz only */
    30		if ((flags & HK_FLAG_TICK) && !(housekeeping_flags & HK_FLAG_RCU))
    31			return housekeeping_mask_isolcpus;
    32	
    33		return housekeeping_mask_nohz_full;
    34	}
    35	
    36	int housekeeping_any_cpu(enum hk_flags flags)
    37	{
    38		cpumask_var_t housekeeping_mask;
    39		int cpu;
    40	
    41		if (static_branch_unlikely(&housekeeping_overridden)) {
    42			if (housekeeping_flags & flags) {
  > 43				housekeeping_mask = housekeeping_get_mask(flags);
    44				cpu = sched_numa_find_closest(housekeeping_mask, smp_processor_id());
    45				if (cpu < nr_cpu_ids)
    46					return cpu;
    47	
    48				return cpumask_any_and(housekeeping_mask, cpu_online_mask);
    49			}
    50		}
    51		return smp_processor_id();
    52	}
    53	EXPORT_SYMBOL_GPL(housekeeping_any_cpu);
    54	
    55	const struct cpumask *housekeeping_cpumask(enum hk_flags flags)
    56	{
    57		if (static_branch_unlikely(&housekeeping_overridden))
    58			if (housekeeping_flags & flags)
  > 59				return housekeeping_get_mask(flags);
    60		return cpu_possible_mask;
    61	}
    62	EXPORT_SYMBOL_GPL(housekeeping_cpumask);
    63	
    64	void housekeeping_affine(struct task_struct *t, enum hk_flags flags)
    65	{
    66		if (static_branch_unlikely(&housekeeping_overridden))
    67			if (housekeeping_flags & flags) {
    68				cpumask_var_t housekeeping_mask;
    69	
    70				housekeeping_mask = housekeeping_get_mask(flags);
    71				set_cpus_allowed_ptr(t, housekeeping_mask);
    72			}
    73	}
    74	EXPORT_SYMBOL_GPL(housekeeping_affine);
    75	
    76	bool housekeeping_test_cpu(int cpu, enum hk_flags flags)
    77	{
    78		if (static_branch_unlikely(&housekeeping_overridden))
    79			if (housekeeping_flags & flags) {
    80				cpumask_var_t housekeeping_mask;
    81	
    82				housekeeping_mask = housekeeping_get_mask(flags);
    83				return cpumask_test_cpu(cpu, housekeeping_mask);
    84			}
    85		return true;
    86	}
    87	EXPORT_SYMBOL_GPL(housekeeping_test_cpu);
    88	
    89	void __init housekeeping_init(void)
    90	{
    91		if (!housekeeping_flags)
    92			return;
    93	
    94		static_branch_enable(&housekeeping_overridden);
    95	
    96		if (housekeeping_flags & HK_FLAG_TICK)
    97			sched_tick_offload_init();
    98	
    99		/* We need at least one CPU to handle housekeeping work */
 > 100		if (housekeeping_mask_isolcpus)
   101			WARN_ON_ONCE(cpumask_empty(housekeeping_mask_isolcpus));
 > 102		if (housekeeping_mask_nohz_full)
   103			WARN_ON_ONCE(cpumask_empty(housekeeping_mask_nohz_full));
   104	}
   105	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 28982 bytes --]

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

* Re: [PATCH][RFC] sched/isolation: allow isolcpus and nohz_full for different cpus
  2020-04-09  7:57 [PATCH][RFC] sched/isolation: allow isolcpus and nohz_full for different cpus Li RongQing
  2020-04-09 11:33 ` kbuild test robot
@ 2020-04-09 11:40 ` kbuild test robot
  1 sibling, 0 replies; 3+ messages in thread
From: kbuild test robot @ 2020-04-09 11:40 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 5480 bytes --]

Hi Li,

[FYI, it's a private test report for your RFC patch.]
[auto build test WARNING on tip/sched/core]
[also build test WARNING on v5.6 next-20200409]
[if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

url:    https://github.com/0day-ci/linux/commits/Li-RongQing/sched-isolation-allow-isolcpus-and-nohz_full-for-different-cpus/20200409-174606
base:   https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git 313f16e2e35abb833eab5bdebc6ae30699adca18
config: arm-spear13xx_defconfig (attached as .config)
compiler: arm-linux-gnueabi-gcc (GCC) 9.3.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        GCC_VERSION=9.3.0 make.cross ARCH=arm 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kbuild test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

   kernel/sched/isolation.c:24:22: error: 'housekeeping_get_mask' declared as function returning an array
      24 | static cpumask_var_t housekeeping_get_mask(enum hk_flags flags)
         |                      ^~~~~~~~~~~~~~~~~~~~~
   kernel/sched/isolation.c: In function 'housekeeping_get_mask':
>> kernel/sched/isolation.c:27:10: warning: returning 'struct cpumask *' from a function with return type 'int' makes integer from pointer without a cast [-Wint-conversion]
      27 |   return housekeeping_mask_isolcpus;
         |          ^~~~~~~~~~~~~~~~~~~~~~~~~~
   kernel/sched/isolation.c:31:10: warning: returning 'struct cpumask *' from a function with return type 'int' makes integer from pointer without a cast [-Wint-conversion]
      31 |   return housekeeping_mask_isolcpus;
         |          ^~~~~~~~~~~~~~~~~~~~~~~~~~
   kernel/sched/isolation.c:33:9: warning: returning 'struct cpumask *' from a function with return type 'int' makes integer from pointer without a cast [-Wint-conversion]
      33 |  return housekeeping_mask_nohz_full;
         |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~
   kernel/sched/isolation.c: In function 'housekeeping_any_cpu':
   kernel/sched/isolation.c:43:22: error: assignment to expression with array type
      43 |    housekeeping_mask = housekeeping_get_mask(flags);
         |                      ^
   kernel/sched/isolation.c: In function 'housekeeping_cpumask':
>> kernel/sched/isolation.c:59:11: warning: returning 'int' from a function with return type 'const struct cpumask *' makes pointer from integer without a cast [-Wint-conversion]
      59 |    return housekeeping_get_mask(flags);
         |           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
   kernel/sched/isolation.c: In function 'housekeeping_affine':
   kernel/sched/isolation.c:70:22: error: assignment to expression with array type
      70 |    housekeeping_mask = housekeeping_get_mask(flags);
         |                      ^
   kernel/sched/isolation.c: In function 'housekeeping_test_cpu':
   kernel/sched/isolation.c:82:22: error: assignment to expression with array type
      82 |    housekeeping_mask = housekeeping_get_mask(flags);
         |                      ^
   kernel/sched/isolation.c: In function 'housekeeping_init':
   kernel/sched/isolation.c:100:6: warning: the address of 'housekeeping_mask_isolcpus' will always evaluate as 'true' [-Waddress]
     100 |  if (housekeeping_mask_isolcpus)
         |      ^~~~~~~~~~~~~~~~~~~~~~~~~~
   kernel/sched/isolation.c:102:6: warning: the address of 'housekeeping_mask_nohz_full' will always evaluate as 'true' [-Waddress]
     102 |  if (housekeeping_mask_nohz_full)
         |      ^~~~~~~~~~~~~~~~~~~~~~~~~~~

vim +27 kernel/sched/isolation.c

    23	
    24	static cpumask_var_t housekeeping_get_mask(enum hk_flags flags)
    25	{
    26		if (flags & (HK_FLAG_DOMAIN | HK_FLAG_MANAGED_IRQ))
  > 27			return housekeeping_mask_isolcpus;
    28	
    29		/* set by isolcpus=nohz only */
    30		if ((flags & HK_FLAG_TICK) && !(housekeeping_flags & HK_FLAG_RCU))
    31			return housekeeping_mask_isolcpus;
    32	
    33		return housekeeping_mask_nohz_full;
    34	}
    35	
    36	int housekeeping_any_cpu(enum hk_flags flags)
    37	{
    38		cpumask_var_t housekeeping_mask;
    39		int cpu;
    40	
    41		if (static_branch_unlikely(&housekeeping_overridden)) {
    42			if (housekeeping_flags & flags) {
    43				housekeeping_mask = housekeeping_get_mask(flags);
    44				cpu = sched_numa_find_closest(housekeeping_mask, smp_processor_id());
    45				if (cpu < nr_cpu_ids)
    46					return cpu;
    47	
    48				return cpumask_any_and(housekeeping_mask, cpu_online_mask);
    49			}
    50		}
    51		return smp_processor_id();
    52	}
    53	EXPORT_SYMBOL_GPL(housekeeping_any_cpu);
    54	
    55	const struct cpumask *housekeeping_cpumask(enum hk_flags flags)
    56	{
    57		if (static_branch_unlikely(&housekeeping_overridden))
    58			if (housekeeping_flags & flags)
  > 59				return housekeeping_get_mask(flags);
    60		return cpu_possible_mask;
    61	}
    62	EXPORT_SYMBOL_GPL(housekeeping_cpumask);
    63	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 20640 bytes --]

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

end of thread, other threads:[~2020-04-09 11:40 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-04-09  7:57 [PATCH][RFC] sched/isolation: allow isolcpus and nohz_full for different cpus Li RongQing
2020-04-09 11:33 ` kbuild test robot
2020-04-09 11:40 ` kbuild test robot

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.