Re: [Xen-devel] [PATCH v5 04/14] tables.h: add linker table support

2017-01-09 Thread Luis R. Rodriguez
On Fri, Jan 06, 2017 at 10:43:59PM +0200, Andy Shevchenko wrote:
> On Fri, Jan 6, 2017 at 10:00 PM, Luis R. Rodriguez  wrote:
> > On Wed, Jan 04, 2017 at 11:47:14AM +0200, Andy Shevchenko wrote:
> >> On Tue, Jan 3, 2017 at 11:25 PM, Luis R. Rodriguez  
> >> wrote:
> >> > On Thu, Dec 22, 2016 at 03:58:18PM +0200, Andy Shevchenko wrote:
> >> >> On Wed, 2016-12-21 at 18:38 -0800, Luis R. Rodriguez wrote:
> >> >> > +#define LINKTABLE_FOR_EACH(pointer, tbl)
> >> >>
> >> >> Hmm... SOMEONE LIKES CAPITAL LETTERS FOR everything, right? :-)
> >> >>
> >> >> I would expect more standard linktable_for_each() macro
> >> >
> >> > hpa had recommended this, if he prefers a lower case I can change that
> >>
> >>
> >> > but I really do consider this bikeshedding.
> >>
> >> I don't think so:
> >> $ git grep -n FOR_EACH | wc -l
> >> 83
> >> $ git grep -n for_each | wc -l
> >>  23317
> >
> > OK, would you also prefer if LINKTABLE_RUN_ERR() and LINKTABLE_RUN_ALL()
> > were lowercase ? Or is that fine ? To be clear I'll leave upper case the
> > declarers and defines.
> 
> My understanding that macros to run code -- lower case, definitions --
> upper case.
> 
> Thus, *_run_*() macros to lower.

Very well, I've changed these, and since there were users I had to change
a bit of the other patches so will send a v6 series follow up.

  Luis

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


Re: [Xen-devel] [PATCH v5 04/14] tables.h: add linker table support

2017-01-06 Thread Andy Shevchenko
On Fri, Jan 6, 2017 at 10:00 PM, Luis R. Rodriguez  wrote:
> On Wed, Jan 04, 2017 at 11:47:14AM +0200, Andy Shevchenko wrote:
>> On Tue, Jan 3, 2017 at 11:25 PM, Luis R. Rodriguez  wrote:
>> > On Thu, Dec 22, 2016 at 03:58:18PM +0200, Andy Shevchenko wrote:
>> >> On Wed, 2016-12-21 at 18:38 -0800, Luis R. Rodriguez wrote:
>> >> > +#define LINKTABLE_FOR_EACH(pointer, tbl)
>> >>
>> >> Hmm... SOMEONE LIKES CAPITAL LETTERS FOR everything, right? :-)
>> >>
>> >> I would expect more standard linktable_for_each() macro
>> >
>> > hpa had recommended this, if he prefers a lower case I can change that
>>
>>
>> > but I really do consider this bikeshedding.
>>
>> I don't think so:
>> $ git grep -n FOR_EACH | wc -l
>> 83
>> $ git grep -n for_each | wc -l
>>  23317
>
> OK, would you also prefer if LINKTABLE_RUN_ERR() and LINKTABLE_RUN_ALL()
> were lowercase ? Or is that fine ? To be clear I'll leave upper case the
> declarers and defines.

My understanding that macros to run code -- lower case, definitions --
upper case.

Thus, *_run_*() macros to lower.

-- 
With Best Regards,
Andy Shevchenko

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


Re: [Xen-devel] [PATCH v5 04/14] tables.h: add linker table support

2017-01-06 Thread Luis R. Rodriguez
On Wed, Jan 04, 2017 at 11:47:14AM +0200, Andy Shevchenko wrote:
> On Tue, Jan 3, 2017 at 11:25 PM, Luis R. Rodriguez  wrote:
> > On Thu, Dec 22, 2016 at 03:58:18PM +0200, Andy Shevchenko wrote:
> >> On Wed, 2016-12-21 at 18:38 -0800, Luis R. Rodriguez wrote:
> >> > +#define LINKTABLE_FOR_EACH(pointer, tbl)
> >>
> >> Hmm... SOMEONE LIKES CAPITAL LETTERS FOR everything, right? :-)
> >>
> >> I would expect more standard linktable_for_each() macro
> >
> > hpa had recommended this, if he prefers a lower case I can change that
> 
> 
> > but I really do consider this bikeshedding.
> 
> I don't think so:
> $ git grep -n FOR_EACH | wc -l
> 83
> $ git grep -n for_each | wc -l
>  23317

OK, would you also prefer if LINKTABLE_RUN_ERR() and LINKTABLE_RUN_ALL()
were lowercase ? Or is that fine ? To be clear I'll leave upper case the
declarers and defines.

  Luis

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


Re: [Xen-devel] [PATCH v5 04/14] tables.h: add linker table support

2017-01-04 Thread Andy Shevchenko
On Tue, Jan 3, 2017 at 11:25 PM, Luis R. Rodriguez  wrote:
> On Thu, Dec 22, 2016 at 03:58:18PM +0200, Andy Shevchenko wrote:
>> On Wed, 2016-12-21 at 18:38 -0800, Luis R. Rodriguez wrote:
>> > +#define LINKTABLE_FOR_EACH(pointer, tbl)
>>
>> Hmm... SOMEONE LIKES CAPITAL LETTERS FOR everything, right? :-)
>>
>> I would expect more standard linktable_for_each() macro
>
> hpa had recommended this, if he prefers a lower case I can change that


> but I really do consider this bikeshedding.

I don't think so:
$ git grep -n FOR_EACH | wc -l
83
$ git grep -n for_each | wc -l
 23317

-- 
With Best Regards,
Andy Shevchenko

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


Re: [Xen-devel] [PATCH v5 04/14] tables.h: add linker table support

2017-01-03 Thread Luis R. Rodriguez
On Thu, Dec 22, 2016 at 03:58:18PM +0200, Andy Shevchenko wrote:
> On Wed, 2016-12-21 at 18:38 -0800, Luis R. Rodriguez wrote:
> > +#define LINKTABLE_FOR_EACH(pointer, tbl)   
> 
> Hmm... SOMEONE LIKES CAPITAL LETTERS FOR everything, right? :-)
>
> I would expect more standard linktable_for_each() macro

hpa had recommended this, if he prefers a lower case I can change that
but I really do consider this bikeshedding.

> Same to the rest of similar macros.

Same answer here.

> > +/**
> > + * LINKTABLE_RUN_ERR - run each linker table entry func and return
> > error if any
> > + *
> > + * @tbl: linker table
> > + * @func: structure name for the function name we want to call.
> > + * @args...: arguments to pass to func
> > + *
> > + * Example usage::
> > + *
> > + *   unsigned int err = LINKTABLE_RUN_ERR(frobnicator_fns,
> > some_run,);
> > + */
> > +#define LINKTABLE_RUN_ERR(tbl, func, args...)  
> > \
> > +({ 
> > \
> > +   size_t i;   
> > \
> > +   int err = 0;
> > \
> > +   for (i = 0; !err && i < LINKTABLE_SIZE(tbl); i++)   
> > \
> > +   err = (LINKTABLE_START(tbl)[i]).func (args);
> 
> 
> > \
> > +   err;
> 
> Indentation here a bit confusing.

Ah yes, good catch, fixed.

  Luis

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


Re: [Xen-devel] [PATCH v5 04/14] tables.h: add linker table support

2016-12-22 Thread Andy Shevchenko
On Wed, 2016-12-21 at 18:38 -0800, Luis R. Rodriguez wrote:
> A linker table is a data structure that is stitched together from
> items
> in multiple object files. Linux has historically implicitly used
> linker
> tables for ages, however they were all built in an adhoc manner which
> requires linker script modifications, per architecture. This adds a
> general linker table solution so that a new linker table can be
> implemented by changing C code only. The Linux linker table was
> inspired by Michael Brown's iPXE's linker table solution, it has been
> been completely re-written and adapted for integration and use on
> Linux.




> +/**
> + * LINKTABLE_FOR_EACH - iterate through all entries within a linker
> table
> + *
> + * @pointer: entry pointer
> + * @tbl: linker table
> + *
> + * Example usage::
> + *
> + *   struct frobnicator *frob;
> + *
> + *   LINKTABLE_FOR_EACH(frob, frobnicator_fns) {
> + * ...
> + *   }
> + */
> +
> +#define LINKTABLE_FOR_EACH(pointer, tbl) 
> \

Hmm... SOMEONE LIKES CAPITAL LETTERS FOR everything, right? :-)

I would expect more standard 
linktable_for_each()
macro

Same to the rest of similar macros.


> +/**
> + * LINKTABLE_RUN_ERR - run each linker table entry func and return
> error if any
> + *
> + * @tbl: linker table
> + * @func: structure name for the function name we want to call.
> + * @args...: arguments to pass to func
> + *
> + * Example usage::
> + *
> + *   unsigned int err = LINKTABLE_RUN_ERR(frobnicator_fns,
> some_run,);
> + */
> +#define LINKTABLE_RUN_ERR(tbl, func, args...)
> \
> +({   
> \
> + size_t i;   
> \
> + int err = 0;
> \
> + for (i = 0; !err && i < LINKTABLE_SIZE(tbl); i++)   
> \
> + err = (LINKTABLE_START(tbl)[i]).func (args);


> \
> + err;

Indentation here a bit confusing.

> \
> +})


-- 
Andy Shevchenko 
Intel Finland Oy

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


[Xen-devel] [PATCH v5 04/14] tables.h: add linker table support

2016-12-21 Thread Luis R. Rodriguez
A linker table is a data structure that is stitched together from items
in multiple object files. Linux has historically implicitly used linker
tables for ages, however they were all built in an adhoc manner which
requires linker script modifications, per architecture. This adds a
general linker table solution so that a new linker table can be
implemented by changing C code only. The Linux linker table was
inspired by Michael Brown's iPXE's linker table solution, it has been
been completely re-written and adapted for integration and use on Linux.

The same philosophy is borrowed, extended and further simplified:

Linker tables enable an extremely light weight linker build time
solution for feature ordering and selection, this can help to both
simplify init sequences in a generic fashion and helps avoiding code
bit-rotting when desirable. Further changes will be added later
which will make more evident how code bit rot can be avoided using
linker tables.

v5:
o Use ..tbl.* instead of .tbl.* as suggested by Nicholas Piggin.
  This is the typical way to avoid clashes with compiler generated
  sections.
o Replace section macros with section names
o Dropped SECTION_RNG_ALL()
o Fix documentation typos
o To make this easier to read, as per Nicholas Piggin, add our own
  LINKTABLE_START(), LINKTABLE_END(). After reviewing the changes
  affected by this it seemed clearer and better then to also
  use our own specific LINKTABLE_SIZE(), LINKTABLE_EMPTY() and
  LINKTABLE_ALIGNMENT() as well.
o Clarifies SECTION_TBL_RO needs to be kept since some toolchains
  are buggy, and so we also add SECTION_TBL_RO_STR.
o We were using LINUX_SECTION_START() and LINUX_SECTION_END() in some places
  but in some other places VMLINUX_SYMBOL(name), VMLINUX_SYMBOL(name##__end).
  Since we are adding LINKTABLE_START() and LINKTABLE_END() just use those
  consistently.
o Fix DEFINE_LINKTABLE_INIT() by making it use DECLARE_LINKTABLE_RO()
  which forces const.
o Fix powerpc .text use: it does not use TEXT_TEXT so we must
  add our *(SORT(.text.tbl.*)) to its linker script manually.

v4:

o Split out kbuild additions to help with code bit rot into
  its own patch
o tons of documentation love
o fix arch/x86/tools/relocs.c typo - which caused compilation issues
  on old toolchains
o add c6x toolchain work around as discussed with Mark Salter
o sprinkle a few more needed VMLINUX_SYMBOL() - fixes
  compilation on blackfin
o suggested name changes by boris:
- %s/SECTION_TYPE_RANGES/rng/g
- %s/SECTION_TYPE/SECTION_CORE/g
- %s/section_type_asmtype/section_core_type/g
- %s/section_type/section_core/g
- %s/section_rng/set_section_rng/g
- Drop DECLARE_SECTION_TBL() -- this is an asm equivalent
  DEFINE_LINKTABLE() -- this however is not used yet, and it requires
  a bit more work to match the C code definitions.
o drop tools/include/linux/sections.h in favor of the more popular open
  coding the names for tools
o expand documentation to include module support
o add maintaners
o Use generic-y
o move .text.tbl before unlikely to match the other sections

v3:

o addressed initial modular support test cases
o added generic asm macros so linker tables can be used in
  asm code / C asm calls
o section ranges are now split up into their own set of files
o use asm/sections.h instead of linux/sections.h for the linker
  script
o add a sections.h file for each architecture that was missing one,
  this is needed now as we'll be relying on sections.h for custom
  section types in code rather than custom architecture specific
  linker script hacks.
o full rewrite at this point, decided to pick copyleft-next license
  for this work

v2:

o modified completely to match feedback by community, made equivalent
  modifications to userspace solution. This is pretty much a complete
  rewrite of how we present and use linker tables. By using standard
  sections we no longer have to make custom linker script extensions
  for each new linker table solution, you just pick a linker table
  type by section type.
o extend documention considerably, including use of kdoc
o drop ICC hacks per popular request to ignore such issues for now
o use sections.h - this lets us streamline a clean use case of
  well documented sections. To help further with this make use of
  SECTION_TBL() to allow use of these in code and SECTION_TBL_ALL()
  on linker scripts, as well as SECTION_TBL_ALL_STR() on relocs.c
  when needed.

Cc: Michael Brown 
Signed-off-by: Luis R. Rodriguez 
---
 Documentation/sections/index.rst |   1 +
 Documentation/sections/linker-tables.rst | 212 +++
 MAINTAINERS  |  10 +
 arch/alpha/include/asm/Kbuild|   1 +
 arch/arc/include/asm/Kbuild  |   1 +
 arch/arm/include/asm/Kbuild  |   1 +
 arch/arm64/include/asm/Kbuild|   1 +
 arch/avr32/include/asm/Kbuild|   1 +
 arch/blackfin/include/asm/Kbuild |   1 +