public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
To: Lai Jiangshan <laijs@cn.fujitsu.com>
Cc: "H. Peter Anvin" <hpa@linux.intel.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Michal Marek <mmarek@suse.cz>, Jan Beulich <JBeulich@novell.com>,
	Ingo Molnar <mingo@elte.hu>,
	Alexander van Heukelum <heukelum@fastmail.fm>,
	Dipankar Sarma <dipankar@in.ibm.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Sam Ravnborg <sam@ravnborg.org>,
	David Howells <dhowells@redhat.com>,
	Oleg Nesterov <oleg@redhat.com>,
	Roland McGrath <roland@redhat.com>,
	linux-kernel@vger.kernel.org,
	Thomas Gleixner <tglx@linutronix.de>,
	Steven Rostedt <rostedt@goodmis.org>
Subject: Re: [RFC PATCH 4/5] RCU: Add TASK_RCU_OFFSET
Date: Sat, 23 Apr 2011 13:30:01 -0700	[thread overview]
Message-ID: <20110423203001.GG2628@linux.vnet.ibm.com> (raw)
In-Reply-To: <4DB12C1E.8050200@cn.fujitsu.com>

On Fri, Apr 22, 2011 at 03:19:58PM +0800, Lai Jiangshan wrote:
> 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@vger.kernel.org
> >> 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@vger.kernel.org
> > 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?

My belief is that the Linux kernel's include files need to have a designed
approach to reduce the include-file problems.  For example, one approach
would be to split out the data declarations from the access functions --
but it is not clear to me that this is the right approach.  But whatever
approach is chosen, that approach needs to have a clear design behind it,
because otherwise we will end up continually refactoring.  And whatever
approach is chosen, putting simple/small data/type declarations into
types.h is very likely to be part of the approach, given that types.h
has worked well in a great many projects over a long period of time.
I do hope that whatever overall approach we evolve to, that this approach
will allow use of inline functions rather than macros.  But it is easy
to change these back and forth, so I am not too worried about them.

In the meantime, for rcupdate.h, it appears that putting struct rcu_head
into types.h and then converting a few inline functions to macros will
suffice.  Furthermore, this split of the rcupdate.h functionality will
likely hold up for quite some time.

You have been doing a much more thorough job of testing this change than
I have, so it does make sense that you carry out the change.

So, could you please try out this approach?  Put rcu_head into types.h,
re-order rcupdate.h as needed, and convert a few inline functions to
macros?

As I have said before, it will be really cool to allow rcu_read_lock()
and rcu_read_unlock() to be inline functions for preemptible RCU!!!

							Thanx, Paul

  parent reply	other threads:[~2011-04-23 20:30 UTC|newest]

Thread overview: 67+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-28  2:55 [RFC PATCH 0/5] Add kernel-offset file and make rcu_read_[un]lock() included Lai Jiangshan
2011-03-28  2:58 ` [RFC PATCH 1/5] Move task's RCU code to rcupdate.h Lai Jiangshan
2011-03-31 11:31   ` Peter Zijlstra
2011-03-31 23:24     ` Paul E. McKenney
2011-03-28  2:58 ` [RFC PATCH 2/5] kbuild: dedumplicated the generating code Lai Jiangshan
2011-03-28  8:31   ` Jan Beulich
2011-03-31 18:26   ` David Howells
2011-03-28  2:59 ` [RFC PATCH 3/5] kbuild: add kernel-offset file Lai Jiangshan
2011-03-31 18:28   ` David Howells
2011-03-28  3:00 ` [RFC PATCH 4/5] RCU: Add TASK_RCU_OFFSET Lai Jiangshan
2011-03-28  8:35   ` Jan Beulich
2011-03-29  9:41     ` Lai Jiangshan
2011-03-29 21:14     ` H. Peter Anvin
2011-03-29 21:31       ` Paul E. McKenney
2011-03-29 21:32         ` H. Peter Anvin
2011-03-29 21:47           ` Paul E. McKenney
2011-03-29 22:01             ` H. Peter Anvin
2011-03-30  0:47               ` Paul E. McKenney
2011-03-30  5:25                 ` Lai Jiangshan
2011-03-30  7:22                   ` Lai Jiangshan
2011-03-30 10:55                     ` Michal Marek
2011-03-30 10:57                       ` Peter Zijlstra
2011-03-30 11:46                         ` Michal Marek
2011-03-31  1:02                           ` Lai Jiangshan
2011-03-31  1:21                             ` Paul E. McKenney
2011-03-31  1:53                               ` Lai Jiangshan
2011-03-31 23:30                                 ` Paul E. McKenney
2011-04-01  3:28                                   ` Paul E. McKenney
2011-03-31  8:04                             ` Peter Zijlstra
2011-03-31  9:50                               ` Lai Jiangshan
2011-03-31 11:18                                 ` Peter Zijlstra
2011-04-01  1:57                                   ` Lai Jiangshan
2011-04-01 11:35                                     ` Peter Zijlstra
2011-04-05 21:54                                       ` Paul E. McKenney
2011-04-05 23:07                                         ` Paul E. McKenney
2011-04-06  8:10                                           ` Peter Zijlstra
2011-04-06 19:21                                             ` Paul E. McKenney
2011-04-06 20:13                                               ` Paul E. McKenney
2011-04-06 21:06                                                 ` Peter Zijlstra
2011-04-06 21:27                                                   ` H. Peter Anvin
2011-04-07  0:30                                                     ` Paul E. McKenney
2011-04-07  5:49                                                       ` Lai Jiangshan
2011-04-07 15:47                                                         ` Paul E. McKenney
2011-04-07 16:26                                                           ` Paul E. McKenney
2011-04-08  1:26                                                             ` Lai Jiangshan
2011-04-08  5:13                                                               ` Paul E. McKenney
2011-04-11  3:08                                                                 ` Lai Jiangshan
2011-04-11  5:12                                                                   ` Paul E. McKenney
2011-04-11  6:01                                                                     ` Lai Jiangshan
2011-04-11  8:31                                                                     ` Lai Jiangshan
2011-04-11 21:02                                                                       ` Paul E. McKenney
2011-04-11 21:24                                                                         ` Peter Zijlstra
2011-04-22  7:19                                                                         ` Lai Jiangshan
2011-04-22  8:10                                                                           ` Peter Zijlstra
2011-04-25  7:21                                                                             ` Lai Jiangshan
2011-04-23 20:30                                                                           ` Paul E. McKenney [this message]
2011-04-11  8:33                                                                     ` Lai Jiangshan
2011-04-07  7:05                                                       ` [PATCH 1/4] rcu: split rcupdate.h Lai Jiangshan
2011-04-07  7:07                                                       ` [PATCH 2/4] rcu: make rcudpate.h can use struct task_struct Lai Jiangshan
2011-04-07  7:07                                                       ` [PATCH 3/4] rcu: introduce task_rcu_struct and move task's RCU code to rcupdate_defs.h Lai Jiangshan
2011-04-07 13:40                                                         ` Alexey Dobriyan
2011-04-07  7:08                                                       ` [PATCH 4/4] rcu: declare preemptible __rcu_read_[un]lock() as inline function Lai Jiangshan
2011-04-06 17:41                                           ` [RFC PATCH 4/5] RCU: Add TASK_RCU_OFFSET Paul E. McKenney
2011-03-31 19:28                                 ` H. Peter Anvin
2011-03-31 19:25                   ` H. Peter Anvin
2011-03-28  3:01 ` [RFC PATCH 5/5] RCU: declare preemptible __rcu_read_[un]lock() as inline function Lai Jiangshan
2011-03-28 22:17 ` [RFC PATCH 0/5] Add kernel-offset file and make rcu_read_[un]lock() included Paul E. McKenney

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20110423203001.GG2628@linux.vnet.ibm.com \
    --to=paulmck@linux.vnet.ibm.com \
    --cc=JBeulich@novell.com \
    --cc=akpm@linux-foundation.org \
    --cc=dhowells@redhat.com \
    --cc=dipankar@in.ibm.com \
    --cc=heukelum@fastmail.fm \
    --cc=hpa@linux.intel.com \
    --cc=laijs@cn.fujitsu.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=mmarek@suse.cz \
    --cc=oleg@redhat.com \
    --cc=peterz@infradead.org \
    --cc=roland@redhat.com \
    --cc=rostedt@goodmis.org \
    --cc=sam@ravnborg.org \
    --cc=tglx@linutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox