Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp720275ybn; Wed, 2 Oct 2019 05:14:49 -0700 (PDT) X-Google-Smtp-Source: APXvYqzxLudNRJE8nTByZyMTB5628UUkMnkkLx6uPjm3mxExJEA4HFdeehNz6j8f3xXLyZWYykMV X-Received: by 2002:a17:906:e10a:: with SMTP id gj10mr2707296ejb.134.1570018488935; Wed, 02 Oct 2019 05:14:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570018488; cv=none; d=google.com; s=arc-20160816; b=q8i+fv1G93OY4eAayYbb6//NhmKtg8uQWVcAsv4F/oclREJ6A98pGIQ6BYQCTE/zba AGbEBPrq0E4RpN0Sb0VWQuw2jZ4ub9oARPsainPpgmEivGVizOzX5em7xdv1ivVeNJic fJ/KR2QLKMaTha9130VRKWInVchqX8tN3d2LssamQUcGWyjxmRtR+EP8kSnSFZKvqG4x 5g76iva8pVidf5RX5qAi8Wq0TBndIdohsvu60RQ9lwnxvTSEAJDPVnUpfKNo6pSsWrON gGguWJVPkxEKDSWqZxtRzi108dbOdC3S7lsePi4hmI8/H7YInigYWKIOjgBrX5iALzOz 5xYQ== 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=D2/NYV5gsCZGGqK2XGaMH1MPpXqGUtsJlf29Errhr4A=; b=i5JVfeVmp6c7xnIsIndr9cTJAM3UIJEYU7Wt1lyIJ2JOCQ3KrBoOWRqoV5aOXZQ1yR hrkZrV+B03ZGNcCJ7T+A71wQiO7oJvm9NaxNBB/FWFWU5x1UEsepKd6Lde4FTz6Fg9ev XYYqYfd/Kdmc+uc4yDOZgRx7CjF1pFLVqGKEII3DovNOKPAPKYjkQ9EVyq3CjDIUoLDW VZopVJBvzKUJdvKvobdLC6Ix7vlmKBo6fbpJhquwDnSqCc5G/FVOFlMGfLtmpskWwiMo fI0GhprMmq1dk9aPVVZ+3DfwhlwbTHqwOMe2X5nUmYC0bn3qrUGMZb7xZ78pa7skdHw0 moYQ== 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 d35si10657648ede.440.2019.10.02.05.14.24; Wed, 02 Oct 2019 05:14:48 -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 S1726761AbfJBKus (ORCPT + 99 others); Wed, 2 Oct 2019 06:50:48 -0400 Received: from foss.arm.com ([217.140.110.172]:41272 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726231AbfJBKus (ORCPT ); Wed, 2 Oct 2019 06:50:48 -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 944F41000; Wed, 2 Oct 2019 03:50:47 -0700 (PDT) Received: from [10.0.2.15] (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 527983F739; Wed, 2 Oct 2019 03:50:45 -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 , Srikar Dronamraju , Quentin Perret , Dietmar Eggemann , 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> From: Valentin Schneider Message-ID: <31cac0c1-98e4-c70e-e156-51a70813beff@arm.com> Date: Wed, 2 Oct 2019 11:47:59 +0100 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 09:30, Vincent Guittot wrote: >> Isn't that one somewhat risky? >> >> Say both groups are classified group_has_spare and we do prefer_sibling. >> We'd select busiest as the one with the maximum number of busy CPUs, but it >> could be so that busiest.sum_h_nr_running < local.sum_h_nr_running (because >> pinned tasks or wakeup failed to properly spread stuff). >> >> The thing should be unsigned so at least we save ourselves from right >> shifting a negative value, but we still end up with a gygornous imbalance >> (which we then store into env.imbalance which *is* signed... Urgh). > > so it's not clear what happen with a right shift on negative signed > value and this seems to be compiler dependent so even > max_t(long, 0, (local->idle_cpus - busiest->idle_cpus) >> 1) might be wrong > Yeah, right shift on signed negative values are implementation defined. This is what I was worried about initially, but I think the expression resulting from the subtraction is unsigned (both terms are unsigned) so this would just wrap when busiest < local - but that is still a problem. ((local->idle_cpus - busiest->idle_cpus) >> 1) should be fine because we do have this check in find_busiest_group() before heading off to calculate_imbalance(): if (busiest->group_type != group_overloaded && (env->idle == CPU_NOT_IDLE || local->idle_cpus <= (busiest->idle_cpus + 1))) /* ... */ goto out_balanced; which ensures the subtraction will be at least 2. We're missing something equivalent for the sum_h_nr_running case. > I'm going to update it > > >> >> [...]