summaryrefslogtreecommitdiffstats
path: root/include/linux/list.h
diff options
context:
space:
mode:
authorSasha Levin <sashal@kernel.org>2019-05-16 21:30:49 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2019-05-21 18:50:12 +0200
commitba16982371e3ca3306763e401d1ad257d581df19 (patch)
tree55c8fe7aea11de0ebc19607595559b4696aa3659 /include/linux/list.h
parente6fedb8802c7543852cc6b06d8c009f89b3af3d8 (diff)
downloadlinux-stable-ba16982371e3ca3306763e401d1ad257d581df19.tar.gz
linux-stable-ba16982371e3ca3306763e401d1ad257d581df19.tar.bz2
linux-stable-ba16982371e3ca3306763e401d1ad257d581df19.zip
net: core: another layer of lists, around PF_MEMALLOC skb handling
[ Upstream commit 78ed8cc25986ac5c21762eeddc1e86e94d422e36 ] First example of a layer splitting the list (rather than merely taking individual packets off it). Involves new list.h function, list_cut_before(), like list_cut_position() but cuts on the other side of the given entry. Signed-off-by: Edward Cree <ecree@solarflare.com> Signed-off-by: David S. Miller <davem@davemloft.net> [sl: cut out non list.h bits, we only want list_cut_before] Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'include/linux/list.h')
-rw-r--r--include/linux/list.h30
1 files changed, 30 insertions, 0 deletions
diff --git a/include/linux/list.h b/include/linux/list.h
index 4b129df4d46b..de04cc5ed536 100644
--- a/include/linux/list.h
+++ b/include/linux/list.h
@@ -285,6 +285,36 @@ static inline void list_cut_position(struct list_head *list,
__list_cut_position(list, head, entry);
}
+/**
+ * list_cut_before - cut a list into two, before given entry
+ * @list: a new list to add all removed entries
+ * @head: a list with entries
+ * @entry: an entry within head, could be the head itself
+ *
+ * This helper moves the initial part of @head, up to but
+ * excluding @entry, from @head to @list. You should pass
+ * in @entry an element you know is on @head. @list should
+ * be an empty list or a list you do not care about losing
+ * its data.
+ * If @entry == @head, all entries on @head are moved to
+ * @list.
+ */
+static inline void list_cut_before(struct list_head *list,
+ struct list_head *head,
+ struct list_head *entry)
+{
+ if (head->next == entry) {
+ INIT_LIST_HEAD(list);
+ return;
+ }
+ list->next = head->next;
+ list->next->prev = list;
+ list->prev = entry->prev;
+ list->prev->next = list;
+ head->next = entry;
+ entry->prev = head;
+}
+
static inline void __list_splice(const struct list_head *list,
struct list_head *prev,
struct list_head *next)