From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f74.google.com (mail-wr1-f74.google.com [209.85.221.74]) (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 390FF3E5EE8 for ; Thu, 23 Apr 2026 09:48:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.74 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776937696; cv=none; b=TkOPKILGbb4C968lQhCZINAY16exTdi5JIKhHT+/aHye7ITv1wsN00qE/7EGFWbdInEzk63UJhXOUhWoA2gY9KqrZ/QZMBBfP+v/+XDKya9KhxZA9blUhdLnWY4PG6u/phqKVNG920laOI8dMsCEAhrH/oR2sTYLwNsjPljHueA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776937696; c=relaxed/simple; bh=isUGdThoupT1njkgBQnVVrdFvbO/3BNw0h/VGihjLec=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=ZaR0/s2/GW6oCaWJHMKXPfaEz2y44ZQHZpGT4YkoEyHcVQ6ERz0uUUNoZC+Xkoz5ouVT/iAPCf9OP7FVaSPrXBnj2T7otsLJttDR3iDPOegxwTVLd1toFRDllxsRoxT5px96zTIjfFwqSPBcK8H767U15Hz/GXo/1vA8ag+dtm4= 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=ssmbySBN; arc=none smtp.client-ip=209.85.221.74 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="ssmbySBN" Received: by mail-wr1-f74.google.com with SMTP id ffacd0b85a97d-440d0d7872aso3727076f8f.2 for ; Thu, 23 Apr 2026 02:48:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1776937693; x=1777542493; 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=9Hl1kWGbH9q/qjzDK/ZdU4A22sT2z4nhW5mix2FM6i4=; b=ssmbySBNlTDxqXlc1h7mTy9YWhWE7gaRKodRBI3xZ5+sNOClpmzwu43OE4g5Lczcht FFDF+Vqh2lkf7Me2Mrp/lA5hIs9PRitgXBmGuW3wu3pzPE0T0WLoi4alrBjW/zr3MvW+ K7VTCZyUZKrc6YntbqSRq+VRl+ApVS08Yil5RUU5VwstkeoLcJAvxTGl+sCpb+GbcuPH 8zB+f97hc98bQ6ImrGJ7G9M8PbAhrjwS7j0OkXlrRSbeqlLA4zdQ4KP+mTegQhSJncFR xad95dDqKiHb81RjPAybVT93J/01S/rewkp3QqUuB7ogsXmXSxS5kGNcEfrXaJzOz/Tp qUeA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776937693; x=1777542493; 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=9Hl1kWGbH9q/qjzDK/ZdU4A22sT2z4nhW5mix2FM6i4=; b=AS4aF3X/ZTf+Ihgq4ki+/jSP1D+acaLBPyi80T5eEzlOHPCjadyDILLjFYbSs59SGf kn4u/eNBZKBv+bSl3I0jlc1zdhcY6XDEJQ1SqDipRcPWjT0IDFbAaSqLdoay2/GE0X9M weknbQgypUoJMRuZo9J/2a/IwlMqt2cmqptZxf2KfTXb7C5jtcuntnBOJbzjTBoFvYBi xbOsdIGu2x0hJfwdXrPFpiZzqCAOjWsVhE4Mr296NRammtCFSxo3XeVVOg1YHuqyQ8x2 ZMpN5dn4o2knFPdCpBlYVNY8V+p63hPxqv9KB8VaruwDkOxrXaPIEWeIa+GNu+CDyVWY 4AZA== X-Forwarded-Encrypted: i=1; AFNElJ8w7717TtZ76ghp3gDuoboF8ADBbFAQYPM1PK44uKaRz4BcG9iGgsFZ8XEjR4PKyG4ruRwbaCiLot3xfZs=@vger.kernel.org X-Gm-Message-State: AOJu0YzYHbRXLikJ4yPYvyZPlEBI/WJEh3MbJ35BjYCfH6w2tbpx7Awr tsd/BPmBMQFzdQMtb8URtXNMvUWp11nPY+qGK5b87rxVanyCyQ7uSB1w25vGYPb8j5DAakUoLIg vq2FY6R8834o2CQ== X-Received: from wmro12.prod.google.com ([2002:a05:600c:378c:b0:488:c2a4:dd33]) (user=jpiecuch job=prod-delivery.src-stubby-dispatcher) by 2002:a05:600c:a305:b0:48a:53cb:85f4 with SMTP id 5b1f17b1804b1-48a53cb8734mr145926305e9.24.1776937692621; Thu, 23 Apr 2026 02:48:12 -0700 (PDT) Date: Thu, 23 Apr 2026 09:48:11 +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: X-Mailer: aerc 0.21.0-0-g5549850facc2 Message-ID: Subject: Re: SCX_ENQ_IMMED potentially leaving dispatched tasks lingering on local DSQs From: Kuba Piecuch To: Tejun Heo , Kuba Piecuch Cc: Andrea Righi , Changwoo Min , David Vernet , , Content-Type: text/plain; charset="UTF-8" Hi Tejun, On Wed Apr 22, 2026 at 4:50 PM UTC, Tejun Heo wrote: > Hello, Kuba. > > On Wed, Apr 22, 2026 at 01:21:27PM +0000, Kuba Piecuch wrote: >> diff --git i/kernel/sched/ext.c w/kernel/sched/ext.c >> index d66fea57ee69..480627fdc203 100644 >> --- i/kernel/sched/ext.c >> +++ w/kernel/sched/ext.c >> @@ -3079,8 +3079,11 @@ do_pick_task_scx(struct rq *rq, struct rq_flags *rf, bool force_scx) >> * If @force_scx is true, always try to pick a SCHED_EXT task, >> * regardless of any higher-priority sched classes activity. >> */ >> - if (!force_scx && rq_modified_above(rq, &ext_sched_class)) >> + if (!force_scx && rq_modified_above(rq, &ext_sched_class)) { >> + if (rq->scx.nr_immed) >> + schedule_reenq_local(rq, 0); >> return RETRY_TASK; >> + } >> >> keep_prev = rq->scx.flags & SCX_RQ_BAL_KEEP; >> if (unlikely(keep_prev && > > Ah, good catch. > >> ...but I think this only fixes the case where the RT task wakes up on the CPU >> that is doing the dispatch. The other case is one where the RT task wakes up >> on the remote CPU (the one the second task was dispatched to) after insertion >> of the second task, assuming the remote CPU is initially idle. >> >> To fix both cases, one potential solution that comes to mind is bumping >> rq->next_class to &ext_sched_class when inserting a task into rq->scx.local_dsq. >> Perhaps we should call wakeup_preempt() in dispatch_to_local_dsq()? > > I think what's missing is wakeup_preempt() call in > move_remote_task_to_local_dsq(). This is SCX's version of move_queued_task() > and we're missing wakeup_preempt() call after activate_task(). I'm not sure if we should limit ourselves to just remote tasks. If we call wakeup_preempt(rq, p, flags) when adding @p to @rq's local DSQ regardless of whether @p/@rq is remote, then I think that should cover all cases and the patch above wouldn't be needed. Perhaps local_dsq_post_enq() would be a good place to invoke wakeup_preempt()? Thanks, Kuba