From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from SN4PR0501CU005.outbound.protection.outlook.com (mail-southcentralusazon11011009.outbound.protection.outlook.com [40.93.194.9]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C3C631F3BA4 for ; Mon, 13 Jul 2026 03:51:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.93.194.9 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783914700; cv=fail; b=Kd+04Tehj9fze5kvgQsnLj2qFTlNL5ZrzOBZWApaAVyiWDMarqf7tTIpKYRJRFZrchae4jOXzFArNzEcBPKp6tMswAaRZCiF4lh3EYtfOFn/4oCrsvcsQAzOgPwzi4is/E2qXdJNnw/GCT+yRJ8FtWe2IdAi2mu/0ggSE+6kdc8= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783914700; c=relaxed/simple; bh=u6eowAOc/sauoPFwhrHns96o9qmeBCi+xgShD8xJWMo=; h=Message-ID:Date:MIME-Version:Subject:To:CC:References:From: In-Reply-To:Content-Type; b=oz5Qi1txAK3aeLI8Kv4US8KYODmTFTTYfN3Lfmx3Gizf+tbnBJ9/oYAsi2qMTsVKHg/UOtC5z5Dwvn3z/dA7nLSa6PMYtYCBWyXk+rlkf0iYnM9mdc+KaJF/QYA1E0PJu4oU78ShDIQN7Y1K1ujRooVaCyI8C5wTFJxrXqGGnv4= ARC-Authentication-Results:i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=DCUzxsU+; arc=fail smtp.client-ip=40.93.194.9 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="DCUzxsU+" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=JtQ2VCDv4OrrrpPPKqhcRntPTQR0DWmWyjG+dgP/hgqL2MOpZoLmzuiwVvge4sTo1DzLpZzDb30nTQu5pG1TAezWAytPirJOF6cju99bA3MwKh5FWUdvlNQ85gwyUcE1fNopfD1aXBjwN7DP4o+iMAVXq/AOSSFUNCmFZJyPxph+mdzDMES9/b+zaX5FdSipGFIqXIMJBroZ8Ef9dF+EzA3/vVz3IjxDUQhVT/dbas560uNochzXq2nL4gOnTvTA6CEDH8H1kUbT7RrptPDv7mtnDHhCKOHY/OCZhyy92iH7TQzmfOd8WJQWgQ8E6jFRcZr67dnpai7hgcfV6tldhw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=kaY4UH9c26zT6IKQCBfGUgTaBRwgnfl9gQ9h7TZJvwE=; b=brRlx5qelR84baR9Zc8B5vEuiU7ZiHVFDxblJSmwi9WiODjPtV3NBlkaJqp8l4ZhiqrrOJ29f2mTVMbCcGRgJdV/ghNcb3XwLMg4eQ6JJiwOVvbDtENb2Zl3n0gOjoZBmPLN5w6KPLRwr1ntlrjoqVrTCCnTWuUa0R00Arlz0lDPPPjJbKnkHlrOlG9FAycvm+7JutIN8BcIcGhJ35Rj7Lwiway2qHDdbvuyx01dgVSigOKUaT292fr273ozk+DdU2cmL+d4pYVxEw2qv6dlWGOcAZEVGWJ4yWBj1U+diQvGo20JAOmxaXTjFqk31QT1hzfPy606SOijzUVnUs6Skw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=gentwo.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=kaY4UH9c26zT6IKQCBfGUgTaBRwgnfl9gQ9h7TZJvwE=; b=DCUzxsU+ZIADXT4YuViuFn2h6uPiQgyfP0dnUsoQPckIG3HvSNxJiUn/FDz96b2ph/PMoiqHYjTxHG0ArGB1ohg2queg4nvChH8pRP+pET3kp0012536hfZ+aVyYAH6cO7kOAabcbR9XHm8kcCHNzPqsEGgqYsdqwVXioIwgtGk= Received: from PH8PR02CA0051.namprd02.prod.outlook.com (2603:10b6:510:2da::21) by DS5PPFFF21E27DC.namprd12.prod.outlook.com (2603:10b6:f:fc00::66b) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.181.22; Mon, 13 Jul 2026 03:51:33 +0000 Received: from SN1PEPF000252A4.namprd05.prod.outlook.com (2603:10b6:510:2da:cafe::b) by PH8PR02CA0051.outlook.office365.com (2603:10b6:510:2da::21) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.202.19 via Frontend Transport; Mon, 13 Jul 2026 03:51:33 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=satlexmb08.amd.com; pr=C Received: from satlexmb08.amd.com (165.204.84.17) by SN1PEPF000252A4.mail.protection.outlook.com (10.167.242.11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.223.9 via Frontend Transport; Mon, 13 Jul 2026 03:51:32 +0000 Received: from satlexmb07.amd.com (10.181.42.216) by satlexmb08.amd.com (10.181.42.217) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.41; Sun, 12 Jul 2026 22:51:32 -0500 Received: from [10.136.35.249] (10.180.168.240) by satlexmb07.amd.com (10.181.42.216) with Microsoft SMTP Server id 15.2.2562.41 via Frontend Transport; Sun, 12 Jul 2026 22:51:27 -0500 Message-ID: Date: Mon, 13 Jul 2026 09:21:26 +0530 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] sched/core: Preserve wake flags across queued wakeups To: "Shubhang Kaushik (Ampere)" , Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Valentin Schneider CC: Christoph Lameter , Shubhang Kaushik , References: <20260710-b4-sched-ttwu-wake-flags-v1-1-23182a4c5367@gentwo.org> Content-Language: en-US From: K Prateek Nayak In-Reply-To: <20260710-b4-sched-ttwu-wake-flags-v1-1-23182a4c5367@gentwo.org> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN1PEPF000252A4:EE_|DS5PPFFF21E27DC:EE_ X-MS-Office365-Filtering-Correlation-Id: 5731b970-283c-4b6f-6efd-08dee0920796 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|36860700016|23010399003|7416014|1800799024|82310400026|921020|13003099007|22082099003|11063799006|56012099006|6133799003|18002099003; X-Microsoft-Antispam-Message-Info: g2RYhrXZMUnddZs4LJ+UHEktnO4Ml0U3pwrA0nxPzMKXCWBWsI97ZQ7cMySegQn2dLoX2IsZGDehE3xG7uk5853xiAAjXDquJkTjck0DqDLEA3RpUdPS6aYmu5s3tBKlBhBM/VgbZ8W/rK2WjGYqlNJO9BVa5sbc9jnqBxye+UBqFugJwAT7m3Wt/VuP+EqjyiSQ1dfVGZitBIcsHUCYg+Pj6iWWMZA15Z6Cqy5mqmkCQZGcnsdGdsdNe9IE/uUztxuA9gsEOD2kYknmhlpwLzNIQE+ooJ3dD6DfZcZaAiP1D7bsMZzIrdBtvb7HmCTfIT3pu0fqSAHvFe8XxM0MTOR5y1swxbRaR4FvkurjD1wTvvgXzAX4srX6zx7FDyJrfnZiSGOSFb4SH7fVH+ps7OMiCmyrtfKQXUgankjUA/+MGobrvcVCeX5Ukdh9awWZClKucmLnq4ja4SRZe3btkHKtYYy8lzVBJ4g+zlfv8UvVHS3J5nt1WL7MgfUS3hcIfAw+DZeQvo4X2XLMXTuyMrz7Sa/M28Zsy4EFwXyOpQsYhaDYd8lDbvV3DDc9hxbKFaB3F/BDtA/c8ceMoBMDyblR+EcX15etjt9N1K8TBot+xLnmh1Tlkal3zJPk/4HATI61hQPVLzltd4dJt2fiop+iT3OXZEUhVy9OD0cwcvg8e3iP6nkh9lDpCr3pilSjtxwls92mQuyYjS4zitxN8HKi22tccWLpkZt1oAwR9qCf5jZFHetcaMVqIztEbR4K X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:satlexmb08.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(376014)(36860700016)(23010399003)(7416014)(1800799024)(82310400026)(921020)(13003099007)(22082099003)(11063799006)(56012099006)(6133799003)(18002099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Yl6Bbuisq2/TgMcFWcHwfVgAotpx4q5/yw7VigopWKrZfWc9URCsjsTzD0p4exHHSwob49Z4a7ihQvIcdLYbG32eA7AjkMR/tJRRkyEGb1LQZJj1Hk9yAB1Mn4X80PpGCjb8rnKnDkS7KcIBIKs37/Pt/3PiIGwM4ped83G12kut6f0nELiprfHANvkcT/lNLUHQ71pJmKQRaVuHw7xCZXN4tUM5CREoqVQzpW/ZteEuJ39RXskgo3gLZIKcY1SYydhsfrx1cHEgq+AA9Sr/G7JN6jgK3c/lars51JQnK8IR1QPWppI8k+3y7cTh5XiH12MdeGJ4dXZP5z4JpLHgHaohYy+wjlja+aHBnogkxgv/tfHs9gDg2cXy+Zw5LEF1khZtMFiy6i9Mds3uP7hbD3ekpdWS74uHB7wT4BWQgE+hv88t3iWVcMH5QCyor371 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Jul 2026 03:51:32.9709 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5731b970-283c-4b6f-6efd-08dee0920796 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[satlexmb08.amd.com] X-MS-Exchange-CrossTenant-AuthSource: SN1PEPF000252A4.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS5PPFFF21E27DC Hello Shubhang, On 7/11/2026 10:47 AM, Shubhang Kaushik (Ampere) wrote: > diff --git a/include/linux/sched.h b/include/linux/sched.h > index 373bcc0598d10b4256a11f8c8373ece78fa5e0e5..5d55cdf696c13ed1c95869a1b6fb4dc1485727dc 100644 > --- a/include/linux/sched.h > +++ b/include/linux/sched.h > @@ -1003,12 +1003,12 @@ struct task_struct { > * schedule() if (p->on_rq && ..) // false > * smp_mb__after_spinlock(); if (smp_load_acquire(&p->on_cpu) && //true > * deactivate_task() ttwu_queue_wakelist()) > - * p->on_rq = 0; p->sched_remote_wakeup = Y; > + * p->on_rq = 0; p->sched_remote_wakeup_flags = Y; > * > * guarantees all stores of 'current' are visible before > - * ->sched_remote_wakeup gets used, so it can be in this word. > + * ->sched_remote_wakeup_flags gets used, so it can be in this word. > */ > - unsigned sched_remote_wakeup:1; > + unsigned sched_remote_wakeup_flags:8; If we are keeping a byte for it, we can just make it a u8 just after the "personality" variable. The reason to keep it at a byte boundary from the rq_lock serialized stuff was to prevent clobbering them but that would be moot now since a byte sized writes is always atomic across all architectures afaik. (https://lore.kernel.org/lkml/20201116142005.GE3121392@hirez.programming.kicks-ass.net/) > #ifdef CONFIG_RT_MUTEXES > unsigned sched_rt_mutex:1; > #endif > diff --git a/kernel/sched/core.c b/kernel/sched/core.c > index 96226707c2f6135341aa779b8262f113e103d8ad..0d2918b66be277ec09109022bf3ede4b9ec8220c 100644 > --- a/kernel/sched/core.c > +++ b/kernel/sched/core.c > @@ -3902,13 +3902,17 @@ void sched_ttwu_pending(void *arg) > update_rq_clock(rq); > > llist_for_each_entry_safe(p, t, llist, wake_entry.llist) { > + int wake_flags; > + > if (WARN_ON_ONCE(p->on_cpu)) > smp_cond_load_acquire(&p->on_cpu, !VAL); > > if (WARN_ON_ONCE(task_cpu(p) != cpu_of(rq))) > set_task_cpu(p, cpu_of(rq)); > > - ttwu_do_activate(rq, p, p->sched_remote_wakeup ? WF_MIGRATED : 0, &rf); > + wake_flags = p->sched_remote_wakeup_flags; > + p->sched_remote_wakeup_flags = 0; No need to reset it. This path is only used for wakeups and next remote wakeup would set these flags correctly before putting the task on the list. > + ttwu_do_activate(rq, p, wake_flags, &rf); On aside note: Only preempt_sync() in wakeup_preempt_fair() cares for this but if the ttwu manages to find an idle CPU, it would preempt the idle tasks anyways and if there are no idle CPUs and WF_SYNC works, it will never use the sched_ttwu_pending() path since it is a wakeup on the local CPU. So, the question is, are these flags even relevant with the remote enqueue path? > } > > /* > @@ -3951,7 +3955,8 @@ static void __ttwu_queue_wakelist(struct task_struct *p, int cpu, int wake_flags > { > struct rq *rq = cpu_rq(cpu); > > - p->sched_remote_wakeup = !!(wake_flags & WF_MIGRATED); > + p->sched_remote_wakeup_flags = wake_flags & > + (WF_TTWU | WF_SYNC | WF_MIGRATED | WF_RQ_SELECTED); You can define a WF_MASK next to all the WF_* flags definition and use it here. It is slightly easier on the eyes ;-) > > WRITE_ONCE(rq->ttwu_pending, 1); > #ifdef CONFIG_SMP > -- Thanks and Regards, Prateek