linux-rt-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RT] remove_waiter does not need to do chain walk?(2.6.25.4-rt)
@ 2008-06-24  8:07 hyl
  2008-06-26 13:13 ` hyl
  0 siblings, 1 reply; 2+ messages in thread
From: hyl @ 2008-06-24  8:07 UTC (permalink / raw)
  To: linux-kernel, linux-rt-users; +Cc: mingo

Hi, everyone

lets us just focus on remove_waiter in rt_spin_lock_slowlock
(2.6.25.4-rt).  refer to bellowing brief code .

i notice the comments above calling the  remove_waiter , but i can't
figure out the  sequence which meet
the comment.

I  do figure out a event sequence to proof  we must call
remove_waiter , but chain walk seems is not needed.

 0).  current process block on this lock (note:block on lock not the process)
 1).  adaptive_wait  continue  the loop without sleeping due to event
2): owner change( held no lock while adaptive wait)
 2.)  owner free the lock, another process be selected as pending
owner, then release lock
 2.x) then  current be boosted , and become pending owner's top
waiter, so pending owner be boosted too
 3.  in the new round loop: do_try_to_take_rt_mutex->try_to_steal_lock
lucky own the lock,
     and at this time, waiter.task is not NULL

 Question is: seems pending owner's block_on is null,   remove_waiter
seems need no chain walk?

 My scenario may not be the one of author,  please don't hesitate to
offer a example to clarity this question,
i think discuss about this make it clear and easy to maintain.


rt_spin_lock_slowlock(struct rt_mutex *lock)
{
      .........
	for (;;) {
		if (do_try_to_take_rt_mutex(lock, STEAL_LATERAL)) {
		...
		if (!waiter.task) {
		  . ..
		}
         	....
		if (adaptive_wait(&waiter, orig_owner)) {
		......
		}

	.....
	}
	....
	/*
	 * Extremely rare case, if we got woken up by a non-mutex wakeup,
	 * and we managed to steal the lock despite us not being the
	 * highest-prio waiter (due to SCHED_OTHER changing prio), then we
	 * can end up with a non-NULL waiter.task:
	 */
	if (unlikely(waiter.task))
		remove_waiter(lock, &waiter, flags);
.....
}

Regards
hyl

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [RT] remove_waiter does not need to do chain walk?(2.6.25.4-rt)
  2008-06-24  8:07 [RT] remove_waiter does not need to do chain walk?(2.6.25.4-rt) hyl
@ 2008-06-26 13:13 ` hyl
  0 siblings, 0 replies; 2+ messages in thread
From: hyl @ 2008-06-26 13:13 UTC (permalink / raw)
  To: linux-kernel, linux-rt-users; +Cc: mingo

2008/6/24 hyl <heyongli@gmail.com>:
> Hi, everyone
>
> lets us just focus on remove_waiter in rt_spin_lock_slowlock
> (2.6.25.4-rt).  refer to bellowing brief code .
>
> i notice the comments above calling the  remove_waiter , but i can't
> figure out the  sequence which meet
> the comment.
>
> I  do figure out a event sequence to proof  we must call
> remove_waiter , but chain walk seems is not needed.
>
>  0).  current process block on this lock (note:block on lock not the process)
>  1).  adaptive_wait  continue  the loop without sleeping due to event
> 2): owner change( held no lock while adaptive wait)
>  2.)  owner free the lock, another process be selected as pending
> owner, then release lock
>  2.x) then  current be boosted , and become pending owner's top
> waiter, so pending owner be boosted too
>  3.  in the new round loop: do_try_to_take_rt_mutex->try_to_steal_lock
> lucky own the lock,
>     and at this time, waiter.task is not NULL
>
>  Question is: seems pending owner's block_on is null,   remove_waiter
> seems need no chain walk?
   look into the for(;;){}  loop there are only  one break, it is that
we got the lock.
so we must be the owner,  in remove_waiter,
{
	int first = (waiter == rt_mutex_top_waiter(lock));
	struct task_struct *owner = rt_mutex_owner(lock);
	int chain_walk = 0;

	spin_lock(&current->pi_lock);
	plist_del(&waiter->list_entry, &lock->wait_list);
	waiter->task = NULL;
	current->pi_blocked_on = NULL;
	spin_unlock(&current->pi_lock);

	if (first && owner != current && !task_is_reader(owner)) {
        ==>/*we are the owner, so never a chain walk for
rt_spin_lock_slowlock->remove_waiter,*/

but for mutex/reader/writer senerio, the chain walk is possible.

for rt_spin_lock,  it seems that we are never  going to have a non-mutex wakeup.
FIX ME.


>
>  My scenario may not be the one of author,  please don't hesitate to
> offer a example to clarity this question,
> i think discuss about this make it clear and easy to maintain.
>
>
> rt_spin_lock_slowlock(struct rt_mutex *lock)
> {
>      .........
>        for (;;) {
>                if (do_try_to_take_rt_mutex(lock, STEAL_LATERAL)) {
>                ...
>                if (!waiter.task) {
>                  . ..
>                }
>                ....
>                if (adaptive_wait(&waiter, orig_owner)) {
>                ......
>                }
>
>        .....
>        }
>        ....
>        /*
>         * Extremely rare case, if we got woken up by a non-mutex wakeup,
>         * and we managed to steal the lock despite us not being the
>         * highest-prio waiter (due to SCHED_OTHER changing prio), then we
>         * can end up with a non-NULL waiter.task:
>         */
>        if (unlikely(waiter.task))
>                remove_waiter(lock, &waiter, flags);
> .....
> }
>
> Regards
> hyl
>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2008-06-26 13:13 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-06-24  8:07 [RT] remove_waiter does not need to do chain walk?(2.6.25.4-rt) hyl
2008-06-26 13:13 ` hyl

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).