diff options
author | Hans Petter Selasky <hselasky@FreeBSD.org> | 2020-10-20 08:40:39 +0000 |
---|---|---|
committer | Hans Petter Selasky <hselasky@FreeBSD.org> | 2020-10-20 08:40:39 +0000 |
commit | 8cf457ba5e41a719d2b4abfe8c4f8f87330f924c (patch) | |
tree | ba9ef344097c8efa2889e1dcdc0582afbc271ecd | |
parent | 1781c9e9f376f419ee39b512946d40c8209677a6 (diff) | |
download | src-test2-8cf457ba5e41a719d2b4abfe8c4f8f87330f924c.tar.gz src-test2-8cf457ba5e41a719d2b4abfe8c4f8f87330f924c.zip |
MFC r349277 and r366669:
Implement more RCU list functions in the LinuxKPI.
Differential Revision: https://reviews.freebsd.org/D20719
Sponsored by: Mellanox Technologies // NVIDIA Networking
Notes
Notes:
svn path=/stable/11/; revision=366889
-rw-r--r-- | sys/compat/linuxkpi/common/include/linux/rculist.h | 62 | ||||
-rw-r--r-- | sys/sys/param.h | 2 |
2 files changed, 60 insertions, 4 deletions
diff --git a/sys/compat/linuxkpi/common/include/linux/rculist.h b/sys/compat/linuxkpi/common/include/linux/rculist.h index e4823de7a3bf..bff2f7e13184 100644 --- a/sys/compat/linuxkpi/common/include/linux/rculist.h +++ b/sys/compat/linuxkpi/common/include/linux/rculist.h @@ -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 @@ -33,6 +33,58 @@ #include <linux/list.h> #include <linux/rcupdate.h> +#define list_entry_rcu(ptr, type, member) \ + 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); \ + &(pos)->member != (head); \ + pos = list_entry_rcu((pos)->member.next, typeof(*(pos)), member)) + +static inline void +linux_list_add_rcu(struct list_head *new, struct list_head *prev, + struct list_head *next) +{ + new->next = next; + new->prev = prev; + rcu_assign_pointer(list_next_rcu(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))) #define hlist_next_rcu(node) (*((struct hlist_node **)(&(node)->next))) #define hlist_pprev_rcu(node) (*((struct hlist_node **)((node)->pprev))) @@ -47,8 +99,12 @@ hlist_add_behind_rcu(struct hlist_node *n, struct hlist_node *prev) n->next->pprev = &n->next; } -#define hlist_for_each_entry_rcu(pos, head, member) \ - hlist_for_each_entry(pos, head, member) +#define hlist_for_each_entry_rcu(pos, head, member) \ + for (pos = hlist_entry_safe (rcu_dereference_raw(hlist_first_rcu(head)),\ + typeof(*(pos)), member); \ + (pos); \ + pos = hlist_entry_safe(rcu_dereference_raw(hlist_next_rcu( \ + &(pos)->member)), typeof(*(pos)), member)) static inline void hlist_del_rcu(struct hlist_node *n) diff --git a/sys/sys/param.h b/sys/sys/param.h index caee86d8c028..e6a1e10e7d58 100644 --- a/sys/sys/param.h +++ b/sys/sys/param.h @@ -58,7 +58,7 @@ * in the range 5 to 9. */ #undef __FreeBSD_version -#define __FreeBSD_version 1104508 /* Master, propagated to newvers */ +#define __FreeBSD_version 1104509 /* Master, propagated to newvers */ /* * __FreeBSD_kernel__ indicates that this system uses the kernel of FreeBSD, |