lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20161114151105.GH3142@twins.programming.kicks-ass.net>
Date:   Mon, 14 Nov 2016 16:11:05 +0100
From:   Peter Zijlstra <peterz@...radead.org>
To:     Jacob Pan <jacob.jun.pan@...ux.intel.com>
Cc:     LKML <linux-kernel@...r.kernel.org>,
        Linux PM <linux-pm@...r.kernel.org>,
        Thomas Gleixner <tglx@...utronix.de>,
        Ingo Molnar <mingo@...hat.com>,
        Zhang Rui <rui.zhang@...el.com>,
        Rafael Wysocki <rafael.j.wysocki@...el.com>,
        "Chen, Yu C" <yu.c.chen@...el.com>,
        Sebastian Andrzej Siewior <bigeasy@...utronix.de>,
        Petr Mladek <pmladek@...e.com>,
        Srinivas Pandruvada <srinivas.pandruvada@...ux.intel.com>,
        Arjan van de Ven <arjan@...ux.intel.com>
Subject: Re: [PATCH 3/3] thermal/powerclamp: use PF_IDLE in injection kthread

On Wed, Nov 09, 2016 at 11:05:12AM -0800, Jacob Pan wrote:
> +static enum hrtimer_restart idle_inject_timer_fn(struct hrtimer *hrtimer)
> +{
> +	set_tsk_need_resched(current);

So drivers really should not use this, which is why I had that in
play_idle().

> +	return HRTIMER_NORESTART;
> +}
> +
>  static void clamp_idle_injection_func(struct kthread_work *work)
>  {
>  	struct powerclamp_worker_data *w_data;
> -	unsigned long target_jiffies;
> +	unsigned long end_time;
> +	unsigned int duration_ms;
>  
>  	w_data = container_of(work, struct powerclamp_worker_data,
>  			      idle_injection_work.work);
>  
> +	hrtimer_init(&w_data->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL_PINNED);
> +	w_data->timer.function = idle_inject_timer_fn;
> +
>  	/*
>  	 * only elected controlling cpu can collect stats and update
>  	 * control parameters.
> @@ -453,31 +459,17 @@ static void clamp_idle_injection_func(struct kthread_work *work)
>  	if (should_skip)
>  		goto balance;
>  
> +	end_time = jiffies + w_data->duration_jiffies;
> +	duration_ms = jiffies_to_msecs(w_data->duration_jiffies);
> +	hrtimer_start(&w_data->timer, ms_to_ktime(duration_ms),
> +		HRTIMER_MODE_REL_PINNED);
> +
> +	cpuidle_use_deepest_state(true);
> +	while (time_after(end_time, jiffies))
> +		play_idle();

Why that loop?

> +	cpuidle_use_deepest_state(false);

> +
> +	hrtimer_cancel(&w_data->timer);

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ