Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp4612493ybf; Wed, 4 Mar 2020 07:18:59 -0800 (PST) X-Google-Smtp-Source: ADFU+vvGCUcHnyfijMjQ/VxWBcVoAoyfCZI26FRPWsL0caWoCBp+McUyQl5wv5OuXVP6Raohwp3x X-Received: by 2002:a9d:6a2:: with SMTP id 31mr2672945otx.313.1583335139357; Wed, 04 Mar 2020 07:18:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583335139; cv=none; d=google.com; s=arc-20160816; b=pKOzangj49DZNrEAdMakcKvJlCGCraJZZKr468FxpzJAID1qmxTgBAunaSTbbGrBg3 5xgwW1qYXAWIPftR8RmbrThee7WjRYBBscSYTksCfWPCirM1r3+i7UcO/PMXPbj3D+VH qubJZ34NDpn5z5d0u+60zJL2FdrCqxAJfFw6HPCo53TWYCKDv8y6kMGGeb5DAnOqoFZN 50fzURJqyz/u1Sug+D1l8PscqY8Qx9PyHOwcOHtdvijyRmvjYdIKo1Dc+O4KPpiNJjvt tVj6LUUrX7/n0/+wcXraEnClJgVbfPQWaBeszJ16r4ZIW1sdSbHxx0U/8/zsr5dE79ee MS8Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=ybgPvFU2MJ4ZhHKG6Jgq70Mz1224Org0Nb1bd0qagwE=; b=A6H9Y+EtLcoMiJHzfCOcmCmuaCoxn7cytF3ddvj2fB0ex1/rmTmzjSVcJUqPqxFiiq 7FAKKI9I2IOz5YiBjtmt6A/+G0RcN/xsQzwnh01jPM8pqq9di5KNnW62/JHmA7OQYZAz 9EKqrHbt80XbAwX1ts0MOzCY4orK94ztJjvzobtMxO9eekrnPsmvhSH+gXIWXJG010RK jkqxwZQfrevEOwjsdfC/BOW4ST/IVoSewLq40QMA35CbftH9aqgMyWkRALPW3Gl4hmFR jAVWRNa4Mf+jU30WvZ+ZHvrvM4+fcc8sruecMMkteaSl+mH0aSoouD0XyUIvtliWJM1A 9JVA== 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 h7si1211855otm.165.2020.03.04.07.18.46; Wed, 04 Mar 2020 07:18:59 -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; 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 S1728926AbgCDPS2 (ORCPT + 99 others); Wed, 4 Mar 2020 10:18:28 -0500 Received: from foss.arm.com ([217.140.110.172]:35622 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726661AbgCDPS2 (ORCPT ); Wed, 4 Mar 2020 10:18:28 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 8961F31B; Wed, 4 Mar 2020 07:18:27 -0800 (PST) Received: from e107158-lin.cambridge.arm.com (e107158-lin.cambridge.arm.com [10.1.195.21]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 055A33F6CF; Wed, 4 Mar 2020 07:18:25 -0800 (PST) Date: Wed, 4 Mar 2020 15:18:23 +0000 From: Qais Yousef To: Tao Zhou Cc: Ingo Molnar , Peter Zijlstra , Steven Rostedt , Dietmar Eggemann , Pavan Kondeti , Juri Lelli , Vincent Guittot , Ben Segall , Mel Gorman , linux-kernel@vger.kernel.org, t1zhou@163.com Subject: Re: [PATCH v3 1/6] sched/rt: cpupri_find: Implement fallback mechanism for !fit case Message-ID: <20200304151823.phpcz7twxzxiu3j5@e107158-lin.cambridge.arm.com> References: <20200302132721.8353-1-qais.yousef@arm.com> <20200302132721.8353-2-qais.yousef@arm.com> <20200304143200.GA13200@geo.homenetwork> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20200304143200.GA13200@geo.homenetwork> User-Agent: NeoMutt/20171215 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Tao On 03/04/20 22:51, Tao Zhou wrote: [...] > > /** > > * cpupri_find - find the best (lowest-pri) CPU in the system > > * @cp: The cpupri context > > @@ -62,80 +115,72 @@ int cpupri_find(struct cpupri *cp, struct task_struct *p, > > struct cpumask *lowest_mask, > > bool (*fitness_fn)(struct task_struct *p, int cpu)) > > { > > - int idx = 0; > > int task_pri = convert_prio(p->prio); > > + int best_unfit_idx = -1; > > How about using cpumask to store CPUs when the "best unfit" > happened. So, no need to call __cpupri_find() again. I considered the CPU mask but it's expensive. I either have to create a percpu variable, or allocate something at every call here. Neither of which seemed acceptable to me. Recording the idx is simple and cheap IMO. [...] > > + /* > > + * If we failed to find a fitting lowest_mask, make sure we fall back > > + * to the last known unfitting lowest_mask. > > + * > > + * Note that the map of the recorded idx might have changed since then, > > + * so we must ensure to do the full dance to make sure that level still > > + * holds a valid lowest_mask. > > + * > > + * As per above, the map could have been concurrently emptied while we > > + * were busy searching for a fitting lowest_mask at the other priority > > + * levels. > > + * > > + * This rule favours honouring priority over fitting the task in the > > + * correct CPU (Capacity Awareness being the only user now). > > + * The idea is that if a higher priority task can run, then it should > > + * run even if this ends up being on unfitting CPU. > > + * > > + * The cost of this trade-off is not entirely clear and will probably > > + * be good for some workloads and bad for others. > > + * > > + * The main idea here is that if some CPUs were overcommitted, we try > > + * to spread which is what the scheduler traditionally did. Sys admins > > + * must do proper RT planning to avoid overloading the system if they > > + * really care. > > + */ > > + if (best_unfit_idx != -1) > > + return __cpupri_find(cp, p, lowest_mask, best_unfit_idx); > > + > > Even use a loop again here, i don't know. I don't see if going through the loop twice will help here. The proces is racy, and I think by the time we reached here we would have tried hard enough to find the best cpu to run on? Thanks -- Qais Yousef