Re: [RFC PATCH 4/5] RCU: Add TASK_RCU_OFFSET

From: Lai Jiangshan
Date: Fri Apr 22 2011 - 03:17:52 EST


On 04/12/2011 05:02 AM, Paul E. McKenney wrote:
> On Mon, Apr 11, 2011 at 04:31:10PM +0800, Lai Jiangshan wrote:
>> On 04/11/2011 01:12 PM, Paul E. McKenney wrote:
>>
>>> -static inline struct task_struct *next_thread(const struct task_struct *p)
>>> -{
>>> - return list_entry_rcu(p->thread_group.next,
>>> - struct task_struct, thread_group);
>>> -}
>>> +/* Avoid #include hell for inlining rcu_read_lock(). */
>>> +#define next_thread(p) \
>>> + list_entry_rcu((p)->thread_group.next, struct task_struct, thread_group)
>>>
>>
>>
>> It is strange for me.
>> The user of the API "next_thread(p)" must has two headers included, sched.h and rculist.h
>>
>> I know this is a very popular pattern of user space code, is it OK for kernel?
>> I think a file(even a header file) uses API(Marco), it should includes the the corresponding
>> headers, it reduces surprises(example, the name of "next_thread()" has no "rcu",
>> it is not expected that rcuxxxx.h is required).
>>
>> I admit the work will become very much simpler if this pattern is allowed.
>
> The guy who maintains much of sched.h suggested it. ;-)
>
> Thanx, Paul
>
>> man fcntl:
>> #include <unistd.h>
>> #include <fcntl.h>
>>
>> int fcntl(int fd, int cmd, ... /* arg */ );
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
>> the body of a message to majordomo@xxxxxxxxxxxxxxx
>> More majordomo info at http://vger.kernel.org/majordomo-info.html
>> Please read the FAQ at http://www.tux.org/lkml/
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@xxxxxxxxxxxxxxx
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
>

Hi, Paul

What is the solution you prefer to?

I insist on the solution which split rcupdate.h into 2 parts,
the first part is rcupdate_defs.h which only contains:
1) struct rcu_head
2) MACRO rcu_dereference*
3) MACRO rcu_access_pointer rcu_access_index rcu_assign_pointer RCU_INIT_POINTER
4) rcu_*_lock_held() which is required by 2)

All of these is required by sched.h, it is all about 450 lines of code.

It does not just separate struct rcu_head out only, because rcu_dereference*()
and APIs in rculist.h are required by in sched.h or headers included by sched.h.

Any suggestion?

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