Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp1178113ybp; Wed, 9 Oct 2019 09:56:21 -0700 (PDT) X-Google-Smtp-Source: APXvYqwS6eQz7gMGUIWN7v9FH++axTDDnJphBKg69uQ0MzHezUYE9pgj/5R6b4Mg06g3PuXsfQej X-Received: by 2002:a17:906:6858:: with SMTP id a24mr3883049ejs.27.1570640181637; Wed, 09 Oct 2019 09:56:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570640181; cv=none; d=google.com; s=arc-20160816; b=DMPPv4AHSJ+EpPJlXKMPqfa3LsNYLiACfakNEE7/4fPaaaEGf4qEWdjELgsgi0rQqR XzNZU6OnRkb6PAaBxP9Rv1RmEm6ZIVLXMmaQ9+ijjOu381DgxH+TRS1J5Sk9fp9f/ZQI RwfGuViQreSNqB49NQmUr8G6gN3r+KHXwU7/XGSqTGS/WyZtPWc+Utmbe0HYr4/hChXc Ppb4SiFVi51fWFGElYo3FEm7XEz1cl+4lA/Po5qo1+9yObPxN1gRlswuHQjBr3Db9Cna VJH31Kzpq6tG4KOwZrtXTVl/9eknnBpEjUu1QIzFYwsDAdrkn1K2qR+cGSd13x7WGFEN 0elg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date:from :references:cc:to:subject; bh=sTu0FwnWCorWEZUg2VMYyPlPiI+ZpBVHzfrDC1Aa5dI=; b=S0jWdEta4qnMDHsjyJv3qCwRIov4669k2gPUKzZOp/KLMUn6C4LMTLtviQDoRtZuo5 Oml6IVvkHgny6Q27M9Ag6Wml3cjzP18Mu+dmAKW1uZWU3P5RSqVg47JLw3Bz+7muohuQ rFCO8TJ/IwVN84SDs0ujHl9cU37QPSnV4VBEu4MfNPn5s39u3DJjZzOVD9UGnNg4AfcC 0snrfXqd2gjPO94+9U2y7IJ2huW3EAj2sPrYAaqpYWaeRv4XBPE3iyS8o0lXtcZfyEZV vszejugvSdItYAKr4UAg7PeOKl4sCzb8zaS88IrcxdEcCDh4594nK4DLc8zA9kxluF/b jjYg== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p1si1645067eda.406.2019.10.09.09.55.57; Wed, 09 Oct 2019 09:56:21 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731787AbfJIQzj (ORCPT + 99 others); Wed, 9 Oct 2019 12:55:39 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:6014 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1730490AbfJIQzi (ORCPT ); Wed, 9 Oct 2019 12:55:38 -0400 Received: from pps.filterd (m0098421.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x99GjbXi121561 for ; Wed, 9 Oct 2019 12:55:37 -0400 Received: from e06smtp03.uk.ibm.com (e06smtp03.uk.ibm.com [195.75.94.99]) by mx0a-001b2d01.pphosted.com with ESMTP id 2vhk3f8vv2-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 09 Oct 2019 12:55:36 -0400 Received: from localhost by e06smtp03.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 9 Oct 2019 17:55:35 +0100 Received: from b06avi18878370.portsmouth.uk.ibm.com (9.149.26.194) by e06smtp03.uk.ibm.com (192.168.101.133) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Wed, 9 Oct 2019 17:55:29 +0100 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06avi18878370.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x99GtTWv45220108 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 9 Oct 2019 16:55:29 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id EF22A4C050; Wed, 9 Oct 2019 16:55:28 +0000 (GMT) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 61EBF4C044; Wed, 9 Oct 2019 16:55:24 +0000 (GMT) Received: from localhost.localdomain (unknown [9.85.75.123]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTP; Wed, 9 Oct 2019 16:55:24 +0000 (GMT) Subject: Re: [RFC v5 4/6] sched/fair: Tune task wake-up logic to pack small background tasks on fewer cores To: Vincent Guittot , Hillf Danton Cc: linux-kernel , "open list:THERMAL" , Peter Zijlstra , Ingo Molnar , Dietmar Eggemann , Patrick Bellasi , Valentin Schneider , Pavel Machek , Doug Smythies , Quentin Perret , "Rafael J. Wysocki" , Tim Chen , Daniel Lezcano References: <20191007083051.4820-1-parth@linux.ibm.com> <20191008132842.6612-1-hdanton@sina.com> From: Parth Shah Date: Wed, 9 Oct 2019 22:25:23 +0530 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 x-cbid: 19100916-0012-0000-0000-000003568EB5 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19100916-0013-0000-0000-0000219194CD Message-Id: <24b07842-1770-13b9-8182-8dcf4f0a28fa@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-10-09_08:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1908290000 definitions=main-1910090147 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 10/9/19 5:04 PM, Vincent Guittot wrote: > On Wed, 9 Oct 2019 at 11:23, Parth Shah wrote: >> >> >> >> On 10/8/19 6:58 PM, Hillf Danton wrote: >>> >>> On Mon, 7 Oct 2019 14:00:49 +0530 Parth Shah wrote: >>>> +/* >>>> + * Try to find a non idle core in the system based on few heuristics: >>>> + * - Keep track of overutilized (>80% util) and busy (>12.5% util) CPUs >>>> + * - If none CPUs are busy then do not select the core for task packing >>>> + * - If atleast one CPU is busy then do task packing unless overutilized CPUs >>>> + * count is < busy/2 CPU count >>>> + * - Always select idle CPU for task packing >>>> + */ >>>> +static int select_non_idle_core(struct task_struct *p, int prev_cpu, int target) >>>> +{ >>>> + struct cpumask *cpus = this_cpu_cpumask_var_ptr(turbo_sched_mask); >>>> + int iter_cpu, sibling; >>>> + >>>> + cpumask_and(cpus, cpu_online_mask, p->cpus_ptr); >>>> + >>>> + for_each_cpu_wrap(iter_cpu, cpus, prev_cpu) { >>>> + int idle_cpu_count = 0, non_idle_cpu_count = 0; >>>> + int overutil_cpu_count = 0; >>>> + int busy_cpu_count = 0; >>>> + int best_cpu = iter_cpu; >>>> + >>>> + for_each_cpu(sibling, cpu_smt_mask(iter_cpu)) { >>>> + __cpumask_clear_cpu(sibling, cpus); >>>> + if (idle_cpu(iter_cpu)) { >>> >>> Would you please elaborate the reasons that the iter cpu is checked idle >>> more than once for finding a busy core? >>> >> >> Thanks for looking at the patches. >> Could you please point me out where iter_cpu is checked more than once? > > I think that point is that you have a sibling that there is > for_each_cpu(sibling, cpu_smt_mask(iter_cpu) but you never use sibling > in the loop except for clearing it on the cpumask cpus > All the tests are done with iter_cpu so you will test several time > iter_cpus but never the other sibling > Should you use sibling instead ? > oh got it. it was unintentional here, my bad. good find I did s/iter_cpu/sibling/ at required places: diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index d4a1b6474338..a75c2b382771 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -6001,14 +6001,14 @@ static int select_non_idle_core(struct task_struct *p, int prev_cpu, int target) for_each_cpu(sibling, cpu_smt_mask(iter_cpu)) { __cpumask_clear_cpu(sibling, cpus); - if (idle_cpu(iter_cpu)) { + if (idle_cpu(sibling)) { idle_cpu_count++; - best_cpu = iter_cpu; + best_cpu = sibling; } else { non_idle_cpu_count++; - if (cpu_overutilized(iter_cpu)) + if (cpu_overutilized(sibling)) overutil_cpu_count++; - if (is_cpu_busy(cpu_util(iter_cpu))) + if (is_cpu_busy(cpu_util(sibling))) busy_cpu_count++; } } and the took the results again to see functionality changes. Results are still within the bounds with maximum of 15% gain in performance and <2% of regression. Frequency benefit of TurboSched w.r.t. CFS +-+-+-+-+--+-+-+-+-+-+-+-+--+-+-+-+-+-+-+-+--+-+-+-+-+-+-+-+--+-+-+-+-+ 20 +-+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +-+ | Frequency benefit in % | | ** | 15 +-+ * * ** ****** +-+ | * * ************ | | ** * * ************ * | 10 +-+ ** * * ************ * +-+ | ** * * ************ * * **** | | **** * * ************ * * **** | 5 +-+ ****** * * ************ * * ****** +-+ | ****** * * ************ * * ********** | 0 +-******** * * ************ * * ************ * * * ********** * * * **+ | | | | -5 +-+ +-+ | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | +-+-+-+-+--+-+-+-+-+-+-+-+--+-+-+-+-+-+-+-+--+-+-+-+-+-+-+-+--+-+-+-+-+ 0 1 2 3 4 5 6 7 8 91011 1213141516171819 2021222324252627 28293031 No. of workload threads Performance benefit of TurboSched w.r.t. CFS 20 +-+-+-+-+--+-+-+-+-+-+-+-+--+-+-+-+-+-+-+-+--+-+-+-+-+-+-+-+--+-+-+-+-+ | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | | Performance benefit in % | 15 +-+ ** +-+ | ** | | ******** * | 10 +-+ ******** * ** +-+ | ******** * * ** | | ******** * * ** | 5 +-+ ********** * * ****** +-+ | ********** * * ********** | | ************ * * ********** * ** | 0 +-******** * * ************ * * ************ * * * ********** * * * **+ | ******** * | | | -5 +-+ +-+ | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | +-+-+-+-+--+-+-+-+-+-+-+-+--+-+-+-+-+-+-+-+--+-+-+-+-+-+-+-+--+-+-+-+-+ 0 1 2 3 4 5 6 7 8 91011 1213141516171819 2021222324252627 28293031 No. of workload threads Thanks, Parth > >> >>>> + idle_cpu_count++; >>>> + best_cpu = iter_cpu; >>>> + } else { >>>> + non_idle_cpu_count++; >>>> + if (cpu_overutilized(iter_cpu)) >>>> + overutil_cpu_count++; >>>> + if (is_cpu_busy(cpu_util(iter_cpu))) >>>> + busy_cpu_count++; >>>> + } >>>> + } >>>> + >>> >>