|
Revision tags: v6.15, v6.15-rc7, v6.15-rc6, v6.15-rc5, v6.15-rc4, v6.15-rc3, v6.15-rc2, v6.15-rc1, v6.14, v6.14-rc7, v6.14-rc6, v6.14-rc5, v6.14-rc4, v6.14-rc3, v6.14-rc2 |
|
| #
c6594d64 |
| 06-Feb-2025 |
Alexander Lobakin <[email protected]> |
unroll: add generic loop unroll helpers
There are cases when we need to explicitly unroll loops. For example, cache operations, filling DMA descriptors on very high speeds etc. Add compiler-specific
unroll: add generic loop unroll helpers
There are cases when we need to explicitly unroll loops. For example, cache operations, filling DMA descriptors on very high speeds etc. Add compiler-specific attribute macros to give the compiler a hint that we'd like to unroll a loop. Example usage:
#define UNROLL_BATCH 8
unrolled_count(UNROLL_BATCH) for (u32 i = 0; i < UNROLL_BATCH; i++) op(priv, i);
Note that sometimes the compilers won't unroll loops if they think this would have worse optimization and perf than without unrolling, and that unroll attributes are available only starting GCC 8. For older compiler versions, no hints/attributes will be applied. For better unrolling/parallelization, don't have any variables that interfere between iterations except for the iterator itself.
Co-developed-by: Jose E. Marchesi <[email protected]> # pragmas Signed-off-by: Jose E. Marchesi <[email protected]> Reviewed-by: Przemek Kitszel <[email protected]> Signed-off-by: Alexander Lobakin <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
show more ...
|
|
Revision tags: v6.14-rc1, v6.13, v6.13-rc7, v6.13-rc6, v6.13-rc5, v6.13-rc4, v6.13-rc3, v6.13-rc2, v6.13-rc1, v6.12, v6.12-rc7, v6.12-rc6, v6.12-rc5, v6.12-rc4, v6.12-rc3, v6.12-rc2, v6.12-rc1, v6.11, v6.11-rc7, v6.11-rc6, v6.11-rc5, v6.11-rc4 |
|
| #
7cff549d |
| 16-Aug-2024 |
KP Singh <[email protected]> |
kernel: Add helper macros for loop unrolling
This helps in easily initializing blocks of code (e.g. static calls and keys).
UNROLL(N, MACRO, __VA_ARGS__) calls MACRO N times with the first argument
kernel: Add helper macros for loop unrolling
This helps in easily initializing blocks of code (e.g. static calls and keys).
UNROLL(N, MACRO, __VA_ARGS__) calls MACRO N times with the first argument as the index of the iteration. This allows string pasting to create unique tokens for variable names, function calls etc.
As an example:
#include <linux/unroll.h>
#define MACRO(N, a, b) \ int add_##N(int a, int b) \ { \ return a + b + N; \ }
UNROLL(2, MACRO, x, y)
expands to:
int add_0(int x, int y) { return x + y + 0; }
int add_1(int x, int y) { return x + y + 1; }
Tested-by: Guenter Roeck <[email protected]> Reviewed-by: Kees Cook <[email protected]> Reviewed-by: Casey Schaufler <[email protected]> Reviewed-by: John Johansen <[email protected]> Acked-by: Jiri Olsa <[email protected]> Acked-by: Song Liu <[email protected]> Acked-by: Andrii Nakryiko <[email protected]> Acked-by: Casey Schaufler <[email protected]> Nacked-by: Tetsuo Handa <[email protected]> Signed-off-by: KP Singh <[email protected]> Signed-off-by: Paul Moore <[email protected]>
show more ...
|