From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qk1-f179.google.com (mail-qk1-f179.google.com [209.85.222.179]) (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 39A192877CD for ; Fri, 12 Dec 2025 05:57:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.179 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765519069; cv=none; b=IvcvgySjckURq8T/TqRUor2sC5FWPSPpF941yoqIQe8YpXiALPv0caN+2vLQMhUvNwoDGOE3IDVfKK0aQ3Ty6E9FPr6B6sfFKfYyZNQ2viPGy6XHQBfNpga5uAR7ytSGzYqcTn62AJtyexHR0lTrTFmKqZfO2AobcBUwiC6jMX4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765519069; c=relaxed/simple; bh=fgsSX3Xvqg0pVTixbgqmuCjN8XlgMkq8rvUKPfF/H5k=; h=Mime-Version:Content-Type:Date:Message-Id:Cc:Subject:From:To: References:In-Reply-To; b=WWFH0+plowJLIiXIIF+RpDn7CwmD8216AKB3R3v/p9IUKv7V8rxZy4F4CPi7kIeFKrLC8ilPtpIbA19JQiQrJyX1gvsagTEL/3j1zbyXMufOIbOxgJiewSsSYLiTNwAjyPLTo7zmpG9fAW6+J0wK535gfMflecfb5GFk67W6AcM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=etsalapatis.com; spf=pass smtp.mailfrom=etsalapatis.com; dkim=pass (2048-bit key) header.d=etsalapatis-com.20230601.gappssmtp.com header.i=@etsalapatis-com.20230601.gappssmtp.com header.b=fs4ajX5K; arc=none smtp.client-ip=209.85.222.179 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=etsalapatis.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=etsalapatis.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=etsalapatis-com.20230601.gappssmtp.com header.i=@etsalapatis-com.20230601.gappssmtp.com header.b="fs4ajX5K" Received: by mail-qk1-f179.google.com with SMTP id af79cd13be357-8b2da83f721so99865985a.1 for ; Thu, 11 Dec 2025 21:57:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=etsalapatis-com.20230601.gappssmtp.com; s=20230601; t=1765519065; x=1766123865; darn=vger.kernel.org; h=in-reply-to:references:to:from:subject:cc:message-id:date :content-transfer-encoding:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=+obT2GMuFzYEIOMsvhKf6eth8yBNwnM9yUNGgmvY90g=; b=fs4ajX5KzWGM+RerUpncj3pWCJpEVtQEOYnJMRlaaHtS3T5suJInmPan2+FirVW2+a eXEkj/7z00VRlZh9VODVmyprU8cSMxnaI09Nub+dO1Hjg7dgkkMZExIy1eU8z4B+j0TA ebwnwkb4b03k3mDfwzA/ofTwfbEGN83XDOJ5PpahuXWoAKH4sh1Dg3YAClKH1YlAQk3L E6SCvV1mlISyRx95GIqUm468xfOHFHHKCjLjlSy2g79JBq66Bq5YqL/g4HxVJU2JGDGE 4AuOAwwBa8IKSCEWGsLrG/k1doKv7e4jipWmkJjJKcsf2cxijtgAO9Icn61/C9iUG/BY sUVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765519065; x=1766123865; h=in-reply-to:references:to:from:subject:cc:message-id:date :content-transfer-encoding:mime-version:x-gm-gg:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=+obT2GMuFzYEIOMsvhKf6eth8yBNwnM9yUNGgmvY90g=; b=vS6V8zLOIDTNMRsMYNFknorj3RUxel7X+xGbBBdASe64muPtmbjMdRHPxMUtRK75En YxPfOujCMpu6/S7m7KAUJMLt8U8wYQ0S8Fn4Mnd1oadIkAMw5kyDCyr1SiolhB4pD0f4 I6u8ilMx2k+6dK+7hd/lqd+9U5j/y9zJk/k1Cba0ZL+g5LmA5BzfTi3QDvqI2ud3bbPe xYLHp7XcAV3ABJNa1Oo8nzNff8kSKZ9UvHJnSaAdAwADt6E6WuZBktHqXRQrEvg1K/Ak xhXoZ9eVTf58dnTok7O+jsgc3Xb1u+kvKaSwARSAYPIpYry0oJM2TYt0EMVaYuUzrFdI IQlw== X-Gm-Message-State: AOJu0Yzvp4Xr4WxpIn4todBavf5xTWihOdVKgK33v7MpVoP3M8H8GeFy twbPJgYkd8GjvldQiX+CQJPh9bcSW5oDMgUKgwNLOrhuXnERa4ppa3KCoJDb+VAwa80= X-Gm-Gg: AY/fxX4vNOfYLOM7HZKBg1/WBVIQVrRfx/lxGPkORjJD4FYGul10+cq3jVFMao61CB0 9DOlHE5JQwx/p5CEfZ6Y75ZDpADVYRU6pbJ74D3RnTJXZKUtPzYCwJLpSCTfhnuJIp/1LDdwFDQ G8BlVHmc4LZT5qWoYIg2xFQoTQTzeXKsH4b+ksHEJsdWzX9wg4dHzhnf/ilvqIP89Jtzau+7eJB NpQR563a5zlOyNK92xGkUhcbrzx+9M4Ix1dyROf5Mg5Nj+8V1phALhZWvssJywH7O15uLeA4WAi /rCy96Gn+3uWhUJjZ7uI+nlRb6Hm3kSRg/GmW1wTmJSDFdCsdvCeDfB6CZm824oynQV9cobnYqy Z/VFl8LcaQoEzNbslU1U91v2a2IQ+p0sQpQF55idXVN/H/u06hoXDpa+oWUSkMQE1JoTCQ9Ko0d GoeQ8qCBozhlXmkxNyqffcFw== X-Google-Smtp-Source: AGHT+IFJyCJZmyqnZwBk6jh7An7wM8i4gimml50s/3knWSXiY1rTb4VzoUtzWii88NakKgFz7dRRCQ== X-Received: by 2002:a05:620a:2a01:b0:8b2:76c6:a7cb with SMTP id af79cd13be357-8bad3fb038dmr613360885a.16.1765519064974; Thu, 11 Dec 2025 21:57:44 -0800 (PST) Received: from localhost ([140.174.219.137]) by smtp.gmail.com with ESMTPSA id af79cd13be357-8bab5d4edbasm381614985a.51.2025.12.11.21.57.44 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 11 Dec 2025 21:57:44 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Fri, 12 Dec 2025 00:57:42 -0500 Message-Id: Cc: , , Subject: Re: [PATCH 2/2] sched_ext: Fix missing post-enqueue handling in move_local_task_to_local_dsq() From: "Emil Tsalapatis" To: "Tejun Heo" , "Andrea Righi" , "Changwoo Min" , "David Vernet" X-Mailer: aerc 0.20.1 References: <20251211224809.3383633-1-tj@kernel.org> <20251212014504.3431169-1-tj@kernel.org> <20251212014504.3431169-3-tj@kernel.org> In-Reply-To: <20251212014504.3431169-3-tj@kernel.org> On Thu Dec 11, 2025 at 8:45 PM EST, Tejun Heo wrote: > move_local_task_to_local_dsq() is used when moving a task from a non-loca= l > DSQ to a local DSQ on the same CPU. It directly manipulates the local DSQ > without going through dispatch_enqueue() and was missing the post-enqueue > handling that triggers preemption when SCX_ENQ_PREEMPT is set or the idle > task is running. > > The function is used by move_task_between_dsqs() which backs > scx_bpf_dsq_move() and may be called while the CPU is busy. > > Add local_dsq_post_enq() call to move_local_task_to_local_dsq(). As the > dispatch path doesn't need post-enqueue handling, add SCX_RQ_IN_BALANCE > early exit to keep consume_dispatch_q() behavior unchanged and avoid > triggering unnecessary resched when scx_bpf_dsq_move() is used from the > dispatch path. > > Fixes: 4c30f5ce4f7a ("sched_ext: Implement scx_bpf_dispatch[_vtime]_from_= dsq()") > Cc: stable@vger.kernel.org # v6.12+ > Reviewed-by: Andrea Righi > Signed-off-by: Tejun Heo Reviewed-by: Emil Tsalapatis > --- > kernel/sched/ext.c | 10 ++++++++++ > 1 file changed, 10 insertions(+) > > diff --git a/kernel/sched/ext.c b/kernel/sched/ext.c > index c78efa99406f..695503a2f7d1 100644 > --- a/kernel/sched/ext.c > +++ b/kernel/sched/ext.c > @@ -988,6 +988,14 @@ static void local_dsq_post_enq(struct scx_dispatch_q= *dsq, struct task_struct *p > struct rq *rq =3D container_of(dsq, struct rq, scx.local_dsq); > bool preempt =3D false; > =20 > + /* > + * If @rq is in balance, the CPU is already vacant and looking for the > + * next task to run. No need to preempt or trigger resched after moving > + * @p into its local DSQ. > + */ > + if (rq->scx.flags & SCX_RQ_IN_BALANCE) > + return; > + > if ((enq_flags & SCX_ENQ_PREEMPT) && p !=3D rq->curr && > rq->curr->sched_class =3D=3D &ext_sched_class) { > rq->curr->scx.slice =3D 0; > @@ -1636,6 +1644,8 @@ static void move_local_task_to_local_dsq(struct tas= k_struct *p, u64 enq_flags, > =20 > dsq_mod_nr(dst_dsq, 1); > p->scx.dsq =3D dst_dsq; > + > + local_dsq_post_enq(dst_dsq, p, enq_flags); > } > =20 > /**