Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp2103290yba; Sun, 5 May 2019 22:53:34 -0700 (PDT) X-Google-Smtp-Source: APXvYqxet0+0pMM04mbs4ci+A/sRytinQmpJxwceq9CbQz+UILzeo+NUUBhFYOWqO+atReBjcJbb X-Received: by 2002:a17:902:22:: with SMTP id 31mr15320661pla.15.1557122014391; Sun, 05 May 2019 22:53:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557122014; cv=none; d=google.com; s=arc-20160816; b=wEZgKEivQ/vkzWvWPAdGryaZlEg7Uqad3+rBwu+zBrftys8PtgSw42JufMvSj4h2+Z 6A/+4CZsbLHMk90gShRiMwL8py/1487t7WgQgJmd1dxjVbqkuprT+ll4Lo8DMC8VUWP9 qHgcUYQFANhBN3HMD5cK8fkry/rfmwH3h2U++ZRJfHCNznVb3KkaX2L6GK5BWtR9D9MH IH2b4J5N1Pxzd1gwQPtP6CilhHXDYK/MFAGInkm+wCW69JAP91j/Z2Kd2lqdZihPZZhv 8uNzuW7pb4ejDA9szTkaXVH9mXdk5wUOHWzrFFFV06sLoa6aIBzHifMY2h3JMQnq4wAo s4EA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=dwSh6IcKgjBhaBPEk6k56Kwwq1r3KJOBxTFq9x3hT30=; b=dF2usm9wKY21XPeLrVStm/T2kfkI8lX9UybGJNMg2C+Vrzpo1R78drBvGxLosQ32+R Oi3osox11DSvLiOUuKZtsK8E5NWk04HWrELmz2EkMg7wUmeFy2y8yyau1RPiLQLHMpK+ UbQ8RApqzZ9w+fhIH2pi6xGDjJJTWVkJLBbLMzHuTdEtuvUNJrEEoD3yDUSZ4L3a4SwY CX87rv1jMsvB4VX0qgRxVZaXc30G5Qww+eQfPOyGNYR5hNSp2M8eN1lYqeadEkpueJah RIBqFZPxox/GcmW4CvlzzruwcwRBsaZgW0o8DBHF8Rs+kNqMizZdyh+bg/D5/wIhSA6h sZhA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s14si13170418pgs.343.2019.05.05.22.53.18; Sun, 05 May 2019 22:53:34 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726297AbfEFFtQ (ORCPT + 99 others); Mon, 6 May 2019 01:49:16 -0400 Received: from ms01.santannapisa.it ([193.205.80.98]:57922 "EHLO mail.santannapisa.it" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725840AbfEFFtK (ORCPT ); Mon, 6 May 2019 01:49:10 -0400 X-Greylist: delayed 3600 seconds by postgrey-1.27 at vger.kernel.org; Mon, 06 May 2019 01:48:55 EDT Received: from [151.41.47.232] (account l.abeni@santannapisa.it HELO sweethome.home-life.hub) by santannapisa.it (CommuniGate Pro SMTP 6.1.11) with ESMTPSA id 138841012; Mon, 06 May 2019 06:49:02 +0200 From: Luca Abeni To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , "Rafael J . Wysocki" , Ingo Molnar , Peter Zijlstra , Vincent Guittot , "Paul E . McKenney" , Joel Fernandes , Quentin Perret , Luc Van Oostenryck , Morten Rasmussen , Juri Lelli , Daniel Bristot de Oliveira , Patrick Bellasi , Tommaso Cucinotta , luca abeni Subject: [RFC PATCH 6/6] sched/dl: Try not to select a too fast core Date: Mon, 6 May 2019 06:48:36 +0200 Message-Id: <20190506044836.2914-7-luca.abeni@santannapisa.it> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190506044836.2914-1-luca.abeni@santannapisa.it> References: <20190506044836.2914-1-luca.abeni@santannapisa.it> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: luca abeni When a task can fit on multiple CPU cores, try to select the slowest core that is able to properly serve the task. This avoids useless future migrations, leaving the "fast cores" idle for more heavyweight tasks. Signed-off-by: luca abeni --- kernel/sched/cpudeadline.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/kernel/sched/cpudeadline.c b/kernel/sched/cpudeadline.c index 2a4ac7b529b7..897ed71af515 100644 --- a/kernel/sched/cpudeadline.c +++ b/kernel/sched/cpudeadline.c @@ -143,17 +143,24 @@ int cpudl_find(struct cpudl *cp, struct task_struct *p, struct cpumask *later_mask) { const struct sched_dl_entity *dl_se = &p->dl; + struct cpumask tmp_mask; if (later_mask && - cpumask_and(later_mask, cp->free_cpus, &p->cpus_allowed)) { + cpumask_and(&tmp_mask, cp->free_cpus, &p->cpus_allowed)) { int cpu, max_cpu = -1; - u64 max_cap = 0; + u64 max_cap = 0, min_cap = SCHED_CAPACITY_SCALE * SCHED_CAPACITY_SCALE; - for_each_cpu(cpu, later_mask) { + cpumask_clear(later_mask); + for_each_cpu(cpu, &tmp_mask) { u64 cap; - if (!dl_task_fit(&p->dl, cpu, &cap)) - cpumask_clear_cpu(cpu, later_mask); + if (dl_task_fit(&p->dl, cpu, &cap) && (cap <= min_cap)) { + if (cap < min_cap) { + min_cap = cap; + cpumask_clear(later_mask); + } + cpumask_set_cpu(cpu, later_mask); + } if (cap > max_cap) { max_cap = cap; -- 2.20.1