From: Greg Kroah-Hartman Date: Wed, 6 Apr 2022 13:00:32 +0000 (+0200) Subject: drop sched-tracing-don-t-re-read-p-state-when-emitting-sc.patch X-Git-Tag: v5.17.2~7 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=c178216f5eea84fd27daae68c3d1ec632a833f5a;p=thirdparty%2Fkernel%2Fstable-queue.git drop sched-tracing-don-t-re-read-p-state-when-emitting-sc.patch from 5.15, 5.16, and 5.17 queues --- diff --git a/queue-5.15/sched-tracing-don-t-re-read-p-state-when-emitting-sc.patch b/queue-5.15/sched-tracing-don-t-re-read-p-state-when-emitting-sc.patch deleted file mode 100644 index 84b3766fd06..00000000000 --- a/queue-5.15/sched-tracing-don-t-re-read-p-state-when-emitting-sc.patch +++ /dev/null @@ -1,247 +0,0 @@ -From b858895d47341993c9549ba7563f61c811af77f1 Mon Sep 17 00:00:00 2001 -From: Sasha Levin -Date: Thu, 20 Jan 2022 16:25:19 +0000 -Subject: sched/tracing: Don't re-read p->state when emitting sched_switch - event - -From: Valentin Schneider - -[ Upstream commit fa2c3254d7cfff5f7a916ab928a562d1165f17bb ] - -As of commit - - c6e7bd7afaeb ("sched/core: Optimize ttwu() spinning on p->on_cpu") - -the following sequence becomes possible: - - p->__state = TASK_INTERRUPTIBLE; - __schedule() - deactivate_task(p); - ttwu() - READ !p->on_rq - p->__state=TASK_WAKING - trace_sched_switch() - __trace_sched_switch_state() - task_state_index() - return 0; - -TASK_WAKING isn't in TASK_REPORT, so the task appears as TASK_RUNNING in -the trace event. - -Prevent this by pushing the value read from __schedule() down the trace -event. - -Reported-by: Abhijeet Dharmapurikar -Signed-off-by: Valentin Schneider -Signed-off-by: Peter Zijlstra (Intel) -Reviewed-by: Steven Rostedt (Google) -Link: https://lore.kernel.org/r/20220120162520.570782-2-valentin.schneider@arm.com -Signed-off-by: Sasha Levin ---- - include/linux/sched.h | 11 ++++++++--- - include/trace/events/sched.h | 11 +++++++---- - kernel/sched/core.c | 4 ++-- - kernel/trace/fgraph.c | 4 +++- - kernel/trace/ftrace.c | 4 +++- - kernel/trace/trace_events.c | 8 ++++++-- - kernel/trace/trace_osnoise.c | 4 +++- - kernel/trace/trace_sched_switch.c | 1 + - kernel/trace/trace_sched_wakeup.c | 1 + - 9 files changed, 34 insertions(+), 14 deletions(-) - -diff --git a/include/linux/sched.h b/include/linux/sched.h -index 76e869550646..8fcf76fed984 100644 ---- a/include/linux/sched.h -+++ b/include/linux/sched.h -@@ -1616,10 +1616,10 @@ static inline pid_t task_pgrp_nr(struct task_struct *tsk) - #define TASK_REPORT_IDLE (TASK_REPORT + 1) - #define TASK_REPORT_MAX (TASK_REPORT_IDLE << 1) - --static inline unsigned int task_state_index(struct task_struct *tsk) -+static inline unsigned int __task_state_index(unsigned int tsk_state, -+ unsigned int tsk_exit_state) - { -- unsigned int tsk_state = READ_ONCE(tsk->__state); -- unsigned int state = (tsk_state | tsk->exit_state) & TASK_REPORT; -+ unsigned int state = (tsk_state | tsk_exit_state) & TASK_REPORT; - - BUILD_BUG_ON_NOT_POWER_OF_2(TASK_REPORT_MAX); - -@@ -1629,6 +1629,11 @@ static inline unsigned int task_state_index(struct task_struct *tsk) - return fls(state); - } - -+static inline unsigned int task_state_index(struct task_struct *tsk) -+{ -+ return __task_state_index(READ_ONCE(tsk->__state), tsk->exit_state); -+} -+ - static inline char task_index_to_char(unsigned int state) - { - static const char state_char[] = "RSDTtXZPI"; -diff --git a/include/trace/events/sched.h b/include/trace/events/sched.h -index 94640482cfe7..65e786756321 100644 ---- a/include/trace/events/sched.h -+++ b/include/trace/events/sched.h -@@ -187,7 +187,9 @@ DEFINE_EVENT(sched_wakeup_template, sched_wakeup_new, - TP_ARGS(p)); - - #ifdef CREATE_TRACE_POINTS --static inline long __trace_sched_switch_state(bool preempt, struct task_struct *p) -+static inline long __trace_sched_switch_state(bool preempt, -+ unsigned int prev_state, -+ struct task_struct *p) - { - unsigned int state; - -@@ -208,7 +210,7 @@ static inline long __trace_sched_switch_state(bool preempt, struct task_struct * - * it for left shift operation to get the correct task->state - * mapping. - */ -- state = task_state_index(p); -+ state = __task_state_index(prev_state, p->exit_state); - - return state ? (1 << (state - 1)) : state; - } -@@ -220,10 +222,11 @@ static inline long __trace_sched_switch_state(bool preempt, struct task_struct * - TRACE_EVENT(sched_switch, - - TP_PROTO(bool preempt, -+ unsigned int prev_state, - struct task_struct *prev, - struct task_struct *next), - -- TP_ARGS(preempt, prev, next), -+ TP_ARGS(preempt, prev_state, prev, next), - - TP_STRUCT__entry( - __array( char, prev_comm, TASK_COMM_LEN ) -@@ -239,7 +242,7 @@ TRACE_EVENT(sched_switch, - memcpy(__entry->next_comm, next->comm, TASK_COMM_LEN); - __entry->prev_pid = prev->pid; - __entry->prev_prio = prev->prio; -- __entry->prev_state = __trace_sched_switch_state(preempt, prev); -+ __entry->prev_state = __trace_sched_switch_state(preempt, prev_state, prev); - memcpy(__entry->prev_comm, prev->comm, TASK_COMM_LEN); - __entry->next_pid = next->pid; - __entry->next_prio = next->prio; -diff --git a/kernel/sched/core.c b/kernel/sched/core.c -index c51bd3692316..2fd338bcbdcc 100644 ---- a/kernel/sched/core.c -+++ b/kernel/sched/core.c -@@ -4787,7 +4787,7 @@ static struct rq *finish_task_switch(struct task_struct *prev) - { - struct rq *rq = this_rq(); - struct mm_struct *mm = rq->prev_mm; -- long prev_state; -+ unsigned int prev_state; - - /* - * The previous task will have left us with a preempt_count of 2 -@@ -6295,7 +6295,7 @@ static void __sched notrace __schedule(unsigned int sched_mode) - migrate_disable_switch(rq, prev); - psi_sched_switch(prev, next, !task_on_rq_queued(prev)); - -- trace_sched_switch(sched_mode & SM_MASK_PREEMPT, prev, next); -+ trace_sched_switch(sched_mode & SM_MASK_PREEMPT, prev_state, prev, next); - - /* Also unlocks the rq: */ - rq = context_switch(rq, prev, next, &rf); -diff --git a/kernel/trace/fgraph.c b/kernel/trace/fgraph.c -index b8a0d1d564fb..bb383ac91198 100644 ---- a/kernel/trace/fgraph.c -+++ b/kernel/trace/fgraph.c -@@ -413,7 +413,9 @@ static int alloc_retstack_tasklist(struct ftrace_ret_stack **ret_stack_list) - - static void - ftrace_graph_probe_sched_switch(void *ignore, bool preempt, -- struct task_struct *prev, struct task_struct *next) -+ unsigned int prev_state, -+ struct task_struct *prev, -+ struct task_struct *next) - { - unsigned long long timestamp; - int index; -diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c -index c672040142e9..136520a5b7c0 100644 ---- a/kernel/trace/ftrace.c -+++ b/kernel/trace/ftrace.c -@@ -7093,7 +7093,9 @@ ftrace_func_t ftrace_ops_get_func(struct ftrace_ops *ops) - - static void - ftrace_filter_pid_sched_switch_probe(void *data, bool preempt, -- struct task_struct *prev, struct task_struct *next) -+ unsigned int prev_state, -+ struct task_struct *prev, -+ struct task_struct *next) - { - struct trace_array *tr = data; - struct trace_pid_list *pid_list; -diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c -index 44d031ffe511..dd17171829d6 100644 ---- a/kernel/trace/trace_events.c -+++ b/kernel/trace/trace_events.c -@@ -759,7 +759,9 @@ void trace_event_follow_fork(struct trace_array *tr, bool enable) - - static void - event_filter_pid_sched_switch_probe_pre(void *data, bool preempt, -- struct task_struct *prev, struct task_struct *next) -+ unsigned int prev_state, -+ struct task_struct *prev, -+ struct task_struct *next) - { - struct trace_array *tr = data; - struct trace_pid_list *no_pid_list; -@@ -783,7 +785,9 @@ event_filter_pid_sched_switch_probe_pre(void *data, bool preempt, - - static void - event_filter_pid_sched_switch_probe_post(void *data, bool preempt, -- struct task_struct *prev, struct task_struct *next) -+ unsigned int prev_state, -+ struct task_struct *prev, -+ struct task_struct *next) - { - struct trace_array *tr = data; - struct trace_pid_list *no_pid_list; -diff --git a/kernel/trace/trace_osnoise.c b/kernel/trace/trace_osnoise.c -index 93de784ee681..c3bd968e6147 100644 ---- a/kernel/trace/trace_osnoise.c -+++ b/kernel/trace/trace_osnoise.c -@@ -1000,7 +1000,9 @@ thread_exit(struct osnoise_variables *osn_var, struct task_struct *t) - * used to record the beginning and to report the end of a thread noise window. - */ - static void --trace_sched_switch_callback(void *data, bool preempt, struct task_struct *p, -+trace_sched_switch_callback(void *data, bool preempt, -+ unsigned int prev_state, -+ struct task_struct *p, - struct task_struct *n) - { - struct osnoise_variables *osn_var = this_cpu_osn_var(); -diff --git a/kernel/trace/trace_sched_switch.c b/kernel/trace/trace_sched_switch.c -index e304196d7c28..993b0ed10d8c 100644 ---- a/kernel/trace/trace_sched_switch.c -+++ b/kernel/trace/trace_sched_switch.c -@@ -22,6 +22,7 @@ static DEFINE_MUTEX(sched_register_mutex); - - static void - probe_sched_switch(void *ignore, bool preempt, -+ unsigned int prev_state, - struct task_struct *prev, struct task_struct *next) - { - int flags; -diff --git a/kernel/trace/trace_sched_wakeup.c b/kernel/trace/trace_sched_wakeup.c -index 2402de520eca..46429f9a96fa 100644 ---- a/kernel/trace/trace_sched_wakeup.c -+++ b/kernel/trace/trace_sched_wakeup.c -@@ -426,6 +426,7 @@ tracing_sched_wakeup_trace(struct trace_array *tr, - - static void notrace - probe_wakeup_sched_switch(void *ignore, bool preempt, -+ unsigned int prev_state, - struct task_struct *prev, struct task_struct *next) - { - struct trace_array_cpu *data; --- -2.34.1 - diff --git a/queue-5.15/series b/queue-5.15/series index 7742ca1d9da..bf87ba66021 100644 --- a/queue-5.15/series +++ b/queue-5.15/series @@ -709,7 +709,6 @@ atomics-fix-atomic64_-read_acquire-set_release-fallb.patch locking-lockdep-iterate-lock_classes-directly-when-r.patch ext4-correct-cluster-len-and-clusters-changed-accoun.patch ext4-fix-ext4_mb_mark_bb-with-flex_bg-with-fast_comm.patch -sched-tracing-don-t-re-read-p-state-when-emitting-sc.patch sched-tracing-report-task_rtlock_wait-tasks-as-task_.patch ext4-don-t-bug-if-someone-dirty-pages-without-asking.patch f2fs-fix-to-do-sanity-check-on-curseg-alloc_type.patch diff --git a/queue-5.15/tracing-have-trace_define_enum-affect-trace-event-ty.patch b/queue-5.15/tracing-have-trace_define_enum-affect-trace-event-ty.patch index f8bd2d71b32..7efbe5b82a8 100644 --- a/queue-5.15/tracing-have-trace_define_enum-affect-trace-event-ty.patch +++ b/queue-5.15/tracing-have-trace_define_enum-affect-trace-event-ty.patch @@ -29,14 +29,12 @@ Tested-by: Ritesh Harjani Signed-off-by: Steven Rostedt (Google) Signed-off-by: Sasha Levin --- - kernel/trace/trace_events.c | 28 ++++++++++++++++++++++++++++ + kernel/trace/trace_events.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) -diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c -index dd17171829d6..b35a66a8e7ce 100644 --- a/kernel/trace/trace_events.c +++ b/kernel/trace/trace_events.c -@@ -2637,6 +2637,33 @@ static void update_event_printk(struct trace_event_call *call, +@@ -2633,6 +2633,33 @@ static void update_event_printk(struct t } } @@ -70,7 +68,7 @@ index dd17171829d6..b35a66a8e7ce 100644 void trace_event_eval_update(struct trace_eval_map **map, int len) { struct trace_event_call *call, *p; -@@ -2672,6 +2699,7 @@ void trace_event_eval_update(struct trace_eval_map **map, int len) +@@ -2668,6 +2695,7 @@ void trace_event_eval_update(struct trac first = false; } update_event_printk(call, map[i]); @@ -78,6 +76,3 @@ index dd17171829d6..b35a66a8e7ce 100644 } } } --- -2.34.1 - diff --git a/queue-5.15/tracing-have-type-enum-modifications-copy-the-strings.patch b/queue-5.15/tracing-have-type-enum-modifications-copy-the-strings.patch index 46acdff5a0e..328938dab67 100644 --- a/queue-5.15/tracing-have-type-enum-modifications-copy-the-strings.patch +++ b/queue-5.15/tracing-have-type-enum-modifications-copy-the-strings.patch @@ -62,7 +62,7 @@ Signed-off-by: Greg Kroah-Hartman #define GFP_TRACE (GFP_KERNEL | __GFP_ZERO) static struct kmem_cache *field_cachep; -@@ -2637,14 +2645,40 @@ static void update_event_printk(struct t +@@ -2633,14 +2641,40 @@ static void update_event_printk(struct t } } @@ -103,7 +103,7 @@ Signed-off-by: Greg Kroah-Hartman head = trace_get_fields(call); list_for_each_entry(field, head, link) { ptr = strchr(field->type, '['); -@@ -2658,9 +2692,26 @@ static void update_event_fields(struct t +@@ -2654,9 +2688,26 @@ static void update_event_fields(struct t if (strncmp(map->eval_string, ptr, len) != 0) continue; @@ -131,7 +131,7 @@ Signed-off-by: Greg Kroah-Hartman } } -@@ -2883,6 +2934,7 @@ static void trace_module_add_events(stru +@@ -2879,6 +2930,7 @@ static void trace_module_add_events(stru static void trace_module_remove_events(struct module *mod) { struct trace_event_call *call, *p; @@ -139,7 +139,7 @@ Signed-off-by: Greg Kroah-Hartman down_write(&trace_event_sem); list_for_each_entry_safe(call, p, &ftrace_events, list) { -@@ -2891,6 +2943,14 @@ static void trace_module_remove_events(s +@@ -2887,6 +2939,14 @@ static void trace_module_remove_events(s if (call->module == mod) __trace_remove_event_call(call); } diff --git a/queue-5.16/sched-tracing-don-t-re-read-p-state-when-emitting-sc.patch b/queue-5.16/sched-tracing-don-t-re-read-p-state-when-emitting-sc.patch deleted file mode 100644 index 044a2486db4..00000000000 --- a/queue-5.16/sched-tracing-don-t-re-read-p-state-when-emitting-sc.patch +++ /dev/null @@ -1,247 +0,0 @@ -From a1dc99beee5717d3ef92d4c21ddf8a6240e9ea6c Mon Sep 17 00:00:00 2001 -From: Sasha Levin -Date: Thu, 20 Jan 2022 16:25:19 +0000 -Subject: sched/tracing: Don't re-read p->state when emitting sched_switch - event - -From: Valentin Schneider - -[ Upstream commit fa2c3254d7cfff5f7a916ab928a562d1165f17bb ] - -As of commit - - c6e7bd7afaeb ("sched/core: Optimize ttwu() spinning on p->on_cpu") - -the following sequence becomes possible: - - p->__state = TASK_INTERRUPTIBLE; - __schedule() - deactivate_task(p); - ttwu() - READ !p->on_rq - p->__state=TASK_WAKING - trace_sched_switch() - __trace_sched_switch_state() - task_state_index() - return 0; - -TASK_WAKING isn't in TASK_REPORT, so the task appears as TASK_RUNNING in -the trace event. - -Prevent this by pushing the value read from __schedule() down the trace -event. - -Reported-by: Abhijeet Dharmapurikar -Signed-off-by: Valentin Schneider -Signed-off-by: Peter Zijlstra (Intel) -Reviewed-by: Steven Rostedt (Google) -Link: https://lore.kernel.org/r/20220120162520.570782-2-valentin.schneider@arm.com -Signed-off-by: Sasha Levin ---- - include/linux/sched.h | 11 ++++++++--- - include/trace/events/sched.h | 11 +++++++---- - kernel/sched/core.c | 4 ++-- - kernel/trace/fgraph.c | 4 +++- - kernel/trace/ftrace.c | 4 +++- - kernel/trace/trace_events.c | 8 ++++++-- - kernel/trace/trace_osnoise.c | 4 +++- - kernel/trace/trace_sched_switch.c | 1 + - kernel/trace/trace_sched_wakeup.c | 1 + - 9 files changed, 34 insertions(+), 14 deletions(-) - -diff --git a/include/linux/sched.h b/include/linux/sched.h -index ee5ed8821963..084de9b70a77 100644 ---- a/include/linux/sched.h -+++ b/include/linux/sched.h -@@ -1612,10 +1612,10 @@ static inline pid_t task_pgrp_nr(struct task_struct *tsk) - #define TASK_REPORT_IDLE (TASK_REPORT + 1) - #define TASK_REPORT_MAX (TASK_REPORT_IDLE << 1) - --static inline unsigned int task_state_index(struct task_struct *tsk) -+static inline unsigned int __task_state_index(unsigned int tsk_state, -+ unsigned int tsk_exit_state) - { -- unsigned int tsk_state = READ_ONCE(tsk->__state); -- unsigned int state = (tsk_state | tsk->exit_state) & TASK_REPORT; -+ unsigned int state = (tsk_state | tsk_exit_state) & TASK_REPORT; - - BUILD_BUG_ON_NOT_POWER_OF_2(TASK_REPORT_MAX); - -@@ -1625,6 +1625,11 @@ static inline unsigned int task_state_index(struct task_struct *tsk) - return fls(state); - } - -+static inline unsigned int task_state_index(struct task_struct *tsk) -+{ -+ return __task_state_index(READ_ONCE(tsk->__state), tsk->exit_state); -+} -+ - static inline char task_index_to_char(unsigned int state) - { - static const char state_char[] = "RSDTtXZPI"; -diff --git a/include/trace/events/sched.h b/include/trace/events/sched.h -index 94640482cfe7..65e786756321 100644 ---- a/include/trace/events/sched.h -+++ b/include/trace/events/sched.h -@@ -187,7 +187,9 @@ DEFINE_EVENT(sched_wakeup_template, sched_wakeup_new, - TP_ARGS(p)); - - #ifdef CREATE_TRACE_POINTS --static inline long __trace_sched_switch_state(bool preempt, struct task_struct *p) -+static inline long __trace_sched_switch_state(bool preempt, -+ unsigned int prev_state, -+ struct task_struct *p) - { - unsigned int state; - -@@ -208,7 +210,7 @@ static inline long __trace_sched_switch_state(bool preempt, struct task_struct * - * it for left shift operation to get the correct task->state - * mapping. - */ -- state = task_state_index(p); -+ state = __task_state_index(prev_state, p->exit_state); - - return state ? (1 << (state - 1)) : state; - } -@@ -220,10 +222,11 @@ static inline long __trace_sched_switch_state(bool preempt, struct task_struct * - TRACE_EVENT(sched_switch, - - TP_PROTO(bool preempt, -+ unsigned int prev_state, - struct task_struct *prev, - struct task_struct *next), - -- TP_ARGS(preempt, prev, next), -+ TP_ARGS(preempt, prev_state, prev, next), - - TP_STRUCT__entry( - __array( char, prev_comm, TASK_COMM_LEN ) -@@ -239,7 +242,7 @@ TRACE_EVENT(sched_switch, - memcpy(__entry->next_comm, next->comm, TASK_COMM_LEN); - __entry->prev_pid = prev->pid; - __entry->prev_prio = prev->prio; -- __entry->prev_state = __trace_sched_switch_state(preempt, prev); -+ __entry->prev_state = __trace_sched_switch_state(preempt, prev_state, prev); - memcpy(__entry->prev_comm, prev->comm, TASK_COMM_LEN); - __entry->next_pid = next->pid; - __entry->next_prio = next->prio; -diff --git a/kernel/sched/core.c b/kernel/sched/core.c -index 0e4b8214af31..527ee363db3f 100644 ---- a/kernel/sched/core.c -+++ b/kernel/sched/core.c -@@ -4821,7 +4821,7 @@ static struct rq *finish_task_switch(struct task_struct *prev) - { - struct rq *rq = this_rq(); - struct mm_struct *mm = rq->prev_mm; -- long prev_state; -+ unsigned int prev_state; - - /* - * The previous task will have left us with a preempt_count of 2 -@@ -6257,7 +6257,7 @@ static void __sched notrace __schedule(unsigned int sched_mode) - migrate_disable_switch(rq, prev); - psi_sched_switch(prev, next, !task_on_rq_queued(prev)); - -- trace_sched_switch(sched_mode & SM_MASK_PREEMPT, prev, next); -+ trace_sched_switch(sched_mode & SM_MASK_PREEMPT, prev_state, prev, next); - - /* Also unlocks the rq: */ - rq = context_switch(rq, prev, next, &rf); -diff --git a/kernel/trace/fgraph.c b/kernel/trace/fgraph.c -index 22061d38fc00..19028e072cdb 100644 ---- a/kernel/trace/fgraph.c -+++ b/kernel/trace/fgraph.c -@@ -415,7 +415,9 @@ static int alloc_retstack_tasklist(struct ftrace_ret_stack **ret_stack_list) - - static void - ftrace_graph_probe_sched_switch(void *ignore, bool preempt, -- struct task_struct *prev, struct task_struct *next) -+ unsigned int prev_state, -+ struct task_struct *prev, -+ struct task_struct *next) - { - unsigned long long timestamp; - int index; -diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c -index be5f6b32a012..bbfa4606cba6 100644 ---- a/kernel/trace/ftrace.c -+++ b/kernel/trace/ftrace.c -@@ -7317,7 +7317,9 @@ ftrace_func_t ftrace_ops_get_func(struct ftrace_ops *ops) - - static void - ftrace_filter_pid_sched_switch_probe(void *data, bool preempt, -- struct task_struct *prev, struct task_struct *next) -+ unsigned int prev_state, -+ struct task_struct *prev, -+ struct task_struct *next) - { - struct trace_array *tr = data; - struct trace_pid_list *pid_list; -diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c -index 92be9cb1d7d4..c097d89ca946 100644 ---- a/kernel/trace/trace_events.c -+++ b/kernel/trace/trace_events.c -@@ -759,7 +759,9 @@ void trace_event_follow_fork(struct trace_array *tr, bool enable) - - static void - event_filter_pid_sched_switch_probe_pre(void *data, bool preempt, -- struct task_struct *prev, struct task_struct *next) -+ unsigned int prev_state, -+ struct task_struct *prev, -+ struct task_struct *next) - { - struct trace_array *tr = data; - struct trace_pid_list *no_pid_list; -@@ -783,7 +785,9 @@ event_filter_pid_sched_switch_probe_pre(void *data, bool preempt, - - static void - event_filter_pid_sched_switch_probe_post(void *data, bool preempt, -- struct task_struct *prev, struct task_struct *next) -+ unsigned int prev_state, -+ struct task_struct *prev, -+ struct task_struct *next) - { - struct trace_array *tr = data; - struct trace_pid_list *no_pid_list; -diff --git a/kernel/trace/trace_osnoise.c b/kernel/trace/trace_osnoise.c -index b6da7bd2383d..b3b8060e8bdd 100644 ---- a/kernel/trace/trace_osnoise.c -+++ b/kernel/trace/trace_osnoise.c -@@ -1168,7 +1168,9 @@ thread_exit(struct osnoise_variables *osn_var, struct task_struct *t) - * used to record the beginning and to report the end of a thread noise window. - */ - static void --trace_sched_switch_callback(void *data, bool preempt, struct task_struct *p, -+trace_sched_switch_callback(void *data, bool preempt, -+ unsigned int prev_state, -+ struct task_struct *p, - struct task_struct *n) - { - struct osnoise_variables *osn_var = this_cpu_osn_var(); -diff --git a/kernel/trace/trace_sched_switch.c b/kernel/trace/trace_sched_switch.c -index e304196d7c28..993b0ed10d8c 100644 ---- a/kernel/trace/trace_sched_switch.c -+++ b/kernel/trace/trace_sched_switch.c -@@ -22,6 +22,7 @@ static DEFINE_MUTEX(sched_register_mutex); - - static void - probe_sched_switch(void *ignore, bool preempt, -+ unsigned int prev_state, - struct task_struct *prev, struct task_struct *next) - { - int flags; -diff --git a/kernel/trace/trace_sched_wakeup.c b/kernel/trace/trace_sched_wakeup.c -index 2402de520eca..46429f9a96fa 100644 ---- a/kernel/trace/trace_sched_wakeup.c -+++ b/kernel/trace/trace_sched_wakeup.c -@@ -426,6 +426,7 @@ tracing_sched_wakeup_trace(struct trace_array *tr, - - static void notrace - probe_wakeup_sched_switch(void *ignore, bool preempt, -+ unsigned int prev_state, - struct task_struct *prev, struct task_struct *next) - { - struct trace_array_cpu *data; --- -2.34.1 - diff --git a/queue-5.16/series b/queue-5.16/series index 5149abab9c4..b5ffc9cd520 100644 --- a/queue-5.16/series +++ b/queue-5.16/series @@ -784,7 +784,6 @@ atomics-fix-atomic64_-read_acquire-set_release-fallb.patch locking-lockdep-iterate-lock_classes-directly-when-r.patch ext4-correct-cluster-len-and-clusters-changed-accoun.patch ext4-fix-ext4_mb_mark_bb-with-flex_bg-with-fast_comm.patch -sched-tracing-don-t-re-read-p-state-when-emitting-sc.patch sched-tracing-report-task_rtlock_wait-tasks-as-task_.patch ext4-don-t-bug-if-someone-dirty-pages-without-asking.patch f2fs-fix-to-do-sanity-check-on-curseg-alloc_type.patch diff --git a/queue-5.16/tracing-have-trace_define_enum-affect-trace-event-ty.patch b/queue-5.16/tracing-have-trace_define_enum-affect-trace-event-ty.patch index b4715d604d2..f3df291acb4 100644 --- a/queue-5.16/tracing-have-trace_define_enum-affect-trace-event-ty.patch +++ b/queue-5.16/tracing-have-trace_define_enum-affect-trace-event-ty.patch @@ -29,14 +29,12 @@ Tested-by: Ritesh Harjani Signed-off-by: Steven Rostedt (Google) Signed-off-by: Sasha Levin --- - kernel/trace/trace_events.c | 28 ++++++++++++++++++++++++++++ + kernel/trace/trace_events.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) -diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c -index c097d89ca946..f809d795a9a8 100644 --- a/kernel/trace/trace_events.c +++ b/kernel/trace/trace_events.c -@@ -2637,6 +2637,33 @@ static void update_event_printk(struct trace_event_call *call, +@@ -2633,6 +2633,33 @@ static void update_event_printk(struct t } } @@ -70,7 +68,7 @@ index c097d89ca946..f809d795a9a8 100644 void trace_event_eval_update(struct trace_eval_map **map, int len) { struct trace_event_call *call, *p; -@@ -2672,6 +2699,7 @@ void trace_event_eval_update(struct trace_eval_map **map, int len) +@@ -2668,6 +2695,7 @@ void trace_event_eval_update(struct trac first = false; } update_event_printk(call, map[i]); @@ -78,6 +76,3 @@ index c097d89ca946..f809d795a9a8 100644 } } } --- -2.34.1 - diff --git a/queue-5.16/tracing-have-type-enum-modifications-copy-the-strings.patch b/queue-5.16/tracing-have-type-enum-modifications-copy-the-strings.patch index 96b917e9286..1619ce61449 100644 --- a/queue-5.16/tracing-have-type-enum-modifications-copy-the-strings.patch +++ b/queue-5.16/tracing-have-type-enum-modifications-copy-the-strings.patch @@ -62,7 +62,7 @@ Signed-off-by: Greg Kroah-Hartman #define GFP_TRACE (GFP_KERNEL | __GFP_ZERO) static struct kmem_cache *field_cachep; -@@ -2637,14 +2645,40 @@ static void update_event_printk(struct t +@@ -2633,14 +2641,40 @@ static void update_event_printk(struct t } } @@ -103,7 +103,7 @@ Signed-off-by: Greg Kroah-Hartman head = trace_get_fields(call); list_for_each_entry(field, head, link) { ptr = strchr(field->type, '['); -@@ -2658,9 +2692,26 @@ static void update_event_fields(struct t +@@ -2654,9 +2688,26 @@ static void update_event_fields(struct t if (strncmp(map->eval_string, ptr, len) != 0) continue; @@ -131,7 +131,7 @@ Signed-off-by: Greg Kroah-Hartman } } -@@ -2885,6 +2936,7 @@ static void trace_module_add_events(stru +@@ -2881,6 +2932,7 @@ static void trace_module_add_events(stru static void trace_module_remove_events(struct module *mod) { struct trace_event_call *call, *p; @@ -139,7 +139,7 @@ Signed-off-by: Greg Kroah-Hartman down_write(&trace_event_sem); list_for_each_entry_safe(call, p, &ftrace_events, list) { -@@ -2893,6 +2945,14 @@ static void trace_module_remove_events(s +@@ -2889,6 +2941,14 @@ static void trace_module_remove_events(s if (call->module == mod) __trace_remove_event_call(call); } diff --git a/queue-5.17/sched-tracing-don-t-re-read-p-state-when-emitting-sc.patch b/queue-5.17/sched-tracing-don-t-re-read-p-state-when-emitting-sc.patch deleted file mode 100644 index aa805dfb8d9..00000000000 --- a/queue-5.17/sched-tracing-don-t-re-read-p-state-when-emitting-sc.patch +++ /dev/null @@ -1,247 +0,0 @@ -From 535270b11943d367c3b2e10459733dba2b92d4b7 Mon Sep 17 00:00:00 2001 -From: Sasha Levin -Date: Thu, 20 Jan 2022 16:25:19 +0000 -Subject: sched/tracing: Don't re-read p->state when emitting sched_switch - event - -From: Valentin Schneider - -[ Upstream commit fa2c3254d7cfff5f7a916ab928a562d1165f17bb ] - -As of commit - - c6e7bd7afaeb ("sched/core: Optimize ttwu() spinning on p->on_cpu") - -the following sequence becomes possible: - - p->__state = TASK_INTERRUPTIBLE; - __schedule() - deactivate_task(p); - ttwu() - READ !p->on_rq - p->__state=TASK_WAKING - trace_sched_switch() - __trace_sched_switch_state() - task_state_index() - return 0; - -TASK_WAKING isn't in TASK_REPORT, so the task appears as TASK_RUNNING in -the trace event. - -Prevent this by pushing the value read from __schedule() down the trace -event. - -Reported-by: Abhijeet Dharmapurikar -Signed-off-by: Valentin Schneider -Signed-off-by: Peter Zijlstra (Intel) -Reviewed-by: Steven Rostedt (Google) -Link: https://lore.kernel.org/r/20220120162520.570782-2-valentin.schneider@arm.com -Signed-off-by: Sasha Levin ---- - include/linux/sched.h | 11 ++++++++--- - include/trace/events/sched.h | 11 +++++++---- - kernel/sched/core.c | 4 ++-- - kernel/trace/fgraph.c | 4 +++- - kernel/trace/ftrace.c | 4 +++- - kernel/trace/trace_events.c | 8 ++++++-- - kernel/trace/trace_osnoise.c | 4 +++- - kernel/trace/trace_sched_switch.c | 1 + - kernel/trace/trace_sched_wakeup.c | 1 + - 9 files changed, 34 insertions(+), 14 deletions(-) - -diff --git a/include/linux/sched.h b/include/linux/sched.h -index 75ba8aa60248..a76a178f8eb6 100644 ---- a/include/linux/sched.h -+++ b/include/linux/sched.h -@@ -1620,10 +1620,10 @@ static inline pid_t task_pgrp_nr(struct task_struct *tsk) - #define TASK_REPORT_IDLE (TASK_REPORT + 1) - #define TASK_REPORT_MAX (TASK_REPORT_IDLE << 1) - --static inline unsigned int task_state_index(struct task_struct *tsk) -+static inline unsigned int __task_state_index(unsigned int tsk_state, -+ unsigned int tsk_exit_state) - { -- unsigned int tsk_state = READ_ONCE(tsk->__state); -- unsigned int state = (tsk_state | tsk->exit_state) & TASK_REPORT; -+ unsigned int state = (tsk_state | tsk_exit_state) & TASK_REPORT; - - BUILD_BUG_ON_NOT_POWER_OF_2(TASK_REPORT_MAX); - -@@ -1633,6 +1633,11 @@ static inline unsigned int task_state_index(struct task_struct *tsk) - return fls(state); - } - -+static inline unsigned int task_state_index(struct task_struct *tsk) -+{ -+ return __task_state_index(READ_ONCE(tsk->__state), tsk->exit_state); -+} -+ - static inline char task_index_to_char(unsigned int state) - { - static const char state_char[] = "RSDTtXZPI"; -diff --git a/include/trace/events/sched.h b/include/trace/events/sched.h -index 94640482cfe7..65e786756321 100644 ---- a/include/trace/events/sched.h -+++ b/include/trace/events/sched.h -@@ -187,7 +187,9 @@ DEFINE_EVENT(sched_wakeup_template, sched_wakeup_new, - TP_ARGS(p)); - - #ifdef CREATE_TRACE_POINTS --static inline long __trace_sched_switch_state(bool preempt, struct task_struct *p) -+static inline long __trace_sched_switch_state(bool preempt, -+ unsigned int prev_state, -+ struct task_struct *p) - { - unsigned int state; - -@@ -208,7 +210,7 @@ static inline long __trace_sched_switch_state(bool preempt, struct task_struct * - * it for left shift operation to get the correct task->state - * mapping. - */ -- state = task_state_index(p); -+ state = __task_state_index(prev_state, p->exit_state); - - return state ? (1 << (state - 1)) : state; - } -@@ -220,10 +222,11 @@ static inline long __trace_sched_switch_state(bool preempt, struct task_struct * - TRACE_EVENT(sched_switch, - - TP_PROTO(bool preempt, -+ unsigned int prev_state, - struct task_struct *prev, - struct task_struct *next), - -- TP_ARGS(preempt, prev, next), -+ TP_ARGS(preempt, prev_state, prev, next), - - TP_STRUCT__entry( - __array( char, prev_comm, TASK_COMM_LEN ) -@@ -239,7 +242,7 @@ TRACE_EVENT(sched_switch, - memcpy(__entry->next_comm, next->comm, TASK_COMM_LEN); - __entry->prev_pid = prev->pid; - __entry->prev_prio = prev->prio; -- __entry->prev_state = __trace_sched_switch_state(preempt, prev); -+ __entry->prev_state = __trace_sched_switch_state(preempt, prev_state, prev); - memcpy(__entry->prev_comm, prev->comm, TASK_COMM_LEN); - __entry->next_pid = next->pid; - __entry->next_prio = next->prio; -diff --git a/kernel/sched/core.c b/kernel/sched/core.c -index 1620ae8535dc..98f81293bea8 100644 ---- a/kernel/sched/core.c -+++ b/kernel/sched/core.c -@@ -4835,7 +4835,7 @@ static struct rq *finish_task_switch(struct task_struct *prev) - { - struct rq *rq = this_rq(); - struct mm_struct *mm = rq->prev_mm; -- long prev_state; -+ unsigned int prev_state; - - /* - * The previous task will have left us with a preempt_count of 2 -@@ -6299,7 +6299,7 @@ static void __sched notrace __schedule(unsigned int sched_mode) - migrate_disable_switch(rq, prev); - psi_sched_switch(prev, next, !task_on_rq_queued(prev)); - -- trace_sched_switch(sched_mode & SM_MASK_PREEMPT, prev, next); -+ trace_sched_switch(sched_mode & SM_MASK_PREEMPT, prev_state, prev, next); - - /* Also unlocks the rq: */ - rq = context_switch(rq, prev, next, &rf); -diff --git a/kernel/trace/fgraph.c b/kernel/trace/fgraph.c -index 22061d38fc00..19028e072cdb 100644 ---- a/kernel/trace/fgraph.c -+++ b/kernel/trace/fgraph.c -@@ -415,7 +415,9 @@ static int alloc_retstack_tasklist(struct ftrace_ret_stack **ret_stack_list) - - static void - ftrace_graph_probe_sched_switch(void *ignore, bool preempt, -- struct task_struct *prev, struct task_struct *next) -+ unsigned int prev_state, -+ struct task_struct *prev, -+ struct task_struct *next) - { - unsigned long long timestamp; - int index; -diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c -index 6105b7036482..8b568f57cc24 100644 ---- a/kernel/trace/ftrace.c -+++ b/kernel/trace/ftrace.c -@@ -7346,7 +7346,9 @@ ftrace_func_t ftrace_ops_get_func(struct ftrace_ops *ops) - - static void - ftrace_filter_pid_sched_switch_probe(void *data, bool preempt, -- struct task_struct *prev, struct task_struct *next) -+ unsigned int prev_state, -+ struct task_struct *prev, -+ struct task_struct *next) - { - struct trace_array *tr = data; - struct trace_pid_list *pid_list; -diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c -index 3147614c1812..2a19ea747ff4 100644 ---- a/kernel/trace/trace_events.c -+++ b/kernel/trace/trace_events.c -@@ -759,7 +759,9 @@ void trace_event_follow_fork(struct trace_array *tr, bool enable) - - static void - event_filter_pid_sched_switch_probe_pre(void *data, bool preempt, -- struct task_struct *prev, struct task_struct *next) -+ unsigned int prev_state, -+ struct task_struct *prev, -+ struct task_struct *next) - { - struct trace_array *tr = data; - struct trace_pid_list *no_pid_list; -@@ -783,7 +785,9 @@ event_filter_pid_sched_switch_probe_pre(void *data, bool preempt, - - static void - event_filter_pid_sched_switch_probe_post(void *data, bool preempt, -- struct task_struct *prev, struct task_struct *next) -+ unsigned int prev_state, -+ struct task_struct *prev, -+ struct task_struct *next) - { - struct trace_array *tr = data; - struct trace_pid_list *no_pid_list; -diff --git a/kernel/trace/trace_osnoise.c b/kernel/trace/trace_osnoise.c -index 5e3c62a08fc0..e9ae1f33a7f0 100644 ---- a/kernel/trace/trace_osnoise.c -+++ b/kernel/trace/trace_osnoise.c -@@ -1167,7 +1167,9 @@ thread_exit(struct osnoise_variables *osn_var, struct task_struct *t) - * used to record the beginning and to report the end of a thread noise window. - */ - static void --trace_sched_switch_callback(void *data, bool preempt, struct task_struct *p, -+trace_sched_switch_callback(void *data, bool preempt, -+ unsigned int prev_state, -+ struct task_struct *p, - struct task_struct *n) - { - struct osnoise_variables *osn_var = this_cpu_osn_var(); -diff --git a/kernel/trace/trace_sched_switch.c b/kernel/trace/trace_sched_switch.c -index e304196d7c28..993b0ed10d8c 100644 ---- a/kernel/trace/trace_sched_switch.c -+++ b/kernel/trace/trace_sched_switch.c -@@ -22,6 +22,7 @@ static DEFINE_MUTEX(sched_register_mutex); - - static void - probe_sched_switch(void *ignore, bool preempt, -+ unsigned int prev_state, - struct task_struct *prev, struct task_struct *next) - { - int flags; -diff --git a/kernel/trace/trace_sched_wakeup.c b/kernel/trace/trace_sched_wakeup.c -index 2402de520eca..46429f9a96fa 100644 ---- a/kernel/trace/trace_sched_wakeup.c -+++ b/kernel/trace/trace_sched_wakeup.c -@@ -426,6 +426,7 @@ tracing_sched_wakeup_trace(struct trace_array *tr, - - static void notrace - probe_wakeup_sched_switch(void *ignore, bool preempt, -+ unsigned int prev_state, - struct task_struct *prev, struct task_struct *next) - { - struct trace_array_cpu *data; --- -2.34.1 - diff --git a/queue-5.17/series b/queue-5.17/series index a50a210e87f..60fd0617844 100644 --- a/queue-5.17/series +++ b/queue-5.17/series @@ -870,7 +870,6 @@ atomics-fix-atomic64_-read_acquire-set_release-fallb.patch locking-lockdep-iterate-lock_classes-directly-when-r.patch ext4-correct-cluster-len-and-clusters-changed-accoun.patch ext4-fix-ext4_mb_mark_bb-with-flex_bg-with-fast_comm.patch -sched-tracing-don-t-re-read-p-state-when-emitting-sc.patch sched-tracing-report-task_rtlock_wait-tasks-as-task_.patch ext4-don-t-bug-if-someone-dirty-pages-without-asking.patch f2fs-fix-to-do-sanity-check-on-curseg-alloc_type.patch diff --git a/queue-5.17/tracing-have-trace_define_enum-affect-trace-event-ty.patch b/queue-5.17/tracing-have-trace_define_enum-affect-trace-event-ty.patch index b686903f32a..6c674cea0e6 100644 --- a/queue-5.17/tracing-have-trace_define_enum-affect-trace-event-ty.patch +++ b/queue-5.17/tracing-have-trace_define_enum-affect-trace-event-ty.patch @@ -29,14 +29,12 @@ Tested-by: Ritesh Harjani Signed-off-by: Steven Rostedt (Google) Signed-off-by: Sasha Levin --- - kernel/trace/trace_events.c | 28 ++++++++++++++++++++++++++++ + kernel/trace/trace_events.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) -diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c -index 2a19ea747ff4..f382ac9597f2 100644 --- a/kernel/trace/trace_events.c +++ b/kernel/trace/trace_events.c -@@ -2637,6 +2637,33 @@ static void update_event_printk(struct trace_event_call *call, +@@ -2633,6 +2633,33 @@ static void update_event_printk(struct t } } @@ -70,7 +68,7 @@ index 2a19ea747ff4..f382ac9597f2 100644 void trace_event_eval_update(struct trace_eval_map **map, int len) { struct trace_event_call *call, *p; -@@ -2672,6 +2699,7 @@ void trace_event_eval_update(struct trace_eval_map **map, int len) +@@ -2668,6 +2695,7 @@ void trace_event_eval_update(struct trac first = false; } update_event_printk(call, map[i]); @@ -78,6 +76,3 @@ index 2a19ea747ff4..f382ac9597f2 100644 } } } --- -2.34.1 - diff --git a/queue-5.17/tracing-have-type-enum-modifications-copy-the-strings.patch b/queue-5.17/tracing-have-type-enum-modifications-copy-the-strings.patch index 96b917e9286..1619ce61449 100644 --- a/queue-5.17/tracing-have-type-enum-modifications-copy-the-strings.patch +++ b/queue-5.17/tracing-have-type-enum-modifications-copy-the-strings.patch @@ -62,7 +62,7 @@ Signed-off-by: Greg Kroah-Hartman #define GFP_TRACE (GFP_KERNEL | __GFP_ZERO) static struct kmem_cache *field_cachep; -@@ -2637,14 +2645,40 @@ static void update_event_printk(struct t +@@ -2633,14 +2641,40 @@ static void update_event_printk(struct t } } @@ -103,7 +103,7 @@ Signed-off-by: Greg Kroah-Hartman head = trace_get_fields(call); list_for_each_entry(field, head, link) { ptr = strchr(field->type, '['); -@@ -2658,9 +2692,26 @@ static void update_event_fields(struct t +@@ -2654,9 +2688,26 @@ static void update_event_fields(struct t if (strncmp(map->eval_string, ptr, len) != 0) continue; @@ -131,7 +131,7 @@ Signed-off-by: Greg Kroah-Hartman } } -@@ -2885,6 +2936,7 @@ static void trace_module_add_events(stru +@@ -2881,6 +2932,7 @@ static void trace_module_add_events(stru static void trace_module_remove_events(struct module *mod) { struct trace_event_call *call, *p; @@ -139,7 +139,7 @@ Signed-off-by: Greg Kroah-Hartman down_write(&trace_event_sem); list_for_each_entry_safe(call, p, &ftrace_events, list) { -@@ -2893,6 +2945,14 @@ static void trace_module_remove_events(s +@@ -2889,6 +2941,14 @@ static void trace_module_remove_events(s if (call->module == mod) __trace_remove_event_call(call); }