[0/2] freezer,sched: do not restore saved_state of a thawed task

Message ID 20231120-freezer-state-multiple-thaws-v1-0-f2e1dd7ce5a2@quicinc.com
Headers
Series freezer,sched: do not restore saved_state of a thawed task |

Message

Elliot Berman Nov. 20, 2023, 5:36 p.m. UTC
  This series applies couple fixes to commit 8f0eed4a78a8 ("freezer,sched:
Use saved_state to reduce some spurious wakeups") which was found while
testing with legacy cgroup freezer. My original testing was only with
system-wide freezer. We found that thaw_task could be called on a task
which was already frozen. Prior to commit 8f0eed4a78a8 ("freezer,sched:
Use saved_state to reduce some spurious wakeups"), this wasn't an issue
as kernel would try to wake up TASK_FROZEN, which wouldn't match the
thawed task state, and no harm done to task. After commit 8f0eed4a78a8
("freezer,sched: Use saved_state to reduce some spurious wakeups"), it
was possible to overwrite the state of thawed task.

To: Rafael J. Wysocki <rafael@kernel.org>
To: Pavel Machek <pavel@ucw.cz>
To: Ingo Molnar <mingo@kernel.org>
To: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc:  <linux-arm-msm@vger.kernel.org>
Cc: Pavan Kondeti <quic_pkondeti@quicinc.com>
Cc: Aiqun Yu (Maria) <quic_aiquny@quicinc.com>
Cc:  <linux-pm@vger.kernel.org>
Cc:  <linux-kernel@vger.kernel.org>
Signed-off-by: Elliot Berman <quic_eberman@quicinc.com>

Originally sent to only linux-arm-msm, resending to correct authors.
- Link to v1: https://lore.kernel.org/r/20231120-freezer-state-multiple-thaws-v1-0-a4c453f50745@quicinc.com

---
Elliot Berman (2):
      freezer,sched: do not restore saved_state of a thawed task
      freezer,sched: clean saved_state when restoring it during thaw

 kernel/freezer.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
---
base-commit: 6d7e4782bcf549221b4ccfffec2cf4d1a473f1a3
change-id: 20231108-freezer-state-multiple-thaws-7a3a8d9dadb3

Best regards,
  

Comments

Aiqun Yu (Maria) Nov. 28, 2023, 9:12 a.m. UTC | #1
On 11/21/2023 1:36 AM, Elliot Berman wrote:
> This series applies couple fixes to commit 8f0eed4a78a8 ("freezer,sched:
> Use saved_state to reduce some spurious wakeups") which was found while
> testing with legacy cgroup freezer. My original testing was only with
> system-wide freezer. We found that thaw_task could be called on a task
> which was already frozen. Prior to commit 8f0eed4a78a8 ("freezer,sched:
> Use saved_state to reduce some spurious wakeups"), this wasn't an issue
> as kernel would try to wake up TASK_FROZEN, which wouldn't match the
> thawed task state, and no harm done to task. After commit 8f0eed4a78a8
> ("freezer,sched: Use saved_state to reduce some spurious wakeups"), it
> was possible to overwrite the state of thawed task.
> 
> To: Rafael J. Wysocki <rafael@kernel.org>
> To: Pavel Machek <pavel@ucw.cz>
> To: Ingo Molnar <mingo@kernel.org>
> To: Peter Zijlstra (Intel) <peterz@infradead.org>
> Cc:  <linux-arm-msm@vger.kernel.org>
> Cc: Pavan Kondeti <quic_pkondeti@quicinc.com>
> Cc: Aiqun Yu (Maria) <quic_aiquny@quicinc.com>
> Cc:  <linux-pm@vger.kernel.org>
> Cc:  <linux-kernel@vger.kernel.org>
> Signed-off-by: Elliot Berman <quic_eberman@quicinc.com>
Shall we add Fixed tag and Cc: stable@vger.kernel.org ?
Since it is fixing a stable user thread hung issue.
> 
> Originally sent to only linux-arm-msm, resending to correct authors.
> - Link to v1: https://lore.kernel.org/r/20231120-freezer-state-multiple-thaws-v1-0-a4c453f50745@quicinc.com
> 
> ---
> Elliot Berman (2):
>        freezer,sched: do not restore saved_state of a thawed task
>        freezer,sched: clean saved_state when restoring it during thaw
> 
>   kernel/freezer.c | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
> ---
> base-commit: 6d7e4782bcf549221b4ccfffec2cf4d1a473f1a3
> change-id: 20231108-freezer-state-multiple-thaws-7a3a8d9dadb3
> 
> Best regards,
  
Peter Zijlstra Nov. 28, 2023, 5:31 p.m. UTC | #2
On Tue, Nov 28, 2023 at 05:12:00PM +0800, Aiqun(Maria) Yu wrote:
> On 11/21/2023 1:36 AM, Elliot Berman wrote:
> > This series applies couple fixes to commit 8f0eed4a78a8 ("freezer,sched:
> > Use saved_state to reduce some spurious wakeups") which was found while
> > testing with legacy cgroup freezer. My original testing was only with
> > system-wide freezer. We found that thaw_task could be called on a task
> > which was already frozen. Prior to commit 8f0eed4a78a8 ("freezer,sched:
> > Use saved_state to reduce some spurious wakeups"), this wasn't an issue
> > as kernel would try to wake up TASK_FROZEN, which wouldn't match the
> > thawed task state, and no harm done to task. After commit 8f0eed4a78a8
> > ("freezer,sched: Use saved_state to reduce some spurious wakeups"), it
> > was possible to overwrite the state of thawed task.
> > 
> > To: Rafael J. Wysocki <rafael@kernel.org>
> > To: Pavel Machek <pavel@ucw.cz>
> > To: Ingo Molnar <mingo@kernel.org>
> > To: Peter Zijlstra (Intel) <peterz@infradead.org>
> > Cc:  <linux-arm-msm@vger.kernel.org>
> > Cc: Pavan Kondeti <quic_pkondeti@quicinc.com>
> > Cc: Aiqun Yu (Maria) <quic_aiquny@quicinc.com>
> > Cc:  <linux-pm@vger.kernel.org>
> > Cc:  <linux-kernel@vger.kernel.org>
> > Signed-off-by: Elliot Berman <quic_eberman@quicinc.com>
> Shall we add Fixed tag and Cc: stable@vger.kernel.org ?
> Since it is fixing a stable user thread hung issue.

If you want this routed through urgent, then yes.
  
Elliot Berman Nov. 28, 2023, 5:33 p.m. UTC | #3
On 11/28/2023 11:31 AM, Peter Zijlstra wrote:
> On Tue, Nov 28, 2023 at 05:12:00PM +0800, Aiqun(Maria) Yu wrote:
>> On 11/21/2023 1:36 AM, Elliot Berman wrote:
>>> This series applies couple fixes to commit 8f0eed4a78a8 ("freezer,sched:
>>> Use saved_state to reduce some spurious wakeups") which was found while
>>> testing with legacy cgroup freezer. My original testing was only with
>>> system-wide freezer. We found that thaw_task could be called on a task
>>> which was already frozen. Prior to commit 8f0eed4a78a8 ("freezer,sched:
>>> Use saved_state to reduce some spurious wakeups"), this wasn't an issue
>>> as kernel would try to wake up TASK_FROZEN, which wouldn't match the
>>> thawed task state, and no harm done to task. After commit 8f0eed4a78a8
>>> ("freezer,sched: Use saved_state to reduce some spurious wakeups"), it
>>> was possible to overwrite the state of thawed task.
>>>
>>> To: Rafael J. Wysocki <rafael@kernel.org>
>>> To: Pavel Machek <pavel@ucw.cz>
>>> To: Ingo Molnar <mingo@kernel.org>
>>> To: Peter Zijlstra (Intel) <peterz@infradead.org>
>>> Cc:  <linux-arm-msm@vger.kernel.org>
>>> Cc: Pavan Kondeti <quic_pkondeti@quicinc.com>
>>> Cc: Aiqun Yu (Maria) <quic_aiquny@quicinc.com>
>>> Cc:  <linux-pm@vger.kernel.org>
>>> Cc:  <linux-kernel@vger.kernel.org>
>>> Signed-off-by: Elliot Berman <quic_eberman@quicinc.com>
>> Shall we add Fixed tag and Cc: stable@vger.kernel.org ?
>> Since it is fixing a stable user thread hung issue.
> 
> If you want this routed through urgent, then yes.

Fixes tag is added to https://lore.kernel.org/all/20231120-freezer-state-multiple-thaws-v1-1-f2e1dd7ce5a2@quicinc.com/

Is CC'ing stable what triggers routing through urgent?

Thanks,
Elliot
  
Peter Zijlstra Nov. 28, 2023, 5:54 p.m. UTC | #4
On Tue, Nov 28, 2023 at 11:33:23AM -0600, Elliot Berman wrote:
> 
> 
> On 11/28/2023 11:31 AM, Peter Zijlstra wrote:
> > On Tue, Nov 28, 2023 at 05:12:00PM +0800, Aiqun(Maria) Yu wrote:
> >> On 11/21/2023 1:36 AM, Elliot Berman wrote:
> >>> This series applies couple fixes to commit 8f0eed4a78a8 ("freezer,sched:
> >>> Use saved_state to reduce some spurious wakeups") which was found while
> >>> testing with legacy cgroup freezer. My original testing was only with
> >>> system-wide freezer. We found that thaw_task could be called on a task
> >>> which was already frozen. Prior to commit 8f0eed4a78a8 ("freezer,sched:
> >>> Use saved_state to reduce some spurious wakeups"), this wasn't an issue
> >>> as kernel would try to wake up TASK_FROZEN, which wouldn't match the
> >>> thawed task state, and no harm done to task. After commit 8f0eed4a78a8
> >>> ("freezer,sched: Use saved_state to reduce some spurious wakeups"), it
> >>> was possible to overwrite the state of thawed task.
> >>>
> >>> To: Rafael J. Wysocki <rafael@kernel.org>
> >>> To: Pavel Machek <pavel@ucw.cz>
> >>> To: Ingo Molnar <mingo@kernel.org>
> >>> To: Peter Zijlstra (Intel) <peterz@infradead.org>
> >>> Cc:  <linux-arm-msm@vger.kernel.org>
> >>> Cc: Pavan Kondeti <quic_pkondeti@quicinc.com>
> >>> Cc: Aiqun Yu (Maria) <quic_aiquny@quicinc.com>
> >>> Cc:  <linux-pm@vger.kernel.org>
> >>> Cc:  <linux-kernel@vger.kernel.org>
> >>> Signed-off-by: Elliot Berman <quic_eberman@quicinc.com>
> >> Shall we add Fixed tag and Cc: stable@vger.kernel.org ?
> >> Since it is fixing a stable user thread hung issue.
> > 
> > If you want this routed through urgent, then yes.
> 
> Fixes tag is added to https://lore.kernel.org/all/20231120-freezer-state-multiple-thaws-v1-1-f2e1dd7ce5a2@quicinc.com/
> 
> Is CC'ing stable what triggers routing through urgent?

Fixes tag should be enough, lemme go find that other copy then.. so much
email :/