Re: [PATCH v13 01/11] bitops: Introduce the for_each_set_clump8 macro

2019-03-28 Thread Lukas Wunner
On Thu, Mar 28, 2019 at 01:30:13PM +0900, William Breathitt Gray wrote:
> On Wed, Mar 27, 2019 at 07:42:54AM +0100, Lukas Wunner wrote:
> > On Wed, Mar 27, 2019 at 01:58:45PM +0900, William Breathitt Gray wrote:
> > > This macro iterates for each 8-bit group of bits (clump) with set bits,
> > > within a bitmap memory region. For each iteration, "start" is set to the
> > > bit offset of the found clump, while the respective clump value is
> > > stored to the location pointed by "clump". Additionally, the
> > > bitmap_get_value8 and bitmap_set_value8 functions are introduced to
> > > respectively get and set an 8-bit value in a bitmap memory region.
> > 
> > I would have preferred static inlines for bitmap_get_value8(),
> > bitmap_set_value8() and find_next_clump8() to make this as fast
> > as possible in the callers because I've personally worked with
> > an industrial application where the GPIO pins of a 74x164 are
> > written every 250 usec.
> 
> I'm not sure these can be static inline since the symbols are exported
> for use outside this file.

By static inlines I meant that the functions are moved to the appropriate
header file in include/linux/.  You don't need to worry about exporting
in that case as the code is local to each module.  For smallish functions
like these, static inlines are usually fine.  See drivers/dma/virt-dma.h
for an extreme case of static inlines (as compared to the much smaller
virt-dma.c).

Thanks,

Lukas


Re: [PATCH v13 01/11] bitops: Introduce the for_each_set_clump8 macro

2019-03-27 Thread William Breathitt Gray
On Wed, Mar 27, 2019 at 07:42:54AM +0100, Lukas Wunner wrote:
> On Wed, Mar 27, 2019 at 01:58:45PM +0900, William Breathitt Gray wrote:
> > This macro iterates for each 8-bit group of bits (clump) with set bits,
> > within a bitmap memory region. For each iteration, "start" is set to the
> > bit offset of the found clump, while the respective clump value is
> > stored to the location pointed by "clump". Additionally, the
> > bitmap_get_value8 and bitmap_set_value8 functions are introduced to
> > respectively get and set an 8-bit value in a bitmap memory region.
> 
> I would have preferred static inlines for bitmap_get_value8(),
> bitmap_set_value8() and find_next_clump8() to make this as fast
> as possible in the callers because I've personally worked with
> an industrial application where the GPIO pins of a 74x164 are
> written every 250 usec.
> 
> But apart from that I like this series a lot, thanks for working on it.
> 
> Lukas

I'm not sure these can be static inline since the symbols are exported
for use outside this file. However, in theory I have no objection from a
performance standpoint. Since my devices don't have such strict realtime
requirements as your 74x164 application, I'll defer this decision to
someone more knowledgeable in this area; perhaps someone else can
comment in this thread with their advice and suggestions.

William Breathitt Gray


Re: [PATCH v13 01/11] bitops: Introduce the for_each_set_clump8 macro

2019-03-27 Thread Andy Shevchenko
On Wed, Mar 27, 2019 at 01:58:45PM +0900, William Breathitt Gray wrote:
> This macro iterates for each 8-bit group of bits (clump) with set bits,
> within a bitmap memory region. For each iteration, "start" is set to the
> bit offset of the found clump, while the respective clump value is
> stored to the location pointed by "clump". Additionally, the
> bitmap_get_value8 and bitmap_set_value8 functions are introduced to
> respectively get and set an 8-bit value in a bitmap memory region.

> +unsigned long bitmap_get_value8(const unsigned long *addr, unsigned long 
> start)
> +{
> + const size_t idx = BIT_WORD(start);
> + const unsigned long offset = start % BITS_PER_LONG;
> +
> + return (addr[idx] >> offset) & 0xFF;

I would spell index instead of idx, but it's minor and up to you.

> +}

-- 
With Best Regards,
Andy Shevchenko




Re: [PATCH v13 01/11] bitops: Introduce the for_each_set_clump8 macro

2019-03-27 Thread Lukas Wunner
On Wed, Mar 27, 2019 at 01:58:45PM +0900, William Breathitt Gray wrote:
> This macro iterates for each 8-bit group of bits (clump) with set bits,
> within a bitmap memory region. For each iteration, "start" is set to the
> bit offset of the found clump, while the respective clump value is
> stored to the location pointed by "clump". Additionally, the
> bitmap_get_value8 and bitmap_set_value8 functions are introduced to
> respectively get and set an 8-bit value in a bitmap memory region.

I would have preferred static inlines for bitmap_get_value8(),
bitmap_set_value8() and find_next_clump8() to make this as fast
as possible in the callers because I've personally worked with
an industrial application where the GPIO pins of a 74x164 are
written every 250 usec.

But apart from that I like this series a lot, thanks for working on it.

Lukas