From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 52A222C187 for ; Tue, 7 Jan 2025 19:46:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736279209; cv=none; b=jDOf0FpHgcMl4a0kXtgbhXYsSpkykah6zzwQFdtdZIzMK+IpIvksn2vyPdjKaMun15i9hwXTZyflMVFPaNViCT2NYd7P3peWWIiz8EJEk3PViQyc6z2DWuKYQnVGxwTG/epqr4nwGsZSV/1T7FFGdvp1WAeIxcbWy6D3b3YYQQ0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736279209; c=relaxed/simple; bh=PKkfi/pyakUTf87p5SRyUDmmPZlenoWDcFMlF35yTBs=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=INJrLGqVIVlO8nDg4sXUyhfDTUFbihItdoo4sDEXjBt4n/pT+11PBM+AMulcvz4u2akF1eR75homVli4qhLElLcEOeierlsrT/EF4mPjb4Dfhkjq/AjqIrf2TuGiOesmkLFZ279iv+hbO5IjdJkwVmmXP3c1pMBz4m7AXzEIlXY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Xqv3scf1; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Xqv3scf1" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 18278C4CEDD; Tue, 7 Jan 2025 19:46:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1736279209; bh=PKkfi/pyakUTf87p5SRyUDmmPZlenoWDcFMlF35yTBs=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Xqv3scf1yM42Ruj9Mnl6DGkMRi45iF/w+n2A5s8MzWIjxGJtBW9DONc3UemJMvtZK U6XzZAtKNF5vPty7jqU/JPx1XzBH4oPD0sl+SVMkewBlgkn5erZtz3t5aQoDMRQCQu cTXYyp5zwnNilIDnjhAVzt8yDBc3dIPm32ADIcdqibUTBLj4q/zCAT6ns0gEzw0Ytz GKWFKPuR242aEU320QYolDH76GFNnYIxkzi6NOQSjGKOQi5jQPjzt1IPBJXLRro2NE ZVAWYok5lZDVT6iAU83Qzol3kzL/+NOJ8+CBADEdWBtjLZaj9QvX2RirpXZjTWnGob dOxudTjO4xTsw== Date: Tue, 7 Jan 2025 09:46:48 -1000 From: Tejun Heo To: Changwoo Min Cc: void@manifault.com, arighi@nvidia.com, mingo@redhat.com, peterz@infradead.org, changwoo@igalia.com, kernel-dev@igalia.com, linux-kernel@vger.kernel.org Subject: Re: [PATCH v7 0/6] sched_ext: Support high-performance monotonically non-decreasing clock Message-ID: References: <20241230095625.114363-1-changwoo@igalia.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Hello, On Fri, Jan 03, 2025 at 12:16:41PM -1000, Tejun Heo wrote: > On Mon, Dec 30, 2024 at 06:56:19PM +0900, Changwoo Min wrote: > > Many BPF schedulers (such as scx_central, scx_lavd, scx_rusty, scx_bpfland, > > and scx_flash) frequently call bpf_ktime_get_ns() for tracking tasks' runtime > > properties. If supported, bpf_ktime_get_ns() eventually reads a hardware > > timestamp counter (TSC). However, reading a hardware TSC is not > > performant in some hardware platforms, degrading IPC. > > > > This patchset addresses the performance problem of reading hardware TSC > > by leveraging the rq clock in the scheduler core, introducing a > > scx_bpf_now() function for BPF schedulers. Whenever the rq clock > > is fresh and valid, scx_bpf_now() provides the rq clock, which is > > already updated by the scheduler core (update_rq_clock), so it can reduce > > reading the hardware TSC. > > > > When the rq lock is released (rq_unpin_lock), the rq clock is invalidated, > > so a subsequent scx_bpf_now() call gets the fresh sched_clock for the caller. > > > > In addition, scx_bpf_now() guarantees the clock is monotonically > > non-decreasing for the same CPU, so the clock cannot go backward > > in the same CPU. > > > > Using scx_bpf_now() reduces the number of reading hardware TSC > > by 50-80% (76% for scx_lavd, 82% for scx_bpfland, and 51% for scx_rusty) > > for the following benchmark: > > The patch series generally look good to me. Peter, if things look okay to > you, I'll apply the series to sched_ext/for-6.14. Applying to sched_ext/for-6.14. Please holler if there are concerns. Thanks. -- tejun