Linux kernel -stable discussions
 help / color / mirror / Atom feed
From: Sudip Mukherjee <sudipm.mukherjee@gmail.com>
To: Sasha Levin <sashal@kernel.org>
Cc: Chris Redpath <Chris.Redpath@arm.com>,
	"stable@vger.kernel.org" <stable@vger.kernel.org>,
	nd <nd@arm.com>,
	"pkondeti@codeaurora.org" <pkondeti@codeaurora.org>,
	"rostedt@goodmis.org" <rostedt@goodmis.org>,
	Todd Kjos <tkjos@android.com>
Subject: Re: 4.14 stable missing 3054426dc68e "sched, trace: Fix prev_state output in sched_switch tracepoint"
Date: Mon, 18 Feb 2019 09:14:03 +0000	[thread overview]
Message-ID: <20190218091403.jgy6zi7klrijk6oq@debian> (raw)
In-Reply-To: <20190218020636.GT10616@sasha-vm>

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

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

[-- Attachment #2: 0001-sched-trace-Fix-prev_state-output-in-sched_switch-tr.patch --]
[-- Type: text/x-diff, Size: 2277 bytes --]

From f8c12fb36c1164fbd1ffaabd9898dfb2af1ee28a Mon Sep 17 00:00:00 2001
From: Pavankumar Kondeti <pkondeti@codeaurora.org>
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@codeaurora.org

Cc: stable@vger.kernel.org
Fixes: 3f5fe9fef5b2 ("sched/debug: Fix task state recording/printout")
Signed-off-by: Pavankumar Kondeti <pkondeti@codeaurora.org>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
Signed-off-by: Sudip Mukherjee <sudipm.mukherjee@gmail.com>
---
 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


  reply	other threads:[~2019-02-18  9:14 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-15 12:26 4.14 stable missing 3054426dc68e "sched, trace: Fix prev_state output in sched_switch tracepoint" Chris Redpath
2019-02-18  2:06 ` Sasha Levin
2019-02-18  9:14   ` Sudip Mukherjee [this message]
2019-02-18 12:19     ` Greg KH
2019-02-18 12:34       ` Chris Redpath

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190218091403.jgy6zi7klrijk6oq@debian \
    --to=sudipm.mukherjee@gmail.com \
    --cc=Chris.Redpath@arm.com \
    --cc=nd@arm.com \
    --cc=pkondeti@codeaurora.org \
    --cc=rostedt@goodmis.org \
    --cc=sashal@kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=tkjos@android.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox