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:	Mon, 01 Mar 2010 23:22:47 +0900
From:	Tejun Heo <tj@...nel.org>
To:	Oleg Nesterov <oleg@...hat.com>
CC:	torvalds@...ux-foundation.org, mingo@...e.hu, peterz@...radead.org,
	awalls@...ix.net, linux-kernel@...r.kernel.org, jeff@...zik.org,
	akpm@...ux-foundation.org, jens.axboe@...cle.com,
	rusty@...tcorp.com.au, cl@...ux-foundation.org,
	dhowells@...hat.com, arjan@...ux.intel.com, avi@...hat.com,
	johannes@...solutions.net, andi@...stfloor.org,
	Mike Galbraith <efault@....de>
Subject: Re: [PATCH 07/43] sched: implement try_to_wake_up_local()

Hello, Oleg.

On 02/28/2010 09:33 PM, Oleg Nesterov wrote:
> Wow ;)

:-)

> I didn't read the whole series yet, still I'd like to ask a couple
> of questions right now. Tejun, I am just trying to understand this
> code.

Sure.

>> @@ -2438,6 +2438,10 @@ static inline void ttwu_post_activation(struct task_struct *p, struct rq *rq,
>>  		rq->idle_stamp = 0;
>>  	}
>>  #endif
>> +	/*
>> +	 * Wake up is complete, fire wake up notifier.  This allows
>> +	 * try_to_wake_up_local() to be called from wake up notifiers.
>> +	 */
>>  	if (success)
>>  		fire_sched_notifiers(p, wakeup);
> 
> Could you explain the comment? ttwu_post_activation() sets state =
> TASK_RUNNING few lines above, what try_to_wake_up_local() can do if
> called from ->wakeup() notifier ?

It can wake up another task on the same rq.

>> +bool try_to_wake_up_local(struct task_struct *p, unsigned int state,
>> +			  int wake_flags)
>> +{
>> ...
>> +	if (!p->se.on_rq) {
>> +		if (likely(!task_running(rq, p))) {
>> +			schedstat_inc(rq, ttwu_count);
>> +			schedstat_inc(rq, ttwu_local);
>> +		}
>> +		ttwu_activate(p, rq, wake_flags & WF_SYNC, false, true);
>> +		success = true;
>> +	}
> 
> Shouldn't try_to_wake_up_local() check task_contributes_to_load() to
> account ->nr_uninterruptible?

try_to_wake_up() does that because the task may be moved to a
different CPU via select_task_rq() for local wakeups, the accounting
can be safely handled by activate_task().

>> @@ -5498,6 +5549,11 @@ need_resched_nonpreemptible:
>>  		if (unlikely(signal_pending_state(prev->state, prev))) {
>>  			prev->state = TASK_RUNNING;
>>  		} else {
>> +			/*
>> +			 * Fire sleep notifier before changing any scheduler
>> +			 * state.  This allows try_to_wake_up_local() to be
>> +			 * called from sleep notifiers.
>> +			 */
>>  			fire_sched_notifiers(prev, sleep);
>>  			deactivate_task(rq, prev, 1);
> 
> Again, I don't understand the comment... If ->sleep() notifier wakes up
> this task, we shouldn't do deactivate_task() ?
>
> Probably both comment mean a notifier could wake up another task bound
> to this rq, in this case it looks a bit confusing, imho.

Correct.  I'll update the comment.

> Off-topic, but it is a bit sad wait_task_inactive() can not use ->sleep()
> notifier to avoid schedule_timeout(), afaics we can't add the notifier
> to !current task.

Agreed.  The whole thing avoids sync cost by only allowing current to
adjust the notifiers and it's a bit sad that wait_task_inactive()
can't use it for that.

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