Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp719651pxa; Tue, 11 Aug 2020 13:18:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyHsgQZuSxk2Wc3zsUMDVGjmDQSl8lZVT01VpUsvRTqC5Wkd6MwjZGRmBXbp6P8lwy5cIMN X-Received: by 2002:a17:906:b749:: with SMTP id fx9mr27524958ejb.186.1597177094689; Tue, 11 Aug 2020 13:18:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597177094; cv=none; d=google.com; s=arc-20160816; b=m67Ypvik5/8vwMc4R154XEUbmgOJpw7voFeX2o8l7c03aFzOYvIdT9b6H9MVcpBzdH c2Qkvyv6x+L9KRO6L+atyzuDoqhOMto/XeGSHKbsFCes7qrP4vveG/WQpAndRNVQ0Wq+ rDaTx8ALEejfNtJOL+QLLo2BvxFkp2ruEM9plIGPa6hAz0ouvG2AQJZ89g81nkQadaFw s7GbWrkf+qBnssC4qg6bS/AmEi2dfQ05ReTTbvu+XSbEmALNrOhiIklS1DCKiPQDbAZx NkWYHBal02GIVr2cAxUY2DoaPBeMnmV8l6fAHEKwX+3VsM6fL0/GiNlLXVcBNEzUZgyt qAxg== 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:mime-version :message-id:date:in-reply-to:subject:cc:to:from:user-agent :references; bh=38BuKa7UnxmZnCFO4u+X2vSI7ZMb62F9xlbDiFh3IDA=; b=Aw5FMNId4GaHUUjQt1L/XtidkTOnti+nC8nVxsMmo0zHCT/nsRa7w2TLnBIK0eVQe9 02gjd4noFq3fkd7O9+a7qz85wzrTkrkSfNvaTXrgw1o95yrNt3dsHHGfkfPR+wuaihVl C0LVrE40rKNkMrlCrjKXQ6q8Jmj28MHQM8i/IjJaUCd+VFuweDYXfvMruNI80uy1myN9 dW5d1BmfoXTMabgEVSNtQx5K2b3YFN6gdClsHZU5sam3fb/866Kq7hhJySZgXtnVgumX SpSTjej1SOCuepdL4lj4tlnyxc+1l9E/qE4zo2mFZB3pSrOAf5fqYWyumzWEl0yTV7xy iLmw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 89si13903928edq.575.2020.08.11.13.17.50; Tue, 11 Aug 2020 13:18:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726274AbgHKUQb convert rfc822-to-8bit (ORCPT + 99 others); Tue, 11 Aug 2020 16:16:31 -0400 Received: from foss.arm.com ([217.140.110.172]:40006 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725889AbgHKUQa (ORCPT ); Tue, 11 Aug 2020 16:16:30 -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 E6377D6E; Tue, 11 Aug 2020 13:16:29 -0700 (PDT) Received: from e113632-lin (e113632-lin.cambridge.arm.com [10.1.194.46]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 8EA423F6CF; Tue, 11 Aug 2020 13:16:28 -0700 (PDT) References: <20200810010009.92758-1-arch0.zheng@gmail.com> <9425382c-2a42-57ca-512d-c93c589dc701@gmail.com> <01fe6a9b-fd3a-9b36-b2fa-6cea58415670@gmail.com> <905d8887-e79c-daf6-cbce-80fd0509e37d@gmail.com> User-agent: mu4e 0.9.17; emacs 26.3 From: Valentin Schneider To: Qi Zheng Cc: mingo@redhat.com, peterz@infradead.org, juri.lelli@redhat.com, vincent.guittot@linaro.org, dietmar.eggemann@arm.com, rostedt@goodmis.org, bsegall@google.com, mgorman@suse.de, linux-kernel@vger.kernel.org Subject: Re: [PATCH] sched/fair: Remove the duplicate check from group_has_capacity() In-reply-to: <905d8887-e79c-daf6-cbce-80fd0509e37d@gmail.com> Date: Tue, 11 Aug 2020 21:16:26 +0100 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 11/08/20 14:12, Qi Zheng wrote: > On 2020/8/11 下午8:48, Valentin Schneider wrote: >> On 11/08/20 12:44, Qi Zheng wrote: >>> In fact, at the beginning, I added unlikely() here to hint the compiler: >>> >>> - if ((sgs->group_capacity * imbalance_pct) < >>> - (sgs->group_runnable * 100)) >>> + if (unlikely((sgs->group_capacity * imbalance_pct) < >>> + (sgs->group_runnable * 100))) >>> >>> The corresponding patch is as follows: >>> >>> [PATCH]sched/core: add unlikely in group_has_capacity() >>> >>> Do you think it is necessary? >> >> The "unlikely" approach has the benefit of keeping all corner cases in >> place. I was tempted to say it could still make sense to get rid of the >> extra check entirely, given that it has an impact only when: >> >> - sum_nr_running == group_weight >> - group capacity has been noticeably reduced >> >> If sum_nr_running < group_weight, we won't evaluate it. >> If sum_nr_running > group_weight, we either won't call into >> group_has_capacity() or we'll have checked it already in >> group_overloaded(). >> >> That said, it does make very much sense to check it in that == >> case. Vincent might have a different take on this, but right now I'd say >> the unlikely approach is the safest one of the two. >> > > So what should I do next? Do I resubmit a patch with unlikely() or > add your email to the old patch([PATCH]sched/core: add unlikely in > group_has_capacity())? Or continue to wait for suggestions from > other maintainers? I guess you can add a reply to the original thread where you had the unlikely() to point out *removing* the check isn't 100% harmless. Vincent might want to have a look at it, but AFAIA he's on holidays ATM.