Skip to content

Commit

Permalink
xskmap: Move non-standard list manipulation to helper
Browse files Browse the repository at this point in the history
Add a helper in list.h for the non-standard way of clearing a list that is
used in xskmap. This makes it easier to reuse it in the other map types,
and also makes sure this usage is not forgotten in any list refactorings in
the future.

Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
  • Loading branch information
Toke Høiland-Jørgensen authored and Daniel Borkmann committed Jun 28, 2019
1 parent 2d6dbb9 commit c8af5cd
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
14 changes: 14 additions & 0 deletions include/linux/list.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,20 @@ static inline void __list_del(struct list_head * prev, struct list_head * next)
WRITE_ONCE(prev->next, next);
}

/*
* Delete a list entry and clear the 'prev' pointer.
*
* This is a special-purpose list clearing method used in the networking code
* for lists allocated as per-cpu, where we don't want to incur the extra
* WRITE_ONCE() overhead of a regular list_del_init(). The code that uses this
* needs to check the node 'prev' pointer instead of calling list_empty().
*/
static inline void __list_del_clearprev(struct list_head *entry)
{
__list_del(entry->prev, entry->next);
entry->prev = NULL;
}

/**
* list_del - deletes entry from list.
* @entry: the element to delete from the list.
Expand Down
3 changes: 1 addition & 2 deletions kernel/bpf/xskmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,7 @@ void __xsk_map_flush(struct bpf_map *map)

list_for_each_entry_safe(xs, tmp, flush_list, flush_node) {
xsk_flush(xs);
__list_del(xs->flush_node.prev, xs->flush_node.next);
xs->flush_node.prev = NULL;
__list_del_clearprev(&xs->flush_node);
}
}

Expand Down

0 comments on commit c8af5cd

Please sign in to comment.