18 May, 2022

1 commit

  • [ Upstream commit ee1444b5e1df4155b591d0d9b1e72853a99ea861 ]

    The W=2 build pointed out that the code wasn't initializing all the
    variables in the dim_cq_moder declarations with the struct initializers.
    The net change here is zero since these structs were already static
    const globals and were initialized with zeros by the compiler, but
    removing compiler warnings has value in and of itself.

    lib/dim/net_dim.c: At top level:
    lib/dim/net_dim.c:54:9: warning: missing initializer for field ‘comps’ of ‘const struct dim_cq_moder’ [-Wmissing-field-initializers]
    54 | NET_DIM_RX_EQE_PROFILES,
    | ^~~~~~~~~~~~~~~~~~~~~~~
    In file included from lib/dim/net_dim.c:6:
    ./include/linux/dim.h:45:13: note: ‘comps’ declared here
    45 | u16 comps;
    | ^~~~~

    and repeats for the tx struct, and once you fix the comps entry then
    the cq_period_mode field needs the same treatment.

    Use the commonly accepted style to indicate to the compiler that we
    know what we're doing, and add a comma at the end of each struct
    initializer to clean up the issue, and use explicit initializers
    for the fields we are initializing which makes the compiler happy.

    While here and fixing these lines, clean up the code slightly with
    a fix for the super long lines by removing the word "_MODERATION" from a
    couple defines only used in this file.

    Fixes: f8be17b81d44 ("lib/dim: Fix -Wunused-const-variable warnings")
    Signed-off-by: Jesse Brandeburg
    Link: https://lore.kernel.org/r/20220507011038.14568-1-jesse.brandeburg@intel.com
    Signed-off-by: Jakub Kicinski
    Signed-off-by: Sasha Levin

    Jesse Brandeburg
     

19 Nov, 2020

1 commit

  • This reverts commit 6a9dc5fd6170 ("lib: Revert use of fallthrough
    pseudo-keyword in lib/")

    Now that we can build arch/powerpc/boot/ free of -Wimplicit-fallthrough,
    re-enable these fixes for lib/.

    Signed-off-by: Nick Desaulniers
    Tested-by: Nathan Chancellor
    Reviewed-by: Nathan Chancellor
    Reviewed-by: Gustavo A. R. Silva
    Reviewed-by: Miguel Ojeda
    Link: https://github.com/ClangBuiltLinux/linux/issues/236
    Signed-off-by: Gustavo A. R. Silva

    Nick Desaulniers
     

25 Aug, 2020

1 commit

  • The following build error for powerpc64 was reported by Nathan Chancellor:

    "$ scripts/config --file arch/powerpc/configs/powernv_defconfig -e KERNEL_XZ

    $ make -skj"$(nproc)" ARCH=powerpc CROSS_COMPILE=powerpc64le-linux- distclean powernv_defconfig zImage
    ...
    In file included from arch/powerpc/boot/../../../lib/decompress_unxz.c:234,
    from arch/powerpc/boot/decompress.c:38:
    arch/powerpc/boot/../../../lib/xz/xz_dec_stream.c: In function 'dec_main':
    arch/powerpc/boot/../../../lib/xz/xz_dec_stream.c:586:4: error: 'fallthrough' undeclared (first use in this function)
    586 | fallthrough;
    | ^~~~~~~~~~~

    This will end up affecting distribution configurations such as Debian
    and OpenSUSE according to my testing. I am not sure what the solution
    is, the PowerPC wrapper does not set -D__KERNEL__ so I am not sure
    that compiler_attributes.h can be safely included."

    In order to avoid these sort of problems, it seems that the best
    solution is to use /* fall through */ comments instead of the
    fallthrough pseudo-keyword macro in lib/, for now.

    Reported-by: Nathan Chancellor
    Fixes: df561f6688fe ("treewide: Use fallthrough pseudo-keyword")
    Signed-off-by: Gustavo A. R. Silva
    Reviewed-and-tested-by: Nathan Chancellor
    Signed-off-by: Linus Torvalds

    Gustavo A. R. Silva
     

24 Aug, 2020

1 commit

  • Replace the existing /* fall through */ comments and its variants with
    the new pseudo-keyword macro fallthrough[1]. Also, remove unnecessary
    fall-through markings when it is the case.

    [1] https://www.kernel.org/doc/html/v5.7/process/deprecated.html?highlight=fallthrough#implicit-switch-case-fall-through

    Signed-off-by: Gustavo A. R. Silva

    Gustavo A. R. Silva
     

26 Jul, 2019

2 commits

  • DIM causes to the following warnings during kernel compilation
    which indicates that tx_profile and rx_profile are supposed to
    be declared in *.c and not in *.h files.

    In file included from ./include/rdma/ib_verbs.h:64,
    from ./include/linux/mlx5/device.h:37,
    from ./include/linux/mlx5/driver.h:51,
    from ./include/linux/mlx5/vport.h:36,
    from drivers/infiniband/hw/mlx5/ib_virt.c:34:
    ./include/linux/dim.h:326:1: warning: _tx_profile_ defined but not used [-Wunused-const-variable=]
    326 | tx_profile[DIM_CQ_PERIOD_NUM_MODES][NET_DIM_PARAMS_NUM_PROFILES] = {
    | ^~~~~~~~~~
    ./include/linux/dim.h:320:1: warning: _rx_profile_ defined but not used [-Wunused-const-variable=]
    320 | rx_profile[DIM_CQ_PERIOD_NUM_MODES][NET_DIM_PARAMS_NUM_PROFILES] = {
    | ^~~~~~~~~~

    Fixes: 4f75da3666c0 ("linux/dim: Move implementation to .c files")
    Signed-off-by: Leon Romanovsky
    Reviewed-by: Bart Van Assche
    Acked-by: Saeed Mahameed
    Signed-off-by: David S. Miller

    Leon Romanovsky
     
  • While using net_dim, a dim_sample was used without ever initializing the
    comps value. Added use of DIV_ROUND_DOWN_ULL() to prevent potential
    overflow, it should not be a problem to save the final result in an int
    because after the division by epms the value should not be larger than a
    few thousand.

    [ 1040.127124] UBSAN: Undefined behaviour in lib/dim/dim.c:78:23
    [ 1040.130118] signed integer overflow:
    [ 1040.131643] 134718714 * 100 cannot be represented in type 'int'

    Fixes: 398c2b05bbee ("linux/dim: Add completions count to dim_sample")
    Signed-off-by: Yamin Friedman
    Signed-off-by: Leon Romanovsky
    Acked-by: Saeed Mahameed
    Signed-off-by: David S. Miller

    Yamin Friedman
     

09 Jul, 2019

1 commit

  • RDMA DIM implements a different algorithm from net DIM and is based on
    completions which is how we can implement interrupt moderation in RDMA.

    The algorithm optimizes for number of completions and ratio between
    completions and events. In order to avoid long latencies, the
    implementation performs fast reduction of moderation level when the
    traffic changes.

    Signed-off-by: Yamin Friedman
    Reviewed-by: Max Gurtovoy
    Reviewed-by: Sagi Grimberg
    Signed-off-by: Saeed Mahameed
    Signed-off-by: Leon Romanovsky
    Signed-off-by: Jason Gunthorpe

    Yamin Friedman
     

26 Jun, 2019

2 commits

  • Added a measurement of completions per/msec to allow for completion based
    dim algorithms.

    In order to use dynamic interrupt moderation with RDMA we need to have a
    different measurment than packets per second. This change is meant to
    prepare for adding a new DIM method.

    All drivers that use net_dim and thus do not need a completion count will
    have the completions set to 0.

    Signed-off-by: Yamin Friedman
    Reviewed-by: Max Gurtovoy
    Signed-off-by: Saeed Mahameed

    Yamin Friedman
     
  • Moved all logic from dim.h and net_dim.h to dim.c and net_dim.c.
    This is both more structurally appealing and would allow to only
    expose externally used functions.

    Signed-off-by: Tal Gilboa
    Signed-off-by: Saeed Mahameed

    Tal Gilboa