svn commit: r366669 - head/sys/compat/linuxkpi/common/include/linux

Hans Petter Selasky hselasky at FreeBSD.org
Tue Oct 13 16:19:22 UTC 2020


Author: hselasky
Date: Tue Oct 13 16:19:21 2020
New Revision: 366669
URL: https://svnweb.freebsd.org/changeset/base/366669

Log:
  Implement more RCU list functions in the LinuxKPI.
  
  This also fixes a bug in the existing list_add_rcu() where the
  prev->prev pointer was updated to the new element instead of
  next->prev. Currently this function is not widely used.
  
  MFC after:		1 week
  Sponsored by:		Mellanox Technologies // NVIDIA Networking

Modified:
  head/sys/compat/linuxkpi/common/include/linux/rculist.h

Modified: head/sys/compat/linuxkpi/common/include/linux/rculist.h
==============================================================================
--- head/sys/compat/linuxkpi/common/include/linux/rculist.h	Tue Oct 13 14:10:49 2020	(r366668)
+++ head/sys/compat/linuxkpi/common/include/linux/rculist.h	Tue Oct 13 16:19:21 2020	(r366669)
@@ -1,6 +1,6 @@
 /*-
  * Copyright (c) 2015 François Tigeot
- * Copyright (c) 2016-2017 Mellanox Technologies, Ltd.
+ * Copyright (c) 2016-2020 Mellanox Technologies, Ltd.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -37,6 +37,7 @@
 	container_of(READ_ONCE(ptr), type, member)
 
 #define	list_next_rcu(head)	(*((struct list_head **)(&(head)->next)))
+#define	list_prev_rcu(head)	(*((struct list_head **)(&(head)->prev)))
 
 #define	list_for_each_entry_rcu(pos, head, member) \
 	for (pos = list_entry_rcu((head)->next, typeof(*(pos)), member); \
@@ -44,12 +45,44 @@
 	     pos = list_entry_rcu((pos)->member.next, typeof(*(pos)), member))
 
 static inline void
-list_add_rcu(struct list_head *new, struct list_head *prev)
+linux_list_add_rcu(struct list_head *new, struct list_head *prev,
+    struct list_head *next)
 {
-	new->next = prev->next;
+	new->next = next;
 	new->prev = prev;
 	rcu_assign_pointer(list_next_rcu(prev), new);
-	prev->prev = new;
+	next->prev = new;
+}
+
+static inline void
+list_add_rcu(struct list_head *new, struct list_head *head)
+{
+	linux_list_add_rcu(new, head, head->next);
+}
+
+static inline void
+list_add_tail_rcu(struct list_head *new, struct list_head *head)
+{
+	linux_list_add_rcu(new, head->prev, head);
+}
+
+static inline void
+__list_del_rcu(struct list_head *prev, struct list_head *next)
+{
+	next->prev = prev;
+	rcu_assign_pointer(list_next_rcu(prev), next);
+}
+
+static inline void
+__list_del_entry_rcu(struct list_head *entry)
+{
+	__list_del_rcu(entry->prev, entry->next);
+}
+
+static inline void
+list_del_rcu(struct list_head *entry)
+{
+	__list_del_rcu(entry->prev, entry->next);
 }
 
 #define	hlist_first_rcu(head)	(*((struct hlist_node **)(&(head)->first)))


More information about the svn-src-all mailing list