[RFC,v3,31/33] timers: sched/psi: Use timer_shutdown_sync() before freeing timer

Message ID 20221104054917.543373979@goodmis.org
State New
Headers
Series timers: Use timer_shutdown*() before freeing timers |

Commit Message

Steven Rostedt Nov. 4, 2022, 5:41 a.m. UTC
  From: "Steven Rostedt (Google)" <rostedt@goodmis.org>

Before a timer is freed, timer_shutdown_sync() must be called.

Link: https://lore.kernel.org/all/20220407161745.7d6754b3@gandalf.local.home/

Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Suren Baghdasaryan <surenb@google.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Juri Lelli <juri.lelli@redhat.com>
Cc: Vincent Guittot <vincent.guittot@linaro.org>
Cc: Dietmar Eggemann <dietmar.eggemann@arm.com>
Cc: Ben Segall <bsegall@google.com>
Cc: Mel Gorman <mgorman@suse.de>
Cc: Daniel Bristot de Oliveira <bristot@redhat.com>
Cc: Valentin Schneider <vschneid@redhat.com>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
---
 kernel/sched/psi.c | 1 +
 1 file changed, 1 insertion(+)
  

Comments

Johannes Weiner Nov. 4, 2022, 8:11 p.m. UTC | #1
On Fri, Nov 04, 2022 at 01:41:24AM -0400, Steven Rostedt wrote:
> From: "Steven Rostedt (Google)" <rostedt@goodmis.org>
> 
> Before a timer is freed, timer_shutdown_sync() must be called.
> 
> Link: https://lore.kernel.org/all/20220407161745.7d6754b3@gandalf.local.home/
> 
> Cc: Johannes Weiner <hannes@cmpxchg.org>
> Cc: Suren Baghdasaryan <surenb@google.com>
> Cc: Ingo Molnar <mingo@redhat.com>
> Cc: Peter Zijlstra <peterz@infradead.org>
> Cc: Juri Lelli <juri.lelli@redhat.com>
> Cc: Vincent Guittot <vincent.guittot@linaro.org>
> Cc: Dietmar Eggemann <dietmar.eggemann@arm.com>
> Cc: Ben Segall <bsegall@google.com>
> Cc: Mel Gorman <mgorman@suse.de>
> Cc: Daniel Bristot de Oliveira <bristot@redhat.com>
> Cc: Valentin Schneider <vschneid@redhat.com>
> Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>

Acked-by: Johannes Weiner <hannes@cmpxchg.org>
  
Suren Baghdasaryan Nov. 4, 2022, 8:29 p.m. UTC | #2
On Fri, Nov 4, 2022 at 1:11 PM Johannes Weiner <hannes@cmpxchg.org> wrote:
>
> On Fri, Nov 04, 2022 at 01:41:24AM -0400, Steven Rostedt wrote:
> > From: "Steven Rostedt (Google)" <rostedt@goodmis.org>
> >
> > Before a timer is freed, timer_shutdown_sync() must be called.
> >
> > Link: https://lore.kernel.org/all/20220407161745.7d6754b3@gandalf.local.home/
> >
> > Cc: Johannes Weiner <hannes@cmpxchg.org>
> > Cc: Suren Baghdasaryan <surenb@google.com>
> > Cc: Ingo Molnar <mingo@redhat.com>
> > Cc: Peter Zijlstra <peterz@infradead.org>
> > Cc: Juri Lelli <juri.lelli@redhat.com>
> > Cc: Vincent Guittot <vincent.guittot@linaro.org>
> > Cc: Dietmar Eggemann <dietmar.eggemann@arm.com>
> > Cc: Ben Segall <bsegall@google.com>
> > Cc: Mel Gorman <mgorman@suse.de>
> > Cc: Daniel Bristot de Oliveira <bristot@redhat.com>
> > Cc: Valentin Schneider <vschneid@redhat.com>
> > Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
>
> Acked-by: Johannes Weiner <hannes@cmpxchg.org>

Assuming the whole patchset makes it through the reviews, this part LGTM.

Reviewed-by: Suren Baghdasaryan <surenb@google.com>
  

Patch

diff --git a/kernel/sched/psi.c b/kernel/sched/psi.c
index ee2ecc081422..f5f2613c4292 100644
--- a/kernel/sched/psi.c
+++ b/kernel/sched/psi.c
@@ -1033,6 +1033,7 @@  void psi_cgroup_free(struct cgroup *cgroup)
 
 	cancel_delayed_work_sync(&cgroup->psi->avgs_work);
 	free_percpu(cgroup->psi->pcpu);
+	timer_shutdown_sync(&cgroup->psi->poll_timer);
 	/* All triggers must be removed by now */
 	WARN_ONCE(cgroup->psi->poll_states, "psi: trigger leak\n");
 	kfree(cgroup->psi);