History

rcu: Add and update docbook header comments in list.h

[ paulmck: Fix typo found by kbuild test robot. ] Signed-off-by: Paul E. McKenney <paulmck@kernel.org>

Paul E. McKenney committed 7 years ago

Commit 46deb741 parent 860c8801 file · +95 −17Browse files

Showing the changes to include/linux (1 of 1 file). Show all

Unified · Split

include/linux/list.h+95−17
@@ -23,6 +23,13 @@ · 22 unmodified lines
2323 #define LIST_HEAD(name) \
2424 struct list_head name = LIST_HEAD_INIT(name)
2525
26+/**
27+ * INIT_LIST_HEAD - Initialize a list_head structure
28+ * @list: list_head structure to be initialized.
29+ *
30+ * Initializes the list_head to point to itself. If it is a list header,
31+ * the result is an empty list.
32+ */
2633 static inline void INIT_LIST_HEAD(struct list_head *list)
2734 {
2835 WRITE_ONCE(list->next, list);
@@ -120,12 +127,6 @@ static inline void __list_del_clearprev(struct list_head *entry) · 91 unmodified lines
120127 entry->prev = NULL;
121128 }
122129
123−/**
124− * list_del - deletes entry from list.
125− * @entry: the element to delete from the list.
126− * Note: list_empty() on entry does not return true after this, the entry is
127− * in an undefined state.
128− */
129130 static inline void __list_del_entry(struct list_head *entry)
130131 {
131132 if (!__list_del_entry_valid(entry))
@@ -134,6 +135,12 @@ static inline void __list_del_entry(struct list_head *entry) · 2 unmodified lines
134135 __list_del(entry->prev, entry->next);
135136 }
136137
138+/**
139+ * list_del - deletes entry from list.
140+ * @entry: the element to delete from the list.
141+ * Note: list_empty() on entry does not return true after this, the entry is
142+ * in an undefined state.
143+ */
137144 static inline void list_del(struct list_head *entry)
138145 {
139146 __list_del_entry(entry);
@@ -157,8 +164,15 @@ static inline void list_replace(struct list_head *old, · 17 unmodified lines
157164 new->prev->next = new;
158165 }
159166
167+/**
168+ * list_replace_init - replace old entry by new one and initialize the old one
169+ * @old : the element to be replaced
170+ * @new : the new element to insert
171+ *
172+ * If @old was empty, it will be overwritten.
173+ */
160174 static inline void list_replace_init(struct list_head *old,
161− struct list_head *new)
175+ struct list_head *new)
162176 {
163177 list_replace(old, new);
164178 INIT_LIST_HEAD(old);
@@ -744,21 +758,36 @@ static inline void INIT_HLIST_NODE(struct hlist_node *h) · 579 unmodified lines
744758 h->pprev = NULL;
745759 }
746760
761+/**
762+ * hlist_unhashed - Has node been removed from list and reinitialized?
763+ * @h: Node to be checked
764+ *
765+ * Not that not all removal functions will leave a node in unhashed
766+ * state. For example, hlist_nulls_del_init_rcu() does leave the
767+ * node in unhashed state, but hlist_nulls_del() does not.
768+ */
747769 static inline int hlist_unhashed(const struct hlist_node *h)
748770 {
749771 return !h->pprev;
750772 }
751773
752−/* This variant of hlist_unhashed() must be used in lockless contexts
753− * to avoid potential load-tearing.
754− * The READ_ONCE() is paired with the various WRITE_ONCE() in hlist
755− * helpers that are defined below.
774+/**
775+ * hlist_unhashed_lockless - Version of hlist_unhashed for lockless use
776+ * @h: Node to be checked
777+ *
778+ * This variant of hlist_unhashed() must be used in lockless contexts
779+ * to avoid potential load-tearing. The READ_ONCE() is paired with the
780+ * various WRITE_ONCE() in hlist helpers that are defined below.
756781 */
757782 static inline int hlist_unhashed_lockless(const struct hlist_node *h)
758783 {
759784 return !READ_ONCE(h->pprev);
760785 }
761786
787+/**
788+ * hlist_empty - Is the specified hlist_head structure an empty hlist?
789+ * @h: Structure to check.
790+ */
762791 static inline int hlist_empty(const struct hlist_head *h)
763792 {
764793 return !READ_ONCE(h->first);
@@ -774,6 +803,13 @@ static inline void __hlist_del(struct hlist_node *n) · 9 unmodified lines
774803 WRITE_ONCE(next->pprev, pprev);
775804 }
776805
806+/**
807+ * hlist_del - Delete the specified hlist_node from its list
808+ * @n: Node to delete.
809+ *
810+ * Note that this function leaves the node in hashed state. Use
811+ * hlist_del_init() or similar instead to unhash @n.
812+ */
777813 static inline void hlist_del(struct hlist_node *n)
778814 {
779815 __hlist_del(n);
@@ -781,6 +817,12 @@ static inline void hlist_del(struct hlist_node *n) · 1 unmodified line
781817 n->pprev = LIST_POISON2;
782818 }
783819
820+/**
821+ * hlist_del_init - Delete the specified hlist_node from its list and initialize
822+ * @n: Node to delete.
823+ *
824+ * Note that this function leaves the node in unhashed state.
825+ */
784826 static inline void hlist_del_init(struct hlist_node *n)
785827 {
786828 if (!hlist_unhashed(n)) {
@@ -789,6 +831,14 @@ static inline void hlist_del_init(struct hlist_node *n) · 2 unmodified lines
789831 }
790832 }
791833
834+/**
835+ * hlist_add_head - add a new entry at the beginning of the hlist
836+ * @n: new entry to be added
837+ * @h: hlist head to add it after
838+ *
839+ * Insert a new entry after the specified head.
840+ * This is good for implementing stacks.
841+ */
792842 static inline void hlist_add_head(struct hlist_node *n, struct hlist_head *h)
793843 {
794844 struct hlist_node *first = h->first;
@@ -799,9 +849,13 @@ static inline void hlist_add_head(struct hlist_node *n, struct hlist_head *h) · 4 unmodified lines
799849 WRITE_ONCE(n->pprev, &h->first);
800850 }
801851
802−/* next must be != NULL */
852+/**
853+ * hlist_add_before - add a new entry before the one specified
854+ * @n: new entry to be added
855+ * @next: hlist node to add it before, which must be non-NULL
856+ */
803857 static inline void hlist_add_before(struct hlist_node *n,
804− struct hlist_node *next)
858+ struct hlist_node *next)
805859 {
806860 WRITE_ONCE(n->pprev, next->pprev);
807861 WRITE_ONCE(n->next, next);
@@ -809,6 +863,11 @@ static inline void hlist_add_before(struct hlist_node *n, · 1 unmodified line
809863 WRITE_ONCE(*(n->pprev), n);
810864 }
811865
866+/**
867+ * hlist_add_behing - add a new entry after the one specified
868+ * @n: new entry to be added
869+ * @prev: hlist node to add it after, which must be non-NULL
870+ */
812871 static inline void hlist_add_behind(struct hlist_node *n,
813872 struct hlist_node *prev)
814873 {
@@ -820,20 +879,35 @@ static inline void hlist_add_behind(struct hlist_node *n, · 5 unmodified lines
820879 WRITE_ONCE(n->next->pprev, &n->next);
821880 }
822881
823−/* after that we'll appear to be on some hlist and hlist_del will work */
882+/**
883+ * hlist_add_fake - create a fake hlist consisting of a single headless node
884+ * @n: Node to make a fake list out of
885+ *
886+ * This makes @n appear to be its own predecessor on a headless hlist.
887+ * The point of this is to allow things like hlist_del() to work correctly
888+ * in cases where there is no list.
889+ */
824890 static inline void hlist_add_fake(struct hlist_node *n)
825891 {
826892 n->pprev = &n->next;
827893 }
828894
895+/**
896+ * hlist_fake: Is this node a fake hlist?
897+ * @h: Node to check for being a self-referential fake hlist.
898+ */
829899 static inline bool hlist_fake(struct hlist_node *h)
830900 {
831901 return h->pprev == &h->next;
832902 }
833903
834−/*
904+/**
905+ * hlist_is_singular_node - is node the only element of the specified hlist?
906+ * @n: Node to check for singularity.
907+ * @h: Header for potentially singular list.
908+ *
835909 * Check whether the node is the only node of the head without
836− * accessing head:
910+ * accessing head, thus avoiding unnecessary cache misses.
837911 */
838912 static inline bool
839913 hlist_is_singular_node(struct hlist_node *n, struct hlist_head *h)
@@ -841,7 +915,11 @@ hlist_is_singular_node(struct hlist_node *n, struct hlist_head *h) · 1 unmodified line
841915 return !n->next && n->pprev == &h->first;
842916 }
843917
844−/*
918+/**
919+ * hlist_move_list - Move an hlist
920+ * @old: hlist_head for old list.
921+ * @new: hlist_head for new list.
922+ *
845923 * Move a list from one list head to another. Fixup the pprev
846924 * reference of the first entry if it exists.
847925 */