From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) (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 610173B47CC for ; Mon, 3 Aug 2026 08:41:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.69 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785746504; cv=none; b=ROTPiTxRI9/DHRpw4k+uJgBUvXRsSAwwudfXkaR/tEduhj/sDdVVF2MXYTaPEe2NqXL7zfJFLTuU0AFtnijrA8vonBJ1XaE03zZJV/jQKFor8YaHxFzS8ji/W1dWztvx0dfhCPiBTQDXidEJmHCUJu0ng4w45enx1hs7kccbivo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785746504; c=relaxed/simple; bh=1qZLkMzxbNVeupdxnfY1qtQ+t96GPwnCSyrC+92BIMI=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=RkrYSmos6LiFz9vZdpanChLWSPXE6MFd4IFPIeKQksg45IJ5tWpBoK5WVqg2Z52aN/48gfmhhEMFTySZsd7+Nz5bv69yCATvVT/dURzVDoj3DVo+BC2iha3hhPVlX1XM1UrZTaXgIRGQ/AUHr4ouYm9vVGpDsGhLIs+jHz594pw= 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=d87XID6t; arc=none smtp.client-ip=209.85.128.69 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="d87XID6t" Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-495689bfcc8so11533635e9.1 for ; Mon, 03 Aug 2026 01:41:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1785746497; x=1786351297; darn=vger.kernel.org; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:from:to:cc:subject:date:message-id:reply-to :content-type; bh=q0tDL/ftQGMKvtHX/czwWb9AVoAwimBy8i+zDmKBWzs=; b=d87XID6tiam9Df8iPB2JI68cPwF94ylgt8rrwi6JvAO+yDNCmR9lDQgwnQeuxRow7n 0jSYIASkzIp9g3YWB1DFfkFKl7szrg61OXA4v3uo0sRQatcWqCPsQLPJIw5EGi94JHyJ cTkJFY30FBimK18a+/5vlj3uEZtrCjgOFFm0F6DaiB13jsXzEG+dbkEUl6Gn7g6oPUTz DGBaQgMY8cwv0ckzwEmu19uKHdqZqeiLrAHYkc52bP05RB4CQ8ZziHMCgu09kfC2H8x/ LMrfKmZTTMin+/yMZcuTYeuuiblskHgVg5vB2OWys2oAd4Bmq/JPGciCSCzHyAMIW/56 RpUQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785746497; x=1786351297; h=content-type: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:content-type; bh=q0tDL/ftQGMKvtHX/czwWb9AVoAwimBy8i+zDmKBWzs=; b=FTN1D6PR1UnOBGmqpqHRhuTGv1FeRdPtyktK8dohHTH39wps5Z9hdmGlJNKdsPcfZY WX+TKCUqvz7YJKZUypFDHrHbUwRJNjGIj90Qy/MO/bBTIDUg1vH7T+dAzk3qN87ioZ+M RWIih45pJRKBKrcef4bRVj96tFrbOp+XTw6z6PBSlUlPyPrZqP3/C0xC95kXxE/JzsDB XW8q/doJlwI6SW0RqwwszLBCNHmL8H+P5RHje0oThuiIHuahdSlNEFiuPfOL1Lq6vdaC U9zAl/kRoQUkVkx+NUl0fBVLDD5pCmsFIaXoc5VU8LvJ1U9eu0xUlQ3diZv9VmPYrCKc 2mpQ== X-Forwarded-Encrypted: i=1; AHgh+Rol1q0/IiySvPV+Ntbniak8v8AqDHQHvEcmZiiBPou8GidhqAkRIQmVlJ5USBEwMhwqIPavx+VxshWJtiI=@vger.kernel.org X-Gm-Message-State: AOJu0YxVh1E+csKoHAR0kyCRJczy0Q8OjDRSnuxs5InjZzT2B0/rakP4 PrFdaqMxqA081F7SyUHkuvpRxPoVoRtNfF/dlvr0SKqYOO/M81flhD7vJ38xRkNcw34//199sMW ML3dGrdIMSHtRZw== X-Received: from wmbil26.prod.google.com ([2002:a05:600c:a59a:b0:48f:dc9f:6f1a]) (user=jpiecuch job=prod-delivery.src-stubby-dispatcher) by 2002:a05:600c:871a:b0:498:952:e276 with SMTP id 5b1f17b1804b1-4980c66c991mr235781265e9.8.1785746497363; Mon, 03 Aug 2026 01:41:37 -0700 (PDT) Date: Mon, 03 Aug 2026 08:41:36 +0000 In-Reply-To: <20260803060930.4111746-1-arighi@nvidia.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260803060930.4111746-1-arighi@nvidia.com> X-Mailer: aerc 0.21.0-0-g5549850facc2 Message-ID: Subject: Re: [PATCHSET v4 sched_ext/for-7.3] sched_ext: Fix idle CPU state initialization and validation From: Kuba Piecuch To: Andrea Righi , Tejun Heo , David Vernet , Changwoo Min Cc: Kuba Piecuch , , Content-Type: text/plain; charset="UTF-8" On Mon Aug 3, 2026 at 6:08 AM UTC, Andrea Righi wrote: > The built-in idle masks are initialized with all online CPUs marked idle, but > idle tracking currently starts only after sched_ext is fully enabled. This > leaves busy CPUs incorrectly advertised as idle during ops.init() and until > their next idle transition. > > Moreover, the allowed_cpus selftest checks that a remotely selected CPU is no > longer present in the idle mask. An idle-to-idle re-pick can re-advertise the > CPU before the test performs this check, making the validation inherently racy. > > Fix this by initializing the built-in idle masks empty. This makes the initial > state conservative, so busy CPUs are never incorrectly advertised as idle. Once > the scheduler is enabled and bypass is lifted, the existing idle re-notification > path reschedules every online CPU. Idle-to-idle re-picks then populate the masks > with CPUs that are actually idle. > > Also rework the allowed_cpus kselftest to replace the racy remote-CPU check with > a stable local invariant: a CPU running a non-idle scheduling context must not > be advertised as idle. > > Changes in v4: > - Initialize the built-in idle masks empty instead of enabling idle tracking > before ops.init() and refreshing every CPU under its rq lock (Tejun Heo) > - Rely on the existing bypass idle re-notification path to populate the masks > with CPUs that are actually idle > - Link to v3: https://lore.kernel.org/all/20260731182406.3166853-1-arighi@nvidia.com/ > > Changes in v3: > - Reuse the built-in idle-selection static key instead of introducing a > dedicated idle-tracking key (Kuba Piecuch) > - Check the local CPU-idle invariant from both ops.select_cpu() and > ops.enqueue() (Kuba Piecuch) > - Inspect the idle mask without modifying it and perform the check before > calling scx_bpf_select_cpu_and() (Kuba Piecuch) > - Link to v2: https://lore.kernel.org/all/20260731090334.2911948-1-arighi@nvidia.com/ > > Changes in v2: > - Move idle-mask initialization from the selftest into the sched_ext > core (Kuba Piecuch) > - Add a dedicated idle-tracking static key so transitions are tracked > before the scheduler is fully enabled (Kuba Piecuch) > - Rework the allowed_cpus selftest to validate the stable local CPU-idle > invariant > - Link to v1: https://lore.kernel.org/all/20260726064754.378671-1-arighi@nvidia.com/ > > Andrea Righi (2): > sched_ext: Initialize idle masks as busy > selftests/sched_ext: Make allowed_cpus idle validation race-free > > kernel/sched/ext/idle.c | 16 +++---- > .../testing/selftests/sched_ext/allowed_cpus.bpf.c | 49 ++++++++++++++++++---- > 2 files changed, 50 insertions(+), 15 deletions(-) Thanks Andrea, looks good to me! For the entire series: Reviewed-by: Kuba Piecuch