From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f73.google.com (mail-wm1-f73.google.com [209.85.128.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 5C93332E6BD for ; Thu, 2 Apr 2026 14:13:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.73 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775139206; cv=none; b=iFxcMGaxzgx9aYWHVxTJYDIBlj4GjD2h/V1XBkWpuyKzX5z/kQJSjikLPISZLFunT9XVtq+19FMsVP+7qhLDSFjh2d9N7I2d9FTUFXqJRYG+5WEGS/wCliB5ZMmAIXg4iuLL+oqhbWjik6iomgADn0rFlU8obHqBuYJ52VGH+dU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775139206; c=relaxed/simple; bh=SuRN7qly4s3ceLzd5tJA5RAgim6jIz/S496DedkAKRA=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=rhbXmpoaOwD+2xdrEw82wQ2qFnLJGb/amoBCOo5gjcNyFYGN07A17PwlCD47YepDhe4rljjn7U+raOvC8I8QnoAKbK9LOzIOUI174Ob/Ti0JdDgn4S37R9p2+tOeq8piV2wX8PNyRDDGZyD/DLhCj2Qj7o89Pl6fMQ5Go7LoAHc= 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=uGBX8S4E; arc=none smtp.client-ip=209.85.128.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="uGBX8S4E" Received: by mail-wm1-f73.google.com with SMTP id 5b1f17b1804b1-48544725bdeso11383635e9.2 for ; Thu, 02 Apr 2026 07:13:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1775139204; x=1775744004; 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=hR7KwIEWfhUL9vCYoy3LE/AFP3V7kb39QeSgR/ASWis=; b=uGBX8S4EeWgry0mR3y8N3MSS0QMDmMM9POY0HJ9S8sJR5BF2c+ICxLUS+UxFBMul47 2zVNOyBLsb0Df/yIMwH+OhsNybM0R2IsoJ7RPzUnv0HTQptJmBPMEHqTLHw4sP4i5ruc r4YFHbb9ZQwmp+BtgIGeKw5niEzDEFkz21o+qRtU/KpOVvAXQJZjd5OPdFO8G1CInqP8 wcdwpswOVBrv6BF2aKEoiCXfLFQ+kUq76luuMfV/x+DzivjGQIluUJPLcgOeNLLd76uU Z6CBv64e6lzpXZu2XrF50Fc9rdV5lHXBAQU4l2vgJiaFvFjWFWFzhHX1ztC1bPRauKpU qVmQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775139204; x=1775744004; 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=hR7KwIEWfhUL9vCYoy3LE/AFP3V7kb39QeSgR/ASWis=; b=XZORAEy1W55UPBM3ZCACdWt+v8v2UHYooI3ktdfNfMl+Qe8lafW0z4oXYvX0HvRiQg vgs/HTcRBAyV/ye7+y0bHiLeMnxCNhp9R3Z0dpyZAv12AyyZ5AYCWeNgTryMtXwNjsOD JqNB+O3yZ0NLKxaZCezWqdI5ge8MXSa8vEuacVgQD53Fd6HJeFFkcQKhkRiQ3grnL9SZ DoyuZoWWZd/gckn5TQrrkq+a7bKfgF8f8ESjuoAIPaAy6k9FrnHgt5RF3gXfTIHdqhbV wjxZtuQlsUNdw1B3Z/TW5ZSyJB8Ggfs/LfgFWEEPYeVsYJcPIof0UPigc+b9S03KCS+i Stfw== X-Forwarded-Encrypted: i=1; AJvYcCUoPT6ayq6YYiStFhLgUl5bl6ZQha1gyzafqrt2tkiGq4NnwjAmVlSj7T5kPMwwaO0aiF6g6ue06UU+Vjc=@vger.kernel.org X-Gm-Message-State: AOJu0YzwCqio/nu6eClL8NBLX8C9uDxfJdjY94LSSm1wlYZiXbdu0hWe iDMXPRpN9Wr/LxOaCx+/FP2X0B3kXDrAWPDR+opCk2i8zvjIhaYW4WliAM6iN8HsavJ2iLXVD4E PN2Bmx3JD+9W6xQ== X-Received: from wmrk22.prod.google.com ([2002:a05:600c:b56:b0:485:3ddc:f27a]) (user=jpiecuch job=prod-delivery.src-stubby-dispatcher) by 2002:a05:600c:a10f:b0:488:81b1:ae36 with SMTP id 5b1f17b1804b1-4888b78657bmr40367425e9.23.1775139203662; Thu, 02 Apr 2026 07:13:23 -0700 (PDT) Date: Thu, 02 Apr 2026 14:13:22 +0000 In-Reply-To: <20260402023150.660967-1-changwoo@igalia.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260402023150.660967-1-changwoo@igalia.com> X-Mailer: aerc 0.21.0-0-g5549850facc2 Message-ID: Subject: Re: [PATCH] sched_ext: Fix is_bpf_migration_disabled() false negative on non-PREEMPT_RCU From: Kuba Piecuch To: Changwoo Min , , , Cc: , , Content-Type: text/plain; charset="UTF-8" Hi Changwoo, On Thu Apr 2, 2026 at 2:31 AM UTC, Changwoo Min wrote: ... > static bool is_bpf_migration_disabled(const struct task_struct *p) > { > - if (p->migration_disabled == 1) > - return p != current; > - else > - return p->migration_disabled; > + if (p->migration_disabled == 1) { > + if (IS_ENABLED(CONFIG_PREEMPT_RCU)) > + return p != current; > + return true; > + } > + return p->migration_disabled; > } The fix looks correct, but the logic looks somewhat convoluted. How about something like this: static bool is_bpf_migration_disabled(const struct task_struct *p) { - if (p->migration_disabled == 1) - return p != current; - else - return p->migration_disabled; + if (IS_ENABLED(CONFIG_PREEMPT_RCU) && + p == current && + !WARN_ON_ONCE(!p->migration_disabled)) { + return p->migration_disabled - 1; + } + return p->migration_disabled; } My thinking here is: if CONFIG_PREEMPT_RCU is enabled and we're current, subtract 1 from p->migration_disabled to account for the BPF prologue. Otherwise just return p->migration_disabled. I've also thrown in a WARN_ON_ONCE to help catch potential bugs if the assumption about the BPF prologue ever changes. Thanks, Kuba