Re: 4.14 stable missing 3054426dc68e "sched, trace: Fix prev_state output in sched_switch tracepoint"

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Sasha,

On Sun, Feb 17, 2019 at 09:06:36PM -0500, Sasha Levin wrote:
> On Fri, Feb 15, 2019 at 12:26:35PM +0000, Chris Redpath wrote:
> > Hi Greg et al.
> > 
> > A user of android-4.14 has pointed the following missing commit out.
> > 
> > Commit 3054426dc68e ("sched, trace: Fix prev_state output in sched_switch tracepoint") was put into linux-4.20 around rc5 to fix an issue in a tracepoint. According to the patch itself, the broken commit was 3f5fe9fef5b2 ("sched/debug: Fix task state recording/printout") which was merged at what looks like 4.15-rc2. The broken commit was also picked for 4.14.64 as 13f12749af15 ("sched/debug: Fix task state recording/printout"). The fix (3054426dc68e) was pulled into 4.19. but was not called out as needing to go back to 4.14.
> > 
> > Is it possible to pick 3054426dc68e ("sched, trace: Fix prev_state output in sched_switch tracepoint") for the next stable 4.14 release? If not I can do a backport for android-4.14, just let me know.
> 
> It wasn't backported because it didn't apply cleanly, since 4.4's
> backport of 3f5fe9fef5b2 differs from Linus's tree.
> 
> The backport for that commit was done by Sudip (Cc'ed). I'll be happy to
> take a backport of 3054426dc68e if someone sense one my way.

Happy to do a backport for 4.14-stable. :)

It did not apply before as the function was only renamed by:
1d48b080bcce ("sched/debug: Rename task-state printing helpers")

There was no other functionality change.


--
Regards
Sudip
>From f8c12fb36c1164fbd1ffaabd9898dfb2af1ee28a Mon Sep 17 00:00:00 2001
From: Pavankumar Kondeti <pkondeti@xxxxxxxxxxxxxx>
Date: Tue, 30 Oct 2018 12:24:33 +0530
Subject: [PATCH] sched, trace: Fix prev_state output in sched_switch tracepoint

commit 3054426dc68e5d63aa6a6e9b91ac4ec78e3f3805 upstream

commit 3f5fe9fef5b2 ("sched/debug: Fix task state recording/printout")
tried to fix the problem introduced by a previous commit efb40f588b43
("sched/tracing: Fix trace_sched_switch task-state printing"). However
the prev_state output in sched_switch is still broken.

task_state_index() uses fls() which considers the LSB as 1. Left
shifting 1 by this value gives an incorrect mapping to the task state.
Fix this by decrementing the value returned by __get_task_state()
before shifting.

Link: http://lkml.kernel.org/r/1540882473-1103-1-git-send-email-pkondeti@xxxxxxxxxxxxxx

Cc: stable@xxxxxxxxxxxxxxx
Fixes: 3f5fe9fef5b2 ("sched/debug: Fix task state recording/printout")
Signed-off-by: Pavankumar Kondeti <pkondeti@xxxxxxxxxxxxxx>
Signed-off-by: Steven Rostedt (VMware) <rostedt@xxxxxxxxxxx>
Signed-off-by: Sudip Mukherjee <sudipm.mukherjee@xxxxxxxxx>
---
 include/trace/events/sched.h | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/include/trace/events/sched.h b/include/trace/events/sched.h
index 0812cd5408c9..6e692a52936c 100644
--- a/include/trace/events/sched.h
+++ b/include/trace/events/sched.h
@@ -107,6 +107,8 @@ DEFINE_EVENT(sched_wakeup_template, sched_wakeup_new,
 #ifdef CREATE_TRACE_POINTS
 static inline long __trace_sched_switch_state(bool preempt, struct task_struct *p)
 {
+	unsigned int state;
+
 #ifdef CONFIG_SCHED_DEBUG
 	BUG_ON(p != current);
 #endif /* CONFIG_SCHED_DEBUG */
@@ -118,7 +120,15 @@ static inline long __trace_sched_switch_state(bool preempt, struct task_struct *
 	if (preempt)
 		return TASK_REPORT_MAX;
 
-	return 1 << __get_task_state(p);
+	/*
+	 * task_state_index() uses fls() and returns a value from 0-8 range.
+	 * Decrement it by 1 (except TASK_RUNNING state i.e 0) before using
+	 * it for left shift operation to get the correct task->state
+	 * mapping.
+	 */
+	state = __get_task_state(p);
+
+	return state ? (1 << (state - 1)) : state;
 }
 #endif /* CREATE_TRACE_POINTS */
 
-- 
2.11.0


[Index of Archives]     [Linux Kernel]     [Kernel Development Newbies]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux