linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Question regarding list_for_each_entry_safe usage in move_one_task
@ 2013-09-02  6:26 Lei Wen
  2013-09-09 11:15 ` Peter Zijlstra
  0 siblings, 1 reply; 3+ messages in thread
From: Lei Wen @ 2013-09-02  6:26 UTC (permalink / raw)
  To: Peter Zijlstra, Ingo Molnar, mingo, leiwen, linux-kernel

Hi Peter,

I find one list API usage may not be correct in current fair.c code.
In move_one_task function, it may iterate through whole cfs_tasks
list to get one task to move.

But in dequeue_task(), it would delete one task node from list
without the lock protection. So that we could see from
list_for_each_entry_safe API definitoin:

#define list_for_each_entry_safe(pos, n, head, member)
 \
        for (pos = list_entry((head)->next, typeof(*pos), member),      \
                n = list_entry(pos->member.next, typeof(*pos),
member); \
             &pos->member != (head);                                    \
             pos = n, n = list_entry(n->member.next, typeof(*n), member))

As this task node may be listed in the middle of this queue chain, it
may lead to error of searching for the next node when iterating.

Would this be possible to happen? Please help to comment it.

Thanks,
Lei

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

* Re: Question regarding list_for_each_entry_safe usage in move_one_task
  2013-09-02  6:26 Question regarding list_for_each_entry_safe usage in move_one_task Lei Wen
@ 2013-09-09 11:15 ` Peter Zijlstra
  2013-09-10  2:50   ` Lei Wen
  0 siblings, 1 reply; 3+ messages in thread
From: Peter Zijlstra @ 2013-09-09 11:15 UTC (permalink / raw)
  To: Lei Wen; +Cc: Ingo Molnar, mingo, leiwen, linux-kernel

On Mon, Sep 02, 2013 at 02:26:45PM +0800, Lei Wen wrote:
> Hi Peter,
> 
> I find one list API usage may not be correct in current fair.c code.
> In move_one_task function, it may iterate through whole cfs_tasks
> list to get one task to move.
> 
> But in dequeue_task(), it would delete one task node from list
> without the lock protection. So that we could see from
> list_for_each_entry_safe API definitoin:

Both sites hold the required rq->lock.

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

* Re: Question regarding list_for_each_entry_safe usage in move_one_task
  2013-09-09 11:15 ` Peter Zijlstra
@ 2013-09-10  2:50   ` Lei Wen
  0 siblings, 0 replies; 3+ messages in thread
From: Lei Wen @ 2013-09-10  2:50 UTC (permalink / raw)
  To: Peter Zijlstra; +Cc: Ingo Molnar, mingo, leiwen, linux-kernel

On Mon, Sep 9, 2013 at 7:15 PM, Peter Zijlstra <peterz@infradead.org> wrote:
> On Mon, Sep 02, 2013 at 02:26:45PM +0800, Lei Wen wrote:
>> Hi Peter,
>>
>> I find one list API usage may not be correct in current fair.c code.
>> In move_one_task function, it may iterate through whole cfs_tasks
>> list to get one task to move.
>>
>> But in dequeue_task(), it would delete one task node from list
>> without the lock protection. So that we could see from
>> list_for_each_entry_safe API definitoin:
>
> Both sites hold the required rq->lock.

I see, sorry for the noise...

Thanks,
Lei

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

end of thread, other threads:[~2013-09-10  2:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-09-02  6:26 Question regarding list_for_each_entry_safe usage in move_one_task Lei Wen
2013-09-09 11:15 ` Peter Zijlstra
2013-09-10  2:50   ` Lei Wen

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).