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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20120725000901.GA5304@google.com>
Date:	Tue, 24 Jul 2012 17:09:01 -0700
From:	Tejun Heo <tj@...nel.org>
To:	Peter Boonstoppel <pboonstoppel@...dia.com>
Cc:	"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
	Paul Gortmaker <paul.gortmaker@...driver.com>,
	Henrique de Moraes Holschuh <ibm-acpi@....eng.br>,
	Andy Walls <awalls@...metrocast.net>,
	Diwakar Tundlam <dtundlam@...dia.com>
Subject: Re: [PATCH 1/1] kthread: disable preemption during complete()

Hello,

On Tue, Jul 24, 2012 at 05:05:32PM -0700, Peter Boonstoppel wrote:
> After a kthread is created it signals the requester using complete()
> and enters TASK_UNINTERRUPTIBLE. However, since complete() wakes up
> the requesting thread this can cause a preemption. The preemption will
> not remove the task from the runqueue (for that schedule() has to be
> invoked directly).
> 
> This is a problem if directly after kthread creation you try to do a
> kthread_bind(), which will block in HZ steps until the thread is off
> the runqueue.
> 
> This patch disables preemption during complete(), since we call
> schedule() directly afterwards, so it will correctly enter
> TASK_UNINTERRUPTIBLE. This speeds up kthread creation/binding during
> cpu hotplug significantly.
> 
> Change-Id: I856ddd4e01ebdb198ba90f343b4a0c5933fd2b23

Is this from internal gerrit?  Can you please remove it before sending
things upstream?

>  #include <linux/mutex.h>
>  #include <linux/slab.h>
>  #include <linux/freezer.h>
> +#include <linux/preempt.h>
> +#include <linux/thread_info.h>
>  #include <trace/events/sched.h>
>  
>  static DEFINE_SPINLOCK(kthread_create_lock);
> @@ -113,7 +115,10 @@ static int kthread(void *_create)
>  	/* OK, tell user we're spawned, wait for stop or wakeup */
>  	__set_current_state(TASK_UNINTERRUPTIBLE);
>  	create->result = current;
> +	preempt_disable();
>  	complete(&create->done);
> +	clear_need_resched();

Is the above really necessary given that you're calling
preempt_enable_no_resched() right after?

> +	preempt_enable_no_resched();
>  	schedule();

Some comments would be really nice.

Thanks.

-- 
tejun
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ