Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp1101939yba; Wed, 24 Apr 2019 15:10:04 -0700 (PDT) X-Google-Smtp-Source: APXvYqyembyq0ksep1Z4eD3RHRtlUc1atXZkTOBbN/6RLcSSytDQJzyrYpZ6NrXsbcgiyBBLnoBp X-Received: by 2002:a63:744b:: with SMTP id e11mr33221274pgn.327.1556143804913; Wed, 24 Apr 2019 15:10:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556143804; cv=none; d=google.com; s=arc-20160816; b=gSeqzCAXn4rLVcFd/4MYU6NdIfDmArgjeb9jA1kB5LRYwt91C8akOD+o02AHsagiWD wP4Gy+TMr6yDEDRzO7rzgwP4BUQflUcP6unGN3WwWA47/vSaa8KvbYh0/uw4bqZea3l7 7jWhBCmJn0gbcbAjE9QICXugiJBjY5kaEFGat8W1Za7gQCwWyTu7n2NKNKYxbRtbcnOM 1gAXTv94CqpWJbRBu8WRtjydzdQLIJmzL5Dbop6qQkK543AnaI2L9AfNO7WGChpSvyxt tedOHHWSsTb0Gh8Q1rSo22mVWv0TS/Ja1ss051lk4bXHZHQaUq3brR+201427qNBMBbd 5QFg== 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=g6DlFLP7NrnGwdEHow1YOFKyE5JRz/OpjxDYhcwMvsg=; b=rLMWl4Hyle03IHp3PTOHk5RsGIIyCf3caqacjPFPQCznKYwAjPcboDJtVeEEchF5OX C9p/6NxlF4Icim/g5dP4tI4Da5SmmzbtPYzC1HD3Hp5yN9IHypmDGLrQvrlCGkB7mYPm ptHWEOqLMRHzgynFGZ9XqNNlXGBYx74JhgHMwVdndXG5mnKcVKLXM0iUdwZfbX4vLbyH Wlfujcpo42HGwwHRBNGwfibyJKwfKdq22uBt7JG43VX0vjevqvsuCeFT6aRYUxT2D9gs GCQdOg2RL1hhE5EoZD/MpGZNqx6JkRdQ/7EHf58EKtqV7XJeXIoqUtezmr8m6BFf1wxA 7hRw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=e6jVDiv9; 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 z11si20525425pfa.153.2019.04.24.15.09.49; Wed, 24 Apr 2019 15:10:04 -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=merlin.20170209 header.b=e6jVDiv9; 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 S1732736AbfDXQpc (ORCPT + 99 others); Wed, 24 Apr 2019 12:45:32 -0400 Received: from merlin.infradead.org ([205.233.59.134]:38932 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726935AbfDXQpc (ORCPT ); Wed, 24 Apr 2019 12:45:32 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.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=g6DlFLP7NrnGwdEHow1YOFKyE5JRz/OpjxDYhcwMvsg=; b=e6jVDiv921F5TcDqtCnSTfzFm bMZtMxt/K2ZZFvdGG/vLX2QWT67KW09wv81ztt6OKZNngo9yMJtxv+TsrW+GcOVOSQ/kOWhfc3ITJ 13XoIC86lAdd00Vf1XacVrTqJIBaew33WU0Fea8nQhcmuHacSakFSQYyjVUTPy9NHpEj8Hxh+SJ9E kSzHTG2+pMxMwbLVbtzpnKjRCEzo7Bs5qxF9YWdZSgPS6vXTgMiv3TtqI45guoodif0Q1rpPyRMQR AywqnZ2qeEJtqG3tGk16Vwk8TdwlkNp9Wc+FY1BWHy9gCoxkZeDhAlrcR3nXGuMt4uznmD+RxZ6z5 8PA4UKYgQ==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=hirez.programming.kicks-ass.net) by merlin.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1hJL1M-0005wW-NB; Wed, 24 Apr 2019 16:45:20 +0000 Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 2FFF9203C0A58; Wed, 24 Apr 2019 18:45:19 +0200 (CEST) Date: Wed, 24 Apr 2019 18:45:19 +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: <20190424164519.GI4038@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 __init init_thermal_pressure(void) > +{ > + struct thermal_pressure *cpu_thermal; > + unsigned long scale; > + int cpu; > + > + pr_debug("Init thermal pressure\n"); > + for_each_possible_cpu(cpu) { > + cpu_thermal = per_cpu(thermal_pressure_cpu, cpu); > + if (cpu_thermal) > + continue; > + > + cpu_thermal = kzalloc(sizeof(*cpu_thermal), GFP_KERNEL); > + if (!cpu_thermal) > + continue; So if you unconditinoally allocate this memory, why not just have: DEFINE_PER_CPU(struct thermal_pressure, cpu_thermal_pressure); ? Or stick it in struct rq or whatever. > + scale = SCHED_CAPACITY_SCALE; > + cpu_thermal->scale = scale; > + cpu_thermal->old_scale = scale; > + cpu_thermal->raw_scale = scale; > + cpu_thermal->age_stamp = sched_clock_cpu(cpu); > + cpu_thermal->last_update = sched_clock_cpu(cpu); > + cpu_thermal->cpu = cpu; > + spin_lock_init(&cpu_thermal->lock); > + timer_setup(&cpu_thermal->timer, thermal_pressure_timeout, > + TIMER_DEFERRABLE); > + per_cpu(thermal_pressure_cpu, cpu) = cpu_thermal; > + pr_debug("cpu %d thermal scale = %ld\n", cpu, cpu_thermal->scale); > + } > + > + for_each_possible_cpu(cpu) { You just done that, what gives? > + cpu_thermal = per_cpu(thermal_pressure_cpu, cpu); > + if (!cpu_thermal) > + continue; > + cpu_thermal->timer.expires = jiffies + > + usecs_to_jiffies(TICK_USEC); That's like a very copmlicated way of writing: '1', right? > + add_timer(&cpu_thermal->timer); > + } > +} So really what you want is a hook into the tick?