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
23#define LIST_HEAD(name) \23#define LIST_HEAD(name) \
24 struct list_head name = LIST_HEAD_INIT(name)24 struct list_head name = LIST_HEAD_INIT(name)
25 25
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 */
26static inline void INIT_LIST_HEAD(struct list_head *list)33static inline void INIT_LIST_HEAD(struct list_head *list)
27{34{
28 WRITE_ONCE(list->next, list);35 WRITE_ONCE(list->next, list);
@@ -120,12 +127,6 @@ static inline void __list_del_clearprev(struct list_head *entry) · 91 unmodified lines
120 entry->prev = NULL;127 entry->prev = NULL;
121}128}
122 129
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 */
129static inline void __list_del_entry(struct list_head *entry)130static inline void __list_del_entry(struct list_head *entry)
130{131{
131 if (!__list_del_entry_valid(entry))132 if (!__list_del_entry_valid(entry))
@@ -134,6 +135,12 @@ static inline void __list_del_entry(struct list_head *entry) · 2 unmodified lines
134 __list_del(entry->prev, entry->next);135 __list_del(entry->prev, entry->next);
135}136}
136 137
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 */
137static inline void list_del(struct list_head *entry)144static inline void list_del(struct list_head *entry)
138{145{
139 __list_del_entry(entry);146 __list_del_entry(entry);
@@ -157,8 +164,15 @@ static inline void list_replace(struct list_head *old, · 17 unmodified lines
157 new->prev->next = new;164 new->prev->next = new;
158}165}
159 166
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 */
160static inline void list_replace_init(struct list_head *old,174static inline void list_replace_init(struct list_head *old,
161 struct list_head *new)175 struct list_head *new)
162{176{
163 list_replace(old, new);177 list_replace(old, new);
164 INIT_LIST_HEAD(old);178 INIT_LIST_HEAD(old);
@@ -744,21 +758,36 @@ static inline void INIT_HLIST_NODE(struct hlist_node *h) · 579 unmodified lines
744 h->pprev = NULL;758 h->pprev = NULL;
745}759}
746 760
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 */
747static inline int hlist_unhashed(const struct hlist_node *h)769static inline int hlist_unhashed(const struct hlist_node *h)
748{770{
749 return !h->pprev;771 return !h->pprev;
750}772}
751 773
752/* This variant of hlist_unhashed() must be used in lockless contexts774/**
753 * to avoid potential load-tearing.775 * hlist_unhashed_lockless - Version of hlist_unhashed for lockless use
754 * The READ_ONCE() is paired with the various WRITE_ONCE() in hlist776 * @h: Node to be checked
755 * helpers that are defined below.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.
756 */781 */
757static inline int hlist_unhashed_lockless(const struct hlist_node *h)782static inline int hlist_unhashed_lockless(const struct hlist_node *h)
758{783{
759 return !READ_ONCE(h->pprev);784 return !READ_ONCE(h->pprev);
760}785}
761 786
787/**
788 * hlist_empty - Is the specified hlist_head structure an empty hlist?
789 * @h: Structure to check.
790 */
762static inline int hlist_empty(const struct hlist_head *h)791static inline int hlist_empty(const struct hlist_head *h)
763{792{
764 return !READ_ONCE(h->first);793 return !READ_ONCE(h->first);
@@ -774,6 +803,13 @@ static inline void __hlist_del(struct hlist_node *n) · 9 unmodified lines
774 WRITE_ONCE(next->pprev, pprev);803 WRITE_ONCE(next->pprev, pprev);
775}804}
776 805
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 */
777static inline void hlist_del(struct hlist_node *n)813static inline void hlist_del(struct hlist_node *n)
778{814{
779 __hlist_del(n);815 __hlist_del(n);
@@ -781,6 +817,12 @@ static inline void hlist_del(struct hlist_node *n) · 1 unmodified line
781 n->pprev = LIST_POISON2;817 n->pprev = LIST_POISON2;
782}818}
783 819
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 */
784static inline void hlist_del_init(struct hlist_node *n)826static inline void hlist_del_init(struct hlist_node *n)
785{827{
786 if (!hlist_unhashed(n)) {828 if (!hlist_unhashed(n)) {
@@ -789,6 +831,14 @@ static inline void hlist_del_init(struct hlist_node *n) · 2 unmodified lines
789 }831 }
790}832}
791 833
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 */
792static inline void hlist_add_head(struct hlist_node *n, struct hlist_head *h)842static inline void hlist_add_head(struct hlist_node *n, struct hlist_head *h)
793{843{
794 struct hlist_node *first = h->first;844 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
799 WRITE_ONCE(n->pprev, &h->first);849 WRITE_ONCE(n->pprev, &h->first);
800}850}
801 851
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 */
803static inline void hlist_add_before(struct hlist_node *n,857static inline void hlist_add_before(struct hlist_node *n,
804 struct hlist_node *next)858 struct hlist_node *next)
805{859{
806 WRITE_ONCE(n->pprev, next->pprev);860 WRITE_ONCE(n->pprev, next->pprev);
807 WRITE_ONCE(n->next, next);861 WRITE_ONCE(n->next, next);
@@ -809,6 +863,11 @@ static inline void hlist_add_before(struct hlist_node *n, · 1 unmodified line
809 WRITE_ONCE(*(n->pprev), n);863 WRITE_ONCE(*(n->pprev), n);
810}864}
811 865
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 */
812static inline void hlist_add_behind(struct hlist_node *n,871static inline void hlist_add_behind(struct hlist_node *n,
813 struct hlist_node *prev)872 struct hlist_node *prev)
814{873{
@@ -820,20 +879,35 @@ static inline void hlist_add_behind(struct hlist_node *n, · 5 unmodified lines
820 WRITE_ONCE(n->next->pprev, &n->next);879 WRITE_ONCE(n->next->pprev, &n->next);
821}880}
822 881
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 */
824static inline void hlist_add_fake(struct hlist_node *n)890static inline void hlist_add_fake(struct hlist_node *n)
825{891{
826 n->pprev = &n->next;892 n->pprev = &n->next;
827}893}
828 894
895/**
896 * hlist_fake: Is this node a fake hlist?
897 * @h: Node to check for being a self-referential fake hlist.
898 */
829static inline bool hlist_fake(struct hlist_node *h)899static inline bool hlist_fake(struct hlist_node *h)
830{900{
831 return h->pprev == &h->next;901 return h->pprev == &h->next;
832}902}
833 903
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 *
835 * Check whether the node is the only node of the head without909 * Check whether the node is the only node of the head without
836 * accessing head:910 * accessing head, thus avoiding unnecessary cache misses.
837 */911 */
838static inline bool912static inline bool
839hlist_is_singular_node(struct hlist_node *n, struct hlist_head *h)913hlist_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
841 return !n->next && n->pprev == &h->first;915 return !n->next && n->pprev == &h->first;
842}916}
843 917
844/*918/**
919 * hlist_move_list - Move an hlist
920 * @old: hlist_head for old list.
921 * @new: hlist_head for new list.
922 *
845 * Move a list from one list head to another. Fixup the pprev923 * Move a list from one list head to another. Fixup the pprev
846 * reference of the first entry if it exists.924 * reference of the first entry if it exists.
847 */925 */