From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f54.google.com (mail-wm1-f54.google.com [209.85.128.54]) (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 302EA355F3B for ; Sat, 28 Feb 2026 13:06:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.54 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772284013; cv=none; b=OfDodtLI7R8ZmsXiOs5LSx3OUKD7xTE5JhW4LIXLO2tVCFxhLMdLvjdbZGX918/6E/TBlL4hb9Lv7ChU62LHLehkrMD+60jY3rkSRXfEPEwvVipI5ry43t3jAHHAIxDtf2jbu1HqUBgeL4eRn1RPg2y92FeeEH0Q/ADLwmfMV4Y= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772284013; c=relaxed/simple; bh=9p5CUtnhxUpt+91EFTobPI7CLYKd5BJOPWPcoaLYlZA=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=rjyviioz2UoDWH1XsqxG9JI50n6pKIejBOTFFliEW0Fq6gvj/ZzkoGPKiMkmWaV7DAQAfYoD1xtliHVbWzmWw/XASDkfAogdK9Mhidj8wr87V1MWKRUds4y8wo49xVzVd/6xf90roYE1bhuGFZGOku8HoU6o05UJgph8d2n7/DQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=YFGHChWa; arc=none smtp.client-ip=209.85.128.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="YFGHChWa" Received: by mail-wm1-f54.google.com with SMTP id 5b1f17b1804b1-4838c15e3cbso25614075e9.3 for ; Sat, 28 Feb 2026 05:06:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1772284010; x=1772888810; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=R/uU9Q3rk7V7hamXBepNveyff9hJF0AIVNcRb7MAnDw=; b=YFGHChWaspNhHa+jLhViSH8Cu7XxCrz8erd2WZnc8nUpv72/cHqnwbHbh6rpJV1No3 sQ2F0qjS7PyTXQ96z/6Ozvy6Dk4+QFirRtqv9bZR32Zc0uKw3PL7CR3KmLswALxtW+5p n9+/eYlxY0zAryaCM/FMLhbzKU2ozpH77iUYYfAh0LKIVoJxqRTJDVQPQGURlvROoHYF AhnE3hd1yyjQ0sbEcqsH3j8QZaNLMHB03Gy9bvgFoixs2u1AC8IDDsvXRMvwvQDG1LsB VbL4RLsQavKGGaU70TGYGrnEXML+udfGvEZeQuz/R4TofLqdog4f/QbAy2X/Anqyb0Lk ev9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772284010; x=1772888810; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=R/uU9Q3rk7V7hamXBepNveyff9hJF0AIVNcRb7MAnDw=; b=ZvwDnkobSO8WnF+DJrc1+LfrAMb7TahRm0rvnEK8s5qGb2hyh7UO1iD8Fn/8vvVaDK C5Q6Ci3v/yKTV+dMJBadExmZRsJgVIWIITec0pxsWS82w8kq0dd7HnIZY74kYFXoqrO5 u7LSIhF4DMy1MNuLJKG/dJYQ1yJAG3fy5ZslcoxcVmTjhcR3/pnc2LbRvZbSDr1b9a2o +o4m2QeuqrFP6rOOs4PNnbvgnj8JiRsJWWiW7OC6kHqHtxx+hkKDLlMBKYrL9TgZ7gSO 0xGJtuM5UBM8fHt1bKqCpgF7l9YXeBr5bayZnvebopl8S+7rhcH8QIBywu+t8JCFfbqR Bdsw== X-Gm-Message-State: AOJu0YyMTcUWokO2d0iz6xxKL687pX3sCT4UmKHHnvQn7rV08OzWrQPi zTrKhe0Xyy4nlxr9Gj0YMVaZi5mqQfoOTXjmHw/dC1GuCFiAGFbzLgYo X-Gm-Gg: ATEYQzwQGqhtDNy/C8ZjmmJ4rlyybrkoRXeCACZanCfdRyS9MRcOGMkBOXMlpV9x7Js fFVlY8oJNTwqbL9YyfTl/r4QZDj3mUTODOXdZ0rgNtwHaSjuClesZHbj+ja2juePIBNYLC2ldhS 1oTfXsSLp3ryGTkaFobhp4IW/ddcXcv4PoRO5YcEfCI4K5tj1/RXJlg+obnanVlQob3IXqWntc/ JapXedlif2QEfaJnypcR88OL6/1nJtmmbk/NGb05FAh1wrezxMrGvEKQgWbR8S3F97kv/6eQiMP zmm5FiLWg0SpEm9NvujCDFuLoUI7u4xKif+KnRmtvgED7iAKIqmjClpbCSaJ7W9K8pYbBp4/Ajq 5KqF0Q8DEmN+qz9iI7kFbMRodP/RncMvh35nY5ZkcTzN19zXwcMbJjJNLtQpFn7GbqY5Up4Q9fV NrOvivMWnMJieDr2ZZcVxsaT+Hs7Jo/heFV/U7UirD17mIOBcbA5IyCFEqbxsFTvz9BoHt7k9dg MdczMUgwtQuSut5DsTD X-Received: by 2002:a05:600c:4592:b0:480:52fd:d2e4 with SMTP id 5b1f17b1804b1-483c9b78c20mr112274995e9.0.1772284010263; Sat, 28 Feb 2026 05:06:50 -0800 (PST) Received: from rozandragon.chello.ie (188-141-5-72.dynamic.upc.ie. [188.141.5.72]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-483bd7030b9sm227294245e9.4.2026.02.28.05.06.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 Feb 2026 05:06:49 -0800 (PST) From: David Carlier To: Tejun Heo , David Vernet Cc: linux-kernel@vger.kernel.org, David Carlier Subject: [PATCH] sched_ext: Separate lock and first_task into distinct cache lines in scx_dispatch_q Date: Sat, 28 Feb 2026 13:06:47 +0000 Message-ID: <20260228130647.87606-1-devnexen@gmail.com> X-Mailer: git-send-email 2.51.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit lock (write-heavy) and first_task (read-mostly, lockless RCU peek) share the same cache line in struct scx_dispatch_q. Every lock acquire/release by a dispatching CPU invalidates the line for all CPUs performing lockless first_task peeks, causing unnecessary cache coherence traffic, especially across NUMA nodes. Add ____cacheline_aligned_in_smp to first_task to place it on its own cache line, eliminating this false sharing on SMP systems. On uniprocessor builds the annotation is a no-op, so no space is wasted. On SMP, the trade-off is increased struct size: each scx_dispatch_q grows by up to ~56 bytes of padding. There are two instances embedded per-CPU in scx_rq (local_dsq and bypass_dsq), plus any dynamically allocated custom DSQs, so the total overhead scales with the number of CPUs and active DSQs. Signed-off-by: David Carlier --- include/linux/sched/ext.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/sched/ext.h b/include/linux/sched/ext.h index bcb962d5ee7d..2988df68a97a 100644 --- a/include/linux/sched/ext.h +++ b/include/linux/sched/ext.h @@ -70,7 +70,7 @@ enum scx_dsq_id_flags { */ struct scx_dispatch_q { raw_spinlock_t lock; - struct task_struct __rcu *first_task; /* lockless peek at head */ + struct task_struct __rcu *first_task ____cacheline_aligned_in_smp; /* lockless peek at head */ struct list_head list; /* tasks in dispatch order */ struct rb_root priq; /* used to order by p->scx.dsq_vtime */ u32 nr; -- 2.51.0