From nobody Thu Nov 28 22:39:09 2024 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7B8B718A6D0; Fri, 27 Sep 2024 08:59:22 +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=1727427564; cv=none; b=BkIq/lWwqZ2rlmlLGmit0m0Yvd1SDE+iwEU9cQppX7vBl5L5iX+wdhtP+Tk2EmAuadPHpUGLqfUgCOVX299w6grnl7IpiUZIxuJOeC/vCBveaktpl2qEiGZUSBCBLZdL8FRRijwJi+AtWV9/QIP1GS0zty6nZK/cZA4c3QCBge8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727427564; c=relaxed/simple; bh=NGLIU0j9AdC9AAMMc2VPzHjSqyonkN6Gs5Ot0xEAcOk=; h=Message-ID:Date:MIME-Version:To:Cc:From:Subject:Content-Type; b=JQ9JCneAcVN1/aAVqXg3FL+Adbxi0RA50Fx2mHQm0kxIY2M2c0gfMrBYhin8oar8o9bqMWJ0eCazx9lZ8uJE2g8eXBFKYryUofvyQmWlWGirTIh9k/bXu+BuA3SQJyiwso4Bo2mDB0xs0eoMRrZYkUEGtMYyD0iDjIuT20/PnDI= 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 3FBC514BF; Fri, 27 Sep 2024 01:59:51 -0700 (PDT) Received: from [192.168.0.16] (usa-sjc-mx-foss1.foss.arm.com [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 7CEE03F64C; Fri, 27 Sep 2024 01:59:19 -0700 (PDT) Message-ID: Date: Fri, 27 Sep 2024 09:59:16 +0100 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Content-Language: en-US To: Viresh Kumar , "Rafael J. Wysocki" , Juri Lelli Cc: Qais Yousef , Vincent Guittot , "linux-kernel@vger.kernel.org" , linux-pm , Peter Zijlstra , Dietmar Eggemann , Pierre Gondois From: Christian Loehle Subject: [PATCHv2] cpufreq/schedutil: Only bind threads if needed Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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: Juri Lelli Acked-by: Rafael J. Wysocki Acked-by: Vincent Guittot Acked-by: Viresh Kumar --- - v2: Add comment for the dl_task_check_affinity return (Juri) v1: https://lore.kernel.org/lkml/480f2140-ea59-4e1d-a68d-18cbcec10941@arm.c= om/ 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_schedu= til.c index c6ba15388ea7..10faab849a3e 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 *s= g_policy) } =20 sg_policy->thread =3D 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); =20 diff --git a/kernel/sched/syscalls.c b/kernel/sched/syscalls.c index aa70beee9895..2ef1cb8626bc 100644 --- a/kernel/sched/syscalls.c +++ b/kernel/sched/syscalls.c @@ -1172,6 +1172,13 @@ int dl_task_check_affinity(struct task_struct *p, co= nst struct cpumask *mask) if (!task_has_dl_policy(p) || !dl_bandwidth_enabled()) return 0; =20 + /* + * 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 --=20 2.34.1