From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.208.70 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796043962; b=qLEofrEs2PmthHu9Y/0pyD9cXo+PXHcmD4m+OPyXQnAg7wtseA0eArcIJU5zgKT8wKkI R0agYlbPLCNV73GgWhNofn5gjzuYB5DrCg/VTJslLfB/R6RNrbORy1tOmApLwd94/Fl+S IdZVVQwkTcITgKNvt8ZxpzZdSffGJ0WiE7PZm6rwhgZgucynoqcD7JHDNkpgAzBl9Jffo ko6BybFOcd+UJolN6CNQrke3ByRDf3jUlBR1kLQvdLS+ioYuCZhWa4wGGLsgOuLaVINGi loirm5WOekEvAst39s/b90LTYuMqHPIEJ+qaCtqRnkHdIu5QVeve7eJLmM7YADlg65Q== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796043962; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Received:Date:Mime-Version: X-Mailer:Message-ID:Subject:From:To:Cc:Content-Type; bh=g/Tz4N6HK/wYj0Rxgg5B4AW3uxojodXZzOnn6zHVMAs=; b=lanXFbzDAK9RSxuz0X74jNJiZE1IeKT8CTnSBEInDBbdDAy54UpUEYS1ekziaDDvUTny zwjTuqfV0VtRpoFVTrhtHuYHGllHDWvh5bEBsm6Kmt27aSKwgN63sapMt9Oz/+fhbXmQt Tp2ba4mMxAXIuTLhQg16z3ij78RYpL16uhiTwSAf1Zygc+70TxV8nYL+HMeG2bF1axMR/ sUlpIW2/7+GUQ+trhSlUmmNPdKpyjj7ujc8aGIjI0LzGglomYZepZZ9Tm/uR5D5sSO027 52woRJYqSyAeuhDhPY2RvocN2l1pKJSW9ozPuxUHvHrs7myTe8guSRsDvfEA7t3YnhA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=google.com; spf=pass smtp.mailfrom=flex--jpiecuch.bounces.google.com; dkim=pass header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b=XGL7bXW+; arc=none smtp.remote-ip=209.85.208.70 Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2EBA6606A684 for ; Mon, 30 Nov 2026 13:06:02 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 2EBA6606A684 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.a=rsa-sha256 header.s=20260707 header.b=XGL7bXW+ Received: by mail-ed1-f70.google.com with SMTP id 4fb4d7f45d1cf-6b879130a02so9362283a12.0 for ; Mon, 30 Nov 2026 05:06:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20260707; t=1796043960; x=1796648760; darn=vger.kernel.org; h=content-type:cc:to:from:subject:message-id:mime-version:date:from :to:cc:subject:date:message-id:reply-to:content-type; bh=g/Tz4N6HK/wYj0Rxgg5B4AW3uxojodXZzOnn6zHVMAs=; b=XGL7bXW+Uo1WuEDQlBiSLIW0Yw7wS3nRV1gzmcONelSvS+YAhlzlKAt8NkyDYF1GOu jyl4EYX7OBlfniX/ysMbEVxtElXbd00+yQFw9TZ8IEL1+/Gnwj8+yC4exHkfC/Tk2Mmz s81AozEpkq5sUT0eL9RL2tf3w9mco2qsDNT0WXSJI/WdO1VI1ZRiyL19uuBl3TxPocKQ 0EMU+60QUZfHMf18TG5f+/U9+VYkaUsvLmBW/TjPkrA+ikT3v0KWN+wTuUKT4TvVHbcR ssfVcwBXpOP90YLO9J4E1FG2eOTTffy2j1us3Ch/dUKGVccG0dsMfAASBYXydWDQrfAa O2ew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796043960; x=1796648760; h=content-type:cc:to:from:subject:message-id:mime-version:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=g/Tz4N6HK/wYj0Rxgg5B4AW3uxojodXZzOnn6zHVMAs=; b=2O771c+VeetPSIsCJ+YZN87Liv4Vyll/H8IkwLjKRhx27fWhcQtdmRf8Yah7Frio8P Z/Fx/12GnrcyYgSfDrJ7GcfPto5IcthSd9068lBBsc6RLUow4EZzk+Rli6xtYvzYDc+J 26uL5jalLaS1eNAp/HUnW0R4s8uOczfYRDXGS66R6zwRCtVfpzmBW/WW34iPFFqgaNhR J03VRdi6ypVzGq1hTgij7fDhXxlNvhnR7l2UseFWzq6oGbqsksTbeq4hp8ZbJpq3U9zk 5xJ6h1O1v37XRGZ38QN8gRfil1onO0KMOs1sSdsVbSDCRc1iKGkh/tt5xHB/z6qdql7N HRFA== X-Forwarded-Encrypted: i=1; AL+hErEwT1dI6u6cOZV1WDR2AdL0lSPre5sYimNGvedMUPLESyuJ4lsQ3S+5rcIQ+GDAfSH19XzY6Ienw3tHpoY=@vger.kernel.org X-Gm-Message-State: APuU4Z/XmseH7+B4/t4SQdSp8KGbjddtRvtvLcm8ZDdO4LLysImYVMvr aKYi9z2JrTuLjBzbLreOVVWK+HlwIckVC5AGHlLQwmNEPtWtPphpVwHono8bG5s5q5/djwtN5Yx qCwDh9ou3uXZc9w== X-Received: from edn12.prod.google.com ([2002:a05:6402:a0cc:b0:6ba:bdbd:ff11]) (user=jpiecuch job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6402:1941:b0:6ba:7be9:ad85 with SMTP id 4fb4d7f45d1cf-6ba7be9aff6mr20568324a12.29.1796043959904; Mon, 30 Nov 2026 05:05:59 -0800 (PST) Date: Mon, 30 Nov 2026 13:05:56 +0000 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 X-Mailer: git-send-email 2.56.1.839.g22a8290db9-goog Message-ID: <20261130130447.2225810-1-jpiecuch@google.com> Subject: [PATCHSET v3 sched_ext/for-7.4-fixes] sched: Fix SCX_ENQ_CPU_SELECTED for queued wakeups From: Kuba Piecuch To: Tejun Heo , David Vernet , Andrea Righi , Changwoo Min , Peter Zijlstra Cc: Kuba Piecuch , Ingo Molnar , sched-ext@lists.linux.dev, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" SCX_ENQ_CPU_SELECTED is meant to tell ops.enqueue() whether ops.select_cpu() ran for a wakeup. However, wakeups delivered through the ttwu wakelist never have the flag set, because sched_ttwu_pending() drops WF_RQ_SELECTED. Schedulers that set SCX_OPS_ALLOW_QUEUED_WAKEUP therefore cannot tell whether ops.select_cpu() was skipped, and SCX_EV_SELECT_CPU_FALLBACK is undercounted. Patch 1 carries WF_RQ_SELECTED across the wakelist the same way WF_MIGRATED already is. Patch 2 adds the enq_cpu_selected selftest. enq_cpu_selected fails without patch 1 because every queued wakeup reaches ops.enqueue() with SCX_ENQ_CPU_SELECTED clear despite ops.select_cpu() having run. Patch 1 changes kernel/sched/core.c and include/linux/sched.h, but only sched_ext consumes ENQUEUE_RQ_SELECTED. A similar change in kernel/sched/core.c, commit 2f7928516314 ("sched/core: Pass ENQUEUE_RQ_SELECTED on initial enqueue"), was taken through the sched_ext tree, so this version is rebased onto sched_ext/for-7.4-fixes. The patches were written with the help of an AI coding assistant. I have reviewed the patches and verified the tests run by the tool. Changes in v3: - Rebase onto sched_ext/for-7.4-fixes (d43078a23723) (Tejun). - Patch 1: Add Cc: stable@vger.kernel.org # v6.15+. - Patch 2: Destroy the BPF skeleton on load failure in setup(), and close open pipe fds on error paths in spawn_pair() as well as unused pipe ends in the forked workers (Sashiko). Resend of v2: - Rebase onto tip/sched/urgent (f4eb2ace3efd); no code or commit-message changes. Changes in v2: - Patch 1: Reword the description to distinguish the wakelist path before ->select_task_rq() from the one after it, and fix the ttwu_do_activate() name (Andrea). Add Acked-by from Tejun and Reviewed-by from Andrea. - Patch 2: Give each ping-pong task its own two CPUs and dispatch to SCX_DSQ_LOCAL. The waker and the wakee then always run on different CPUs, so the test no longer depends on tasks spreading out on their own (Sashiko). Skip on systems with fewer than four CPUs. v2 resend: https://lore.kernel.org/all/20261123171637.3859594-1-jpiecuch@google.com/ v2: https://lore.kernel.org/all/20261026114429.209588-1-jpiecuch@google.com/ v1: https://lore.kernel.org/all/20261023144811.2230393-1-jpiecuch@google.com/ Kuba Piecuch (2): sched/core: Preserve WF_RQ_SELECTED across queued wakeups selftests/sched_ext: Test SCX_ENQ_CPU_SELECTED with queued wakeups include/linux/sched.h | 6 +- kernel/sched/core.c | 10 +- tools/testing/selftests/sched_ext/Makefile | 1 + .../sched_ext/enq_cpu_selected.bpf.c | 111 +++++++++ .../selftests/sched_ext/enq_cpu_selected.c | 215 ++++++++++++++++++ 5 files changed, 340 insertions(+), 3 deletions(-) create mode 100644 tools/testing/selftests/sched_ext/enq_cpu_selected.bpf.c create mode 100644 tools/testing/selftests/sched_ext/enq_cpu_selected.c base-commit: d43078a237230fd8fb6bf082ff285c93d0ccd763 -- 2.56.1.839.g22a8290db9-goog