Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp5983409ybv; Tue, 18 Feb 2020 07:39:00 -0800 (PST) X-Google-Smtp-Source: APXvYqxBVxOCwLMxM2EuahbfIk8zYtC4yx70C5iN24AbdFxlmlQVE9L035SOuNSneprujV1h5Srn X-Received: by 2002:aca:f44a:: with SMTP id s71mr1608120oih.7.1582040340625; Tue, 18 Feb 2020 07:39:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582040340; cv=none; d=google.com; s=arc-20160816; b=jIZ1/uzdsUuvnD2g//APjn4ZMp6qOauSuDA1cL0M4CuC4mdesvUtsxq1jZfdE5CzQ/ eFlPa4c77KIaPHK+HnjmTt72yVEUox8dYU4VU5Qkb48inyL5dlFUDcgR19rbmuKstkf6 aohQ3wnD9EhmHOn/si10GqZJjC0GNlUh1x09YjNLFp+Lhmosvbz+ZpIqFW0PznDun0ua Y8R9RYRm8/vIPgMznSQzAqQUvmdFwi7TYOppWrAK9eWc4ddqjv4m9pFoqCrN7dbDHy2T PALiy6IiYBHppMvuQ4Xhkp/XltwnV4RZR6/mGkiytRon7FxA0e4L8qIyqLVq3XqIOdLT /uqA== 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=TxEDFLeDCzYF1p+y8Y8ZELzBSg9CBtU7BUcKC8btH7Y=; b=J1QwEMsdQKqZEwOPeT2EC+Yg5sdTDSWW/7oZ6FN+7fjw+9GsNUEdsjMNBnLwkOMCRn X6j/jCbqGZFBJhnsF8eT9G1lu/GJ9NonVzW+gabUBxzj2jIAZW8lA/eONAUljRsgH4xj o0xOjYtTz7fqe8fHLjZwmul4i6BgmQ7GigB8KD2aM9oMMywKzVxARyPOesAn7UhDVlqf eG23EC9zuAkwcGvqANv6Om998lxtUgUq33CrvZ4Bk8emDvzkT8onT7hKpzDty3r+XgTI skfU2QH0ackScjMi1ZQfu1WCY5PdDQrD7HVMnz7j1H7kDc7HeMvkpwRyXCqwh41IwGjh KN9g== 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 22si7580981oin.34.2020.02.18.07.38.47; Tue, 18 Feb 2020 07:39:00 -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 S1726492AbgBRPiK (ORCPT + 99 others); Tue, 18 Feb 2020 10:38:10 -0500 Received: from mx2.suse.de ([195.135.220.15]:42878 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726338AbgBRPiK (ORCPT ); Tue, 18 Feb 2020 10:38:10 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id B2057BAF0; Tue, 18 Feb 2020 15:38:04 +0000 (UTC) Date: Tue, 18 Feb 2020 15:38:01 +0000 From: Mel Gorman To: Valentin Schneider Cc: Vincent Guittot , mingo@redhat.com, peterz@infradead.org, juri.lelli@redhat.com, dietmar.eggemann@arm.com, rostedt@goodmis.org, bsegall@google.com, linux-kernel@vger.kernel.org, pauld@redhat.com, parth@linux.ibm.com, hdanton@sina.com Subject: Re: [PATCH v2 2/5] sched/numa: Replace runnable_load_avg by load_avg Message-ID: <20200218153801.GF3420@suse.de> References: <20200214152729.6059-1-vincent.guittot@linaro.org> <20200214152729.6059-3-vincent.guittot@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Feb 18, 2020 at 02:54:14PM +0000, Valentin Schneider wrote: > On 2/14/20 3:27 PM, Vincent Guittot wrote: > > @@ -1473,38 +1473,35 @@ bool should_numa_migrate_memory(struct task_struct *p, struct page * page, > > group_faults_cpu(ng, src_nid) * group_faults(p, dst_nid) * 4; > > } > > > > -static inline unsigned long cfs_rq_runnable_load_avg(struct cfs_rq *cfs_rq); > > - > > -static unsigned long cpu_runnable_load(struct rq *rq) > > -{ > > - return cfs_rq_runnable_load_avg(&rq->cfs); > > -} > > +/* > > + * 'numa_type' describes the node at the moment of load balancing. > > + */ > > +enum numa_type { > > + /* The node has spare capacity that can be used to run more tasks. */ > > + node_has_spare = 0, > > + /* > > + * The node is fully used and the tasks don't compete for more CPU > > + * cycles. Nevertheless, some tasks might wait before running. > > + */ > > + node_fully_busy, > > + /* > > + * The node is overloaded and can't provide expected CPU cycles to all > > + * tasks. > > + */ > > + node_overloaded > > +}; > > Could we reuse group_type instead? The definitions are the same modulo > s/group/node/. > I kept the naming because there is the remote possibility that NUMA balancing will deviate in some fashion. Right now, it's harmless. > > > > /* Cached statistics for all CPUs within a node */ > > struct numa_stats { > > unsigned long load; > > - > > + unsigned long util; > > /* Total compute capacity of CPUs on a node */ > > unsigned long compute_capacity; > > + unsigned int nr_running; > > + unsigned int weight; > > + enum numa_type node_type; > > }; > > > > -/* > > - * XXX borrowed from update_sg_lb_stats > > - */ > > -static void update_numa_stats(struct numa_stats *ns, int nid) > > -{ > > - int cpu; > > - > > - memset(ns, 0, sizeof(*ns)); > > - for_each_cpu(cpu, cpumask_of_node(nid)) { > > - struct rq *rq = cpu_rq(cpu); > > - > > - ns->load += cpu_runnable_load(rq); > > - ns->compute_capacity += capacity_of(cpu); > > - } > > - > > -} > > - > > struct task_numa_env { > > struct task_struct *p; > > > > @@ -1521,6 +1518,47 @@ struct task_numa_env { > > int best_cpu; > > }; > > > > +static unsigned long cpu_load(struct rq *rq); > > +static unsigned long cpu_util(int cpu); > > + > > +static inline enum > > +numa_type numa_classify(unsigned int imbalance_pct, > > + struct numa_stats *ns) > > +{ > > + if ((ns->nr_running > ns->weight) && > > + ((ns->compute_capacity * 100) < (ns->util * imbalance_pct))) > > + return node_overloaded; > > + > > + if ((ns->nr_running < ns->weight) || > > + ((ns->compute_capacity * 100) > (ns->util * imbalance_pct))) > > + return node_has_spare; > > + > > + return node_fully_busy; > > +} > > + > > As Mel pointed out, this is group_is_overloaded() and group_has_capacity(). > @Mel, you mentioned having a common helper, do you have that laying around? > I haven't seen it in your reconciliation series. > I didn't merge that part of the first version of my series. I was waiting to see how the implementation for allowing a small degree of imbalance looks like. If it's entirely confined in adjust_numa_balance then I'll create the common helper at the same time. For now, I left the possibility open that numa_classify would use something different than group_is_overloaded or group_has_capacity even if I find that hard to imagine at the moment. > What I'm naively thinking here is that we could have either move the whole > thing to just sg_lb_stats (AFAICT the fields of numa_stats are a subset of it), > or if we really care about the stack we could tweak the ordering to ensure > we can cast one into the other (not too enticed by that one though). > Yikes, no I'd rather not do that. Basically all I did before was create a common helper like __lb_has_capacity that only took basic types as parameters. group_has_capacity and numa_has_capacity were simple wrappers that read the correct fields from their respective stats structures. -- Mel Gorman SUSE Labs