From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f74.google.com (mail-wm1-f74.google.com [209.85.128.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 535A6347C7 for ; Thu, 23 Apr 2026 20:03:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.74 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776974634; cv=none; b=behKYyv7N8MblyJ2pxhwDRvXV051ZWdeWVhG6TqgiF+W5ylj20/s/JrRNRG13Ew2QrO1/2E2ew8Zg1Wy2R7DINug9+p3qfEheDOqyJ4eM5BiXp87MlRLShoZ1FQEGOrjwIYb7/wSy9L0XtNs4yzv8d0Fs6ePphbLuUfJjyOdrrQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776974634; c=relaxed/simple; bh=88D6n42hHBginyUlsBuZx6d74baBjPj5PUCPzUJNaFM=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=OkxZYt5ea3DdVDjpi2I23+HAKLXWNjOQ4+gJRI2y0z8F2rRA/5I3DF0QCpNuWKbx/esksWGx8CfeKqrEfUaLQ+O3euofUJbRvXrJpdxHlgVMq8knilrGcVL4haEImJYOCJcnprQ7U29VyUFi9POCcdmPttWSRZIi5dJllxl9j5k= 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=kcrJ2CHg; arc=none smtp.client-ip=209.85.128.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="kcrJ2CHg" Received: by mail-wm1-f74.google.com with SMTP id 5b1f17b1804b1-48a588ff84eso23988105e9.1 for ; Thu, 23 Apr 2026 13:03:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1776974632; x=1777579432; 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=dcERZJmtOPbxdqesXvSzInYm/8CS6RdqVfONcfaSFZ4=; b=kcrJ2CHgF7Pi7zD9C/R5E6n/lYtG/g2Q+zhcVsErp1g5UCoh5I59KqzgJl0woTpZTU dHZ13uqM608yCvK5B3Rac4w8EOM8KEDDSNQvvpaKhfKoZSfxvojjRdR5F2gfrmnKKdoH RXOtS9hsv5Khpr7IvTg1gIi1KG6WDg/F6vp1tiHqF18H+Ihlvwb31zUMhlhX5ZL23IDl tJg8rm/S2cPB8DAzGq1WRRjjCmwHbVunAMLSfBdTp5vOVvtXLkv0n2PuecQXVklgKtCE l2oWFZzmUdkYw5rKgZFanxqz3TQ1wawZG6/pvWMQSFPnjKEL/0qfsjXS18nSdXKJeLuB z5aQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776974632; x=1777579432; 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=dcERZJmtOPbxdqesXvSzInYm/8CS6RdqVfONcfaSFZ4=; b=GDIPz6pJWJAlXcdTUzSitL22rwgobaf+fIqCl3BZDgurR74cg3LSTq1WMs3+9rPXLB G1+Cz4akS/UXYzyi7tVbytssIv/G8hz7ln1gUBaRJQWVyIDCBZuwmRDUSOWE35/LgWfz HWDZn1hPj5UQgHVBVfQ+nGOWYlDxSCRx3NX29ms3E3WsQVVIokEtBVE27Mvxf3dBU6CG KxFhtCVSvZU25O3k9/kUxYNKJAMf2aduzUqUe0yQlr9dPYh3+uo8dhxLw3xgg10mL0Rt zmwWfUj3KhxRdISmMS6Jy5EWN8ypp9aPZpSyE/+eehR2fcqEzPioUgxX0TILSTVdMoUN cvnQ== X-Forwarded-Encrypted: i=1; AFNElJ/4uYvF+HRVu5wsP222R1JvVPelpOapcBw/UXleHNgn8uAX8TgsG4PGlsFfw7fYNXFXUSfEx1nnRLg7lIo=@vger.kernel.org X-Gm-Message-State: AOJu0Yzk5TfuzBR8OKvsq01ZLLRlfLuYmYcoJ+Ba09R27d8udJJUrI9l QxaSXZ9EyopRRYjyyznSlA1iBmhT5dwcTZNkXe9rJhjXi1Cx2FgsGRB8H8ur3FX4o1/gs5i2yZC nhM7jgrCEJR2iqw== X-Received: from wmd5.prod.google.com ([2002:a05:600c:6045:b0:488:c686:2b56]) (user=jpiecuch job=prod-delivery.src-stubby-dispatcher) by 2002:a05:600c:8183:b0:488:b187:3c with SMTP id 5b1f17b1804b1-488fb765ab5mr416322805e9.14.1776974631613; Thu, 23 Apr 2026 13:03:51 -0700 (PDT) Date: Thu, 23 Apr 2026 20:03:51 +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" On Thu Apr 23, 2026 at 7:29 PM UTC, Tejun Heo wrote: > Hello, > > On Thu, Apr 23, 2026 at 07:12:18PM +0000, Kuba Piecuch wrote: > ... >> I think these two cases show that we don't necessarily have to migrate a task >> for wakeup_preempt() to be warranted. > > I see. > >> So to cover all cases (that I'm aware of), we need four checks: >> >> * wakeup_preempt() in dispatch_to_local_dsq() in the case of rq != src_rq && >> src_rq == dst_rq >> >> * wakeup_preempt() at the end of move_remote_task_to_local_dsq() >> >> * wakeup_preempt() somewhere on the scx_dsq_move() path, but only if we're >> moving the task to the local DSQ of a remote CPU (?) >> >> * nr_immed check before returning RETRY_TASK >> >> > Adding wakeup_preempt() to local_dsq_post_enq() for every insertion would >> > work too, but I'd rather keep it in sync with how core sched handles >> > move_queued_task() and only add it where it's actually needed. >> >> Does having four separate cases to handle, not all of which involve task >> migration, change that calculus somewhat? >> I believe all of these cases will be handled if we add wakeup_preempt() >> to local_dsq_post_enq(). > > If we call wakeup_preempt() unconditionally, we'd be calling > wakeup_preempt_scx() on every dispatch, which isn't too appealing. We can > add an ENQ flag to mark these sites specifically but I'm not sure whether > that's necessarily better. The invovled code paths are inherently subtle and > finicky, so might as well just add the calls where they're necessary. What > do you think? I don't like the idea of maintaining the separate checks, precisely because of how subtle and finnicky they are. I worry that it will be difficult to keep all cases covered as the codebase evolves. As an optimization, we could skip wakeup_preempt() in local_dsq_post_enq() if rq->next_class == &ext_sched_class. That should make the performance impact negligible in the common case, WDYT? Thanks, Kuba