On Fri, Nov 11, 2016 at 10:55:09AM -0800, Martin KaFai Lau wrote: > Provide a LRU version of the existing BPF_MAP_TYPE_HASH. > > Signed-off-by: Martin KaFai Lau <ka...@fb.com> ... > +/* Instead of having one common LRU list in the > + * BPF_MAP_TYPE_LRU_HASH map, use a percpu LRU list > + * which can scale and perform better. > + * Note, the LRU nodes (including free nodes) cannot be moved > + * across different LRU lists. > + */ > +#define BPF_F_NO_COMMON_LRU (1U << 1)
I couldn't come up with better name, so I think it's good :) > + if (lru && !capable(CAP_SYS_ADMIN)) > + /* LRU implementation is much complicated than other > + * maps. Hence, limit to CAP_SYS_ADMIN for now. > + */ > + return ERR_PTR(-EPERM); +1 good call. > + if (!percpu && !lru) { > + /* lru itself can remove the least used element, so > + * there is no need for an extra elem during map_update. > + */ yeah. that's an important comment, otherwise @@ -48,11 +52,19 @@ struct htab_elem { union { struct rcu_head rcu; enum extra_elem_state state; + struct bpf_lru_node lru_node; }; wouldn't be correct. Acked-by: Alexei Starovoitov <a...@kernel.org>