From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from fanzine2.igalia.com (fanzine.igalia.com [178.60.130.6]) (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 4510C218AA0 for ; Thu, 9 Jan 2025 13:15:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=178.60.130.6 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736428531; cv=none; b=SIyTXV3h1zDpy/MMv5ltDLTzeD7y6MX9ucU5b+60rc7gSqZ20a+yHxm3guPYKFjpc+sEoQxk09sBAqRDou5wDwUIInOzJIbrM4PldhEa39ZpcQIa40nodpmSYw8XjYqXLrLvHV91zQPganxL+hVUG3D4h1o0W0yFINYZsbVsTT4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736428531; c=relaxed/simple; bh=quj8prKTf0T2wGBr3bhLbhhITyZHTAO5tc+XMf0VBZI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=d4HtkdkwmR01fOEUeN1JQbWTbR487pJZ3eP0RyNaVcQTEpdkH7YYPTljKrPEyS0aXyRcQOyhw0ejeNrQ5kWlJqlRhxyTGjnyt59fil2Nwre4S/jeNhwaxKVdJA2psQVCkz72E/b8e8j6XpTtc3U1AfM6Xfwg0XK7pASaBsh09s8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=igalia.com; spf=pass smtp.mailfrom=igalia.com; dkim=pass (2048-bit key) header.d=igalia.com header.i=@igalia.com header.b=Z59W5DOo; arc=none smtp.client-ip=178.60.130.6 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=igalia.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=igalia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=igalia.com header.i=@igalia.com header.b="Z59W5DOo" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=Wow0f2L0ocjtG3ziib/G7eNZl8dh1HZAWkEJfvze4q0=; b=Z59W5DOoyvzLt1Jc7LdDt1PgoG MmyBCO0m6iUXrXTpNtb8tCJ+soiyNMWEROdnRpS+L7HdyK93dl9MAAUCqASatwKoJSE6iLVI7WBnu 3LdHLEQfgjh8qabUXdclL9NapJ3HY054TELrIb/JrCxRJXfKutXxOBgun4ArcfeTBAlHQu8WPFrYx pzkhGT+kjqhFBGcSBaW9dtLgTkz2Je5aHTlNLtPQkpNfEB5iXsOic/Nze6pu50DI/pqbFF5ZwqlqN rjwX/dpqDnbUoX2DNPo+/NW5Rn4U64iFxD+/+qiuRtGyVfqoO6KSHP+7Q23Sy0/1l8lz56klZda1I o0MVMFkA==; Received: from [58.29.143.236] (helo=localhost) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_SECP256R1__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1tVsNb-00DZ9l-At; Thu, 09 Jan 2025 14:15:20 +0100 From: Changwoo Min To: tj@kernel.org, void@manifault.com, arighi@nvidia.com, mingo@redhat.com, peterz@infradead.org Cc: kernel-dev@igalia.com, linux-kernel@vger.kernel.org, Changwoo Min Subject: [PATCH v8 3/6] sched_ext: Add scx_bpf_now() for BPF scheduler Date: Thu, 9 Jan 2025 22:14:53 +0900 Message-ID: <20250109131456.7055-4-changwoo@igalia.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250109131456.7055-1-changwoo@igalia.com> 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-Transfer-Encoding: 8bit scx_bpf_now() is added to the header files so the BPF scheduler can use it. Signed-off-by: Changwoo Min --- tools/sched_ext/include/scx/common.bpf.h | 1 + tools/sched_ext/include/scx/compat.bpf.h | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/tools/sched_ext/include/scx/common.bpf.h b/tools/sched_ext/include/scx/common.bpf.h index 858ba1f438f6..5c9517190713 100644 --- a/tools/sched_ext/include/scx/common.bpf.h +++ b/tools/sched_ext/include/scx/common.bpf.h @@ -76,6 +76,7 @@ bool scx_bpf_task_running(const struct task_struct *p) __ksym; s32 scx_bpf_task_cpu(const struct task_struct *p) __ksym; struct rq *scx_bpf_cpu_rq(s32 cpu) __ksym; struct cgroup *scx_bpf_task_cgroup(struct task_struct *p) __ksym __weak; +u64 scx_bpf_now(void) __ksym __weak; /* * Use the following as @it__iter when calling scx_bpf_dsq_move[_vtime]() from diff --git a/tools/sched_ext/include/scx/compat.bpf.h b/tools/sched_ext/include/scx/compat.bpf.h index d56520100a26..50e1499ae093 100644 --- a/tools/sched_ext/include/scx/compat.bpf.h +++ b/tools/sched_ext/include/scx/compat.bpf.h @@ -125,6 +125,11 @@ bool scx_bpf_dispatch_vtime_from_dsq___compat(struct bpf_iter_scx_dsq *it__iter, false; \ }) +#define scx_bpf_now() \ + (bpf_ksym_exists(scx_bpf_now) ? \ + scx_bpf_now() : \ + bpf_ktime_get_ns()) + /* * Define sched_ext_ops. This may be expanded to define multiple variants for * backward compatibility. See compat.h::SCX_OPS_LOAD/ATTACH(). -- 2.47.1