public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [RESEND PATCH 1/2] sched/isolation: Use raw_smp_processor_id() in housekeeping_any_cpu()
@ 2022-02-28 14:15 Nicolas Saenz Julienne
  2022-02-28 14:15 ` [RESEND PATCH 2/2] tracing: Avoid isolated CPUs when queueing fsnotify irqwork Nicolas Saenz Julienne
  0 siblings, 1 reply; 5+ messages in thread
From: Nicolas Saenz Julienne @ 2022-02-28 14:15 UTC (permalink / raw)
  To: mingo, peterz, frederic, rostedt
  Cc: tglx, mtosatti, bristot, linux-kernel, Nicolas Saenz Julienne

housekeeping_any_cpu() will return a housekeeping CPU. That's it. It'll
try to optimize for NUMA locality and to use the local CPU when
possible, but it's not a requisite.

So let's use raw_smp_processor_id() instead of its vanilla counterpart
in order to allow users to query for housekeeping CPUs without having to
disable preemption.

Signed-off-by: Nicolas Saenz Julienne <nsaenzju@redhat.com>
---

NOTE: Resent as I forgot to CC the linux mailing list.

 include/linux/sched/isolation.h | 2 +-
 kernel/sched/isolation.c        | 5 +++--
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/include/linux/sched/isolation.h b/include/linux/sched/isolation.h
index 8c15abd67aed..0c09ff1e4599 100644
--- a/include/linux/sched/isolation.h
+++ b/include/linux/sched/isolation.h
@@ -31,7 +31,7 @@ extern void __init housekeeping_init(void);
 
 static inline int housekeeping_any_cpu(enum hk_type type)
 {
-	return smp_processor_id();
+	return raw_smp_processor_id();
 }
 
 static inline const struct cpumask *housekeeping_cpumask(enum hk_type type)
diff --git a/kernel/sched/isolation.c b/kernel/sched/isolation.c
index b4d10815c45a..3b8e1d47bbc0 100644
--- a/kernel/sched/isolation.c
+++ b/kernel/sched/isolation.c
@@ -43,14 +43,15 @@ int housekeeping_any_cpu(enum hk_type type)
 
 	if (static_branch_unlikely(&housekeeping_overridden)) {
 		if (housekeeping.flags & BIT(type)) {
-			cpu = sched_numa_find_closest(housekeeping.cpumasks[type], smp_processor_id());
+			cpu = sched_numa_find_closest(housekeeping.cpumasks[type],
+						      raw_smp_processor_id());
 			if (cpu < nr_cpu_ids)
 				return cpu;
 
 			return cpumask_any_and(housekeeping.cpumasks[type], cpu_online_mask);
 		}
 	}
-	return smp_processor_id();
+	return raw_smp_processor_id();
 }
 EXPORT_SYMBOL_GPL(housekeeping_any_cpu);
 
-- 
2.35.1


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

* [RESEND PATCH 2/2] tracing: Avoid isolated CPUs when queueing fsnotify irqwork
  2022-02-28 14:15 [RESEND PATCH 1/2] sched/isolation: Use raw_smp_processor_id() in housekeeping_any_cpu() Nicolas Saenz Julienne
@ 2022-02-28 14:15 ` Nicolas Saenz Julienne
  2022-02-28 18:07   ` kernel test robot
  2022-02-28 19:49   ` kernel test robot
  0 siblings, 2 replies; 5+ messages in thread
From: Nicolas Saenz Julienne @ 2022-02-28 14:15 UTC (permalink / raw)
  To: mingo, peterz, frederic, rostedt
  Cc: tglx, mtosatti, bristot, linux-kernel, Nicolas Saenz Julienne

Ftrace's fsnotify irq_work doesn't need to be run locally, so avoid
doing so when the CPU is isolated.

Note that this is especially bad when tracing an isolated CPU, as the
noise from running the irq_work might be bigger than what was actually
meant to be traced.

Signed-off-by: Nicolas Saenz Julienne <nsaenzju@redhat.com>
---
 kernel/trace/trace.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index 7c85ce9ffdc3..2a3b969708a7 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -12,6 +12,7 @@
  *  Copyright (C) 2004-2006 Ingo Molnar
  *  Copyright (C) 2004 Nadia Yvette Chambers
  */
+#include <linux/sched/isolation.h>
 #include <linux/ring_buffer.h>
 #include <generated/utsrelease.h>
 #include <linux/stacktrace.h>
@@ -1724,7 +1725,7 @@ void latency_fsnotify(struct trace_array *tr)
 	 * possible that we are called from __schedule() or do_idle(), which
 	 * could cause a deadlock.
 	 */
-	irq_work_queue(&tr->fsnotify_irqwork);
+	irq_work_queue_on(&tr->fsnotify_irqwork, housekeeping_any_cpu(HK_FLAG_MISC));
 }
 
 #elif defined(CONFIG_TRACER_MAX_TRACE) || defined(CONFIG_HWLAT_TRACER)	\
-- 
2.35.1


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

* Re: [RESEND PATCH 2/2] tracing: Avoid isolated CPUs when queueing fsnotify irqwork
  2022-02-28 14:15 ` [RESEND PATCH 2/2] tracing: Avoid isolated CPUs when queueing fsnotify irqwork Nicolas Saenz Julienne
@ 2022-02-28 18:07   ` kernel test robot
  2022-02-28 18:20     ` Nicolas Saenz Julienne
  2022-02-28 19:49   ` kernel test robot
  1 sibling, 1 reply; 5+ messages in thread
From: kernel test robot @ 2022-02-28 18:07 UTC (permalink / raw)
  To: Nicolas Saenz Julienne, mingo, peterz, frederic, rostedt
  Cc: kbuild-all, tglx, mtosatti, bristot, linux-kernel,
	Nicolas Saenz Julienne

Hi Nicolas,

I love your patch! Yet something to improve:

[auto build test ERROR on tip/sched/core]
[also build test ERROR on next-20220225]
[cannot apply to rostedt-trace/for-next linus/master v5.17-rc6]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Nicolas-Saenz-Julienne/sched-isolation-Use-raw_smp_processor_id-in-housekeeping_any_cpu/20220228-221742
base:   https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git 6255b48aebfd4dff375e97fc8b075a235848db0b
config: mips-allyesconfig (https://download.01.org/0day-ci/archive/20220301/202203010138.m94KpMH3-lkp@intel.com/config)
compiler: mips-linux-gcc (GCC) 11.2.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/0day-ci/linux/commit/e3ec0b4adfed05db0d559d2d5234d6d8f1034985
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Nicolas-Saenz-Julienne/sched-isolation-Use-raw_smp_processor_id-in-housekeeping_any_cpu/20220228-221742
        git checkout e3ec0b4adfed05db0d559d2d5234d6d8f1034985
        # save the config file to linux build tree
        mkdir build_dir
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross O=build_dir ARCH=mips SHELL=/bin/bash kernel/

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

All errors (new ones prefixed by >>):

   kernel/trace/trace.c: In function 'latency_fsnotify':
>> kernel/trace/trace.c:1728:71: error: 'HK_FLAG_MISC' undeclared (first use in this function); did you mean 'HK_TYPE_MISC'?
    1728 |         irq_work_queue_on(&tr->fsnotify_irqwork, housekeeping_any_cpu(HK_FLAG_MISC));
         |                                                                       ^~~~~~~~~~~~
         |                                                                       HK_TYPE_MISC
   kernel/trace/trace.c:1728:71: note: each undeclared identifier is reported only once for each function it appears in
   kernel/trace/trace.c: In function 'trace_check_vprintf':
   kernel/trace/trace.c:3827:17: warning: function 'trace_check_vprintf' might be a candidate for 'gnu_printf' format attribute [-Wsuggest-attribute=format]
    3827 |                 trace_seq_vprintf(&iter->seq, iter->fmt, ap);
         |                 ^~~~~~~~~~~~~~~~~
   kernel/trace/trace.c:3894:17: warning: function 'trace_check_vprintf' might be a candidate for 'gnu_printf' format attribute [-Wsuggest-attribute=format]
    3894 |                 trace_seq_vprintf(&iter->seq, p, ap);
         |                 ^~~~~~~~~~~~~~~~~


vim +1728 kernel/trace/trace.c

  1718	
  1719	void latency_fsnotify(struct trace_array *tr)
  1720	{
  1721		if (!fsnotify_wq)
  1722			return;
  1723		/*
  1724		 * We cannot call queue_work(&tr->fsnotify_work) from here because it's
  1725		 * possible that we are called from __schedule() or do_idle(), which
  1726		 * could cause a deadlock.
  1727		 */
> 1728		irq_work_queue_on(&tr->fsnotify_irqwork, housekeeping_any_cpu(HK_FLAG_MISC));
  1729	}
  1730	

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

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

* Re: [RESEND PATCH 2/2] tracing: Avoid isolated CPUs when queueing fsnotify irqwork
  2022-02-28 18:07   ` kernel test robot
@ 2022-02-28 18:20     ` Nicolas Saenz Julienne
  0 siblings, 0 replies; 5+ messages in thread
From: Nicolas Saenz Julienne @ 2022-02-28 18:20 UTC (permalink / raw)
  To: kernel test robot, mingo, peterz, frederic, rostedt
  Cc: kbuild-all, tglx, mtosatti, bristot, linux-kernel

On Tue, 2022-03-01 at 02:07 +0800, kernel test robot wrote:
> Hi Nicolas,
> 
> I love your patch! Yet something to improve:
> 
> [auto build test ERROR on tip/sched/core]
> [also build test ERROR on next-20220225]
> [cannot apply to rostedt-trace/for-next linus/master v5.17-rc6]
> [If your patch is applied to the wrong git tree, kindly drop us a note.
> And when submitting patch, we suggest to use '--base' as documented in
> https://git-scm.com/docs/git-format-patch]
> 
> url:    https://github.com/0day-ci/linux/commits/Nicolas-Saenz-Julienne/sched-isolation-Use-raw_smp_processor_id-in-housekeeping_any_cpu/20220228-221742
> base:   https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git 6255b48aebfd4dff375e97fc8b075a235848db0b
> config: mips-allyesconfig (https://download.01.org/0day-ci/archive/20220301/202203010138.m94KpMH3-lkp@intel.com/config)
> compiler: mips-linux-gcc (GCC) 11.2.0
> reproduce (this is a W=1 build):
>         wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
>         chmod +x ~/bin/make.cross
>         # https://github.com/0day-ci/linux/commit/e3ec0b4adfed05db0d559d2d5234d6d8f1034985
>         git remote add linux-review https://github.com/0day-ci/linux
>         git fetch --no-tags linux-review Nicolas-Saenz-Julienne/sched-isolation-Use-raw_smp_processor_id-in-housekeeping_any_cpu/20220228-221742
>         git checkout e3ec0b4adfed05db0d559d2d5234d6d8f1034985
>         # save the config file to linux build tree
>         mkdir build_dir
>         COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross O=build_dir ARCH=mips SHELL=/bin/bash kernel/
> 
> If you fix the issue, kindly add following tag as appropriate
> Reported-by: kernel test robot <lkp@intel.com>
> 
> All errors (new ones prefixed by >>):
> 
>    kernel/trace/trace.c: In function 'latency_fsnotify':
> > > kernel/trace/trace.c:1728:71: error: 'HK_FLAG_MISC' undeclared (first use in this function); did you mean 'HK_TYPE_MISC'?
>     1728 |         irq_work_queue_on(&tr->fsnotify_irqwork, housekeeping_any_cpu(HK_FLAG_MISC));
>          |                                                                       ^~~~~~~~~~~~
>          |                                                                       HK_TYPE_MISC
>    kernel/trace/trace.c:1728:71: note: each undeclared identifier is reported only once for each function it appears in
>    kernel/trace/trace.c: In function 'trace_check_vprintf':
>    kernel/trace/trace.c:3827:17: warning: function 'trace_check_vprintf' might be a candidate for 'gnu_printf' format attribute [-Wsuggest-attribute=format]
>     3827 |                 trace_seq_vprintf(&iter->seq, iter->fmt, ap);
>          |                 ^~~~~~~~~~~~~~~~~
>    kernel/trace/trace.c:3894:17: warning: function 'trace_check_vprintf' might be a candidate for 'gnu_printf' format attribute [-Wsuggest-attribute=format]
>     3894 |                 trace_seq_vprintf(&iter->seq, p, ap);
>          |                 ^~~~~~~~~~~~~~~~~
> 
> 
> vim +1728 kernel/trace/trace.c
> 
>   1718	
>   1719	void latency_fsnotify(struct trace_array *tr)
>   1720	{
>   1721		if (!fsnotify_wq)
>   1722			return;
>   1723		/*
>   1724		 * We cannot call queue_work(&tr->fsnotify_work) from here because it's
>   1725		 * possible that we are called from __schedule() or do_idle(), which
>   1726		 * could cause a deadlock.
>   1727		 */
> > 1728		irq_work_queue_on(&tr->fsnotify_irqwork, housekeeping_any_cpu(HK_FLAG_MISC));
>   1729	}
>   1730	

It seems my patch conflicts with:

04d4e665a609 ("sched/isolation: Use single feature type while referring to housekeeping cpumask")

I'll rebase and send a v2.

-- 
Nicolás Sáenz


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

* Re: [RESEND PATCH 2/2] tracing: Avoid isolated CPUs when queueing fsnotify irqwork
  2022-02-28 14:15 ` [RESEND PATCH 2/2] tracing: Avoid isolated CPUs when queueing fsnotify irqwork Nicolas Saenz Julienne
  2022-02-28 18:07   ` kernel test robot
@ 2022-02-28 19:49   ` kernel test robot
  1 sibling, 0 replies; 5+ messages in thread
From: kernel test robot @ 2022-02-28 19:49 UTC (permalink / raw)
  To: Nicolas Saenz Julienne, mingo, peterz, frederic, rostedt
  Cc: llvm, kbuild-all, tglx, mtosatti, bristot, linux-kernel,
	Nicolas Saenz Julienne

Hi Nicolas,

I love your patch! Yet something to improve:

[auto build test ERROR on tip/sched/core]
[also build test ERROR on next-20220228]
[cannot apply to rostedt-trace/for-next linus/master v5.17-rc6]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Nicolas-Saenz-Julienne/sched-isolation-Use-raw_smp_processor_id-in-housekeeping_any_cpu/20220228-221742
base:   https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git 6255b48aebfd4dff375e97fc8b075a235848db0b
config: i386-randconfig-a002-20220228 (https://download.01.org/0day-ci/archive/20220301/202203010318.S1y5cIXE-lkp@intel.com/config)
compiler: clang version 15.0.0 (https://github.com/llvm/llvm-project d271fc04d5b97b12e6b797c6067d3c96a8d7470e)
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/0day-ci/linux/commit/e3ec0b4adfed05db0d559d2d5234d6d8f1034985
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Nicolas-Saenz-Julienne/sched-isolation-Use-raw_smp_processor_id-in-housekeeping_any_cpu/20220228-221742
        git checkout e3ec0b4adfed05db0d559d2d5234d6d8f1034985
        # save the config file to linux build tree
        mkdir build_dir
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=i386 SHELL=/bin/bash

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

All errors (new ones prefixed by >>):

>> kernel/trace/trace.c:1728:64: error: use of undeclared identifier 'HK_FLAG_MISC'; did you mean 'HK_TYPE_MISC'?
           irq_work_queue_on(&tr->fsnotify_irqwork, housekeeping_any_cpu(HK_FLAG_MISC));
                                                                         ^~~~~~~~~~~~
                                                                         HK_TYPE_MISC
   include/linux/sched/isolation.h:11:2: note: 'HK_TYPE_MISC' declared here
           HK_TYPE_MISC,
           ^
   1 error generated.


vim +1728 kernel/trace/trace.c

  1718	
  1719	void latency_fsnotify(struct trace_array *tr)
  1720	{
  1721		if (!fsnotify_wq)
  1722			return;
  1723		/*
  1724		 * We cannot call queue_work(&tr->fsnotify_work) from here because it's
  1725		 * possible that we are called from __schedule() or do_idle(), which
  1726		 * could cause a deadlock.
  1727		 */
> 1728		irq_work_queue_on(&tr->fsnotify_irqwork, housekeeping_any_cpu(HK_FLAG_MISC));
  1729	}
  1730	

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

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

end of thread, other threads:[~2022-02-28 19:51 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-02-28 14:15 [RESEND PATCH 1/2] sched/isolation: Use raw_smp_processor_id() in housekeeping_any_cpu() Nicolas Saenz Julienne
2022-02-28 14:15 ` [RESEND PATCH 2/2] tracing: Avoid isolated CPUs when queueing fsnotify irqwork Nicolas Saenz Julienne
2022-02-28 18:07   ` kernel test robot
2022-02-28 18:20     ` Nicolas Saenz Julienne
2022-02-28 19:49   ` kernel test robot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox