public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Javi Merino <javi.merino@arm.com>
To: Eduardo Valentin <edubezval@gmail.com>
Cc: "rui.zhang@intel.com" <rui.zhang@intel.com>,
	"linux-pm@vger.kernel.org" <linux-pm@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Punit Agrawal <Punit.Agrawal@arm.com>,
	"broonie@kernel.org" <broonie@kernel.org>,
	"tixy@linaro.org" <tixy@linaro.org>
Subject: Re: [PATCH v2 4/7] thermal: introduce the Power Allocator governor
Date: Fri, 27 Feb 2015 16:12:24 +0000	[thread overview]
Message-ID: <20150227161224.GE2877@e104805> (raw)
In-Reply-To: <20150226203615.GB25495@developer.amazonguestwifi.org>

On Thu, Feb 26, 2015 at 08:36:16PM +0000, Eduardo Valentin wrote:
> Javi,
> 
> Replying in v2.
> 
> On Thu, Feb 26, 2015 at 07:00:30PM +0000, Javi Merino wrote:
> 
> <big cut>
> 
> > +
> > +/**
> > + * divvy_up_power() - divvy the allocated power between the actors
> > + * @req_power:	each actor's requested power
> > + * @max_power:	each actor's maximum available power
> > + * @num_actors:	size of the @req_power, @max_power and @granted_power's array
> > + * @total_req_power: sum of @req_power
> > + * @power_range:	total allocated power
> > + * @granted_power:	output array: each actor's granted power
> > + *
> > + * This function divides the total allocated power (@power_range)
> > + * fairly between the actors.  It first tries to give each actor a
> > + * share of the @power_range according to how much power it requested
> > + * compared to the rest of the actors.  For example, if only one actor
> > + * requests power, then it receives all the @power_range.  If
> > + * three actors each requests 1mW, each receives a third of the
> > + * @power_range.
> > + *
> > + * If any actor received more than their maximum power, then that
> > + * surplus is re-divvied among the actors based on how far they are
> > + * from their respective maximums.
> > + *
> > + * Granted power for each actor is written to @granted_power, which
> > + * should've been allocated by the calling function.
> > + */
> > +static void divvy_up_power(u32 *req_power, u32 *max_power, int num_actors,
> > +			   u32 total_req_power, u32 power_range,
> > +			   u32 *granted_power)
> > +{
> > +	u32 extra_power, capped_extra_power, extra_actor_power[num_actors];
> 
> Just now I noticed this variable-size array. I know the number of actors
> are constant, and in average it should be less than 10 in magnitude, but
> I don't believe variable-sized arrays are a good practice in kernel.
> 
> Even though I don't see this one as a treat, can we avoid it?

I can turn it into a devm_kcalloc() and merge it with the other
three allocations that happen earlier.  I'll do that for v3.

Cheers,
Javi

  reply	other threads:[~2015-02-27 16:12 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-26 19:00 [PATCH v2 0/7] The power allocator thermal governor Javi Merino
2015-02-26 19:00 ` [PATCH v2 1/7] thermal: let governors have private data for each thermal zone Javi Merino
2015-02-26 19:00 ` [PATCH v2 2/7] thermal: extend the cooling device API to include power information Javi Merino
2015-02-26 19:00 ` [PATCH v2 3/7] thermal: cpu_cooling: implement the power cooling device API Javi Merino
2015-02-26 19:00 ` [PATCH v2 4/7] thermal: introduce the Power Allocator governor Javi Merino
2015-02-26 20:36   ` Eduardo Valentin
2015-02-27 16:12     ` Javi Merino [this message]
2015-02-26 19:00 ` [PATCH v2 5/7] thermal: add trace events to the power allocator governor Javi Merino
2015-02-26 19:38   ` Steven Rostedt
2015-02-26 19:46     ` Eduardo Valentin
2015-02-26 22:52       ` Steven Rostedt
2015-02-26 21:18         ` Eduardo Valentin
2015-02-27  0:09           ` Steven Rostedt
2015-02-26 19:00 ` [PATCH v2 6/7] of: thermal: Introduce sustainable power for a thermal zone Javi Merino
2015-02-26 19:00 ` [PATCH v2 7/7] thermal: export thermal_zone_parameters to sysfs Javi Merino
2015-02-26 21:30   ` Eduardo Valentin
2015-02-26 22:04     ` Eduardo Valentin
2015-02-27 17:19       ` Javi Merino
2015-02-26 22:10         ` Eduardo Valentin
2015-03-02 14:17           ` Javi Merino
2015-02-26 22:16 ` [PATCH v2 0/7] The power allocator thermal governor Eduardo Valentin
2015-03-02 16:28   ` Javi Merino

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150227161224.GE2877@e104805 \
    --to=javi.merino@arm.com \
    --cc=Punit.Agrawal@arm.com \
    --cc=broonie@kernel.org \
    --cc=edubezval@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=rui.zhang@intel.com \
    --cc=tixy@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox