linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] Remove sched_trace_*() helper functions
@ 2020-09-07  9:17 Dietmar Eggemann
  2020-09-07  9:17 ` [PATCH 1/3] sched/fair: " Dietmar Eggemann
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Dietmar Eggemann @ 2020-09-07  9:17 UTC (permalink / raw)
  To: Peter Zijlstra, Ingo Molnar
  Cc: linux-kernel, Vincent Guittot, Steven Rostedt, Qais Yousef,
	Phil Auld, Vincent Donnefort

The patch ("sched/debug: Add new tracepoint to track cpu_capacity")
https://lkml.kernel.org/r/1598605249-72651-1-git-send-email-vincent.donnefort@arm.com
revealed the issue that with every tracepoint in the scheduler code
there are sched_trace_*() helper functions in fair.c appearing which
are exported via include/linux/sched.h.

Those tracepoints can be used to build tracepoint-to traceevent
(tp-2-te) converters.

The sched_trace_*() helper functions provide access to data of
internal scheduler structures, like struct rq. They support built-in
or kernel module builds outside kernel/sched/. But they don't have to
be maintained in the scheduler code.

kernel/sched/ is the natural place for a tp-2-te converter to get
access to data of internal scheduler structures.

In case a tp-2-te converter has to be build outside the kernel code
tree there is an easy way to make kernel/sched/sched.h visible.
See header of "sched/fair: Remove sched_trace_*() helper functions" for
details.

The first patch removes those sched_trace_*() helper functions from
the scheduler.

The second patch removes cfs_rq_tg_path() from the scheduler since it
can be coded inside a tp-2-te converter as well.

The third patch allows to use autogroup_path() from within a tp-2-te
converter (i.e. from cfs_rq_tg_path()) in kernel modules builds.

The aim of tracepoints in the scheduler code is to keep the footprint of
traceing code as small as possible and to not guarantee any stable ABI
in relation to internal scheduler structures.

Dietmar Eggemann (3):
  sched/fair: Remove sched_trace_*() helper functions
  sched/fair: Remove cfs_rq_tg_path()
  sched/autogroup: Change autogroup_path() into a static inline function

 include/linux/sched.h    |  13 -----
 kernel/sched/autogroup.c |   8 ---
 kernel/sched/autogroup.h |   8 ++-
 kernel/sched/fair.c      | 105 ---------------------------------------
 kernel/sched/sched.h     |   3 --
 5 files changed, 7 insertions(+), 130 deletions(-)

-- 
2.17.1


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

* [PATCH 1/3] sched/fair: Remove sched_trace_*() helper functions
  2020-09-07  9:17 [PATCH 0/3] Remove sched_trace_*() helper functions Dietmar Eggemann
@ 2020-09-07  9:17 ` Dietmar Eggemann
  2020-09-07  9:17 ` [PATCH 2/3] sched/fair: Remove cfs_rq_tg_path() Dietmar Eggemann
  2020-09-07  9:17 ` [PATCH 3/3] sched/autogroup: Change autogroup_path() into a static inline function Dietmar Eggemann
  2 siblings, 0 replies; 4+ messages in thread
From: Dietmar Eggemann @ 2020-09-07  9:17 UTC (permalink / raw)
  To: Peter Zijlstra, Ingo Molnar
  Cc: linux-kernel, Vincent Guittot, Steven Rostedt, Qais Yousef,
	Phil Auld, Vincent Donnefort

The sched_trace_*() helper functions provide access to data of
internal scheduler structures, like struct rq. They support built-in
or kernel module builds outside kernel/sched/. But they don't have to
be maintained in the scheduler code.

kernel/sched/ is the natural place for a tp-2-te converter to get
access to data of internal scheduler structures.

In case a kernel module has to be build out-of tree there is an easy
way to make kernel/sched/sched.h visible.

      CFLAGS_foo.o := -I$KERNEL_SRC/kernel/sched

      all:
          make -C $KERNEL_SRC M=$(PWD) modules

The sched_trace_*() helper functions can be coded in a tp-2-te converter.

Remove them from kernel/sched/fair.c.

Signed-off-by: Dietmar Eggemann <dietmar.eggemann@arm.com>
---
 include/linux/sched.h | 13 -------
 kernel/sched/fair.c   | 86 -------------------------------------------
 2 files changed, 99 deletions(-)

diff --git a/include/linux/sched.h b/include/linux/sched.h
index 2bf0af19a62a..23415088967d 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -2035,17 +2035,4 @@ static inline void rseq_syscall(struct pt_regs *regs)
 
 #endif
 
-const struct sched_avg *sched_trace_cfs_rq_avg(struct cfs_rq *cfs_rq);
-char *sched_trace_cfs_rq_path(struct cfs_rq *cfs_rq, char *str, int len);
-int sched_trace_cfs_rq_cpu(struct cfs_rq *cfs_rq);
-
-const struct sched_avg *sched_trace_rq_avg_rt(struct rq *rq);
-const struct sched_avg *sched_trace_rq_avg_dl(struct rq *rq);
-const struct sched_avg *sched_trace_rq_avg_irq(struct rq *rq);
-
-int sched_trace_rq_cpu(struct rq *rq);
-int sched_trace_rq_nr_running(struct rq *rq);
-
-const struct cpumask *sched_trace_rd_span(struct root_domain *rd);
-
 #endif
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 33699db27ed5..f7640af1dcaa 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -11236,89 +11236,3 @@ __init void init_sched_fair_class(void)
 #endif /* SMP */
 
 }
-
-/*
- * Helper functions to facilitate extracting info from tracepoints.
- */
-
-const struct sched_avg *sched_trace_cfs_rq_avg(struct cfs_rq *cfs_rq)
-{
-#ifdef CONFIG_SMP
-	return cfs_rq ? &cfs_rq->avg : NULL;
-#else
-	return NULL;
-#endif
-}
-EXPORT_SYMBOL_GPL(sched_trace_cfs_rq_avg);
-
-char *sched_trace_cfs_rq_path(struct cfs_rq *cfs_rq, char *str, int len)
-{
-	if (!cfs_rq) {
-		if (str)
-			strlcpy(str, "(null)", len);
-		else
-			return NULL;
-	}
-
-	cfs_rq_tg_path(cfs_rq, str, len);
-	return str;
-}
-EXPORT_SYMBOL_GPL(sched_trace_cfs_rq_path);
-
-int sched_trace_cfs_rq_cpu(struct cfs_rq *cfs_rq)
-{
-	return cfs_rq ? cpu_of(rq_of(cfs_rq)) : -1;
-}
-EXPORT_SYMBOL_GPL(sched_trace_cfs_rq_cpu);
-
-const struct sched_avg *sched_trace_rq_avg_rt(struct rq *rq)
-{
-#ifdef CONFIG_SMP
-	return rq ? &rq->avg_rt : NULL;
-#else
-	return NULL;
-#endif
-}
-EXPORT_SYMBOL_GPL(sched_trace_rq_avg_rt);
-
-const struct sched_avg *sched_trace_rq_avg_dl(struct rq *rq)
-{
-#ifdef CONFIG_SMP
-	return rq ? &rq->avg_dl : NULL;
-#else
-	return NULL;
-#endif
-}
-EXPORT_SYMBOL_GPL(sched_trace_rq_avg_dl);
-
-const struct sched_avg *sched_trace_rq_avg_irq(struct rq *rq)
-{
-#if defined(CONFIG_SMP) && defined(CONFIG_HAVE_SCHED_AVG_IRQ)
-	return rq ? &rq->avg_irq : NULL;
-#else
-	return NULL;
-#endif
-}
-EXPORT_SYMBOL_GPL(sched_trace_rq_avg_irq);
-
-int sched_trace_rq_cpu(struct rq *rq)
-{
-	return rq ? cpu_of(rq) : -1;
-}
-EXPORT_SYMBOL_GPL(sched_trace_rq_cpu);
-
-const struct cpumask *sched_trace_rd_span(struct root_domain *rd)
-{
-#ifdef CONFIG_SMP
-	return rd ? rd->span : NULL;
-#else
-	return NULL;
-#endif
-}
-EXPORT_SYMBOL_GPL(sched_trace_rd_span);
-
-int sched_trace_rq_nr_running(struct rq *rq)
-{
-        return rq ? rq->nr_running : -1;
-}
-EXPORT_SYMBOL_GPL(sched_trace_rq_nr_running);
-- 
2.17.1


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

* [PATCH 2/3] sched/fair: Remove cfs_rq_tg_path()
  2020-09-07  9:17 [PATCH 0/3] Remove sched_trace_*() helper functions Dietmar Eggemann
  2020-09-07  9:17 ` [PATCH 1/3] sched/fair: " Dietmar Eggemann
@ 2020-09-07  9:17 ` Dietmar Eggemann
  2020-09-07  9:17 ` [PATCH 3/3] sched/autogroup: Change autogroup_path() into a static inline function Dietmar Eggemann
  2 siblings, 0 replies; 4+ messages in thread
From: Dietmar Eggemann @ 2020-09-07  9:17 UTC (permalink / raw)
  To: Peter Zijlstra, Ingo Molnar
  Cc: linux-kernel, Vincent Guittot, Steven Rostedt, Qais Yousef,
	Phil Auld, Vincent Donnefort

cfs_rq_tg_path() is used by a tracepoint-to traceevent (tp-2-te)
converter to format the path of a taskgroup or autogroup respectively.
It doesn't have any in-kernel users after the removal of the
sched_trace_cfs_rq_path() helper function.

cfs_rq_tg_path() can be coded in a tp-2-te converter.

Remove it from kernel/sched/fair.c.

Signed-off-by: Dietmar Eggemann <dietmar.eggemann@arm.com>
---
 kernel/sched/fair.c  | 19 -------------------
 kernel/sched/sched.h |  3 ---
 2 files changed, 22 deletions(-)

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index f7640af1dcaa..7b9b5ed3c506 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -285,19 +285,6 @@ static inline struct cfs_rq *group_cfs_rq(struct sched_entity *grp)
 	return grp->my_q;
 }
 
-static inline void cfs_rq_tg_path(struct cfs_rq *cfs_rq, char *path, int len)
-{
-	if (!path)
-		return;
-
-	if (cfs_rq && task_group_is_autogroup(cfs_rq->tg))
-		autogroup_path(cfs_rq->tg, path, len);
-	else if (cfs_rq && cfs_rq->tg->css.cgroup)
-		cgroup_path(cfs_rq->tg->css.cgroup, path, len);
-	else
-		strlcpy(path, "(null)", len);
-}
-
 static inline bool list_add_leaf_cfs_rq(struct cfs_rq *cfs_rq)
 {
 	struct rq *rq = rq_of(cfs_rq);
@@ -472,12 +459,6 @@ static inline struct cfs_rq *group_cfs_rq(struct sched_entity *grp)
 	return NULL;
 }
 
-static inline void cfs_rq_tg_path(struct cfs_rq *cfs_rq, char *path, int len)
-{
-	if (path)
-		strlcpy(path, "(null)", len);
-}
-
 static inline bool list_add_leaf_cfs_rq(struct cfs_rq *cfs_rq)
 {
 	return true;
diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
index 28709f6b0975..5f2e9b396161 100644
--- a/kernel/sched/sched.h
+++ b/kernel/sched/sched.h
@@ -730,7 +730,6 @@ static inline long se_runnable(struct sched_entity *se)
 	else
 		return se->runnable_weight;
 }
-
 #else
 #define entity_is_task(se)	1
 
@@ -1579,7 +1578,6 @@ static inline void set_task_rq(struct task_struct *p, unsigned int cpu)
 	p->rt.parent = tg->rt_se[cpu];
 #endif
 }
-
 #else /* CONFIG_CGROUP_SCHED */
 
 static inline void set_task_rq(struct task_struct *p, unsigned int cpu) { }
@@ -1587,7 +1585,6 @@ static inline struct task_group *task_group(struct task_struct *p)
 {
 	return NULL;
 }
-
 #endif /* CONFIG_CGROUP_SCHED */
 
 static inline void __set_task_cpu(struct task_struct *p, unsigned int cpu)
-- 
2.17.1


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

* [PATCH 3/3] sched/autogroup: Change autogroup_path() into a static inline function
  2020-09-07  9:17 [PATCH 0/3] Remove sched_trace_*() helper functions Dietmar Eggemann
  2020-09-07  9:17 ` [PATCH 1/3] sched/fair: " Dietmar Eggemann
  2020-09-07  9:17 ` [PATCH 2/3] sched/fair: Remove cfs_rq_tg_path() Dietmar Eggemann
@ 2020-09-07  9:17 ` Dietmar Eggemann
  2 siblings, 0 replies; 4+ messages in thread
From: Dietmar Eggemann @ 2020-09-07  9:17 UTC (permalink / raw)
  To: Peter Zijlstra, Ingo Molnar
  Cc: linux-kernel, Vincent Guittot, Steven Rostedt, Qais Yousef,
	Phil Auld, Vincent Donnefort

cfs_rq_tg_path() uses, besides cgroup_path(), autogroup_path() to
format the path of a taskgroup or autogroup respectively.

Provide autogroup_path() as a static inline function like cgroup_path()
so cfs_rq_tg_path() (from a tp-2-te converter) can use both in a kernel
module build.

Signed-off-by: Dietmar Eggemann <dietmar.eggemann@arm.com>
---
 kernel/sched/autogroup.c | 8 --------
 kernel/sched/autogroup.h | 8 +++++++-
 2 files changed, 7 insertions(+), 9 deletions(-)

diff --git a/kernel/sched/autogroup.c b/kernel/sched/autogroup.c
index 2067080bb235..3c6c78d909dd 100644
--- a/kernel/sched/autogroup.c
+++ b/kernel/sched/autogroup.c
@@ -258,11 +258,3 @@ void proc_sched_autogroup_show_task(struct task_struct *p, struct seq_file *m)
 	autogroup_kref_put(ag);
 }
 #endif /* CONFIG_PROC_FS */
-
-int autogroup_path(struct task_group *tg, char *buf, int buflen)
-{
-	if (!task_group_is_autogroup(tg))
-		return 0;
-
-	return snprintf(buf, buflen, "%s-%ld", "/autogroup", tg->autogroup->id);
-}
diff --git a/kernel/sched/autogroup.h b/kernel/sched/autogroup.h
index b96419974a1f..001f4826d781 100644
--- a/kernel/sched/autogroup.h
+++ b/kernel/sched/autogroup.h
@@ -35,7 +35,13 @@ autogroup_task_group(struct task_struct *p, struct task_group *tg)
 	return tg;
 }
 
-extern int autogroup_path(struct task_group *tg, char *buf, int buflen);
+static inline int autogroup_path(struct task_group *tg, char *buf, int buflen)
+{
+	if (!task_group_is_autogroup(tg))
+		return 0;
+
+	return snprintf(buf, buflen, "%s-%ld", "/autogroup", tg->autogroup->id);
+}
 
 #else /* !CONFIG_SCHED_AUTOGROUP */
 
-- 
2.17.1


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

end of thread, other threads:[~2020-09-07  9:17 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-07  9:17 [PATCH 0/3] Remove sched_trace_*() helper functions Dietmar Eggemann
2020-09-07  9:17 ` [PATCH 1/3] sched/fair: " Dietmar Eggemann
2020-09-07  9:17 ` [PATCH 2/3] sched/fair: Remove cfs_rq_tg_path() Dietmar Eggemann
2020-09-07  9:17 ` [PATCH 3/3] sched/autogroup: Change autogroup_path() into a static inline function Dietmar Eggemann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).