LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Shaohua Li <shaohua.li@intel.com>
To: Adam Belay <abelay@novell.com>
Cc: Len Brown <len.brown@intel.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	linux-kernel <linux-kernel@vger.kernel.org>,
	Andrew Morton <akpm@osdl.org>,
	Pallipadi@vger.kernel.org,
	Venkatesh <venkatesh.pallipadi@intel.com>,
	linux-acpi@vger.kernel.org
Subject: Re: [RFC][PATCH 3/3] add the 'menu' cpuidle governor
Date: Mon, 26 Mar 2007 13:36:28 +0800	[thread overview]
Message-ID: <1174887388.5523.7.camel@sli10-conroe.sh.intel.com> (raw)
In-Reply-To: <1174722427.32554.84.camel@localhost.localdomain>

Hi,
On Sat, 2007-03-24 at 03:47 -0400, Adam Belay wrote:
> This patch adds the 'menu' governor, as was described in my first email.
> 

> +/**
> + * menu_select - selects the next idle state to enter
> + * @dev: the CPU
> + */
> +static int menu_select(struct cpuidle_device *dev)
> +{
> +	struct menu_device *data = &__get_cpu_var(menu_devices);
> +	int i, expected_us, max_state = dev->state_count;
> +
> +	/* discard BM history because it is sticky */
> +	cpuidle_get_bm_activity();
Why discard BM history here? This way the next bm check almost always
return 0.
BTW, bm activity is global (Not cpu specific), we'd better account it
system wide.

> +	/* determine the expected residency time */
> +	expected_us = (s32) ktime_to_ns(tick_nohz_get_sleep_length()) / 1000;
> +	expected_us = min(expected_us, data->break_last_us);
> +
> +	/* determine the maximum state compatible with current BM status */
> +	if (cpuidle_get_bm_activity())
> +		data->bm_elapsed_us = 0;
> +	if (data->bm_elapsed_us <= data->bm_holdoff_us)
> +		max_state = data->deepest_bm_state + 1;
> +
> +	/* find the deepest idle state that satisfies our constraints */
> +	for (i = 1; i < max_state; i++) {
> +		struct cpuidle_state *s = &dev->states[i];
> +		if (s->target_residency > expected_us)
> +			break;
> +		if (s->exit_latency > system_latency_constraint())
> +			break;
> +	}
> +
> +	data->last_state_idx = i - 1;
> +	data->idle_jiffies = tick_nohz_get_idle_jiffies();
> +	return i - 1;
> +}
> +
> +/**
> + * menu_reflect - attempts to guess what happened after entry
> + * @dev: the CPU
> + *
> + * NOTE: it's important to be fast here because this operation will add to
> + *       the overall exit latency.
> + */
> +static void menu_reflect(struct cpuidle_device *dev)
> +{
> +	struct menu_device *data = &__get_cpu_var(menu_devices);
> +	int last_idx = data->last_state_idx;
> +	int measured_us = cpuidle_get_last_residency(dev);
> +	struct cpuidle_state *target = &dev->states[last_idx];
> +
> +	/*
> +	 * Ugh, this idle state doesn't support residency measurements, so we
> +	 * are basically lost in the dark.  As a compromise, assume we slept
> +	 * for one full standard timer tick.  However, be aware that this
> +	 * could potentially result in a suboptimal state transition.
> +	 */
> +	if (!(target->flags & CPUIDLE_FLAG_TIME_VALID))
> +		measured_us = USEC_PER_SEC / HZ;
> +
> +	data->bm_elapsed_us += measured_us;
> +	data->break_elapsed_us += measured_us;
See the system state: idle->running->idle
Looks the bm_elapsed_us and break_elapsed_us account ingored the running
state between the two idles. Eg, the 'running' might generate a lot of
bm activity, then maybe we should reset bm_elapsed_us in the next
'idle'.

Thanks,
Shaohua

  reply	other threads:[~2007-03-26  5:39 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-03-24  7:47 Adam Belay
2007-03-26  5:36 ` Shaohua Li [this message]
2007-03-27 19:04 ` Adam Belay
2007-03-28  1:43   ` Venki Pallipadi

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=1174887388.5523.7.camel@sli10-conroe.sh.intel.com \
    --to=shaohua.li@intel.com \
    --cc=Pallipadi@vger.kernel.org \
    --cc=abelay@novell.com \
    --cc=akpm@osdl.org \
    --cc=len.brown@intel.com \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tglx@linutronix.de \
    --cc=venkatesh.pallipadi@intel.com \
    --subject='Re: [RFC][PATCH 3/3] add the '\''menu'\'' cpuidle governor' \
    /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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).