Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp792540yba; Wed, 24 Apr 2019 09:39:21 -0700 (PDT) X-Google-Smtp-Source: APXvYqywkxdLyUn1TPQxWs8XLY76yx96qLcYpn2AwgmoY6x3r28irKftdjcmoV6EEq8MegUfjdsz X-Received: by 2002:aa7:85cc:: with SMTP id z12mr34474381pfn.142.1556123961209; Wed, 24 Apr 2019 09:39:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556123961; cv=none; d=google.com; s=arc-20160816; b=vevrnwpQbxxYd1xXp/x4fiUAZtJgCQH7mrpAHTABP7v77nsjpgWtYekePeGjpZdF8f M3BQ5PlTP5r9ZvFPx2Aeqt5IGzJHMgnWztz6cwFqiQTSzCFo9TPRZOCYxzIoDVSiKu5h XEZ9x12gbZEIKQd3MRFdSUzX02E9oMtrTY74AUTFcW2oNC0ELF76H1e14JZT9AbQSmF+ VajqjnuBxn5lcOZHR7sw4QX/B/WoZStasDelO9MQLAYXbIZqWCgRuH6JqIuYTz0LLDyG 8oM59mvcWOw2gICqZpAnq2T4hwak4j+sfu2/UUb5aAHpFy5cIaOredQDfs/Cjhfj5kk+ 96ew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=lkqxAQL3xt8k0QDsS4LG+HpDDUIEhmWBmfspSXrTCQI=; b=C9Ry7HXZkyWHrS4c34iav7ZeRhmkCtF7kquUiDPNvMBKpkcvMBCkGr+3ho9OIdl6rh X0+nj/qL8A1md1YW0CeL6ax6tpZl0xba5WQvi8P4f61iYxQSR0TWeekycrhREz6jqSA9 v0umWeuOwdmVeHN8wCgQ3e9/eCWsTvMI9UGtCTaqhSiAz83i5aM7jDGAYl3NwenczbuD DoZ3JXyfBtkuzz72fxveOUk/5R6TpvYHcKtKtNUUdYlz3RAtqeKChZyeevEg8PR/Od/7 qKa7YM/O5Aeo2yQc3Q3lXG+PaxB7VnVutm6SPmHwWwm9DnQmDihg654En0UWrYgyJ8p9 fOYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=fGH397TL; 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 y12si685365plt.253.2019.04.24.09.39.05; Wed, 24 Apr 2019 09:39:21 -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=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=fGH397TL; 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 S1732652AbfDXQiH (ORCPT + 99 others); Wed, 24 Apr 2019 12:38:07 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:38952 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732538AbfDXQiG (ORCPT ); Wed, 24 Apr 2019 12:38:06 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=lkqxAQL3xt8k0QDsS4LG+HpDDUIEhmWBmfspSXrTCQI=; b=fGH397TL1RWIS9n8MDs6R6aSh v42q+k7L/BRr08QxkWNRSWtrUgPUsAzYJEBipPfURIyvFi6QYT2obaA32I/4MFAuOCBO035nqCxvs qQw4F5wZttbmjVAos/659UgxkpEYs3Tgoc8c9sDLQlOe4CUQu6rKwVHofHPBISnyKv/BneUFMwW3d A2ikCrEPDJX530yBji+kbmZN+3X59EnbCMChRJsVADRSLXFDmRd6+C3g+84Gl8GAtxmr/+O12iHFD LhyGwABsvLndPoS65MDPceCi9uNGqnHMsN8Iw/VVBvBZwJXZP9+pnv7i1W0r6jpc5jliMbcvoXIDE iFAi2slhg==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=hirez.programming.kicks-ass.net) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1hJKuJ-0006mS-II; Wed, 24 Apr 2019 16:38:03 +0000 Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 11070203C0A58; Wed, 24 Apr 2019 18:38:02 +0200 (CEST) Date: Wed, 24 Apr 2019 18:38:02 +0200 From: Peter Zijlstra To: Thara Gopinath Cc: mingo@redhat.com, rui.zhang@intel.com, linux-kernel@vger.kernel.org, amit.kachhap@gmail.com, viresh.kumar@linaro.org, javi.merino@kernel.org, edubezval@gmail.com, daniel.lezcano@linaro.org, vincent.guittot@linaro.org, nicolas.dechesne@linaro.org, bjorn.andersson@linaro.org, dietmar.eggemann@arm.com Subject: Re: [PATCH V2 1/3] Calculate Thermal Pressure Message-ID: <20190424163802.GH4038@hirez.programming.kicks-ass.net> References: <1555443521-579-1-git-send-email-thara.gopinath@linaro.org> <1555443521-579-2-git-send-email-thara.gopinath@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1555443521-579-2-git-send-email-thara.gopinath@linaro.org> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Apr 16, 2019 at 03:38:39PM -0400, Thara Gopinath wrote: > +static void thermal_pressure_update(struct thermal_pressure *cpu_thermal, > + unsigned long cap_max_freq, > + unsigned long max_freq, bool change_scale) > +{ > + unsigned long flags = 0; > + > + calculate_thermal_pressure(cpu_thermal); > + if (change_scale) > + cpu_thermal->raw_scale = > + (cap_max_freq << SCHED_CAPACITY_SHIFT) / max_freq; That needs {} per coding style. > + > + mod_timer(&cpu_thermal->timer, jiffies + > + usecs_to_jiffies(TICK_USEC)); > + > + spin_unlock_irqrestore(&cpu_thermal->lock, flags); This is busted has heck, @flags should be the result of irqsave(.flags). > +} > + > +/** > + * Function for the tick update of the thermal pressure. > + * The thermal pressure update is aborted if already an update is > + * happening. > + */ > +static void thermal_pressure_timeout(struct timer_list *timer) > +{ > + struct thermal_pressure *cpu_thermal = from_timer(cpu_thermal, timer, > + timer); If you split after the = the result is so very much easier to read. > + unsigned long flags = 0; > + > + if (!cpu_thermal) > + return; > + > + if (!spin_trylock_irqsave(&cpu_thermal->lock, flags)) > + return; > + > + thermal_pressure_update(cpu_thermal, 0, 0, 0); > +} > + > +/** > + * Function to update thermal pressure from cooling device > + * or any framework responsible for capping cpu maximum > + * capacity. Would be useful to know how wide @cpus is, typically. Is that the power culster? > + */ > +void sched_update_thermal_pressure(struct cpumask *cpus, > + unsigned long cap_max_freq, > + unsigned long max_freq) > +{ > + int cpu; > + unsigned long flags = 0; > + struct thermal_pressure *cpu_thermal; You got them in exactly the wrong order here. > + > + for_each_cpu(cpu, cpus) { > + cpu_thermal = per_cpu(thermal_pressure_cpu, cpu); > + if (!cpu_thermal) > + return; > + spin_lock_irqsave(&cpu_thermal->lock, flags); > + thermal_pressure_update(cpu_thermal, cap_max_freq, max_freq, 1); > + } > +} That's just horrible style. Move the unlock out of thermal_pressure_update() such that lock and unlock are in the same function.