Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp902958imm; Wed, 15 Aug 2018 08:05:06 -0700 (PDT) X-Google-Smtp-Source: AA+uWPyW////y6VdunquvPaXyqnSMb3w4SUJLY3gpybJoIvDiche4zkcMdXmjvctA3RpjmWbixm7 X-Received: by 2002:a17:902:6b05:: with SMTP id o5-v6mr24517262plk.338.1534345506797; Wed, 15 Aug 2018 08:05:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534345506; cv=none; d=google.com; s=arc-20160816; b=rVf6AtdYdx+F0rlufrGHMtNXcMD6Wzn1qlqk0spDU3wyM5cE9JL2me4onRENu9FpeE wESWvXTDEJebcF9QwJmhziHXiIGDQB66EO9eLkqq1Y0aTcOU/HvQuICeDwgrBhdYMLqD 7K70cazKKYK37HYPGyISQ7Oe0G+izd6QKp8vMq47dAgRRP4Vtu21VXM8+5cV7Jtsecjn tCHH5Dk4Dg4h4ApwV5X8yoJMSQYd66Tl5yBbrg7LD7sY9dgxJOinSzXkWv2BWYZPSuEJ qfmv2SSelpNV0a7OqucOazcO2NyAqpzDn+Blb85pTSIUkueIIhDxD86rRJ4M0xS89fZ3 YWxg== 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:arc-authentication-results; bh=cAK5/24TSZSJ+/uaipFy7PnYOF69X2qoC04vJEquI1c=; b=gEXFjZtvJxSH/Dz6E1MPf7IxClI1CA3QJKCm3g4nBooNzn+YpPdOvziCIhgQ+Yw+ws zj2qjMZ8//1J61jiNUznUKNfQntIWEgKU7rkNlaesNsDvS6hmmHUk6Kw3ZekrOWpS1NX OE6BvNAy+PJlABYyrVYa31NMx1WnSM168u3vhEs9CrdwlJbMomx8Nn31Ru7jxzfOit3i IBVtmgUkDFtN4+Xb7bxNrvY9QsYORnA5IPDl1yAYE9Rcx0CJbSx5TBwhgDW5DZRX4YtU BQUqXxVSENpLJkOPaLYRWmhR4XRxm3ZmXxTENEYYevLM/qu3nsPcf1nOOjnQDkq/BSGv TSHg== 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 t196-v6si21148087pgc.308.2018.08.15.08.04.38; Wed, 15 Aug 2018 08:05:06 -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 S1729512AbeHORzR (ORCPT + 99 others); Wed, 15 Aug 2018 13:55:17 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:55888 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729436AbeHORzR (ORCPT ); Wed, 15 Aug 2018 13:55:17 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 52A0A80D; Wed, 15 Aug 2018 08:02:47 -0700 (PDT) Received: from [0.0.0.0] (e107985-lin.emea.arm.com [10.4.12.239]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 0E5333F5BD; Wed, 15 Aug 2018 08:02:43 -0700 (PDT) Subject: Re: [PATCH v3 04/14] sched/core: uclamp: update CPU's refcount on clamp changes To: Patrick Bellasi , linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org Cc: Ingo Molnar , Peter Zijlstra , Tejun Heo , "Rafael J . Wysocki" , Viresh Kumar , Vincent Guittot , Paul Turner , Morten Rasmussen , Juri Lelli , Todd Kjos , Joel Fernandes , Steve Muckle , Suren Baghdasaryan References: <20180806163946.28380-1-patrick.bellasi@arm.com> <20180806163946.28380-5-patrick.bellasi@arm.com> From: Dietmar Eggemann Message-ID: <4023267d-be06-c599-136e-1f70bf376d5d@arm.com> Date: Wed, 15 Aug 2018 17:02:42 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <20180806163946.28380-5-patrick.bellasi@arm.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-GB Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 08/06/2018 06:39 PM, Patrick Bellasi wrote: [...] > +/** > + * uclamp_task_active: check if a task is currently clamping a CPU > + * @p: the task to check > + * > + * A task actively affects the utilization clamp of a CPU if: > + * - it's currently enqueued or running on that CPU > + * - it's refcounted in at least one clamp group of that CPU > + * > + * Return: true if p is currently clamping the utilization of its CPU. > + */ > +static inline bool uclamp_task_active(struct task_struct *p) > +{ > + struct rq *rq = task_rq(p); > + int clamp_id; > + > + lockdep_assert_held(&p->pi_lock); > + lockdep_assert_held(&rq->lock); > + > + if (!task_on_rq_queued(p) && !p->on_cpu) > + return false; > + > + for (clamp_id = 0; clamp_id < UCLAMP_CNT; ++clamp_id) { > + if (uclamp_task_affects(p, clamp_id)) > + return true; > + } > + > + return false; > +} Looks like that uclamp_task_active() is only used once (in uclamp_task_update_active()). Can you not code the if condition and the for loop directly in uclamp_task_update_active()? This would save code (lockdep_assert_held() etc.) and comment lines. [...]