From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=213.97.179.56 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796535515; b=sBBL02/ReKoBsgMFVYvGFLGgj8lKA/uIZLiGTrjsUsxoJ7+JdRvgtfxWAbxFzuFWLMG1 hp3ag9L6M0zqxzAxLsbkyfTT6tcSDtz6OcC8l0Yko5owK2MT9yTe66zaeFgZfus+PdchG EzDNTmfDL3fGktRJXS1Rt+UzNGlmrIAuMx7KtKRwaVALwk5xU4xAthFFe1HyqKJ96wqHK gkCnzo35JAtu9qoziKls/T7yY4JR/6zkweUiHtbsq/4sT74esNWdK6tKX99twfIM7hWiG VXO5eAypduI9rifyQw2/NotNF9fprFKVEEq8Mm3r4zhfgSypnUHIn8gZVYPVrB9bsQQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796535515; h=DMARC-Filter:DKIM-Signature:Received:Message-ID:Date:MIME-Version: User-Agent:Subject:To:Cc:References:From:Content-Language:In-Reply-To: Content-Type:Content-Transfer-Encoding; bh=WUTa5zkRXbOZpB8n2sc1xSLZZQ48N7QJmVH9Ei7Io5o=; b=EDlhC4tGy5g7Q5TybIN/5g0pLxlSDcQHVPDLLObyIyl0qSitJUunAwZvdwVAREdLYSGy JqFrLIXazsyimH8GbE0lVV7LZRf5Fpv2minD1QH++hFhxIeG4HCNZFzPJX9gYfnRjrF2Y RxC1L+hF+YPA+DDcvyMFTJaS7p7jESi/usO/BnmUnx2j/sSsySV7sxlqqMQ+qQxQNIXNm 2WsVXlu27DIBHzyxbpagdyqZVs8TXjuRUrboG7gJ0cQ/k9EjmGWCFzO/JW5MavF5aQg/u ySZ/GFhFvg3Pr5hW3dPRu7Lq/gCuTQ6CMV0gkk85xe71blNTIhfrFxXU69B6DTy5gDg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=igalia.com; spf=pass smtp.mailfrom=igalia.com; dkim=pass header.d=igalia.com header.i=@igalia.com header.a=rsa-sha256 header.s=20170329 header.b=RwocAX+9; arc=none smtp.remote-ip=213.97.179.56 Received: from fanzine2.igalia.com (fanzine2.igalia.com [213.97.179.56]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (prime256v1) server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A3E0F606A31F for ; Sun, 6 Dec 2026 05:38:34 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org A3E0F606A31F 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.a=rsa-sha256 header.s=20170329 header.b=RwocAX+9 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Content-Transfer-Encoding:Content-Type:From:Cc:To:Subject: MIME-Version:Date:Message-ID:From:Reply-To; bh=WUTa5zkRXbOZpB8n2sc1xSLZZQ48N7QJmVH9Ei7Io5o=; t=1796535514; x=2111895514; b=RwocAX+9NfxHZks7zE9IRDpuPrbTNGF3z12RvO75WQ7mKv4m+pXBY0EShSL4aeGj2whiceqetiL 8ZsqgsKDoZcAYqmbEu/kjJH8TeL6wUKdNcrQVD3URL0f1ALMp8dTBCapcQdWE7C832Cshz+gXV8re J15d0PNry4WOeZPQhImcSP3UEmOwhUn7NGC6sCBxAj/H5IYnrCDkc+uC103/v1RRASOyK2f1fo2Ne gIjtSB2TSpsEJxzavDAY5UwQc9KJHxFNTY4pl670elk41dhKIRCwoUesCR9Lph7ndLpISeag6LBGF V3Moj0kTDzdEaj0keZRALHI7hHcISZncAv7w==; Received: from [58.29.145.179] (helo=[192.168.8.237]) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_128_GCM:128) (Exim) (envelope-from ) id 1xa4xD-00000002dPU-0dNT; Sun, 06 Dec 2026 06:38:31 +0100 Message-ID: <5eed9c65-ef2e-43d8-9c21-088e20a8c56d@igalia.com> Date: Sun, 6 Dec 2026 14:38:26 +0900 X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2 5/8] sched_ext: Add p->scx.bpf_priv for O(1) task context lookup To: Tejun Heo Cc: void@manifault.com, arighi@nvidia.com, david.dai@linux.dev, Gavin Guo , kernel-dev@igalia.com, sched-ext@lists.linux.dev, linux-kernel@vger.kernel.org References: <20261203045618.982539-1-changwoo@igalia.com> <20261203045618.982539-6-changwoo@igalia.com> <03643694988c245d0cf8da3f7ee61680@kernel.org> From: Changwoo Min Content-Language: en-US, ko-KR, en-US-large, ko In-Reply-To: <03643694988c245d0cf8da3f7ee61680@kernel.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 12/5/26 2:09 AM, Tejun Heo wrote: > Hello, Changwoo. > > On Thu, Dec 03, 2026 at 01:56:15PM +0900, Changwoo Min wrote: >> + * From @p's own ops, ops.enable() included, @p can't leave the scheduler >> + * concurrently. Elsewhere, e.g. from a timer or a tracing program, the write >> + * can race @p leaving and outlive the clear, as with >> + * scx_bpf_task_set_dsq_vtime(). Synchronizing such writes is the BPF >> + * scheduler's responsibility. > > This seems problematic with sub-scheds. AFAICS, a write which races @p > moving to another scheduler can land after the clear and leave the value on > a task that the other scheduler now owns. The other scheduler would then > take it for its own value, so e.g. a sub-sched can make its parent fail. > > We have kfuncs which can be called with or without the rq lock held and > grab it as needed, e.g. scx_bpf_cpuperf_set(). Can scx_bpf_task_set_priv() > follow the same style? Yes, v3 does that. From an op called for @p, it relies on the rq lock or pi_lock the op holds. With no lock held, it takes @p's locks. It fails from any other op, and tracing programs can't call it. The ownership is checked under those locks, so a write can't land after the clear. For lockless readers, the store is ordered after the stores that set up what the value points to, with smp_wmb() and WRITE_ONCE(). Thanks! Changwoo