This patch adds new infrastructure to skip redundant selector store operations on the same register to achieve a performance boost from the packet path. This is particularly noticeable in pure linear rulesets but it also helps in rulesets which are already heaving relying in maps to avoid ruleset linear inspection. The idea is to keep data of the most recurrent store operations on register to reuse them with cmp and lookup expressions. This infrastructure allows for dynamic ruleset updates since the ruleset blob reduction happens from the kernel. Userspace still needs to be updated to maximize register utilization to cooperate to improve register data reuse / reduce number of store on register operations.
Showing the changes to include (1 of 2 files). Show all
Unified · Split
| @@ -122,6 +122,16 @@ struct nft_regs { · 121 unmodified lines | ||
| 122 | 122 | }; |
| 123 | 123 | }; |
| 124 | 124 | |
| 125 | +struct nft_regs_track { | |
| 126 | + struct { | |
| 127 | + const struct nft_expr *selector; | |
| 128 | + const struct nft_expr *bitwise; | |
| 129 | + } regs[NFT_REG32_NUM]; | |
| 130 | + | |
| 131 | + const struct nft_expr *cur; | |
| 132 | + const struct nft_expr *last; | |
| 133 | +}; | |
| 134 | + | |
| 125 | 135 | /* Store/load an u8, u16 or u64 integer to/from the u32 data register. |
| 126 | 136 | * |
| 127 | 137 | * Note, when using concatenations, register allocation happens at 32-bit |
| @@ -886,6 +896,8 @@ struct nft_expr_ops { · 758 unmodified lines | ||
| 886 | 896 | int (*validate)(const struct nft_ctx *ctx, |
| 887 | 897 | const struct nft_expr *expr, |
| 888 | 898 | const struct nft_data **data); |
| 899 | + bool (*reduce)(struct nft_regs_track *track, | |
| 900 | + const struct nft_expr *expr); | |
| 889 | 901 | bool (*gc)(struct net *net, |
| 890 | 902 | const struct nft_expr *expr); |
| 891 | 903 | int (*offload)(struct nft_offload_ctx *ctx, |