Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp555076ybn; Wed, 2 Oct 2019 02:26:23 -0700 (PDT) X-Google-Smtp-Source: APXvYqx+yGjmNV5/PvrmZdQGNET7Rx8EYREJjZ5MFpeHNIJEe7EOVBoLqzOYcSmZYjkYs2Zk2k2+ X-Received: by 2002:a50:a0e2:: with SMTP id 89mr2628176edo.118.1570008383524; Wed, 02 Oct 2019 02:26:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570008383; cv=none; d=google.com; s=arc-20160816; b=QDzUNkflRK21qgAuNV4ircZxeQkb0b+9FmL3hUb+/F9KKwQfZEFGmCQTX94mOBmtkI 7QAtYu7Sz2sOUwHw5NrXXsfHXcLx4z0z4QjbumK30KpcqiFMuQNC0DdMVEj4sqdNdGi6 iwfrdsA6osN8LbAKTvcHcR2mZGAmYFbeC/NoVXx4YgJntkKbC8B5Thm4Nws2zlydO6+L w9UpESqe03OwrOHZwqLg3q/th/sGIGKT0iMr/XZxCoS3HDl2a45dozV1HJ4dSFQN+gmj uyQU7MPuiepEV/3j0RB05MMGhOVL36N5/mghZrGsPbPxFbydSljGC9CjWamiBDm5LcHR 3DKQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=x+vG4ucpktG+rrIyN2NZNE3Ikyl0uUKHlIczBr1rshA=; b=Oaa4bZXuZJ4vanM6Adov6DduZ9SCE24LB738GKQS5K9jNFi5W/q9EZa5VxTgc6yhc9 +e2HHFQcFSpO4UxGCTk9HmB/MvEWKH2vI9r8CMlPAVa1lHKJ20GFcOTlV4PMFCw58GsO y9tDbP9S/W+pVz+aR3L+t85Y1p6gkJkHT2JeoT80Aa0emLsK56YDuTX016Y4Yx/XyfjC QiVs+6Qd1P1K/kJyKK9zKuNUeAO5BB7HqnDE+8FfAr7nfomr2HWnSqEPngOhQE/Tu4k8 7tnJsAkvfk3bGV4dTKB/G92g4F7hMrqfeg+9D/HlDqYOHdbG5hujwaZZWwQbKzCJHyLb 7qCw== 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 h15si11181819ejx.211.2019.10.02.02.25.59; Wed, 02 Oct 2019 02:26:23 -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; 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 S1726712AbfJBJY7 (ORCPT + 99 others); Wed, 2 Oct 2019 05:24:59 -0400 Received: from foss.arm.com ([217.140.110.172]:39776 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726354AbfJBJY7 (ORCPT ); Wed, 2 Oct 2019 05:24:59 -0400 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 9D8EF1000; Wed, 2 Oct 2019 02:24:58 -0700 (PDT) Received: from [192.168.0.9] (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id AB7F13F706; Wed, 2 Oct 2019 02:24:56 -0700 (PDT) Subject: Re: [PATCH v3 04/10] sched/fair: rework load_balance To: Vincent Guittot Cc: linux-kernel , Ingo Molnar , Peter Zijlstra , Phil Auld , Valentin Schneider , Srikar Dronamraju , Quentin Perret , Morten Rasmussen , Hillf Danton References: <1568878421-12301-1-git-send-email-vincent.guittot@linaro.org> <1568878421-12301-5-git-send-email-vincent.guittot@linaro.org> <9bfb3252-c268-8c0c-9c72-65f872e9c8b2@arm.com> <3dca46c5-c395-e2b3-a7e8-e9208ba741c8@arm.com> From: Dietmar Eggemann Message-ID: <1aea9422-a164-ceb6-5b8f-da728718bab9@arm.com> Date: Wed, 2 Oct 2019 11:24:51 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 02/10/2019 10:23, Vincent Guittot wrote: > On Tue, 1 Oct 2019 at 18:53, Dietmar Eggemann wrote: >> >> On 01/10/2019 10:14, Vincent Guittot wrote: >>> On Mon, 30 Sep 2019 at 18:24, Dietmar Eggemann wrote: >>>> >>>> Hi Vincent, >>>> >>>> On 19/09/2019 09:33, Vincent Guittot wrote: >> > [...] > >> >>>>> + if (busiest->group_weight == 1 || sds->prefer_sibling) { >>>>> + /* >>>>> + * When prefer sibling, evenly spread running tasks on >>>>> + * groups. >>>>> + */ >>>>> + env->balance_type = migrate_task; >>>>> + env->imbalance = (busiest->sum_h_nr_running - local->sum_h_nr_running) >> 1; >>>>> + return; >>>>> + } >>>>> + >>>>> + /* >>>>> + * If there is no overload, we just want to even the number of >>>>> + * idle cpus. >>>>> + */ >>>>> + env->balance_type = migrate_task; >>>>> + env->imbalance = max_t(long, 0, (local->idle_cpus - busiest->idle_cpus) >> 1); >>>> >>>> Why do we need a max_t(long, 0, ...) here and not for the 'if >>>> (busiest->group_weight == 1 || sds->prefer_sibling)' case? >>> >>> For env->imbalance = (busiest->sum_h_nr_running - local->sum_h_nr_running) >> 1; >>> >>> either we have sds->prefer_sibling && busiest->sum_nr_running > >>> local->sum_nr_running + 1 >> >> I see, this corresponds to >> >> /* Try to move all excess tasks to child's sibling domain */ >> if (sds.prefer_sibling && local->group_type == group_has_spare && >> busiest->sum_h_nr_running > local->sum_h_nr_running + 1) >> goto force_balance; >> >> in find_busiest_group, I assume. > > yes. But it seems that I missed a case: > > prefer_sibling is set > busiest->sum_h_nr_running <= local->sum_h_nr_running + 1 so we skip > goto force_balance above > But env->idle != CPU_NOT_IDLE and local->idle_cpus > > (busiest->idle_cpus + 1) so we also skip goto out_balance and finally > call calculate_imbalance() > > in calculate_imbalance with prefer_sibling set, imbalance = > (busiest->sum_h_nr_running - local->sum_h_nr_running) >> 1; > > so we probably want something similar to max_t(long, 0, > (busiest->sum_h_nr_running - local->sum_h_nr_running) >> 1) Makes sense. Caught a couple of [ 369.310464] 0-3->4-7 2->5 env->imbalance = 2147483646 [ 369.310796] 0-3->4-7 2->4 env->imbalance = 2147483647 in this if condition on h620 running hackbench.