From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pf1-f173.google.com (mail-pf1-f173.google.com [209.85.210.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7A0392D73B8 for ; Sun, 19 Apr 2026 17:23:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.173 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776619440; cv=none; b=Qm6D+DVW/BIM5Sk3XfM0qRKsWknfEJjZsr4F7pA5BVjibRG4GpYoGWcRQvRe9mv5obEkfuGyIxPlN3I0mApttsX4N5PzXcqBLvh1lKFFLRVJU9wPD+uCf4LZzx0f/AZvXVp2SDTgjvIxePujLGOLa09gkS1WYMppSu2Mtat4PyU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776619440; c=relaxed/simple; bh=z8a6fP5v1JPcuI8Zmurk8eLUfTAbQeopvyp/FVlkx8U=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=rzFHAOmhzWX9Qi/ssMOHPYdydqJRPs/0L8sPckGrB+ttvS2MupNL4P1itstmH9ZcHT7iK+zibAZqN/hFG1t2UFMsRvyAj5Ewf/0J+Ou6KDh30LszHVXZ0hzVYWUkcITlvcjTo9uwQuq4uF/jeRPlTQEtW9aZaL6NghnLo22N+uM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=WDoSYLLZ; arc=none smtp.client-ip=209.85.210.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="WDoSYLLZ" Received: by mail-pf1-f173.google.com with SMTP id d2e1a72fcca58-82ce2e2880cso1561716b3a.0 for ; Sun, 19 Apr 2026 10:23:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1776619439; x=1777224239; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=tfhG1XaYczDmtGOWQsv3r0xVybiKiPWM56MZ5/oAeIU=; b=WDoSYLLZiDamfZAvO81KC+veFyG0LzeZzTl3mKPMzX7fjg1E5iaP0RdrhF6oj4PJXD Nfi/DJRGvShyI/dnI57M6jGI+riAuQTU/Qur/tvxSsuL1OKouk6Nagd35OOg2XS6Z7CB fQAI3zXnpKO4MT4tgK1oLtXTZU1U1r/PvEXUIyaqpcjpA3VGrU7s0MF8U+XctePuDXQU cX/YZkMaATA0R8WysN1NUTEeC5mT33BnT2A9yQ7NN2xOPWUV8/5MbEKfS3QrmJmkrQTf ZeIwefWNIYTbnfyX980vop1i3mNmJ/HnbSQTCNO2bjgvGFSYyY7uXtRfkBwoiAlhakz6 1DFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776619439; x=1777224239; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=tfhG1XaYczDmtGOWQsv3r0xVybiKiPWM56MZ5/oAeIU=; b=pY4K0o/+PKaVIhorxix1s/0sxDkFe7MRhSRrvJEK/FtLDnYrabC7UNrWKBel/PD3aF jM9BM7ObxfTOPMSHZkfAa1Ntah8G5II4hDeimsaJ5P3MZ+iBkTSx0jut2sCZAaT9jwza 8iYSqpcmPOQwwY8UBNq60v3m0wPI10Hnr2JI8RjDB2Asco/Q6LNEtXcruSVh2c/Y/Ysj KzZFkNMZ9Esuc8mH3qtaZp2xNvY6Vz3GvAyL11ElDvmsJDsbJwlK8JHdEiZRXRCbl/Hu BM9mDZQFWcpfCslemkulaqhztHLwndI/MgdPwD1flinsnxupUesO6cLELLz7ho0qIG6P oUZg== X-Forwarded-Encrypted: i=1; AFNElJ884nD1P4+wqvQTbMuy6TyWPO1RjVKV5ZHZPUsNoJBAjLE5VUCtheDPPthYquIzzFEEIbzSncmSLrK41ts=@vger.kernel.org X-Gm-Message-State: AOJu0Yxuv48pIblvkY9H9CvREod4auYrhcu7rZ85cMK+93WjfgYvfE/T MlwsLAwBl84wXHqhBPNztfu3NNRT/p2vOo7GGPOB8G93WBJpc0fyY5Vo X-Gm-Gg: AeBDies19fyCnxACqTAWl36f2YGntsGzkUFVwHny5HJaaE1BFaa+TGKypb9kPRE5MVB ihaE2WDT1gMXADKOmzaqUXBRmMINbQOCNv4EBWuWS2b03I6WAFZSHzdLRSQZfp+au7Emt77iY4/ lMnDv78LHk5dnoCOhCHHlKuPxi3D3hv0yNvX8I+Y/6tyAikNfx9hQjotKCQtjeG1GgCeHGql18V X+Y5JmYNZayKS2O9NjJdnD2lojlu8BW9aVTkMGArB/U1ihxck58qXO+lup+O0qfldioWHLU07CB 9N+8oaEjz4tLdXlGENXOb5gwiosnqNKTAJ8bT5XxpOPtn0mJmyBw/qWLS/wEXMTvlePSLsEi6AH o2RZDabnt+tkPQDOvNKYTBx5bExfl6T1gbSIibV25soJR9EKWHoUvKeUGQuMFb3H+nPfcMK0TD3 DPRwpZaGGMMIdt0wLGgILHVjZYw45hdarrvfMMY34P+ByKAJZWmfP0m3e/OQp/EMBl6yCENbgiJ hwV5J0tfSjq0PsF X-Received: by 2002:a05:6a00:340a:b0:82f:623f:e5b3 with SMTP id d2e1a72fcca58-82f8c92cf98mr9744468b3a.34.1776619438748; Sun, 19 Apr 2026 10:23:58 -0700 (PDT) Received: from cchengyang.duckdns.org (36-225-119-66.dynamic-ip.hinet.net. [36.225.119.66]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-82f8e9d2f9asm8445396b3a.19.2026.04.19.10.23.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Apr 2026 10:23:58 -0700 (PDT) Date: Mon, 20 Apr 2026 01:23:54 +0800 From: Cheng-Yang Chou To: Tejun Heo Cc: David Vernet , Andrea Righi , Changwoo Min , sched-ext@lists.linux.dev, Emil Tsalapatis , linux-kernel@vger.kernel.org, Ching-Chun Huang , Chia-Ping Tsai Subject: Re: [PATCH sched_ext/for-7.2] sched_ext: add p->scx.tid and SCX_OPS_TID_TO_TASK lookup Message-ID: <20260420011217.G0c0c@cchengyang.duckdns.org> References: 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: Hi Tejun, On Sun, Apr 19, 2026 at 06:18:46AM -1000, Tejun Heo wrote: [snipped] > + * scx_bpf_tid_to_task - Look up a task by its scx tid > + * @tid: task ID previously read from p->scx.tid > + * > + * Returns the task with the given tid, or NULL if no such task exists. The > + * returned pointer is valid until the end of the current RCU read section > + * (KF_RCU_PROTECTED). Requires SCX_OPS_TID_TO_TASK to be set on the root > + * scheduler; otherwise an error is raised and NULL returned. > + */ > +__bpf_kfunc struct task_struct *scx_bpf_tid_to_task(u64 tid) > +{ > + struct sched_ext_entity *scx; > + > + if (!scx_tid_to_task_enabled()) { Should we need to add a NULL guard here? Since scx_bpf_tid_to_task() is registered in scx_kfunc_ids_any. > + scx_error(scx_root, > + "scx_bpf_tid_to_task() called without SCX_OPS_TID_TO_TASK"); > + return NULL; > + } > + > + scx = rhashtable_lookup(&scx_tid_hash, &tid, scx_tid_hash_params); > + if (!scx) > + return NULL; > + > + return container_of(scx, struct task_struct, scx); > +} > + > +/** > * scx_bpf_now - Returns a high-performance monotonically non-decreasing > * clock for the current CPU. The clock returned is in nanoseconds. > * > @@ -9470,6 +9595,7 @@ BTF_ID_FLAGS(func, scx_bpf_task_cpu, KF_ > BTF_ID_FLAGS(func, scx_bpf_cpu_rq, KF_IMPLICIT_ARGS) > BTF_ID_FLAGS(func, scx_bpf_locked_rq, KF_IMPLICIT_ARGS | KF_RET_NULL) > BTF_ID_FLAGS(func, scx_bpf_cpu_curr, KF_IMPLICIT_ARGS | KF_RET_NULL | KF_RCU_PROTECTED) > +BTF_ID_FLAGS(func, scx_bpf_tid_to_task, KF_RET_NULL | KF_RCU_PROTECTED) > BTF_ID_FLAGS(func, scx_bpf_now) -- Cheers, Cheng-Yang