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 D5A63214223 for ; Fri, 10 Jan 2025 18:30:10 +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=1736533810; cv=none; b=YSAlOu+dqbG3XiYkRccLxCdf9SoOiT8xfiSm108W1SdNVx1qHceigoZ589qi5LDLnCX4Up92DICtGAJY1RPflfuGFpZfZl+JrCGIvxEVvyDtBMZg2Jvlb2hx1wNzO3nqZA2IACfNvkd85OFJkG0PWBfPLmJ4jX4LdAtT2qC5jg0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736533810; c=relaxed/simple; bh=s9xq/GzEJMpjPA2AdGlaN7TNM+qNtOcwlvhyArn47qw=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=nna+dwKW9eQFjA+68ekGKeu84YXTWraBfswng56upp9yXIt4Hx4YfcM154Uwgcm/vLNdQXO0w+GSy+24t3hCGmeRVyt3yuhBb3I7qlJsdGXK5JTOWIOwQUdLKNIknB+8FrrwJLZxnlnc+VZeK2eVlQHtux24qT9M0eE2ljqmT6A= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=s+9Vfu7x; 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="s+9Vfu7x" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 46690C4CEDF; Fri, 10 Jan 2025 18:30:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1736533810; bh=s9xq/GzEJMpjPA2AdGlaN7TNM+qNtOcwlvhyArn47qw=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=s+9Vfu7xm9TOjFzf8CuN6MnjSeSBTpM8Fq0fubwV62XNRPAD4UXGQR6m/dH+oNPWR kpW0oOqCuMGbx9R4ZY7MRFm0WewsF/SSQ3LkG11Fc2SvopDAoa9/AuMemd/vuqbw/g UKLU1bspHndOJyTrB39UMKW9rszAf00pdnw2nE5MTIUUvWM3ggH/H+JdjmIOzofSD9 7g6/vQNmtNpX1VE55fj6AzJPWMWjmzhPNt/3Ni2qLHOOsJw2tBphFKmzguyrAgAGLv SLeLeWMsQQ0Dz5fw4Qkm4Mxe5UUBZM2xswmQaNb91Mt3CTNfFElnOMyTH2KrPkTqvP 61bpH4jN/wfAg== Date: Fri, 10 Jan 2025 08:30:09 -1000 From: Tejun Heo To: Changwoo Min Cc: void@manifault.com, arighi@nvidia.com, mingo@redhat.com, peterz@infradead.org, kernel-dev@igalia.com, linux-kernel@vger.kernel.org Subject: Re: [PATCH v8 0/6] sched_ext: Support high-performance monotonically non-decreasing clock Message-ID: References: <20250109131456.7055-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: <20250109131456.7055-1-changwoo@igalia.com> On Thu, Jan 09, 2025 at 10:14:50PM +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: > > perf bench -f simple sched messaging -t -g 20 -l 6000 Applied to sched_ext/for-6.14. Thanks. -- tejun