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 CF1E01C1F27 for ; Fri, 3 Jan 2025 22:16:42 +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=1735942602; cv=none; b=LdpxuO4REdJyRiv6iVFbVBCiAaEOU4xISx+JODydtk3nmQ4aKmMVKmzBJ35FY51J84suI0GROBoiXXj8UV3kb4sifXarfIoXmyNn9Dq/Y8i4w8P+buPok8X7XtCxeUv6bEgA+CxVXcb+wxCngc6AuLcSeVuEBxmu3MvJnpZm0is= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735942602; c=relaxed/simple; bh=Nkn7GE6iTTmYm5OuMAVEDq3jMCd/MZb/pvFcOokWA4Q=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=jO1cT06sFuBVB8T/+WlfeR7CkLDZZFE49PE1r4pDuDCyejZ1h9RSJy8TZsnTnH59H7x5DJvHcopfJ/MlA68f+0ro8iyoVpdbvcwI2lLRhzH0Fdyh6F0LZ+JNO9X303YHxzMKM+enlES/zSX0WYNs1Vbto8fuzFLX8an6lYTJHVw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=FlLU/+e0; 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="FlLU/+e0" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3CB19C4CEDC; Fri, 3 Jan 2025 22:16:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1735942602; bh=Nkn7GE6iTTmYm5OuMAVEDq3jMCd/MZb/pvFcOokWA4Q=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=FlLU/+e0Hw0VM0QTFQB7iTZmHkhyLObCAwXr3MI9Vs6OTA5QZComAnd8qf5SpC0D1 CzA/RUG/70ShyJ8fgXjdLWcPJ+NK0jAqvUd1vGKUbIZM8LnGXFadPygIu/MR7/FekC gCnauFdGjOTs1ogZYkJUzRu7XBAd9Lwb4FiXhkaLz6voDzBKyUJGRSVrjaKEoM0ttJ Za8qIFr+VIi7k0F+DCSTLIM8jGDjqoMoSX3/tPTPz2ZsNcoqTMWQcuSyrPzROGnAqx bPy65T303yKmQvVCf/yWkuILaVZg5r2jkGQhNpsU4ILz9IBMWF+WpU0crEjQTJKnql MBWAOOnN7N+mQ== Date: Fri, 3 Jan 2025 12:16:41 -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: <20241230095625.114363-1-changwoo@igalia.com> 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. Thanks. -- tejun