Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp6023953ybp; Tue, 8 Oct 2019 11:49:03 -0700 (PDT) X-Google-Smtp-Source: APXvYqze2pFEJ/bavI+cmLtip3Z+9fRQ4gHfpD/Oq6Aj0BKR25br8nzIGK2HefnKV488LfvXklQF X-Received: by 2002:a17:906:9395:: with SMTP id l21mr3537595ejx.161.1570560543182; Tue, 08 Oct 2019 11:49:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570560543; cv=none; d=google.com; s=arc-20160816; b=PT7oGW0R8mAKh8M17kp91TaL0JHMcQZ5HSyaEMayjaU/8yiT4ha5ZU9dUGJg3UpcLN 7fEa1J7g4TncEJo22BCL12npS56iSxYah+Up6ncv1tYtp5uHAvB8wyahUr9bJx2qd+hZ ZbMPpvZqZXmk6c+vSXYKov0K7cxJuVDZzOm+mR/24cm1KysFssEeoadBLp7/C4uJ9spi 2O/FpwpcQE+UhpT3P/NPYW26JVpEvrwLiSZddSjZ+XpF8UIsknNxS1h89Ijrf2FZdHwI AiBloLzyYmAVIuwP2hg330uD5rkQ8FkLLv1blm1ny/RJ9NFyE5kB9T7/kDl4EhBlwyjH QHNA== 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=qfuM+eOrfkjY3X5vdG1L/3iSehedGNPzsEMXo/fl1Hs=; b=UbJRnvOiSy6EIMBCR/QMCrbfs3j05MmohqOWFm8xqk3dW4vOpCBwqqGtYrGyERQ02S IjgzQk9Z8K4K8AcX0Y62PAKB1WIGxkHMoWMViv3GybxDeMMjzoGfiy+XvlJaZJIrQx39 mKBDArAEE2DudJH9fnMDhBxwBdW4Esa4Eof4NWWKoh/Cw+KNHANKB2mXoca2EZFoz585 bJ8zZI3evM0soLylpPSiR3DI4W4/lv+/Wy3L6iXG1xGv4/lNQ9O9LkIu16yYyy0hLqpD P9OGxfMsE7OuNfrjXAtwTxG0C9tTpEyO5flObmt62E2JnvvL75O/3J6CZ0lt3sm6vszC 5SuA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="x/cCaZXl"; 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 e18si10251008eds.68.2019.10.08.11.48.39; Tue, 08 Oct 2019 11:49:03 -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="x/cCaZXl"; 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 S1729670AbfJHSp0 (ORCPT + 99 others); Tue, 8 Oct 2019 14:45:26 -0400 Received: from mail-lj1-f194.google.com ([209.85.208.194]:44702 "EHLO mail-lj1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726098AbfJHSp0 (ORCPT ); Tue, 8 Oct 2019 14:45:26 -0400 Received: by mail-lj1-f194.google.com with SMTP id m13so18656761ljj.11 for ; Tue, 08 Oct 2019 11:45:25 -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=qfuM+eOrfkjY3X5vdG1L/3iSehedGNPzsEMXo/fl1Hs=; b=x/cCaZXlC//XNrYXPZnfr80qisOKMZMVwbO1hNPgpVxeRN5oUwYVPUeGEo8UMHz8UQ 0HX5OSJ9TqTP4l2dtQJqVXJx+9TD+OaOEGLU7gKgROLqadJaT6TsSX/L/7//1Yb8V2bR 0k98m0Q9Bd5ttF4R05XZgHWx4t44li1DdI8LyrZl82cJiiXryA7PA+ZsCTqQWwS2NW/w heIeaU0vG2FU3Vm8JO0avB5HIwD9XJLlhuP1WeCxOR+en+1VJroRKkxB/TsDSRmJSFRh B/whC+YMw6uTl53LwYkRfwSKomYVg2OSJqDTWCb04dzVFnL52uzMs3QQzSdKgsr3qhGl jvuQ== 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=qfuM+eOrfkjY3X5vdG1L/3iSehedGNPzsEMXo/fl1Hs=; b=mwiQL6aiL/vNy5mnNUl3+vJEVfnb9+VCFAbQsHdpvPGWq07gkl72ccrIu36C7grfM0 eFKdxbcRm1eLH7uSJfR8lfEFyecsyikQxSiRuKd0YOkdLqDNrRZPjadpxnD/k3QyhEDU OwTVzc6cG/pFsDwAA/Bwhw9Jip3j0IRpAkwz1XhPlet0Ttq2xtXX5Of2o7VGAuANJ8hc T1hmJe/WGNb3V5Nu/MDEprvHQhkzCkaEJVkCOA99w4t2IegA7pxnBjojMDlkhlC0Mg1w JI4Xl9AONiJ/axO8Pe1twPV65891JDJf11VfDpvkWv+UfMfE7chXQWAvM99tpzYjaTu8 zRZQ== X-Gm-Message-State: APjAAAVByeDu/vaddaKeqRNvIyZhSDqYDlqv0ElpxzZTM20i3QIutcSD XNfoevygXRlURUe0PLEKOqzpp+oImIzFbAZi+ta/mA== X-Received: by 2002:a2e:5bdd:: with SMTP id m90mr22896723lje.193.1570560323997; Tue, 08 Oct 2019 11:45:23 -0700 (PDT) MIME-Version: 1.0 References: <1568878421-12301-1-git-send-email-vincent.guittot@linaro.org> <1568878421-12301-5-git-send-email-vincent.guittot@linaro.org> <31cac0c1-98e4-c70e-e156-51a70813beff@arm.com> <20191008141642.GQ2294@hirez.programming.kicks-ass.net> <20191008153002.GA21999@linaro.org> <20191008173910.GB22902@worktop.programming.kicks-ass.net> In-Reply-To: <20191008173910.GB22902@worktop.programming.kicks-ass.net> From: Vincent Guittot Date: Tue, 8 Oct 2019 20:45:11 +0200 Message-ID: Subject: Re: [PATCH v3 04/10] sched/fair: rework load_balance To: Peter Zijlstra Cc: Valentin Schneider , linux-kernel , Ingo Molnar , Phil Auld , Srikar Dronamraju , Quentin Perret , Dietmar Eggemann , Morten Rasmussen , 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, 8 Oct 2019 at 19:39, Peter Zijlstra wrote: > > On Tue, Oct 08, 2019 at 05:30:02PM +0200, Vincent Guittot wrote: > > > This is how I plan to get ride of the problem: > > + if (busiest->group_weight == 1 || sds->prefer_sibling) { > > + unsigned int nr_diff = busiest->sum_h_nr_running; > > + /* > > + * When prefer sibling, evenly spread running tasks on > > + * groups. > > + */ > > + env->migration_type = migrate_task; > > + lsub_positive(&nr_diff, local->sum_h_nr_running); > > + env->imbalance = nr_diff >> 1; > > + return; > > + } > > I'm thinking the max_t(long, 0, ...); variant reads a lot simpler and > really _should_ work given that -fno-strict-overflow / -fwrapv mandates > 2s complement. Another point that I have overlooked is that sum_h_nr_running is unsigned int whereas imbalance is long In fact, (long) (unsigned long A - unsigned long B) >> 1 works correctly but (long) (unsigned int A - unsigned int B) >> 1 doesn't