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]
Date:	Thu, 22 May 2014 15:09:31 +0200
From:	Peter Zijlstra <peterz@...radead.org>
To:	Andy Lutomirski <luto@...capital.net>
Cc:	Ingo Molnar <mingo@...nel.org>,
	Thomas Gleixner <tglx@...utronix.de>, nicolas.pitre@...aro.org,
	daniel.lezcano@...aro.org,
	Mike Galbraith <umgwanakikbuti@...il.com>,
	"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: [RFC][PATCH 0/8] sched,idle: need resched polling rework

On Thu, May 22, 2014 at 02:58:18PM +0200, Peter Zijlstra wrote:
> ---
> diff --git a/kernel/sched/core.c b/kernel/sched/core.c
> index 4ea7b3f1a087..a5da85fb3570 100644
> --- a/kernel/sched/core.c
> +++ b/kernel/sched/core.c
> @@ -546,12 +546,38 @@ static bool set_nr_and_not_polling(struct task_struct *p)
>  	struct thread_info *ti = task_thread_info(p);
>  	return !(fetch_or(&ti->flags, _TIF_NEED_RESCHED) & _TIF_POLLING_NRFLAG);
>  }
> +
> +/*
> + * Atomically set TIF_NEED_RESCHED if TIF_POLLING_NRFLAG is set.
> + */
> +static bool set_nr_if_polling(struct task_struct *p)
> +{
> +	struct thread_info *ti = task_thread_info(p);
> +	typeof(ti->flags) old, val = ti->flags;
> +
> +	for (;;) {
> +		if (!(val & _TIF_POLLING_NRFLAG))
> +			return false;
> +		if (val & _TIF_NEED_RESCHED)
> +			return true;

Hmm, I think this is racy, false would be safer. If its already set we
might already be past the sched_ttwu_pending() invocation, while if its
clear and we're the one to set it, we're guaranteed not.

> +		old = cmpxchg(&ti->flags, val, val | _TIF_NEED_RESCHED);
> +		if (old == val)
> +			return true;
> +		val = old;
> +	}
> +}

Content of type "application/pgp-signature" skipped

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ