[dm-devel] [PATCH 3/6] libmultipath: remove code duplication in path counting

Martin Wilck Martin.Wilck at suse.com
Thu Aug 6 10:48:12 UTC 2020


On Mon, 2020-07-27 at 14:24 -0500, Benjamin Marzinski wrote:
> pathcountgr() is never used except by pathcount(), and neither is the
> special case for PATH_WILD. Simplify this and make one function that
> is
> used by both pathcount() and count_active_paths(). This will be used
> again in a future patch.
> 
> Also use count_active_paths() in mpath_persist.

The patch looks correct. I had thought about something like it as well
when I first introduced count_active_paths(). But count_active_paths()
is used a *lot*, and often in critical situations. I wonder whether it
deserves an optimized version. The compiler can surely optimize better
with two constant expressions than with the additional for-loop over an
array with variable size. That's why back then I decided against
implementing it as a special case of a generic function. I actually
considered inlining count_active_paths().

It's hard to quantify the effect, and I haven't done any benchmarks. 
But still, can we perhaps keep the optimized version of
count_active_paths() itself?

Martin






More information about the dm-devel mailing list