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: <20161114145721.GE3142@twins.programming.kicks-ass.net>
Date:   Mon, 14 Nov 2016 15:57:21 +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 1/3] idle: add support for tasks that inject idle

On Wed, Nov 09, 2016 at 11:05:10AM -0800, Jacob Pan wrote:
>  static inline bool is_idle_task(const struct task_struct *p)
>  {
> -	return p->pid == 0;
> +	return !!(p->flags & PF_IDLE);
>  }

> +void play_idle()
> +{
> +	/*
> +	 * Only FIFO tasks can disable the tick since they don't need the forced
> +	 * preemption.
> +	 */
> +	WARN_ON_ONCE(current->policy != SCHED_FIFO);
> +	WARN_ON_ONCE(current->nr_cpus_allowed != 1);
> +	WARN_ON_ONCE(!(current->flags & PF_KTHREAD));
> +	WARN_ON_ONCE(!(current->flags & PF_NO_SETAFFINITY));
> +	rcu_sleep_check();
> +
> +	preempt_disable();
> +	current->flags |= PF_IDLE;
> +	do_idle();
> +	current->flags &= ~PF_IDLE;

Whoops, that will clear PF_IDLE from the idle thread. Maybe do something
like:

	unsigned int idle_flag = (~current->flags & PF_IDLE)

	current->flags |= PF_IDLE;

	current->flags ^= idle_flag;

> +
> +	preempt_fold_need_resched();
> +	preempt_enable();
> +}
> +EXPORT_SYMBOL_GPL(play_idle);

> @@ -299,5 +313,7 @@ void cpu_startup_entry(enum cpuhp_state state)
>  #endif
>  	arch_cpu_idle_prepare();
>  	cpuhp_online_idle(state);
> -	cpu_idle_loop();
> +	while (1)
> +		do_idle();
> +
>  }

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ