lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Z0-WIkfltRm9b3ZN@slm.duckdns.org>
Date: Tue, 3 Dec 2024 13:37:06 -1000
From: Tejun Heo <tj@...nel.org>
To: Changwoo Min <multics69@...il.com>
Cc: void@...ifault.com, mingo@...hat.com, peterz@...radead.org,
	changwoo@...lia.com, kernel-dev@...lia.com,
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH v3 3/5] sched_ext: Implement scx_bpf_clock_get_ns()

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?

> +	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?

> +	/*
> +	 * 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?

> +	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?

Thanks.

-- 
tejun

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ