Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp802069ybp; Wed, 9 Oct 2019 04:34:56 -0700 (PDT) X-Google-Smtp-Source: APXvYqzlyYb+ovRn4qSa1BmlQip3mqw+VwxUJ3Ia7/w7HI7pQnmg9DYNtGq5oTgg1jH/6wvwNClk X-Received: by 2002:aa7:d389:: with SMTP id x9mr2484530edq.33.1570620896330; Wed, 09 Oct 2019 04:34:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570620896; cv=none; d=google.com; s=arc-20160816; b=lcz69/tgio5U0bbUfnrl68SjlolO4KJ0TGUUID66IgUUVjVyVghcfXEDTYf/xSpSBv lAmboKR8GKJi6RzGkb6wggrQkoSl7SIAytxG5s+SS+gH2whc9G7jhHdG3Vz7WehsJOCW xr0Lbew0y80yziCza7U3OfPnPw5LjjHPr90AYh+O6n8CuHKQEO/PLSq+zIZB1RIKVe1b +TZaj/r3AkUTEvpUPiwaC/sl8qrQ2P4kmnn96ELcwgkrPV/aUGkuOlGOuKTqILeWVeLD H7H8FjUBpBEkFA1/26+FWZ0s2aloMokN67qRU14MtIoJOZ8nkZZGhfRVXgHyVISPijoH WeDQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=EG9v3kTZ0STByqKzP1n2q6Lh+2OqkwymViAjwK7ZPds=; b=FUU2anzNV62YP9/xw5CcVbhGraXetHPLYg5wQFswKL8MjWRXKFDGJVtgfBjksGLs4T Au/A4JXL7/TTI9m0OH2Bn6ybjN0bCBb9opie1EOrAToZ8nhr7iJzLW9/nU97btRl+ndE A3UZi7WLcwREJL62FUcI0P1k5jbZ2XRSs3uZ3apNOsdkROn51qM7Qc83azNf+yaKU1Yj pCj4dmC94NcTPKqRBksQiM9pOC0Vajt3P93lK45p35l+zvim9z9m3ZjsIygDDMdib6/4 4+FLb51RSlzuFaS4kibzZJsnmuKIm2EuKsLXsd2isSc18Q82Ip6FORYyY9alHFpKako/ Lmig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=kH+IeUMB; 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 s19si966714ejd.277.2019.10.09.04.34.27; Wed, 09 Oct 2019 04:34:56 -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; dkim=pass header.i=@linaro.org header.s=google header.b=kH+IeUMB; 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 S1730111AbfJILeU (ORCPT + 99 others); Wed, 9 Oct 2019 07:34:20 -0400 Received: from mail-lf1-f65.google.com ([209.85.167.65]:39504 "EHLO mail-lf1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729471AbfJILeU (ORCPT ); Wed, 9 Oct 2019 07:34:20 -0400 Received: by mail-lf1-f65.google.com with SMTP id 72so1380387lfh.6 for ; Wed, 09 Oct 2019 04:34:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=EG9v3kTZ0STByqKzP1n2q6Lh+2OqkwymViAjwK7ZPds=; b=kH+IeUMBfwMkv+Uo4/4m6ZmUuhDopta5OobVSgramulhVEyCCZxL5T5iTJOdzm2ikl viyWRm8qzrngXIFOEtvhZyR3IqmVVW2GF9QmXLIJgbTUyymNdFCnG0qJ4WhHUlH09bZv h2xcgZVPD2u3UzlBpuO2zP5Hl7+jNW5mCu13+X0Y/hE3OATs5Mwrjqk40NwJUBP+2n6i m76Al2ZrYxWeyVpS28DnybxabAHASJg4GFrrYQ8x7oTSsGiAyqCltQZz7Kne5lV28xfp RFj3OwzWPIxsZcRAmtCpYaWSMdzpoXO2EJAz9dCO1akwjDH/mC+W/blXsAhj0wn+HrN3 TKKA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=EG9v3kTZ0STByqKzP1n2q6Lh+2OqkwymViAjwK7ZPds=; b=M7zU7u94rGXZBodDMZdUc+Dh7NuEcKi5kMPowFcmcyQtGgng08pDg8k2ZGEd+wK9ZL YQV7IGgMyN1WYh328EH3wYF0bfy2tOMQ6tkQFRWWbTARijjz7UsXCtKsOTtbxi9Hvgh/ js4HwZIep1NrVeaPJZTU1s4u+5qum+BJK6LplJLFzvo36AnNZsEGju5iQb2OykEUukUm JhAyoqvbA+hVrw/dH69uVFHBnkLOjYprAFAXK1lV4i/DnmSpZ2zAYWK/FDjEWO2MvaUl fsvOoq9f3jTCtn1dj4YTQLdBBdTNvyznYO8/Lsdyp+lFvKvFdaMYnjlvFcIaqAuW5z2W 78zQ== X-Gm-Message-State: APjAAAU0zBdTkF3WNVs+W/C3JD4wrxebG4JQAMtuMfV/Goo4jhULUFT4 b+b6huDJ+PiBJn5jYUbl6Ux1mHyezOlNpGRI2czKBQ== X-Received: by 2002:a19:4f06:: with SMTP id d6mr1847743lfb.15.1570620858079; Wed, 09 Oct 2019 04:34:18 -0700 (PDT) MIME-Version: 1.0 References: <20191007083051.4820-1-parth@linux.ibm.com> <20191008132842.6612-1-hdanton@sina.com> In-Reply-To: From: Vincent Guittot Date: Wed, 9 Oct 2019 13:34:06 +0200 Message-ID: Subject: Re: [RFC v5 4/6] sched/fair: Tune task wake-up logic to pack small background tasks on fewer cores To: Parth Shah Cc: Hillf Danton , 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 Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 ? > > >> + 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++; > >> + } > >> + } > >> + > > >