From patchwork Mon Jan 20 10:09:46 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Loehle X-Patchwork-Id: 13944990 X-Patchwork-Delegate: rjw@sisk.pl Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5C1C91AF0B0; Mon, 20 Jan 2025 10:09:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737367800; cv=none; b=HIf1JX52cYa24Jt4jWorb0Z+40Kd75SC/nynD2pKEIm4KSPAV6YGMFb9AtAXt1ykWCArS+f73La4YoMv8OGYF4VLn9d2Koj/c01QQxm986V+MImzp0Rlrxx/crhGNuhJN1OL4PdR12yN0yAneYOB8ferl4ZK1iCu5wOLoe8ytHM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737367800; c=relaxed/simple; bh=UxOQKa4WkPcS1zv5zpAbRahS3K3XYRt4gKb0MtALyIE=; h=Message-ID:Date:MIME-Version:To:Cc:From:Subject:Content-Type; b=DcymbCVbEC8hWhSX9E8KImbzfFubRLSEmYISYQIyPXft4EnY6BvQpoW0WM4btUnIBzgEf/bG3lg6XsvyJVtED+kAsYYSxOaVCmbuT6+q3Z+f6IvqH0fy7z5yRMyvCrq3Uoec9dXCiIFC/54rs/CEA5FfLNUEZGvAJL1ZAjJaFw8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 047321063; Mon, 20 Jan 2025 02:10:26 -0800 (PST) Received: from [10.57.34.174] (unknown [10.57.34.174]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 9CC8F3F66E; Mon, 20 Jan 2025 02:09:54 -0800 (PST) Message-ID: <5a8deed4-7764-4729-a9d4-9520c25fa7e8@arm.com> Date: Mon, 20 Jan 2025 10:09:46 +0000 Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Content-Language: en-US To: "Rafael J. Wysocki" , Peter Zijlstra , Ingo Molnar , "linux-kernel@vger.kernel.org" Cc: Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Valentin Schneider , linux-pm From: Christian Loehle Subject: [PATCH] cpufreq/schedutil: Only bind threads if needed Remove the unconditional binding of sugov kthreads to the affected CPUs if the cpufreq driver indicates that updates can happen from any CPU. This allows userspace to set affinities to either save power (waking up bigger CPUs on HMP can be expensive) or increasing performance (by letting the utilized CPUs run without preemption of the sugov kthread). Signed-off-by: Christian Loehle Acked-by: Viresh Kumar Acked-by: Vincent Guittot Acked-by: Rafael J. Wysocki Acked-by: Juri Lelli --- - RESEND: pick up tags - v2: Add comment for the dl_task_check_affinity return (Juri) v2: https://lore.kernel.org/lkml/a4a70646-98a4-4b85-955e-62d66ba68927@arm.com/ v1: https://lore.kernel.org/lkml/480f2140-ea59-4e1d-a68d-18cbcec10941@arm.com/ kernel/sched/cpufreq_schedutil.c | 6 +++++- kernel/sched/syscalls.c | 7 +++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/kernel/sched/cpufreq_schedutil.c b/kernel/sched/cpufreq_schedutil.c index 28c77904ea74..a81444501158 100644 --- a/kernel/sched/cpufreq_schedutil.c +++ b/kernel/sched/cpufreq_schedutil.c @@ -691,7 +691,11 @@ static int sugov_kthread_create(struct sugov_policy *sg_policy) } sg_policy->thread = thread; - kthread_bind_mask(thread, policy->related_cpus); + if (policy->dvfs_possible_from_any_cpu) + set_cpus_allowed_ptr(thread, policy->related_cpus); + else + kthread_bind_mask(thread, policy->related_cpus); + init_irq_work(&sg_policy->irq_work, sugov_irq_work); mutex_init(&sg_policy->work_lock); diff --git a/kernel/sched/syscalls.c b/kernel/sched/syscalls.c index ff0e5ab4e37c..8230358d2b90 100644 --- a/kernel/sched/syscalls.c +++ b/kernel/sched/syscalls.c @@ -1139,6 +1139,13 @@ int dl_task_check_affinity(struct task_struct *p, const struct cpumask *mask) if (!task_has_dl_policy(p) || !dl_bandwidth_enabled()) return 0; + /* + * The special/sugov task isn't part of regular bandwidth/admission + * control so let userspace change affinities. + */ + if (dl_entity_is_special(&p->dl)) + return 0; + /* * Since bandwidth control happens on root_domain basis, * if admission test is enabled, we only admit -deadline