Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp6654480pxb; Wed, 17 Feb 2021 09:46:38 -0800 (PST) X-Google-Smtp-Source: ABdhPJx1Ja1KhYeDTwXEtpJNgxtthRMS8RM4JnC8A3qlkwWcGttRazJWp6ShlMxKtNLrGqfuo80T X-Received: by 2002:a17:906:fcb9:: with SMTP id qw25mr92038ejb.11.1613583998225; Wed, 17 Feb 2021 09:46:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613583998; cv=none; d=google.com; s=arc-20160816; b=VtnW/JCkBjIUahy+gC6CI3cEaDAnl3k2QASbpP+97eMr8hVqHVtKlXWVVP6IzcUsw4 XfjFnAmGkSrVJifzmr6Z/mgFKQG3vsNnNqyt2yfe0Y3cdh58x0fWuZbWRM7S1AodIUZ0 Tvn1dXYvMWCz1t8rG2ixeS0ela/DWhHoJ4y9hssACWdJUL+Qc7nX0yvGN0ncfxCd9V7y kiAJHgBU1rmFpAZUu2tD30ILBCgenZmkP7Z8eEzcehtmF/v58i8z438cHfHlGE9no8lr 1lQ40kaaFUBulj5DshVkI3ftd4eErYqwx1jf4/5Sk2bsWuTPqXOGRFWHUioZesY15k9e gY6Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:references:in-reply-to:cc:subject :to:reply-to:sender:from:dkim-signature:dkim-signature:date; bh=BhrL3muAkfD1OC8usgerNu9bZp7BL+G3tfzCSg2lOdY=; b=KmV8aT1jItT5YnGR9ZOjmxeaghTFPCz4ZeuCjoHhjVtqXs/6vNx3nCWUKXW8cqvbSN YdHhYKVxZnq8ob0+uFGV0FFQKStKBXLbmygUXcsOcrVt0IuWlOc7pUbhmURu1S/Os6P1 s/OBvcJQl3762DVdl+zsam6yiFTk0eCUaZ25brD+085EkNTo913sP+MmxcTfqa4HqDeq 5XjwlbT+OUjB52JMMmlCek6NBeEW8M1h/Q58dqfqX00s51jdATPVNwEdS155O4s+hnp5 fLTiApsnxAe2b4wvgtkz1du/6m74hw4DfpTtzsC14c+0da1vZvdMXaQbEAl+X3+gaQqd bFUQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=MnJ52zHx; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w5si2134125edv.513.2021.02.17.09.46.12; Wed, 17 Feb 2021 09:46:38 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=MnJ52zHx; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232935AbhBQNU5 (ORCPT + 99 others); Wed, 17 Feb 2021 08:20:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33094 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232813AbhBQNSQ (ORCPT ); Wed, 17 Feb 2021 08:18:16 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0245BC06178A; Wed, 17 Feb 2021 05:17:35 -0800 (PST) Date: Wed, 17 Feb 2021 13:17:32 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1613567853; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=BhrL3muAkfD1OC8usgerNu9bZp7BL+G3tfzCSg2lOdY=; b=MnJ52zHxszhLJ/ux0M7QU4YYXdpOcO40aMqvXoZTLHY/yQgF1Rtgu41vYFH4YBD0vEZ0O5 1+rpdIIB0OnCAaan/xzn8NJLBoKHfrgun9jZF+X9zsJRGgBqQndQsFf57E6TiY0X8YhViU uIgJxzgOtgYS/5qTNDl4t9xzA/iyu9l7L7KMzEup76bopa52Hzq9KLVEh5hxJtNHvIp0KL 2soVSGiq1Oc2vOiLsbi0uTN5qQHM8TaF0LqHQakwmIaiX5YdAefH2IaETgkYU+N8FAY8l2 s2TI/5KcuKRy5UF1ahlVA0Kkcaik5C7CMdsM6dMl0lo2JTKf6mJZSq3XlJv2/g== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1613567853; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=BhrL3muAkfD1OC8usgerNu9bZp7BL+G3tfzCSg2lOdY=; b=xPUGjGMr5OAf3f3UWGSJMSLnEBkcnHaEbdAoeMstOlTrIB6DDGb/u9NTOvRpK3Hwyq36SE yZ0qrF76nh9jmnDQ== From: "tip-bot2 for Dietmar Eggemann" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: sched/core] sched/deadline: Reduce rq lock contention in dl_add_task_root_domain() Cc: Dietmar Eggemann , "Peter Zijlstra (Intel)" , Ingo Molnar , Quentin Perret , Valentin Schneider , Daniel Bristot de Oliveira , Juri Lelli , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20210119083542.19856-1-dietmar.eggemann@arm.com> References: <20210119083542.19856-1-dietmar.eggemann@arm.com> MIME-Version: 1.0 Message-ID: <161356785255.20312.13367741328558766056.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the sched/core branch of tip: Commit-ID: de40f33e788b0c016bfde512ace2f76339ef7ddb Gitweb: https://git.kernel.org/tip/de40f33e788b0c016bfde512ace2f76339ef7ddb Author: Dietmar Eggemann AuthorDate: Tue, 19 Jan 2021 09:35:42 +01:00 Committer: Ingo Molnar CommitterDate: Wed, 17 Feb 2021 14:12:42 +01:00 sched/deadline: Reduce rq lock contention in dl_add_task_root_domain() dl_add_task_root_domain() is called during sched domain rebuild: rebuild_sched_domains_locked() partition_and_rebuild_sched_domains() rebuild_root_domains() for all top_cpuset descendants: update_tasks_root_domain() for all tasks of cpuset: dl_add_task_root_domain() Change it so that only the task pi lock is taken to check if the task has a SCHED_DEADLINE (DL) policy. In case that p is a DL task take the rq lock as well to be able to safely de-reference root domain's DL bandwidth structure. Most of the tasks will have another policy (namely SCHED_NORMAL) and can now bail without taking the rq lock. One thing to note here: Even in case that there aren't any DL user tasks, a slow frequency switching system with cpufreq gov schedutil has a DL task (sugov) per frequency domain running which participates in DL bandwidth management. Signed-off-by: Dietmar Eggemann Signed-off-by: Peter Zijlstra (Intel) Signed-off-by: Ingo Molnar Reviewed-by: Quentin Perret Reviewed-by: Valentin Schneider Reviewed-by: Daniel Bristot de Oliveira Acked-by: Juri Lelli Link: https://lkml.kernel.org/r/20210119083542.19856-1-dietmar.eggemann@arm.com --- kernel/sched/deadline.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c index 1508d12..6f37796 100644 --- a/kernel/sched/deadline.c +++ b/kernel/sched/deadline.c @@ -2388,9 +2388,13 @@ void dl_add_task_root_domain(struct task_struct *p) struct rq *rq; struct dl_bw *dl_b; - rq = task_rq_lock(p, &rf); - if (!dl_task(p)) - goto unlock; + raw_spin_lock_irqsave(&p->pi_lock, rf.flags); + if (!dl_task(p)) { + raw_spin_unlock_irqrestore(&p->pi_lock, rf.flags); + return; + } + + rq = __task_rq_lock(p, &rf); dl_b = &rq->rd->dl_bw; raw_spin_lock(&dl_b->lock); @@ -2399,7 +2403,6 @@ void dl_add_task_root_domain(struct task_struct *p) raw_spin_unlock(&dl_b->lock); -unlock: task_rq_unlock(rq, p, &rf); }