From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ed1-f73.google.com (mail-ed1-f73.google.com [209.85.208.73]) (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 838663E3155 for ; Fri, 20 Mar 2026 18:16:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.73 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774030601; cv=none; b=bYT8hvJjIlcAG8qMZxa0qfhzJ5TdxQzO4fwujAhGeonGMNR/LIFmszdfO2y0dSnI6mC9Dzozd1Wc/tz9LXUomWPAnqn8zj9/Lk2m/Oi+pAofGyzVjuVQMLura+Ihhvmhi0J3fiBaHxlzJcfV99viUQvsspdulPo50k8AscUgVF4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774030601; c=relaxed/simple; bh=2eaBlWd5jGD3rJQwpesjYfrICE3jh1zZbHY+s3dEnpc=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=b1rXMCYQGu6+pSO84pNAel35Pc2zmnKBXeauLXEJwScxLIZF8QP9dkisILS7Ofoie5p+IEvT7YX1gbkfPyn6ZSjzDP5PHzq1AqquDjmYVE2e2tyRAdCBC3FG0aXUD7nQvz9HmCArxEYGbrinAARFPLFsn+iUeHoIHfnZwneAAds= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--jpiecuch.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=iSOryfJP; arc=none smtp.client-ip=209.85.208.73 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--jpiecuch.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="iSOryfJP" Received: by mail-ed1-f73.google.com with SMTP id 4fb4d7f45d1cf-667d8f30c50so3542124a12.0 for ; Fri, 20 Mar 2026 11:16:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1774030599; x=1774635399; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=175LY80cvo4magxg2e73J6AXfntCy1Gia8IrNOJcCIU=; b=iSOryfJPma8JV4BD9Nn4rwJiqjnnPL7l4PpMdYwGnX2vuiPDBGVj7O3HU32M4Ta9dd IFEK1H36bbislWHWD+RgG2nBISBIRxnPDPgtwMdIoPDmX6MjlCMjV6fjenIJHKN7g3dN BuRAtHEt6Zys8kVZ/y4oYw2YWPk/XMR6F5dusy0OKkBL0MM+XXSm6rvnBQXTfJjSnVXJ 33f8Ry9Yr9G/R3QIrUDPyVsRMjz4yQqCZeBofDHdAA1FXA1ufc9TKFmwhl3ix8WF1HS8 FHdGgYxpoJnV2b6pqTKt46zO1v2wFgSWAl16KmKh7Z8ok+yCQHvf1zVaWI/a7qpiJOtV +noA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774030599; x=1774635399; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=175LY80cvo4magxg2e73J6AXfntCy1Gia8IrNOJcCIU=; b=JE7UXc5Bqevbok5RJFnKuYKItxyIFran7CVAft+Dus55gP/Kx1sgPsmYrc/59vobj0 GIA5N2r2jf+26yMd7DFFMXbFyOdoDHWievkn/BkcyQvNpD8fbCxNoPY6pR+3GkeIebXp OLET/1BYwHErYtbcnn9KF3M/bGq72iar7gb9ItuLvnxLojjpwV/fXXrydF/zqzziq8OT mOKCJotVjEglB8WdwhOdajYTfZZRWHGE20qkaH+qoscnd7pJ6YXEsEIcqaMEmVjff4b2 KxFZJPx1pxgekGlhYQ9BT7PmJZkq1iH+Y3pYhfcSz5E8c0YlkyYhDE6Z7MkZY13vLoHX lw9Q== X-Forwarded-Encrypted: i=1; AJvYcCWFchkQf9l7opzyNbVrFMJ7Wy7gvM/Xhrut1AgKilxUUZLfUio2apSJP8IGR3E2FPuLTp4gBV0/5Hb983c=@vger.kernel.org X-Gm-Message-State: AOJu0YwD9wsqGm1iarzvXO088LPU0e3+92kXfp1YyzZqj+zEeFh6ccvY HFF+hqgGizj/R1ZecxARdg8bsuhh0naoyTvQ6mB1II5MuhDL5xQP6IdsMmRYxcmTKau30rlugF0 QgiZokssebYtgFQ== X-Received: from edsc4.prod.google.com ([2002:aa7:c744:0:b0:667:4c3d:fc68]) (user=jpiecuch job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6402:1ed0:b0:663:f97e:5207 with SMTP id 4fb4d7f45d1cf-668c84f23bcmr3582223a12.0.1774030598677; Fri, 20 Mar 2026 11:16:38 -0700 (PDT) Date: Fri, 20 Mar 2026 18:16:38 +0000 In-Reply-To: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260305062900.43450-1-arighi@nvidia.com> X-Mailer: aerc 0.21.0-0-g5549850facc2 Message-ID: Subject: Re: [PATCH v2] sched_ext: Document task ownership state machine From: Kuba Piecuch To: Kuba Piecuch , Andrea Righi , Tejun Heo , David Vernet , Changwoo Min Cc: Emil Tsalapatis , Daniel Hodges , , Content-Type: text/plain; charset="UTF-8" On Fri Mar 20, 2026 at 1:56 PM UTC, Kuba Piecuch wrote: > On Thu Mar 5, 2026 at 6:29 AM UTC, Andrea Righi wrote: >> + * - %SCX_OPSS_QUEUED: >> + * Task is owned by the BPF scheduler. It's on a DSQ (dispatch queue) >> + * and the BPF scheduler is responsible for dispatching it. A QSEQ > > The task doesn't have to be on a DSQ, it can be queued on some BPF data > structure instead. Even if it is on a DSQ, its state depends on whether it's > on a user DSQ (QUEUED) or a built-in DSQ, e.g. local (NONE). My comment here is incorrect in that a task being on a user DSQ doesn't imply it's in QUEUED state. Now I actually think it's impossible for a task on _any_ DSQ to be in QUEUED state, here's why: In order to initially get on a DSQ a task must be inserted into one via scx_bpf_dsq_insert(). That can happen in ops.{select_cpu,enqueue}() (direct dispatch) or in ops.dispatch() ("normal" dispatch). In the direct dispatch case, the task either: * stays in NONE the whole time (ops.select_cpu()), or * goes from QUEUEING to NONE and stays there (ops.enqueue()). In the normal dispatch case, the task must be in QUEUED state for finish_dispatch() to proceed, meaning it can't have been direct dispatched earlier. Then, the task state goes through QUEUED -> DISPATCHING -> NONE and stays there. scx_bpf_dsq_insert() isn't the only way for a task to be inserted into a DSQ. There's also scx_bpf_dsq_move(), but the task being moved must already be on a DSQ, so it must be in state NONE, and scx_bpf_dsq_move() doesn't affect that state. There are also other mechanisms like SCX automatically inserting a task with slice left into the local DSQ on preemption, but these also preserve the NONE state. So, QUEUED means the task is enqueued purely on the BPF side and isn't present on any DSQ, either user-created or built-in.