History

xskmap: Move non-standard list manipulation to helper

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.

Toke Høiland-Jørgensen committed 7 years ago

Commit c8af5cd1 parent 2d6dbb92 files · +15 −2Browse files

Unified · Split

2 files
  1. include/linux/list.h +14 −0
  2. kernel/bpf/xskmap.c +1 −2
include/linux/list.h+14−0
@@ -106,6 +106,20 @@ static inline void __list_del(struct list_head * prev, struct list_head * next) · 105 unmodified lines
106106 WRITE_ONCE(prev->next, next);
107107 }
108108
109+/*
110+ * Delete a list entry and clear the 'prev' pointer.
111+ *
112+ * This is a special-purpose list clearing method used in the networking code
113+ * for lists allocated as per-cpu, where we don't want to incur the extra
114+ * WRITE_ONCE() overhead of a regular list_del_init(). The code that uses this
115+ * needs to check the node 'prev' pointer instead of calling list_empty().
116+ */
117+static inline void __list_del_clearprev(struct list_head *entry)
118+{
119+ __list_del(entry->prev, entry->next);
120+ entry->prev = NULL;
121+}
122+
109123 /**
110124 * list_del - deletes entry from list.
111125 * @entry: the element to delete from the list.
kernel/bpf/xskmap.c+1−2
@@ -145,8 +145,7 @@ void __xsk_map_flush(struct bpf_map *map) · 144 unmodified lines
145145
146146 list_for_each_entry_safe(xs, tmp, flush_list, flush_node) {
147147 xsk_flush(xs);
148− __list_del(xs->flush_node.prev, xs->flush_node.next);
149− xs->flush_node.prev = NULL;
148+ __list_del_clearprev(&xs->flush_node);
150149 }
151150 }
152151

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t