Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp6046768ybv; Tue, 18 Feb 2020 08:52:09 -0800 (PST) X-Google-Smtp-Source: APXvYqzkuQ0943YU5qx3ZVOoFmU4nJAS2ebszMxFcOKF5H+FXdg60W85dnFB091CjKT/pROju5Jx X-Received: by 2002:a05:6830:1555:: with SMTP id l21mr15572329otp.41.1582044729188; Tue, 18 Feb 2020 08:52:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582044729; cv=none; d=google.com; s=arc-20160816; b=UfGvfNshb8kTj1aOjXCUk3+54sjpSnZOkSxGolAIgXwHolSS4NEaW/reA3VKyHkFZ5 7SaAiJP+4e77bHH0hO8NWqTS24CcyzFUIhr2VxJWADAZm74d3Avudr0ziB1MhR5GeN19 Gy+FjVftDezDAoNSgz6BRQFzLvQEo/lGUXnmziSHLMgfNbVikNnkCD1EiV/OO8TeCVPP vFPozS4kKl/TL8QUywziccgf8EN5nvIavO89KzM1xciV02kp2PPc0U5ZzY2QJBPjkYqj dUPyHHpD38lgiY2hLxt2aDuDUwY3/3ZFYJEondUcA5od4VcI0zh0drDH7jpSfbaf5F/z 3ZvQ== 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=f5zZ75K1w4t2h/6FHw5+qkGDgcX0ElQAs8/WEopDoc0=; b=OXdwhD0x1sFa4WhreHJuIackobeVzg8C5BabF2Xi9rUETOK/oC4UQeBmrvMKQCIXyk go78hIaMbMqdEf8mpBCLkHjhgKLPh/+C3l/JbAdyckjR8fmlLT7YaLy+NUe0PbM88hMq 3MATa4I31skMq7+2UCMRUpT5AjPRFSocBH0fxXmiC82TdaqBz2urp3gzh9bibPH+itGU P6gIp2gxHGKugM7NOB1f/57jgiy+ActAqC/JgljRA+GXkBHRFhHbnD2glzxuVGkA6m4M qxehTgaEjLghH5nP2nzAhcMlW8XSqGs92XKwhDTxaYFPc71kqmPci0ZBRVMuXoXjXqCH PIhg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="Qx/Ndevz"; 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 n2si1975122otk.177.2020.02.18.08.51.56; Tue, 18 Feb 2020 08:52:09 -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="Qx/Ndevz"; 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 S1726762AbgBRQvd (ORCPT + 99 others); Tue, 18 Feb 2020 11:51:33 -0500 Received: from mail-lf1-f65.google.com ([209.85.167.65]:37452 "EHLO mail-lf1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726403AbgBRQvd (ORCPT ); Tue, 18 Feb 2020 11:51:33 -0500 Received: by mail-lf1-f65.google.com with SMTP id b15so15046137lfc.4 for ; Tue, 18 Feb 2020 08:51:31 -0800 (PST) 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=f5zZ75K1w4t2h/6FHw5+qkGDgcX0ElQAs8/WEopDoc0=; b=Qx/Ndevzjm6AQqQl0JlGZ/D9FIhWS2JKw/YZNWKSqCqptoZ2SPo32DPkmTsvLXYajh txOx5GWT9abYHj4mdgeuN9V3zuv3zIdLzGV1qMFLg6yPi64miygWVSbXYCU2bmiIv4lN VXbjmepNbPYMKXI7ttnVgDcmBbVti5dEbtcIFt6DevKG1wXIcRBdscs8+5z7mcC/fZKo EhdTJ2Jf5R7fVyoeT1yGniWRdf2vHeezuHzGO+x8KfxhJ+GClpI/F8yQEhYGmjVUQkho D1iij6h2pB0Q8QtA5n8cylT+oTiA1jVnoRdE3BRCoS70PMcddEXCH8vl8wmzPjFUEZ5g khMA== 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=f5zZ75K1w4t2h/6FHw5+qkGDgcX0ElQAs8/WEopDoc0=; b=EcJl9DuFQ/ueQQugQlsmxezPfZqG7HddWbdxZhcmffvHnaKmUauXHBK5MENl3qbMsy QuI9AWCkBhbYWHQLz1ZF/VGk3JoBJXEke5GxuDz2mKxWgAZ5E83ijcvzeHuaIGc0QiGm ccA9ZTsWILxeLJgUkNwtdo5m2t/yO5cdQesY9Hwvm1MdEJF9YYHzBQb7AyMp7ZDleSvB kmtoIW7+q9YNnW5X3HE697n5fS0Y8T8pYVoOXP5V+s6CsbBW5xKpVaytTmQ7a9g/8seS D0zZe7DQNzEM8ADgxdaN6v0SaGmFXq8+fpfZo3K4SMAfa7zA8hEvLcoBMcCmMn4zCpc5 Gnaw== X-Gm-Message-State: APjAAAXbRejn9tm3WbUlPuoRAJ3gVkLAr1iRnaOqW9TieD8Wwjqkczw1 8nNjbvrCNIu2ZT94lBcPSHsLd5LL1RqSKsRCoZdMEA== X-Received: by 2002:a19:5504:: with SMTP id n4mr10335948lfe.25.1582044689196; Tue, 18 Feb 2020 08:51:29 -0800 (PST) MIME-Version: 1.0 References: <20200214152729.6059-1-vincent.guittot@linaro.org> <20200214152729.6059-3-vincent.guittot@linaro.org> <20200218153801.GF3420@suse.de> In-Reply-To: <20200218153801.GF3420@suse.de> From: Vincent Guittot Date: Tue, 18 Feb 2020 17:51:17 +0100 Message-ID: Subject: Re: [PATCH v2 2/5] sched/numa: Replace runnable_load_avg by load_avg To: Mel Gorman Cc: Valentin Schneider , Ingo Molnar , Peter Zijlstra , Juri Lelli , Dietmar Eggemann , Steven Rostedt , Ben Segall , linux-kernel , Phil Auld , Parth Shah , Hillf Danton 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 Tue, 18 Feb 2020 at 16:38, Mel Gorman wrote: > > 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. +1 This 1st round mainly aims to align NUMA way of working with load balance but we can imagine using some NUMA or memory specific information to create new state > > > > > > > /* 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