[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH v4 04/16] generic-sections: add section core helpers



On Thu, 25 Aug 2016 08:05:40 +0200
"Luis R. Rodriguez" <mcgrof@xxxxxxxxxx> wrote:

> On Thu, Aug 25, 2016 at 12:06:33PM +1000, Nicholas Piggin wrote:
> > On Wed, 24 Aug 2016 22:12:53 +0200
> > "Luis R. Rodriguez" <mcgrof@xxxxxxxxxx> wrote:  
> > > But:
> > > 
> > > git grep SECTION_TEXT works as expected immediately.
> > > 
> > > I guess its a matter of perspective.
> > >   
> > > > They are also
> > > > the names you'll be grepping for when you look at disassembly.    
> > > 
> > > Sure but if you're grepping asm, you very likely know what to look for.  
> > 
> > After you have gone through the extra layer of naming indirection
> > to work out what it is. I'm still not sold on the name indirection
> > and hiding wildcards. Not just for asm grepping, but I don't think
> > it's a negative thing for devs working on the linker to know what
> > actual section names and commands are being used, as much as possible.  
> 
> OK lets see what it looks like after dropping them. Will try that.
> 
> > > The idea was to add helpers to do the globbing more easily.
> > > 
> > > The glob for sections now documented   is SECTION_ALL()
> > > The glob that is range specific        is SECTION_RNG_ALL()
> > > The glob that is linker table specific is SECTION_TBL_ALL()  
> > 
> > I still don't see this is better than
> > 
> > .text*
> > .text.*
> > .text.range.*
> > .text.table.*
> > etc.  
> 
> OK will drop it.

Thank you for considering it, I appreciate that.


> > > How about:
> > > 
> > > At the top just use "Linux sections helpers"
> > > 
> > > Then:
> > > 
> > > /**
> > >  * DOC: Introduction
> > >  *
> > >  * We document below a dedicated set of helpers used in Linux to make 
> > > sections
> > >  * defined in the Linux linker script accessible in C code in a generic 
> > > form and 
> > >  * and provide certain attributes about them.
> > >  */
> > >   
> > > > I just can't work out what exactly is a
> > > > "custom Linux section", and what DECLARE_LINUX_SECTION(), for example, 
> > > > actaully
> > > > gives you.    
> > > 
> > > Its a way to replace the:
> > > 
> > > extern char foo[], foo__end[];
> > > 
> > > So this provides a generalized form to use declarations used in C code to 
> > > make
> > > the linker script start and end symbols from esctions accessible in C 
> > > code. Since
> > > DEFINE_SECTION_RANGE() and DEFINE_LINKTABLE() macros use this, then the
> > > DECLARE_LINUX_SECTION() is only needed if you need access to these 
> > > symbols in C
> > > code outside of the one that is defining and mainly in charge of managing 
> > > the
> > > section. We provide DECLARE_*() helpers for section ranges and linker 
> > > tables
> > > though so those can be used instead to help annotate the type of a custom
> > > section they are.  
> > 
> > Oh, that makes more sense. The SECTION stuff and custom sections was
> > confusing me. I would prefer just to drop all the LINUX_SECTION naming
> > and make it match the functionality you're using. For example:
> > 
> > +DEFINE_LINKTABLE(struct jump_entry, __jump_table);
> > +
> >  /* mutex to protect coming/going of the the jump_label table */
> >  static DEFINE_MUTEX(jump_label_mutex);
> >  
> > @@ -274,8 +277,6 @@ static void __jump_label_update(struct static_key *key,
> >  
> >  void __init jump_label_init(void)
> >  {
> > -   struct jump_entry *iter_start = __start___jump_table;
> > -   struct jump_entry *iter_stop = __stop___jump_table;
> >     struct static_key *key = NULL;
> >     struct jump_entry *iter;
> >  
> > @@ -292,9 +293,10 @@ void __init jump_label_init(void)
> >             return;
> >  
> >     jump_label_lock();
> > -   jump_label_sort_entries(iter_start, iter_stop);
> > +   jump_label_sort_entries(LINUX_SECTION_START(__jump_table),
> > +                           LINUX_SECTION_END(__jump_table));
> > 
> > Now I think this is a fine abstraction to have.  
> 
> OK will keep this one.
> 
> > I think it would look
> > even cleaner if you had:
> > 
> > LINKTABLE_START(__jump_table)
> > LINKTABLE_END(__jump_table)
> >
> > Then do we need to even have the LINUX_SECTION middle man at all?  
> 
> Ah, thing is we use this for both linktables and section ranges.
> Or do we want macros for both that do the same thing ?

I think it would make the code using it more readable.

Thanks,
Nick

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
https://lists.xen.org/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.