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 7CF5D34AAE3 for ; Thu, 19 Mar 2026 13:54:35 +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=1773928477; cv=none; b=VwXvjxAdeejjdSEA1gTicwqo1+X9035u5Cw9r+X59rif1YUT03xiu/AY09zr5+OuQYVvALp2t/XyuFVN5ZUDEUl/+8VzYMHQ3RCLu0EYEiyS3t6bETBO8A1ZYw3fqaNah1zEnAWdLiGC2WktWJDF1fXbf+Hiiv1DekGmFOSf4jY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773928477; c=relaxed/simple; bh=nEiSLs2H3Kvd1s/vRGu/XZ2J2WewS2gX5to8YkkCZ/o=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=ShKJgCd6EXfIuoda3icGo6NEBzD/8wc65rjkscHewj/NptErDYKRPAh493NndQg7hfwXsOSEqNEtRVzAl5y2dY8K966FGhX2go40BK3LQ0nZhKpiLtPigvtmoJDSLDbCA5LCXs9WGFs52+Z56qOhFKUhoylheY5sR0zEImdrCwM= 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=LgSsnOFQ; 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="LgSsnOFQ" Received: by mail-wm1-f73.google.com with SMTP id 5b1f17b1804b1-48535f4d5e1so9632475e9.0 for ; Thu, 19 Mar 2026 06:54:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1773928474; x=1774533274; 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=fV8dT3x1VQ3HsGvnNM5pFRRVLSQGVidD/Hn7+GzBMdw=; b=LgSsnOFQHQkfVZcK1BmZCpdB7m0M75Hx1jRYkBrrypM2Y9P1ZZrqUrgnboBifWPXTJ HfCDuSFAuwxIv/71GKMehiF2B1Ak5XBqz5EUsCW7M7hIudhSq/CyZMEBQ04KqRxjsKz9 VWrD1kzchaSkkmSAeRtdouYtvHSB92U3jP8SNI95e3CsqVs6vtA7cgz+N9SqK7TGpUp2 dbVItebP5344jRLDcEVVen7BL5bOPfdBhwEHVlZTvvJInFUHTBJKOdSXyt7q6bv6/0ZV lXif/nhMKJ4WkU/amqJZb/DboRNLF414f0TVYsG7GvH02kOr7b7aSluKhwuZ09aMXRk0 NwQw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1773928474; x=1774533274; 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=fV8dT3x1VQ3HsGvnNM5pFRRVLSQGVidD/Hn7+GzBMdw=; b=T8jyZaYcVcIBorn2YdjqLMmXAqFxwx8KGX5eZcgz8zSwV26hJXB8owvBdhKvShJfeL UZuSO6qtw/DfM5nBCbk7NuCa+JDMERHzXWqs0CygcdQHlvSzepS/JscfCNY+vo3mkYdT NPHoIjPP7+29cEHsQi+fYQvi62dBJl8CnNsW5flTrGE0W703+ruvn5e+OI6b3eq9B7oP HT+vEjfJUxfdtf5Q5qauyEab79sodaKP+REJyLgag2OQE9oDC/5N2/BHRSdd9uV1TGLX 59H5Ho+RHCwO/D4Pr2nu1NHqDwBlE6JboVG2pLgZxVfYyU10hVWliKHrahnevf9A0hDO NmJQ== X-Forwarded-Encrypted: i=1; AJvYcCWr3JNHUeUSvj8R03oR5EldJ5dKVg99Ckvp0SIfTawXb2kGmr4OO9c68rP/nxnF1lfObV7dEw6oyLv0D7w=@vger.kernel.org X-Gm-Message-State: AOJu0Yx3zlueRH5V08s6VlSE1rRvrYW3bcGLcJupcp43B0FbOfzNfaEr SLRn9PP/yGY1yJQfWjAFgjMLAAFkO16ER+Rv92T4x/HkgtyFYESU++NmWsXHaVj/XG5JdMCTrl7 8KSvyDQD+rG6Ohw== X-Received: from wmdd14.prod.google.com ([2002:a05:600c:a20e:b0:480:6b05:6b9a]) (user=jpiecuch job=prod-delivery.src-stubby-dispatcher) by 2002:a05:600c:c491:b0:485:3f58:d9f with SMTP id 5b1f17b1804b1-486f4465d04mr124104415e9.30.1773928473659; Thu, 19 Mar 2026 06:54:33 -0700 (PDT) Date: Thu, 19 Mar 2026 13:54:32 +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: <20260319083518.94673-1-arighi@nvidia.com> X-Mailer: aerc 0.21.0-0-g5549850facc2 Message-ID: Subject: Re: [PATCH v2 sched_ext/for-7.1] sched_ext: Invalidate dispatch decisions on CPU affinity changes From: Kuba Piecuch To: Kuba Piecuch , Andrea Righi , Tejun Heo , David Vernet , Changwoo Min Cc: Emil Tsalapatis , Christian Loehle , Daniel Hodges , , Content-Type: text/plain; charset="UTF-8" On Thu Mar 19, 2026 at 10:31 AM UTC, Kuba Piecuch wrote: >> @@ -2537,9 +2546,26 @@ static void dispatch_to_local_dsq(struct scx_sched *sch, struct rq *rq, >> } >> >> if (src_rq != dst_rq && >> - unlikely(!task_can_run_on_remote_rq(sch, p, dst_rq, true))) { >> - dispatch_enqueue(sch, rq, find_global_dsq(sch, task_cpu(p)), p, >> - enq_flags | SCX_ENQ_CLEAR_OPSS | SCX_ENQ_GDSQ_FALLBACK); >> + unlikely(!task_can_run_on_remote_rq(sch, p, dst_rq, false))) { >> + /* >> + * Affinity changed after dispatch decision and the task >> + * can't run anymore on the destination rq. >> + * >> + * Drop the dispatch, the task will be re-enqueued. Set the >> + * task back to QUEUED so dequeue (if waiting) can proceed >> + * using current qseq from the task's rq. >> + */ >> + if (src_rq != rq) { >> + raw_spin_rq_unlock(rq); >> + raw_spin_rq_lock(src_rq); >> + } >> + atomic_long_set_release(&p->scx.ops_state, >> + SCX_OPSS_QUEUED | >> + (src_rq->scx.ops_qseq << SCX_OPSS_QSEQ_SHIFT)); >> + if (src_rq != rq) { >> + raw_spin_rq_unlock(src_rq); >> + raw_spin_rq_lock(rq); >> + } >> return; >> } > > My understanding is that task_can_run_on_remote_rq() can run without src_rq > locked, so it's possible that @p's cpumask changes after the check, isn't it? > In that case, I think it's still possible to move the task to the local DSQ > of a CPU that is outside of its cpumask, triggering a warning in > move_remote_task_to_local_dsq(). I've looked at the code more carefully and I don't think this is an issue. It's true that task_can_run_on_remote_rq() can run without src_rq locked, and it's possible that the cpumask changes after the check, but then the dequeue preceding the cpumask change must have waited for ops_state to change from SCX_OPSS_DISPATCHING to SCX_OPSS_NONE and it must have reset holding_cpu to -1, so thanks to the holding_cpu check later we won't insert the task into the DSQ. Apologies for the confusion.