From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from SJ2PR03CU001.outbound.protection.outlook.com (mail-westusazon11012000.outbound.protection.outlook.com [52.101.43.0]) (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 1D73F1D5CFE for ; Fri, 31 Jul 2026 05:21:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.43.0 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785475312; cv=fail; b=Ar1XdmUebItHwjI2RpHQYEpifpttT3O1Z+xlH46Sl8sLuOrXZF60Z68X3KsxzlG31IL9YcKVUtmx1dMRrHdpGNQTVq+73c2MuyMcnZhYjQhNH9F3gjmmd8cDY/X07P5B9SfBNXofQk8uwKEhka2PTK9IeGQ9UhgoWke8KxAikTk= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785475312; c=relaxed/simple; bh=VvZJu9UzJ+HOjpCR6L875ju2pONt9obDPwOEG1v33Ag=; h=Message-ID:Date:MIME-Version:Subject:To:CC:References:From: In-Reply-To:Content-Type; b=EfJvJTk+EZX2Vmh9Cy0X1XafexSDtVRRcNISJZYlaeWhGXCm6b30axrouuDMnWxC3tSmhP+CbpTxQtSEenTPbzKxv1JE8T6YT4Moui6DB5tRMoczDeWnscE/oSQXsSCy9ONt6gFTVj10wrsDaL3O/f2n6H1kcV/QeB4AYPSwl60= 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=bL3N6kMi; arc=fail smtp.client-ip=52.101.43.0 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="bL3N6kMi" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=SkEyFm2zKZjc2oaogT7UUoDa2scDxvr+J6SJkFARdF1tVqGhB+i5pm61kvmhJ187uyVynr65jx/Q7rl6ZM3Y3jdP5XuEhmKXgLHjspvKbNHEp2wERrkR2hTn/BP0IhfEC3o/eIYj7Ev3o3CxBfMIXhRthX7QFV7sUfYTC8TIqV/cdeyGi3GShBH8g4NXYrED/qA56qzv7SLAfV+smD/uuZzxP+d8u7CKGOA/+T78yhSs+fQTpe0tr/7AP/7oFF4o23eUgUR8rbs7nWyTRRkOmkwD69ZULDAIzybFiNPfG/6uKaT0Hr6GHQ0uigzUmux7yVChjY/UAne72DtydyNS/w== 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=A/p3sncyplu+6uB6O0hfKuJ5xetmNmPnJ3PSlji7OhY=; b=T0EeturSonDOIHPCX/JbK8cq4luwm2K+lv3HWcrvOKylEyvlr3jqCtNt+VZRB20tKqOMPiOc3I2APseaqEYoOYzqho+pExOfzVybwhwKYTWPAXgWsbd2muX7AOewPO11GEyDBM//quN1bMUYhulCHxCaq9YK5fE/uE1s1PDH7b7EXbIWuHDBFhG4hSJHeO1G23sA8cxQX0V1GJN8HBNDkW8Y20+LSAccEOay6zWDuVQHRMwYL8R0ROC8jyJOuTDCTkl/HEUrnm4GJynvaL6PJabRxN4eLfXZXeEpy8FXas+dOtigyS4DQVuOpWQfgR3DQ/i5ztRehSs2PPoBK0oOww== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=nvidia.com 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=A/p3sncyplu+6uB6O0hfKuJ5xetmNmPnJ3PSlji7OhY=; b=bL3N6kMiO9J2fuRokK9gQ89gGMPUeHo1ZNG4ENxAAakn6qHRK9OQ7xHp4o05bqAxA+fFHkOhPw0xXl7x6X6npMAYkitdtJNrnz59SjOB4HcSNERh3D9z1lskRs2F0INss47lVh/HwzGXlAESckbDnuryK46JoPH/f2Tt4F1/zfE= Received: from BL1PR13CA0317.namprd13.prod.outlook.com (2603:10b6:208:2c1::22) by MN2PR12MB4238.namprd12.prod.outlook.com (2603:10b6:208:199::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.270.15; Fri, 31 Jul 2026 05:21:46 +0000 Received: from BL02EPF00029929.namprd02.prod.outlook.com (2603:10b6:208:2c1:cafe::6c) by BL1PR13CA0317.outlook.office365.com (2603:10b6:208:2c1::22) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.270.12 via Frontend Transport; Fri, 31 Jul 2026 05:21:46 +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=satlexmb07.amd.com; pr=C Received: from satlexmb07.amd.com (165.204.84.17) by BL02EPF00029929.mail.protection.outlook.com (10.167.249.54) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.292.8 via Frontend Transport; Fri, 31 Jul 2026 05:21:46 +0000 Received: from satlexmb08.amd.com (10.181.42.217) by satlexmb07.amd.com (10.181.42.216) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.41; Fri, 31 Jul 2026 00:21:45 -0500 Received: from [10.136.32.30] (10.180.168.240) by satlexmb08.amd.com (10.181.42.217) with Microsoft SMTP Server id 15.2.2562.41 via Frontend Transport; Fri, 31 Jul 2026 00:21:40 -0500 Message-ID: Date: Fri, 31 Jul 2026 10:51:39 +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 v2] sched: Reject policy changes with SCHED_FLAG_KEEP_PARAMS To: Andrea Righi , Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot CC: Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Valentin Schneider , Tejun Heo , Patrick Bellasi , References: <20260730135858.2460751-1-arighi@nvidia.com> Content-Language: en-US From: K Prateek Nayak In-Reply-To: <20260730135858.2460751-1-arighi@nvidia.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL02EPF00029929:EE_|MN2PR12MB4238:EE_ X-MS-Office365-Filtering-Correlation-Id: 73ef8c07-83fe-4ef1-279a-08deeec39d9c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|82310400026|36860700016|23010399003|7416014|376014|10067099003|5023799004|11063799006|56012099006|3023799007|18002099003|22082099003; X-Microsoft-Antispam-Message-Info: ANTvuV0pMclz7r4a7i1xUzI3nTkNFGdjCw/zG1ebfGOw159z0kSbNHWldMQopvjsZaUsp/5wAGKSZS3LOtGbwm6Au7dVgBPGKlZtkKJMDT0hCGkOJVuD2WqXus8i7nsew+AmkXTMoKSchuUA+UE3ONiPYdcZLNQEPT0vHlxVKLO62HvEFgLj4m6ewkyqDRlBPJQyOFC6gmhkbczENBZPK7y1hDdLGqGXigf4FO4oWa1os5woqlc1z8KVK5phfyquOHTbq6qAkBFkB6axlcD8sR5vjzObSDoTTq+WdAP0Bv+u6P+hwXvrcJ+jM+fIt4MMbTYI042ccNUxCoiPMiYAhs4kQbc8jJvAEe+DpA1qDbP7aPFXT7Id7PUOfLWsw5ILDE1eMmjZTX4HgiLLVqyW1/N0m/taBL1rpBN8L9cdkY1zntIgEl2zIdtOWHWptGg0ry34n45DRtYq9M9XcMOyLSg8U1phMZbyyIJTcucr3TDx1ddWqWbBXjSMWCrzfSeTfGTG3TiSiOCeqSYMTcxejD0oCr3lOBR1PBM31LnwCLmFGy2c9xOyEZjaZ+MVxYCEDu6dzYh8DrcI04U5oCBRQBl+DN+wu5rKCWwYPUgDN2p69Fy5A5gV0YOimy40vSa56qxaq4YL1DLPyMNm/SjKyDWSy8EZWJFUH3xfN9dE9iVhWxyHk+iULG/6MK6HadR7uz70QgxJ7DBQton0lydP7Q== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:satlexmb07.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(1800799024)(82310400026)(36860700016)(23010399003)(7416014)(376014)(10067099003)(5023799004)(11063799006)(56012099006)(3023799007)(18002099003)(22082099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Q9L6Ml+mq7X9lC24NOMQS56FYqrSUQLm2IjwkE9ODzS7D9//y7zLyhGY6kjHoL4l78OmDZTlw35m9pxwe8Nu95K3d0vowtXcn0cyirXHz6538Jfpv1WiRKrOr5RH4x9RTyux7HQ6kV1hT7qXb2R+ljZ7k4JcTwZ2hc+R64C1zc73hXdv3jSOj3PjnkhKvg2fQwYxQ0wBBlY3O0+xGXFbU8HCsI6anroLabKE34v2oc6R0lpYF/KSTuQAuViyKctLG/nStAzo0eZJXZP6g82C2sqKW+FBuxfr1LryR18oNnFKnMnN3ZJ2HlQ0H0+jDlRjpPt9o2qb9Cx0KOs+p4e0wZyY4Wr4lP6DUcxq0vgdr+qL6232ccuy71IscM4h+8oUdxyEMRoSbQBRksYli1ghE96fPmlmW9jlyjM36S+o1oflvrMhOjEubv+qhTagHcU4 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Jul 2026 05:21:46.3007 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 73ef8c07-83fe-4ef1-279a-08deeec39d9c 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=[satlexmb07.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BL02EPF00029929.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4238 Hello Andrea, On 7/30/2026 7:28 PM, Andrea Righi wrote: > diff --git a/kernel/sched/syscalls.c b/kernel/sched/syscalls.c > index b215b0ead9a60..8fb8474d0a0ec 100644 > --- a/kernel/sched/syscalls.c > +++ b/kernel/sched/syscalls.c > @@ -645,12 +645,19 @@ int __sched_setscheduler(struct task_struct *p, > goto recheck; > } > > + /* KEEP_PARAMS only makes sense if the scheduling policy is unchanged */ > + if ((attr->sched_flags & SCHED_FLAG_KEEP_PARAMS) && policy != p->policy) { > + retval = -EINVAL; > + goto unlock; > + } > + > /* > * If setscheduling to SCHED_DEADLINE (or changing the parameters > * of a SCHED_DEADLINE task) we need to check if enough bandwidth > * is available. > */ > - if ((dl_policy(policy) || dl_task(p)) && sched_dl_overflow(p, policy, attr)) { > + if (!(attr->sched_flags & SCHED_FLAG_KEEP_PARAMS) && > + (dl_policy(policy) || dl_task(p)) && sched_dl_overflow(p, policy, attr)) { > retval = -EBUSY; > goto unlock; > } On an unrelated side note, similar concern exists for p->reset_on_fork and that it can be changed by a parallel sched_setscheduler() that finished before and the one that is lagging can continue with a stale copy. reset_on_fork is computed outside the rq_lock for KEEP_POLICY case and p->reset_on_fork will be set to that if nothing else changes (same policy, same attributes, no uclamp changes) in the early unlock case. Peter, is that a concern? > @@ -675,7 +682,7 @@ int __sched_setscheduler(struct task_struct *p, > prev_class = p->sched_class; > next_class = __setscheduler_class(policy, newprio); > > - if (prev_class != next_class) > + if (!(attr->sched_flags & SCHED_FLAG_KEEP_PARAMS) && prev_class != next_class) > queue_flags |= DEQUEUE_CLASS; Can this happen if we've already ensured policy is unchanged under rq_lock for KEEP_PARAMS? The newprio = __normal_prio(policy, ...); above would have fixed it under the rq_lock right based on policy right? > > scoped_guard (sched_change, p, queue_flags) { -- Thanks and Regards, Prateek