From patchwork Thu Feb 7 10:46:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 157686 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp484532jaa; Thu, 7 Feb 2019 02:46:17 -0800 (PST) X-Google-Smtp-Source: AHgI3IZLJQV3XmaoVkCh/xNF0WWwN+UZqAoJswFMtLJY5A314Xmz1TPjvX7V/dhXJvMTZ0Nuz/6+ X-Received: by 2002:a63:5d55:: with SMTP id o21mr13878604pgm.92.1549536377750; Thu, 07 Feb 2019 02:46:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549536377; cv=none; d=google.com; s=arc-20160816; b=Kf03B6ZaP3KkAhYMUYbmF1o+4Ku060DkjxSWLBTo1KAWQ/CNcfAwzMlGj1jhSHqevO uqD3CjC9Y0IffLhiuEQ5W4AL9kUeWteYdDZhGhyL/rPanZ66PTnoyTQ2+99z0jKvZovv MJnKW+16D6+qv6r97nGzkuARzMJZdCkiDrXoa3ou6Qa+qjdjO+DpXqHcDskUjnTz57ZY ZXbPMmPhDiaaboDMedV0cq3PXzSUOCpqcVls59M282Cbg+6Tix+8PWNp0grSV+r2Vtp0 EVdoMJ5KO7dE90KTEmXmZwiZvUgyZAH9sGulQzJ8if2mSaMYI6qIW2vMAQhWnz937YiL INEg== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=b2MAKObbwgm8lJA0u2i67iep8woAREaJgQav9usjeCw=; b=FQOf/8naXxjFmLgmjIcEI7hjL6nxedY52GSk34Sl3DdrPnqFQDMgt+up0tfcR8AMBr d93NTGeo/R/4ihUYBBcT8TOm2Lsk21xoKwXFRsCV7xjpkB9iK4tvEKcXTJH/bsHpcbfZ J/Vv61uSJNutBt7YobRhw01BK6f0GJbVtZwOwlTQDoHOjspMsBJXAhhSQySZvXnMTM6z nvI31VdZ5qG3/8VXzces7fKdiTDrxdqIS+xkrDbUN+zX4LfFvut5L5V/NMswPZZBRW3v EtvFN6a7waSEsRvCp4nSokXewIO8QTM6nuPs4EmoMcivOdArDHGXXn8d6Y3bwUDRK2iz /Bhg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=VCdlDgXP; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m3si3177327pld.331.2019.02.07.02.46.17; Thu, 07 Feb 2019 02:46:17 -0800 (PST) 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; dkim=pass header.i=@linaro.org header.s=google header.b=VCdlDgXP; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726799AbfBGKqP (ORCPT + 31 others); Thu, 7 Feb 2019 05:46:15 -0500 Received: from mail-pf1-f196.google.com ([209.85.210.196]:34829 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726565AbfBGKqP (ORCPT ); Thu, 7 Feb 2019 05:46:15 -0500 Received: by mail-pf1-f196.google.com with SMTP id z9so4597089pfi.2 for ; Thu, 07 Feb 2019 02:46:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=b2MAKObbwgm8lJA0u2i67iep8woAREaJgQav9usjeCw=; b=VCdlDgXPZVK2DY38U2rVU5hpR0QczAQdo1nb8NTcvLX0RVv3WskMBzr6HTw3oTAzsD K946YhyE6G9QT4QCvLWhffOatMbZSkhbIYjGvNXjjvAz9XCSicrPX+2xI42KPE3uJ7X8 Kw0UZBntq93e56NTgna1QtOEr/J0ZWAfwTCpmF6VYn8/llrc4mcU0VRdV0ZZl6k9UGmL lD4fO0Nn16IKcFWsLDVBDcN24JY6+08jChQVJmSWAL4dZd3jquRsdytgBUM7RZg4RPMI DKTDC0eGnil+yKfINZCL3ekvz0qbwmm9xeGwORGUZmI7UriMj/1zfaWiQV65aMK021E8 +laQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=b2MAKObbwgm8lJA0u2i67iep8woAREaJgQav9usjeCw=; b=dcwf6ltloozhN/gFjLbu2+L5mVDX8BuPPGaVb6bLGM7BE9cNx2evnt5x6peTlv5nSH zmVGW4Auic9RQZn0q5wm5w+woxUn07aZ6WcjAef1yXaXoAycinzDHNnFCR9vpfm9IySc +t0AGaJ03Axju1O3Q+MqX/wLdzpjc9YTHLVC9X34F+vAHcbhMrIZM0Wh6tB3a2UBo352 lZtK8oMJRqx/puS4DDAhCYSx3NKm4/MVCVdjupc1tt7eP65Dv/WBV1mtEsLiRNmsg3em aZ5MiH7EKHoiAyiN8YSIAnrXA2/6oY9f+Eh1szwQL/rHCYuvvxOAh67VkTUayw1Bab7B Dtfw== X-Gm-Message-State: AHQUAubsdwOFVMFQVgwzlYfSCfHd/sS2lSCSH8EDbc12H63F1vIcApIh qK1hxDAiPYa4Y+TgF1mrpVPXyA== X-Received: by 2002:a63:534c:: with SMTP id t12mr14114184pgl.205.1549536374129; Thu, 07 Feb 2019 02:46:14 -0800 (PST) Received: from localhost ([122.172.102.63]) by smtp.gmail.com with ESMTPSA id m67sm12209839pfm.73.2019.02.07.02.46.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Feb 2019 02:46:13 -0800 (PST) From: Viresh Kumar To: Ingo Molnar , Peter Zijlstra Cc: Viresh Kumar , Vincent Guittot , linux-kernel@vger.kernel.org Subject: [PATCH 1/2] sched/fair: Don't pass sd to select_idle_smt() Date: Thu, 7 Feb 2019 16:16:05 +0530 Message-Id: X-Mailer: git-send-email 2.20.1.321.g9e740568ce00 MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The parameter sd isn't getting used in select_idle_smt(), drop it. Signed-off-by: Viresh Kumar --- kernel/sched/fair.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) -- 2.20.1.321.g9e740568ce00 diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 38d4669aa2ef..8d5c82342a36 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -6102,7 +6102,7 @@ static int select_idle_core(struct task_struct *p, struct sched_domain *sd, int /* * Scan the local SMT mask for idle CPUs. */ -static int select_idle_smt(struct task_struct *p, struct sched_domain *sd, int target) +static int select_idle_smt(struct task_struct *p, int target) { int cpu; @@ -6126,7 +6126,7 @@ static inline int select_idle_core(struct task_struct *p, struct sched_domain *s return -1; } -static inline int select_idle_smt(struct task_struct *p, struct sched_domain *sd, int target) +static inline int select_idle_smt(struct task_struct *p, int target) { return -1; } @@ -6231,7 +6231,7 @@ static int select_idle_sibling(struct task_struct *p, int prev, int target) if ((unsigned)i < nr_cpumask_bits) return i; - i = select_idle_smt(p, sd, target); + i = select_idle_smt(p, target); if ((unsigned)i < nr_cpumask_bits) return i; From patchwork Thu Feb 7 10:46:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 157687 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp484597jaa; Thu, 7 Feb 2019 02:46:21 -0800 (PST) X-Google-Smtp-Source: AHgI3IZAdtesc6Gc4TQKA2zQ5EId1upzXS4pfH8HP4v9BRzCv/cmWppptyo0T7WQcsfdDfXqnGzm X-Received: by 2002:a17:902:887:: with SMTP id 7mr15678043pll.164.1549536381551; Thu, 07 Feb 2019 02:46:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549536381; cv=none; d=google.com; s=arc-20160816; b=cVmE4qI1gyb39W1MhjKnGI7SfXgFHIjdo2qarPrWWpF9+il5S+zC8E7paP0TuKFBaT XEf6Zvb69U7wJRlyVzWt2CKAyKQXwk0If/9mUnBcJFEYAwiaE8RVW08MVDG11ipXrwLn +sKUjvW7ZLtaSZC3vAkLWhDk3pLABj/QoCWgU/vwIhmqzPAQetkaqkyay/iIsKL8mDa0 A7aBCJbE64QPVIswasLorQbuHRWmBCaeCdb31e9oVnJeViqhJvBT3Ooxaxp2iRNKgi+k n+rnRa3PS4SwpGFVIx1IGPw81R3X83ozWeMSQEdLiHqry1h6SXaBQw0v/dXUmppHq/n8 TpVA== 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 :dkim-signature; bh=l8W/PruHRLm7V9RCGIGL3xdZzxFuSJMsXboxSXJ3x4I=; b=Jxu9e8P3OfmY/QUdQGcCJI2tVetY8se4jT+4Pp9YbmzZ3x4Bwz4mCAO0BdZkD+9p1H u9hLabqihPCBnmANqwGeQQ6QerLIUq9odsa7aiXCp/ed2UnqvaTv9GMQpv3AJRSQvEpi R4FyNBsjy0+jYfd3bprGB9HICqlAFBuVkmLB5L34+LIRppE+ppaQsrUQMM3e4+Sk7c8x kICyKQv08LXItvvC5KD+AORW07w0/YbOveSt70sbWpNi1H0sYAXSRd9rVFNdA3PdoWDj VLV5WVAA4XbrzeYO+pitEh4gEKxUahMIZcqj2Uhvk90xxVXUCBRf3mLqYoEb6qxtFn2v DJgA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QHcllTWL; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v9si4794302pga.126.2019.02.07.02.46.21; Thu, 07 Feb 2019 02:46:21 -0800 (PST) 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; dkim=pass header.i=@linaro.org header.s=google header.b=QHcllTWL; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726902AbfBGKqT (ORCPT + 31 others); Thu, 7 Feb 2019 05:46:19 -0500 Received: from mail-pg1-f196.google.com ([209.85.215.196]:42124 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726565AbfBGKqS (ORCPT ); Thu, 7 Feb 2019 05:46:18 -0500 Received: by mail-pg1-f196.google.com with SMTP id d72so4314702pga.9 for ; Thu, 07 Feb 2019 02:46:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=l8W/PruHRLm7V9RCGIGL3xdZzxFuSJMsXboxSXJ3x4I=; b=QHcllTWLIaJQjzssPmlKe9+gVJPOWK8m+ro3g4JdjkPS3MXqW7Sf1VLMqWz+KEtNEX d+YrmLWWhLH9zi7n7aXCxhEENazemsV3LUzw6p1h1WYPgxkwUc4h8F8MweEIJgNkfTat hZubo3hDhk33dnO2JUDR8xZfiRZ/vLBmiq2L90dAnsZVql2SAfqegzoDOp4nzjEb8xP+ ZWvMgBmYRkD5g1rbLL2OPW6MKuxPz8DyBlbjeEvGd9/LSIHnPNBPMmtB9PHyS28gcM4b mTuwU2/ijV+oION308PqStT7HKyguZzGg6itboUWqL1QJf6Mfk/+o7h3Md0lK89bY9VV NZ8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=l8W/PruHRLm7V9RCGIGL3xdZzxFuSJMsXboxSXJ3x4I=; b=au/5rCfzEANtR3L7Bh83iS9z2oL47SbwFk44eKkzCQ7HZD2ePJkqMyoj2kBNUmfYBM 3u9b/juH8rdbRfIZQhD0l/ZqH4+iv51JzEYWShLnvRk0oDDjFHdLRnxkH5zCSAkc02Mv /5eY24RXlv93xBvpKXNTUZTfM/DwKDCscw/H8wB0MrcJdjsB2lLPxexPemceACyDNe8I oVOecOgWGhHs0BW6x5XgoBIg9XZbTpP34bEQlyEbpJSrK61lgu+CJcLreRsCe8b5GuGM lQ4rZ/TEVKGxJe0wBu0w0mDKLPWKYEASrUX18Ky/69jH9MrqQk8zFsAxGbXRBeuyZ9Wa JPhw== X-Gm-Message-State: AHQUAuZiQPa/QYlLk3OnjalZFXm4Vrrx2sOOcuZXSY25tQlaMgRrOwJO YlRBy+wiE39Nlb6s3pMOEf4izg== X-Received: by 2002:a62:c505:: with SMTP id j5mr15448980pfg.149.1549536377383; Thu, 07 Feb 2019 02:46:17 -0800 (PST) Received: from localhost ([122.172.102.63]) by smtp.gmail.com with ESMTPSA id e23sm8396175pfb.97.2019.02.07.02.46.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Feb 2019 02:46:16 -0800 (PST) From: Viresh Kumar To: Ingo Molnar , Peter Zijlstra Cc: Viresh Kumar , Vincent Guittot , linux-kernel@vger.kernel.org Subject: [PATCH 2/2] sched/fair: Improve the for loop in select_idle_core() Date: Thu, 7 Feb 2019 16:16:06 +0530 Message-Id: <6b165676325a47d67e667582a7b78da85c5c118a.1549536337.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.20.1.321.g9e740568ce00 In-Reply-To: References: MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Once a non-idle thread is found for a core, there is no point in traversing rest of the threads of that core. We continue traversal currently to clear those threads from "cpus" mask. Clear all the threads with a single call to cpumask_andnot(), which will also let us exit the loop earlier. Signed-off-by: Viresh Kumar --- kernel/sched/fair.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) -- 2.20.1.321.g9e740568ce00 diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 8d5c82342a36..ccd0ae9878a2 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -6068,6 +6068,7 @@ void __update_idle_core(struct rq *rq) static int select_idle_core(struct task_struct *p, struct sched_domain *sd, int target) { struct cpumask *cpus = this_cpu_cpumask_var_ptr(select_idle_mask); + const struct cpumask *smt; int core, cpu; if (!static_branch_likely(&sched_smt_present)) @@ -6081,10 +6082,14 @@ static int select_idle_core(struct task_struct *p, struct sched_domain *sd, int for_each_cpu_wrap(core, cpus, target) { bool idle = true; - for_each_cpu(cpu, cpu_smt_mask(core)) { - cpumask_clear_cpu(cpu, cpus); - if (!available_idle_cpu(cpu)) + smt = cpu_smt_mask(core); + cpumask_andnot(cpus, cpus, smt); + + for_each_cpu(cpu, smt) { + if (!available_idle_cpu(cpu)) { idle = false; + break; + } } if (idle)