[ovs-git] [openvswitch/ovs] aadede: dpif-netdev: Implement function pointers/subtable

istokes noreply at github.com
Fri Jul 19 11:53:10 UTC 2019


  Branch: refs/heads/master
  Home:   https://github.com/openvswitch/ovs
  Commit: aadede3dda85859fb5bcb7ade364d29c637c573f
      https://github.com/openvswitch/ovs/commit/aadede3dda85859fb5bcb7ade364d29c637c573f
  Author: Harry van Haaren <harry.van.haaren at intel.com>
  Date:   2019-07-19 (Fri, 19 Jul 2019)

  Changed paths:
    M lib/dpif-netdev.c

  Log Message:
  -----------
  dpif-netdev: Implement function pointers/subtable

This allows plugging-in of different subtable hash-lookup-verify
routines, and allows special casing of those functions based on
known context (eg: # of bits set) of the specific subtable.

Signed-off-by: Harry van Haaren <harry.van.haaren at intel.com>
Tested-by: Malvika Gupta <malvika.gupta at arm.com>
Acked-by: Ilya Maximets <i.maximets at samsung.com>
Signed-off-by: Ian Stokes <ian.stokes at intel.com>


  Commit: f5ace7cd8a854393329f399dfa85a3658acc73cd
      https://github.com/openvswitch/ovs/commit/f5ace7cd8a854393329f399dfa85a3658acc73cd
  Author: Harry van Haaren <harry.van.haaren at intel.com>
  Date:   2019-07-19 (Fri, 19 Jul 2019)

  Changed paths:
    M lib/automake.mk
    A lib/dpif-netdev-private.h
    M lib/dpif-netdev.c

  Log Message:
  -----------
  dpif-netdev: Move dpcls lookup structures to .h

This commit moves some data-structures to be available
in the dpif-netdev-private.h header. This allows specific
implementations of the subtable lookup function to include
just that header file, and not require that the code exists
in dpif-netdev.c

Signed-off-by: Harry van Haaren <harry.van.haaren at intel.com>
Tested-by: Malvika Gupta <malvika.gupta at arm.com>
Acked-by: Ilya Maximets <i.maximets at samsung.com>
Signed-off-by: Ian Stokes <ian.stokes at intel.com>


  Commit: 92c7c870d69a1c433768fc7746c573bc0c4bd5fa
      https://github.com/openvswitch/ovs/commit/92c7c870d69a1c433768fc7746c573bc0c4bd5fa
  Author: Harry van Haaren <harry.van.haaren at intel.com>
  Date:   2019-07-19 (Fri, 19 Jul 2019)

  Changed paths:
    M lib/automake.mk
    A lib/dpif-netdev-lookup-generic.c
    M lib/dpif-netdev.c

  Log Message:
  -----------
  dpif-netdev: Split out generic lookup function

This commit splits the generic hash-lookup-verify function to
its own file, for cleaner seperation between optimized versions.

Signed-off-by: Harry van Haaren <harry.van.haaren at intel.com>
Tested-by: Malvika Gupta <malvika.gupta at arm.com>
Acked-by: Ilya Maximets <i.maximets at samsung.com>
Signed-off-by: Ian Stokes <ian.stokes at intel.com>


  Commit: a0b36b3924c7c7033ebecc2ad79f6fcee2b2e66d
      https://github.com/openvswitch/ovs/commit/a0b36b3924c7c7033ebecc2ad79f6fcee2b2e66d
  Author: Harry van Haaren <harry.van.haaren at intel.com>
  Date:   2019-07-19 (Fri, 19 Jul 2019)

  Changed paths:
    M lib/dpif-netdev-lookup-generic.c
    M lib/dpif-netdev-private.h
    M lib/dpif-netdev.c

  Log Message:
  -----------
  dpif-netdev: Refactor generic implementation

This commit refactors the generic implementation. The
goal of this refactor is to simplify the code to enable
"specialization" of the functions at compile time.

Given compile-time optimizations, the compiler is able
to unroll loops, and create optimized code sequences due
to compile time knowledge of loop-trip counts.

In order to enable these compiler optimizations, we must
refactor the code to pass the loop-trip counts to functions
as compile time constants.

This patch allows the number of miniflow-bits set per "unit"
in the miniflow to be passed around as a function argument.

Note that this patch does NOT yet take advantage of doing so,
this is only a refactor to enable it in the next patches.

Signed-off-by: Harry van Haaren <harry.van.haaren at intel.com>
Tested-by: Malvika Gupta <malvika.gupta at arm.com>
Acked-by: Ilya Maximets <i.maximets at samsung.com>
Signed-off-by: Ian Stokes <ian.stokes at intel.com>


  Commit: f54d8f004fc408d50c71478af3ca6f06baa0e4dd
      https://github.com/openvswitch/ovs/commit/f54d8f004fc408d50c71478af3ca6f06baa0e4dd
  Author: Harry van Haaren <harry.van.haaren at intel.com>
  Date:   2019-07-19 (Fri, 19 Jul 2019)

  Changed paths:
    M NEWS
    M lib/dpif-netdev-lookup-generic.c
    M lib/dpif-netdev-private.h
    M lib/dpif-netdev.c

  Log Message:
  -----------
  dpif-netdev: Add specialized generic scalar functions

This commit adds a number of specialized functions, that handle
common miniflow fingerprints. This enables compiler optimization,
resulting in higher performance. Below a quick description of
how this optimization actually works;

"Specialized functions" are "instances" of the generic implementation,
but the compiler is given extra context when compiling. In the case of
iterating miniflow datastructures, the most interesting value to enable
compile time optimizations is the loop trip count per unit.

In order to create a specialized function, there is a generic implementation,
which uses a for() loop without the compiler knowing the loop trip count at
compile time. The loop trip count is passed in as an argument to the function:

uint32_t miniflow_impl_generic(struct miniflow *mf, uint32_t loop_count)
{
    for(uint32_t i = 0; i < loop_count; i++)
        // do work
}

In order to "specialize" the function, we call the generic implementation
with hard-coded numbers - these are compile time constants!

uint32_t miniflow_impl_loop5(struct miniflow *mf, uint32_t loop_count)
{
    // use hard coded constant for compile-time constant-propogation
    return miniflow_impl_generic(mf, 5);
}

Given the compiler is aware of the loop trip count at compile time,
it can perform an optimization known as "constant propogation". Combined
with inlining of the miniflow_impl_generic() function, the compiler is
now enabled to *compile time* unroll the loop 5x, and produce "flat" code.

The last step to using the specialized functions is to utilize a
function-pointer to choose the specialized (or generic) implementation.
The selection of the function pointer is performed at subtable creation
time, when miniflow fingerprint of the subtable is known. This technique
is known as "multiple dispatch" in some literature, as it uses multiple
items of information (miniflow bit counts) to select the dispatch function.

By pointing the function pointer at the optimized implementation, OvS
benefits from the compile time optimizations at runtime.

Signed-off-by: Harry van Haaren <harry.van.haaren at intel.com>
Tested-by: Malvika Gupta <malvika.gupta at arm.com>
Acked-by: Ilya Maximets <i.maximets at samsung.com>
Signed-off-by: Ian Stokes <ian.stokes at intel.com>


Compare: https://github.com/openvswitch/ovs/compare/300ac0e1847d...f54d8f004fc4


More information about the git mailing list