From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f46.google.com (mail-wm1-f46.google.com [209.85.128.46]) (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 F0800361957 for ; Thu, 13 Aug 2026 04:59:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.46 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786597176; cv=none; b=ZVIz3pYZtgz1H2Mg/XYzT5wVdRSeRNY8I5p8qXloPGM0EIhSVHcjsr0vmtWeCC8LoSSkYiweWYa3s1oQnphX3xQxBdzAJaR5jb5YLI58Yu09mf2bVLGUwUUKzJFikJZHhreuQdwVpQceRPlK40SGBCMusgBXCjOXyU3tO/t7A5I= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786597176; c=relaxed/simple; bh=FhI6XOqCG/rHYjGkvA6Un2LtD5OD7jkFQjW1/WgtJhc=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=tiglv+HQg3HCL5Pa7OUkJN6bSXA/lHlYsSVCdkallFcnRy3M4E6xGbXV/00nb7n56pE0pt6vHy4h/pDfTRT5G7litod7NcgLNmr/XC7v0pzrnG/C3eJ9YEpci97NPvGhBYv2OSGT1HY3F1N9h4nH6kLI/Cx7V47Jg+6eeqbwDl0= 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=NbTPmO7n; arc=none smtp.client-ip=209.85.128.46 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="NbTPmO7n" Received: by mail-wm1-f46.google.com with SMTP id 5b1f17b1804b1-4994c49f588so4929015e9.0 for ; Wed, 12 Aug 2026 21:59:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1786597173; x=1787201973; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=RldXtKBhaRt2S6l0z8oiQPCcZO7pKv6jWrFv1/cNys8=; b=NbTPmO7nnQLrig2WcjjPfdA4tH9yjCvkpdxf4NYHVwOGkNuqrwur5pLSWdAmBRM/sX D6C/ddJCcnKcb1s748lChxgDMmTy4eEgLFjJ5ppbnnprP5voBG5+IRzI1Aquv5RWZNRK LNRB5NlMiU47oi279zvJMdarl3pSj4h5N1WxMtgPt1af04PrP3sKnsKmv8w4ueKSawUu EFOMcs/cj7gGDZ4JxcvaaGBqO6O+G+AvCW3ruQJNJC5i1WCD2bAOQIZRER7DSPRljVoM M/0BQ9secnvwnsFa6ocdZm93VH29vYpDC//s2ZnKf/t+Eaqp1LJLrB6JZP6bgs+pgcGi p+eQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786597173; x=1787201973; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=RldXtKBhaRt2S6l0z8oiQPCcZO7pKv6jWrFv1/cNys8=; b=Tk9a4VPZTwkHYoMjQmdeP1leMuwSLdCbY7cuS4ENJUloqspcCkfYBGLEFAWKlYpV4+ cH0yeTxTvxggT1HM06UvDzDhrUNukrObkUVrnGRzKnR8ZC+rhbbYqOk2BQkcoh5YdXeU 46fR/J0p2JOQPUM/fZiVlBX9Mzj05tNBp5dt+019mgUewlyHMKMtJvtoSvt6u5F6oUSW aevXPnY+4/LqI7VUmybnBG4Z9JbM3PVBq2K3dppN4nOUkN6wRSA/jJ70NI7qLiyZ4Occ lMGk9s21G289Cq+GMRi1MBQaItxM8KKh1CXHRQhCcrd9s+TYMt13aE9et8+++NS01MAj DgIw== X-Forwarded-Encrypted: i=1; AHgh+Rr99irXyCIgperngXuP3Kb1MSYfaklxjKRGPlaHG6MOu3vwwOC0hlpmzl3E9rZrkxVX/e71rqDyyNzLXvQ=@vger.kernel.org X-Gm-Message-State: AOJu0YyLI2DiOZGoyJX40hPNTS7UW/O/2OA6/7/eTdc5RHKu/HqZMLZF UfDsQ1FZgry7Wc17QtLmdbuxGcQkG8JKuGu8l/AaoDlF4+ed24Xohvoe X-Gm-Gg: AR+sD10mLuDwIh3k7bXyGePrgjVT20dKeSozv9s1GhrHkmwqgDh5ezXIChcwZMMBNLe DsV3n99sj8Gqo6WKGrfVuGGKi2NyhGJxksPjoxzBCou4BW0zKe0UxL1nX3LXWryoRxXnLUllIXF m8LmpGsAG60EWH5LBzn9vK0EsXlDMnFn/lEWyp639i+rimPhsKPhS1AQAIgamE49yST/CibcFpC Yuto2n2cJiTlWgjNg04yPVG05K8fuw5PPan3zgMPV2A4NSnekjrbAd+CybMasQnbYkFODNDepdq 8XaEXP2VBqmYoYbKLqPl93gMxwD2hDtp3fPTBHFOVOn3/exxRFwkziEUb+gk3VzBdOm2pBN4raQ XpXJdcTR6jAZOJuJHcM778/PAnTPl49UuMAnQaW6qPDpuRgwMKCCyXqOCL3xIUB+eM1w5z7eaLR 4d93/2de+v+XL71bnOTIOYoZxOiBWPAWNia0QDoQt71Bwc1i0VNFLYvNDiBWlHC58Xh79uKaJPz W6Cp/I5wdhyYe66hLD2C2Pt6Ra5YOkIaC9Ms2L5HbYCjjnCUZN7nxL/qZo= X-Received: by 2002:a05:600c:c87:b0:499:810b:6f57 with SMTP id 5b1f17b1804b1-49982200fa5mr17849475e9.4.1786597173022; Wed, 12 Aug 2026 21:59:33 -0700 (PDT) Received: from dohko.chello.ie (188-141-5-72.dynamic.upc.ie. [188.141.5.72]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49981b6abbcsm36671835e9.15.2026.08.12.21.59.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Aug 2026 21:59:32 -0700 (PDT) From: David Carlier To: Tejun Heo Cc: sched-ext@lists.linux.dev, linux-kernel@vger.kernel.org Subject: [BUG] sched_ext: ops.sub_ecaps_updated() dispatch context is set up on the wrong CPU under core scheduling Date: Thu, 13 Aug 2026 05:59:31 +0100 Message-ID: <20260813045931.8691-1-devnexen@gmail.com> X-Mailer: git-send-email 2.55.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Hello, scx_process_sync_ecaps() looks like a missed instance of the bug class 3dd52416e44a ("sched_ext: Fix this_rq() assumptions in dispatch kfuncs") fixed: before invoking ops.sub_ecaps_updated() it does struct scx_dsp_ctx *dspc = &pcpu->dsp_ctx; dspc->rq = rq; where @pcpu is the *target* CPU's context (recovered from the llist node), while the dispatch kfuncs resolve theirs with this_cpu_ptr(sch->pcpu). Identical until dispatch_core_pick() started running balance_one() for sibling rqs - now a sync processed by a sibling calls the op with the executing CPU's dsp_ctx.rq unset. Nothing ever writes a sub's dsp_ctx.rq on a CPU before the first scx_bpf_sub_dispatch() there, so it is NULL at attach time - exactly when the initial cap-grant notifications fire. If the op then calls e.g. scx_bpf_dsq_move_to_local() (it has SCX_KF_ALLOW_DISPATCH) on a non-empty DSQ, scx_consume_dispatch_q(sch, NULL, ...) reaches task_can_run_on_remote_rq() -> cpu_of(NULL) and oopses in the pick path. A leftover rq from an earlier dispatch instead consumes toward the wrong rq. Fix seems to be a one-liner matching scx_dispatch_sched(): - struct scx_dsp_ctx *dspc = &pcpu->dsp_ctx; + struct scx_dsp_ctx *dspc = + &this_cpu_ptr(pcpu->sch->pcpu)->dsp_ctx; with Fixes: b81a6c018cde ("sched_ext: Add sub_ecaps_updated() effective-cap change notifier"). Happy to send a patch if nobody is on it, or feel free to just fix it directly. Cheers !