mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Changwoo Min <changwoo@igalia.com>
To: Tejun Heo <tj@kernel.org>
Cc: void@manifault.com, mingo@redhat.com, peterz@infradead.org,
	kernel-dev@igalia.com, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3 3/5] sched_ext: Implement scx_bpf_clock_get_ns()
Date: Wed, 4 Dec 2024 14:17:20 +0900	[thread overview]
Message-ID: <51eb6162-ebbf-4fbd-8422-f21ebf9726f7@igalia.com> (raw)
In-Reply-To: <Z0-WIkfltRm9b3ZN@slm.duckdns.org>

Hello,


On 24. 12. 4. 08:37, Tejun Heo wrote:
> Hello,
> 
> On Tue, Dec 03, 2024 at 11:28:00PM +0900, Changwoo Min wrote:
>> +__bpf_kfunc u64 scx_bpf_clock_get_ns(void)
>> +{
>> +	static DEFINE_PER_CPU(u64, prev_clk);
>> +	struct rq *rq = this_rq();
> 
> this_rq() is this_cpu_ptr(). Shouldn't this be below preempt_disable() if
> this function is allowed to be called from sleepable ops?

Thanks for pointing that out. You are right. I will change it in
the next version.

> 
>> +	u64 pr_clk, cr_clk;
>> +
>> +	preempt_disable();
>> +	pr_clk = __this_cpu_read(prev_clk);
> 
> Would it make sense to make the above rq->scx.prev_clk?

That will also work. I will change it as suggested in the next
version.

> 
>> +	/*
>> +	 * If the rq clock is invalid, start a new rq clock period
>> +	 * with a fresh sched_clock().
>> +	 */
>> +	if (!(rq->scx.flags & SCX_RQ_CLK_VALID)) {
>> +		cr_clk = sched_clock();
>> +		scx_rq_clock_update(rq, cr_clk);
>> +	}
>> +	/*
>> +	 * If the rq clock is valid, use the cached rq clock
>> +	 * whenever the clock does not go backward.
>> +	 */
> 
> Can you move the comments inside the if/else bodies so that "} else {" can
> stay on the same line?

Sure.

> 
>> +	else {
>> +		cr_clk = rq->scx.clock;
>> +		/*
>> +		 * If the clock goes backward, start a new rq clock period
>> +		 * with a fresh sched_clock().
>> +		 */
> 
> Can you please add comment explaining how this can happen?

Sure, I will add the explanation in the next version.


Thanks!
Changwoo Min

  reply	other threads:[~2024-12-04  5:17 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-03 14:27 [PATCH v3 0/5] sched_ext: Support high-performance monotonically non-decreasing clock Changwoo Min
2024-12-03 14:27 ` [PATCH v3 1/5] sched_ext: Implement scx_rq_clock_update/stale() Changwoo Min
2024-12-03 23:23   ` Tejun Heo
2024-12-04  1:28     ` Changwoo Min
2024-12-03 14:27 ` [PATCH v3 2/5] sched_ext: Manage the validity of scx_rq_clock Changwoo Min
2024-12-03 23:26   ` Tejun Heo
2024-12-04  1:42     ` Changwoo Min
2024-12-04 18:46       ` Tejun Heo
2024-12-06  1:50         ` Changwoo Min
2024-12-03 14:28 ` [PATCH v3 3/5] sched_ext: Implement scx_bpf_clock_get_ns() Changwoo Min
2024-12-03 23:37   ` Tejun Heo
2024-12-04  5:17     ` Changwoo Min [this message]
2024-12-03 14:28 ` [PATCH v3 4/5] sched_ext: Add scx_bpf_clock_get_ns() for BPF scheduler Changwoo Min
2024-12-03 14:28 ` [PATCH v3 5/5] sched_ext: Replace bpf_ktime_get_ns() to scx_bpf_clock_get_ns() Changwoo Min
2024-12-03 23:40   ` Tejun Heo
2024-12-04  5:41     ` Changwoo Min

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=51eb6162-ebbf-4fbd-8422-f21ebf9726f7@igalia.com \
    --to=changwoo@igalia.com \
    --cc=kernel-dev@igalia.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.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 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®