From: Andrea Righi <arighi@nvidia.com>
To: Changwoo Min <changwoo@igalia.com>
Cc: tj@kernel.org, void@manifault.com, kernel-dev@igalia.com,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] sched_ext: Fix incorrect time delta calculation in time_delta()
Date: Sun, 2 Feb 2025 07:37:13 +0100 [thread overview]
Message-ID: <Z58SmdNMlQiXt9fn@gpd3> (raw)
In-Reply-To: <20250202033748.359169-1-changwoo@igalia.com>
On Sun, Feb 02, 2025 at 12:37:48PM +0900, Changwoo Min wrote:
> When (s64)(after - before) > 0, the code returns the result of
> (s64)(after - before) > 0 while the intended result should be
> (s64)(after - before). That happens because the middle operand of
> the ternary operator was omitted incorrectly, returning the result of
> (s64)(after - before) > 0. Thus, add the middle operand
> -- (s64)(after - before) -- to return the corRECT time calculation.
>
> Fixes: d07be814fc71 ("sched_ext: Add time helpers for BPF schedulers")
> Signed-off-by: Changwoo Min <changwoo@igalia.com>
> ---
> tools/sched_ext/include/scx/common.bpf.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tools/sched_ext/include/scx/common.bpf.h b/tools/sched_ext/include/scx/common.bpf.h
> index f254a39b86a5..d72b60a0c582 100644
> --- a/tools/sched_ext/include/scx/common.bpf.h
> +++ b/tools/sched_ext/include/scx/common.bpf.h
> @@ -432,7 +432,7 @@ void bpf_rcu_read_unlock(void) __ksym;
> */
> static inline s64 time_delta(u64 after, u64 before)
> {
> - return (s64)(after - before) > 0 ? : 0;
> + return (s64)(after - before) > 0 ? (s64)(after - before) : 0;
Ugh.. how did we miss this? Thanks for noticing.
Acked-by: Andrea Righi <arighi@nvidia.com>
-Andrea
next prev parent reply other threads:[~2025-02-02 6:37 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-02 3:37 [PATCH] sched_ext: Fix incorrect time delta calculation in time_delta() Changwoo Min
2025-02-02 6:37 ` Andrea Righi [this message]
2025-02-02 17:42 ` Tejun Heo
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=Z58SmdNMlQiXt9fn@gpd3 \
--to=arighi@nvidia.com \
--cc=changwoo@igalia.com \
--cc=kernel-dev@igalia.com \
--cc=linux-kernel@vger.kernel.org \
--cc=tj@kernel.org \
--cc=void@manifault.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.