From: Juri Lelli <juri.lelli@redhat.com>
To: Wander Lairson Costa <wander@redhat.com>
Cc: Ingo Molnar <mingo@redhat.com>,
Peter Zijlstra <peterz@infradead.org>,
Vincent Guittot <vincent.guittot@linaro.org>,
Dietmar Eggemann <dietmar.eggemann@arm.com>,
Steven Rostedt <rostedt@goodmis.org>,
Ben Segall <bsegall@google.com>, Mel Gorman <mgorman@suse.de>,
Valentin Schneider <vschneid@redhat.com>,
"open list:SCHEDULER" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 3/3] sched/deadline: Consolidate Timer Cancellation
Date: Tue, 23 Jul 2024 11:15:37 +0200 [thread overview]
Message-ID: <Zp90uZSUPkLmluEo@jlelli-thinkpadt14gen4.remote.csb> (raw)
In-Reply-To: <20240722132935.14426-4-wander@redhat.com>
Hi Wander,
Guess this might help yes, only a minor naming suggestion below.
On 22/07/24 10:29, Wander Lairson Costa wrote:
> After commit b58652db66c9 ("sched/deadline: Fix task_struct reference
> leak"), I identified additional calls to hrtimer_try_to_cancel that
> might also require a dl_server check. It remains unclear whether this
> omission was intentional or accidental in those contexts.
>
> This patch consolidates the timer cancellation logic into dedicated
> functions, ensuring consistent behavior across all calls.
> Additionally, it reduces code duplication and improves overall code
> cleanliness.
>
> Note the use of the __always_inline keyword. In some instances, we
> have a task_struct pointer, dereference the dl member, and then use
> the container_of macro to retrieve the task_struct pointer again. By
> inlining the code, the compiler can potentially optimize out this
> redundant round trip.
>
> Signed-off-by: Wander Lairson Costa <wander@redhat.com>
> ---
> kernel/sched/deadline.c | 44 ++++++++++++++++++++++++++---------------
> 1 file changed, 28 insertions(+), 16 deletions(-)
>
> diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c
> index 908d5ce79425..8b0bbade2dcb 100644
> --- a/kernel/sched/deadline.c
> +++ b/kernel/sched/deadline.c
> @@ -320,6 +320,29 @@ void sub_running_bw(struct sched_dl_entity *dl_se, struct dl_rq *dl_rq)
> __sub_running_bw(dl_se->dl_bw, dl_rq);
> }
>
> +static __always_inline
> +void cancel_timer(struct sched_dl_entity *dl_se, struct hrtimer *timer)
> +{
> + /*
> + * If the timer callback was running (hrtimer_try_to_cancel == -1),
> + * it will eventually call put_task_struct().
> + */
> + if (hrtimer_try_to_cancel(timer) == 1 && !dl_server(dl_se))
> + put_task_struct(dl_task_of(dl_se));
> +}
> +
> +static __always_inline
> +void cancel_dl_timer(struct sched_dl_entity *dl_se)
Maybe we could call the above cancel_replenish_timer
> +{
> + cancel_timer(dl_se, &dl_se->dl_timer);
and this one cancel_dl_timer?
Best,
Juri
next prev parent reply other threads:[~2024-07-23 9:15 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-22 13:29 [PATCH 0/3] sched/deadline: fixes and improvements Wander Lairson Costa
2024-07-22 13:29 ` [PATCH 1/3] sched/deadline: Fix warning in migrate_enable for boosted tasks Wander Lairson Costa
2024-07-23 8:50 ` Juri Lelli
2024-07-23 12:28 ` Wander Lairson Costa
2024-07-22 13:29 ` [PATCH 2/3] sched/deadline: avoid redundant check for boosted task Wander Lairson Costa
2024-07-23 8:55 ` Juri Lelli
2024-07-23 12:27 ` Wander Lairson Costa
2024-07-23 14:42 ` Juri Lelli
2024-07-22 13:29 ` [PATCH 3/3] sched/deadline: Consolidate Timer Cancellation Wander Lairson Costa
2024-07-23 9:15 ` Juri Lelli [this message]
2024-07-23 12:33 ` Wander Lairson Costa
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=Zp90uZSUPkLmluEo@jlelli-thinkpadt14gen4.remote.csb \
--to=juri.lelli@redhat.com \
--cc=bsegall@google.com \
--cc=dietmar.eggemann@arm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mgorman@suse.de \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=vincent.guittot@linaro.org \
--cc=vschneid@redhat.com \
--cc=wander@redhat.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
all inboxes | Powered by JetHome®