License cleanup: add SPDX GPL-2.0 license identifier to files with no license
Many source files in the tree are missing licensing information, which
makes it harder for compliance tools to determine the correct license.
By default all files without license information are under the default
license of the kernel, which is GPL version 2.
Update the files which contain no license information with the 'GPL-2.0'
SPDX license identifier. The SPDX identifier is a legally binding
shorthand, which can be used instead of the full boiler plate text.
This patch is based on work done by Thomas Gleixner and Kate Stewart and
Philippe Ombredanne.
How this work was done:
Patches were generated and checked against linux-4.14-rc6 for a subset of
the use cases:
- file had no licensing information it it.
- file was a */uapi/* one with no licensing information in it,
- file was a */uapi/* one with existing licensing information,
Further patches will be generated in subsequent months to fix up cases
where non-standard license headers were used, and references to license
had to be inferred by heuristics based on keywords.
The analysis to determine which SPDX License Identifier to be applied to
a file was done in a spreadsheet of side by side results from of the
output of two independent scanners (ScanCode & Windriver) producing SPDX
tag:value files created by Philippe Ombredanne. Philippe prepared the
base worksheet, and did an initial spot review of a few 1000 files.
The 4.13 kernel was the starting point of the analysis with 60,537 files
assessed. Kate Stewart did a file by file comparison of the scanner
results in the spreadsheet to determine which SPDX license identifier(s)
to be applied to the file. She confirmed any determination that was not
immediately clear with lawyers working with the Linux Foundation.
Criteria used to select files for SPDX license identifier tagging was:
- Files considered eligible had to be source code files.
- Make and config files were included as candidates if they contained >5
lines of source
- File already had some variant of a license header in it (even if <5
lines).
All documentation files were explicitly excluded.
The following heuristics were used to determine which SPDX license
identifiers to apply.
- when both scanners couldn't find any license traces, file was
considered to have no license information in it, and the top level
COPYING file license applied.
For non */uapi/* files that summary was:
SPDX license identifier # files
---------------------------------------------------|-------
GPL-2.0 11139
and resulted in the first patch in this series.
If that file was a */uapi/* path one, it was "GPL-2.0 WITH
Linux-syscall-note" otherwise it was "GPL-2.0". Results of that was:
SPDX license identifier # files
---------------------------------------------------|-------
GPL-2.0 WITH Linux-syscall-note 930
and resulted in the second patch in this series.
- if a file had some form of licensing information in it, and was one
of the */uapi/* ones, it was denoted with the Linux-syscall-note if
any GPL family license was found in the file or had no licensing in
it (per prior point). Results summary:
SPDX license identifier # files
---------------------------------------------------|------
GPL-2.0 WITH Linux-syscall-note 270
GPL-2.0+ WITH Linux-syscall-note 169
((GPL-2.0 WITH Linux-syscall-note) OR BSD-2-Clause) 21
((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) 17
LGPL-2.1+ WITH Linux-syscall-note 15
GPL-1.0+ WITH Linux-syscall-note 14
((GPL-2.0+ WITH Linux-syscall-note) OR BSD-3-Clause) 5
LGPL-2.0+ WITH Linux-syscall-note 4
LGPL-2.1 WITH Linux-syscall-note 3
((GPL-2.0 WITH Linux-syscall-note) OR MIT) 3
((GPL-2.0 WITH Linux-syscall-note) AND MIT) 1
and that resulted in the third patch in this series.
- when the two scanners agreed on the detected license(s), that became
the concluded license(s).
- when there was disagreement between the two scanners (one detected a
license but the other didn't, or they both detected different
licenses) a manual inspection of the file occurred.
- In most cases a manual inspection of the information in the file
resulted in a clear resolution of the license that should apply (and
which scanner probably needed to revisit its heuristics).
- When it was not immediately clear, the license identifier was
confirmed with lawyers working with the Linux Foundation.
- If there was any question as to the appropriate license identifier,
the file was flagged for further research and to be revisited later
in time.
In total, over 70 hours of logged manual review was done on the
spreadsheet to determine the SPDX license identifiers to apply to the
source files by Kate, Philippe, Thomas and, in some cases, confirmation
by lawyers working with the Linux Foundation.
Kate also obtained a third independent scan of the 4.13 code base from
FOSSology, and compared selected files where the other two scanners
disagreed against that SPDX file, to see if there was new insights. The
Windriver scanner is based on an older version of FOSSology in part, so
they are related.
Thomas did random spot checks in about 500 files from the spreadsheets
for the uapi headers and agreed with SPDX license identifier in the
files he inspected. For the non-uapi files Thomas did random spot checks
in about 15000 files.
In initial set of patches against 4.14-rc6, 3 files were found to have
copy/paste license identifier errors, and have been fixed to reflect the
correct identifier.
Additionally Philippe spent 10 hours this week doing a detailed manual
inspection and review of the 12,461 patched files from the initial patch
version early this week with:
- a full scancode scan run, collecting the matched texts, detected
license ids and scores
- reviewing anything where there was a license detected (about 500+
files) to ensure that the applied SPDX license was correct
- reviewing anything where there was no detection but the patch license
was not GPL-2.0 WITH Linux-syscall-note to ensure that the applied
SPDX license was correct
This produced a worksheet with 20 files needing minor correction. This
worksheet was then exported into 3 different .csv files for the
different types of files to be modified.
These .csv files were then reviewed by Greg. Thomas wrote a script to
parse the csv files and add the proper SPDX tag to the file, in the
format that the file expected. This script was further refined by Greg
based on the output to detect more types of files automatically and to
distinguish between header and source .c files (which need different
comment types.) Finally Greg ran the script using the .csv files to
generate the patches.
Reviewed-by: Kate Stewart <kstewart@linuxfoundation.org>
Reviewed-by: Philippe Ombredanne <pombredanne@nexb.com>
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-11-01 22:07:57 +08:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0 */
|
2008-05-13 03:21:05 +08:00
|
|
|
#ifndef _LINUX_RCULIST_H
|
|
|
|
#define _LINUX_RCULIST_H
|
|
|
|
|
|
|
|
#ifdef __KERNEL__
|
|
|
|
|
|
|
|
/*
|
|
|
|
* RCU-protected list version
|
|
|
|
*/
|
|
|
|
#include <linux/list.h>
|
2008-05-13 03:21:06 +08:00
|
|
|
#include <linux/rcupdate.h>
|
2008-05-13 03:21:05 +08:00
|
|
|
|
2010-08-20 12:43:09 +08:00
|
|
|
/*
|
|
|
|
* Why is there no list_empty_rcu()? Because list_empty() serves this
|
|
|
|
* purpose. The list_empty() function fetches the RCU-protected pointer
|
|
|
|
* and compares it to the address of the list head, but neither dereferences
|
|
|
|
* this pointer itself nor provides this pointer to the caller. Therefore,
|
|
|
|
* it is not necessary to use rcu_dereference(), so that list_empty() can
|
|
|
|
* be used anywhere you would want to use a list_empty_rcu().
|
|
|
|
*/
|
|
|
|
|
2013-08-24 00:40:42 +08:00
|
|
|
/*
|
|
|
|
* INIT_LIST_HEAD_RCU - Initialize a list_head visible to RCU readers
|
|
|
|
* @list: list to be initialized
|
|
|
|
*
|
|
|
|
* You should instead use INIT_LIST_HEAD() for normal initialization and
|
|
|
|
* cleanup tasks, when readers have no access to the list being initialized.
|
|
|
|
* However, if the list being initialized is visible to readers, you
|
|
|
|
* need to keep the compiler from being too mischievous.
|
|
|
|
*/
|
|
|
|
static inline void INIT_LIST_HEAD_RCU(struct list_head *list)
|
|
|
|
{
|
2015-03-04 06:57:58 +08:00
|
|
|
WRITE_ONCE(list->next, list);
|
|
|
|
WRITE_ONCE(list->prev, list);
|
2013-08-24 00:40:42 +08:00
|
|
|
}
|
|
|
|
|
2010-02-25 23:55:13 +08:00
|
|
|
/*
|
|
|
|
* return the ->next pointer of a list_head in an rcu safe
|
|
|
|
* way, we must not access it directly
|
|
|
|
*/
|
|
|
|
#define list_next_rcu(list) (*((struct list_head __rcu **)(&(list)->next)))
|
|
|
|
|
2008-05-13 03:21:05 +08:00
|
|
|
/*
|
|
|
|
* Insert a new entry between two known consecutive entries.
|
|
|
|
*
|
|
|
|
* This is only for internal list manipulation where we know
|
|
|
|
* the prev/next entries already!
|
|
|
|
*/
|
|
|
|
static inline void __list_add_rcu(struct list_head *new,
|
|
|
|
struct list_head *prev, struct list_head *next)
|
|
|
|
{
|
2016-08-18 05:42:09 +08:00
|
|
|
if (!__list_add_valid(new, prev, next))
|
|
|
|
return;
|
|
|
|
|
2008-05-13 03:21:05 +08:00
|
|
|
new->next = next;
|
|
|
|
new->prev = prev;
|
2010-02-25 23:55:13 +08:00
|
|
|
rcu_assign_pointer(list_next_rcu(prev), new);
|
2008-05-13 03:21:05 +08:00
|
|
|
next->prev = new;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* list_add_rcu - add a new entry to rcu-protected list
|
|
|
|
* @new: new entry to be added
|
|
|
|
* @head: list head to add it after
|
|
|
|
*
|
|
|
|
* Insert a new entry after the specified head.
|
|
|
|
* This is good for implementing stacks.
|
|
|
|
*
|
|
|
|
* The caller must take whatever precautions are necessary
|
|
|
|
* (such as holding appropriate locks) to avoid racing
|
|
|
|
* with another list-mutation primitive, such as list_add_rcu()
|
|
|
|
* or list_del_rcu(), running on this same list.
|
|
|
|
* However, it is perfectly legal to run concurrently with
|
|
|
|
* the _rcu list-traversal primitives, such as
|
|
|
|
* list_for_each_entry_rcu().
|
|
|
|
*/
|
|
|
|
static inline void list_add_rcu(struct list_head *new, struct list_head *head)
|
|
|
|
{
|
|
|
|
__list_add_rcu(new, head, head->next);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* list_add_tail_rcu - add a new entry to rcu-protected list
|
|
|
|
* @new: new entry to be added
|
|
|
|
* @head: list head to add it before
|
|
|
|
*
|
|
|
|
* Insert a new entry before the specified head.
|
|
|
|
* This is useful for implementing queues.
|
|
|
|
*
|
|
|
|
* The caller must take whatever precautions are necessary
|
|
|
|
* (such as holding appropriate locks) to avoid racing
|
|
|
|
* with another list-mutation primitive, such as list_add_tail_rcu()
|
|
|
|
* or list_del_rcu(), running on this same list.
|
|
|
|
* However, it is perfectly legal to run concurrently with
|
|
|
|
* the _rcu list-traversal primitives, such as
|
|
|
|
* list_for_each_entry_rcu().
|
|
|
|
*/
|
|
|
|
static inline void list_add_tail_rcu(struct list_head *new,
|
|
|
|
struct list_head *head)
|
|
|
|
{
|
|
|
|
__list_add_rcu(new, head->prev, head);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* list_del_rcu - deletes entry from list without re-initialization
|
|
|
|
* @entry: the element to delete from the list.
|
|
|
|
*
|
|
|
|
* Note: list_empty() on entry does not return true after this,
|
|
|
|
* the entry is in an undefined state. It is useful for RCU based
|
|
|
|
* lockfree traversal.
|
|
|
|
*
|
|
|
|
* In particular, it means that we can not poison the forward
|
|
|
|
* pointers that may still be used for walking the list.
|
|
|
|
*
|
|
|
|
* The caller must take whatever precautions are necessary
|
|
|
|
* (such as holding appropriate locks) to avoid racing
|
|
|
|
* with another list-mutation primitive, such as list_del_rcu()
|
|
|
|
* or list_add_rcu(), running on this same list.
|
|
|
|
* However, it is perfectly legal to run concurrently with
|
|
|
|
* the _rcu list-traversal primitives, such as
|
|
|
|
* list_for_each_entry_rcu().
|
|
|
|
*
|
|
|
|
* Note that the caller is not permitted to immediately free
|
|
|
|
* the newly deleted entry. Instead, either synchronize_rcu()
|
|
|
|
* or call_rcu() must be used to defer freeing until an RCU
|
|
|
|
* grace period has elapsed.
|
|
|
|
*/
|
|
|
|
static inline void list_del_rcu(struct list_head *entry)
|
|
|
|
{
|
2012-03-15 10:17:39 +08:00
|
|
|
__list_del_entry(entry);
|
2008-05-13 03:21:05 +08:00
|
|
|
entry->prev = LIST_POISON2;
|
|
|
|
}
|
|
|
|
|
2008-07-29 06:46:22 +08:00
|
|
|
/**
|
|
|
|
* hlist_del_init_rcu - deletes entry from hash list with re-initialization
|
|
|
|
* @n: the element to delete from the hash list.
|
|
|
|
*
|
|
|
|
* Note: list_unhashed() on the node return true after this. It is
|
|
|
|
* useful for RCU based read lockfree traversal if the writer side
|
|
|
|
* must know if the list entry is still hashed or already unhashed.
|
|
|
|
*
|
|
|
|
* In particular, it means that we can not poison the forward pointers
|
|
|
|
* that may still be used for walking the hash list and we can only
|
|
|
|
* zero the pprev pointer so list_unhashed() will return true after
|
|
|
|
* this.
|
|
|
|
*
|
|
|
|
* The caller must take whatever precautions are necessary (such as
|
|
|
|
* holding appropriate locks) to avoid racing with another
|
|
|
|
* list-mutation primitive, such as hlist_add_head_rcu() or
|
|
|
|
* hlist_del_rcu(), running on this same list. However, it is
|
|
|
|
* perfectly legal to run concurrently with the _rcu list-traversal
|
|
|
|
* primitives, such as hlist_for_each_entry_rcu().
|
|
|
|
*/
|
|
|
|
static inline void hlist_del_init_rcu(struct hlist_node *n)
|
|
|
|
{
|
|
|
|
if (!hlist_unhashed(n)) {
|
|
|
|
__hlist_del(n);
|
|
|
|
n->pprev = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-05-13 03:21:05 +08:00
|
|
|
/**
|
|
|
|
* list_replace_rcu - replace old entry by new one
|
|
|
|
* @old : the element to be replaced
|
|
|
|
* @new : the new element to insert
|
|
|
|
*
|
|
|
|
* The @old entry will be replaced with the @new entry atomically.
|
|
|
|
* Note: @old should not be empty.
|
|
|
|
*/
|
|
|
|
static inline void list_replace_rcu(struct list_head *old,
|
|
|
|
struct list_head *new)
|
|
|
|
{
|
|
|
|
new->next = old->next;
|
|
|
|
new->prev = old->prev;
|
2010-02-25 23:55:13 +08:00
|
|
|
rcu_assign_pointer(list_next_rcu(new->prev), new);
|
2008-05-13 03:21:05 +08:00
|
|
|
new->next->prev = new;
|
|
|
|
old->prev = LIST_POISON2;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2015-10-12 23:23:51 +08:00
|
|
|
* __list_splice_init_rcu - join an RCU-protected list into an existing list.
|
2008-05-13 03:21:05 +08:00
|
|
|
* @list: the RCU-protected list to splice
|
2015-10-12 23:23:51 +08:00
|
|
|
* @prev: points to the last element of the existing list
|
|
|
|
* @next: points to the first element of the existing list
|
2008-05-13 03:21:05 +08:00
|
|
|
* @sync: function to sync: synchronize_rcu(), synchronize_sched(), ...
|
|
|
|
*
|
2015-10-12 23:23:51 +08:00
|
|
|
* The list pointed to by @prev and @next can be RCU-read traversed
|
|
|
|
* concurrently with this function.
|
2008-05-13 03:21:05 +08:00
|
|
|
*
|
|
|
|
* Note that this function blocks.
|
|
|
|
*
|
2015-10-12 23:23:51 +08:00
|
|
|
* Important note: the caller must take whatever action is necessary to prevent
|
|
|
|
* any other updates to the existing list. In principle, it is possible to
|
|
|
|
* modify the list as soon as sync() begins execution. If this sort of thing
|
|
|
|
* becomes necessary, an alternative version based on call_rcu() could be
|
|
|
|
* created. But only if -really- needed -- there is no shortage of RCU API
|
|
|
|
* members.
|
2008-05-13 03:21:05 +08:00
|
|
|
*/
|
2015-10-12 23:23:51 +08:00
|
|
|
static inline void __list_splice_init_rcu(struct list_head *list,
|
|
|
|
struct list_head *prev,
|
|
|
|
struct list_head *next,
|
|
|
|
void (*sync)(void))
|
2008-05-13 03:21:05 +08:00
|
|
|
{
|
|
|
|
struct list_head *first = list->next;
|
|
|
|
struct list_head *last = list->prev;
|
|
|
|
|
2013-08-24 00:40:42 +08:00
|
|
|
/*
|
|
|
|
* "first" and "last" tracking list, so initialize it. RCU readers
|
|
|
|
* have access to this list, so we must use INIT_LIST_HEAD_RCU()
|
|
|
|
* instead of INIT_LIST_HEAD().
|
|
|
|
*/
|
2008-05-13 03:21:05 +08:00
|
|
|
|
2013-08-24 00:40:42 +08:00
|
|
|
INIT_LIST_HEAD_RCU(list);
|
2008-05-13 03:21:05 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* At this point, the list body still points to the source list.
|
|
|
|
* Wait for any readers to finish using the list before splicing
|
|
|
|
* the list body into the new list. Any new readers will see
|
|
|
|
* an empty list.
|
|
|
|
*/
|
|
|
|
|
|
|
|
sync();
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Readers are finished with the source list, so perform splice.
|
|
|
|
* The order is important if the new list is global and accessible
|
|
|
|
* to concurrent RCU readers. Note that RCU readers are not
|
|
|
|
* permitted to traverse the prev pointers without excluding
|
|
|
|
* this function.
|
|
|
|
*/
|
|
|
|
|
2015-10-12 23:23:51 +08:00
|
|
|
last->next = next;
|
|
|
|
rcu_assign_pointer(list_next_rcu(prev), first);
|
|
|
|
first->prev = prev;
|
|
|
|
next->prev = last;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* list_splice_init_rcu - splice an RCU-protected list into an existing list,
|
|
|
|
* designed for stacks.
|
|
|
|
* @list: the RCU-protected list to splice
|
|
|
|
* @head: the place in the existing list to splice the first list into
|
|
|
|
* @sync: function to sync: synchronize_rcu(), synchronize_sched(), ...
|
|
|
|
*/
|
|
|
|
static inline void list_splice_init_rcu(struct list_head *list,
|
|
|
|
struct list_head *head,
|
|
|
|
void (*sync)(void))
|
|
|
|
{
|
|
|
|
if (!list_empty(list))
|
|
|
|
__list_splice_init_rcu(list, head, head->next, sync);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* list_splice_tail_init_rcu - splice an RCU-protected list into an existing
|
|
|
|
* list, designed for queues.
|
|
|
|
* @list: the RCU-protected list to splice
|
|
|
|
* @head: the place in the existing list to splice the first list into
|
|
|
|
* @sync: function to sync: synchronize_rcu(), synchronize_sched(), ...
|
|
|
|
*/
|
|
|
|
static inline void list_splice_tail_init_rcu(struct list_head *list,
|
|
|
|
struct list_head *head,
|
|
|
|
void (*sync)(void))
|
|
|
|
{
|
|
|
|
if (!list_empty(list))
|
|
|
|
__list_splice_init_rcu(list, head->prev, head, sync);
|
2008-05-13 03:21:05 +08:00
|
|
|
}
|
|
|
|
|
2009-04-14 23:33:57 +08:00
|
|
|
/**
|
|
|
|
* list_entry_rcu - get the struct for this entry
|
|
|
|
* @ptr: the &struct list_head pointer.
|
|
|
|
* @type: the type of the struct this is embedded in.
|
2014-11-14 09:09:55 +08:00
|
|
|
* @member: the name of the list_head within the struct.
|
2009-04-14 23:33:57 +08:00
|
|
|
*
|
|
|
|
* This primitive may safely run concurrently with the _rcu list-mutation
|
|
|
|
* primitives such as list_add_rcu() as long as it's guarded by rcu_read_lock().
|
|
|
|
*/
|
|
|
|
#define list_entry_rcu(ptr, type, member) \
|
2017-10-24 18:22:48 +08:00
|
|
|
container_of(READ_ONCE(ptr), type, member)
|
2009-04-14 23:33:57 +08:00
|
|
|
|
2017-10-20 05:26:21 +08:00
|
|
|
/*
|
2012-04-11 02:07:40 +08:00
|
|
|
* Where are list_empty_rcu() and list_first_entry_rcu()?
|
|
|
|
*
|
|
|
|
* Implementing those functions following their counterparts list_empty() and
|
|
|
|
* list_first_entry() is not advisable because they lead to subtle race
|
|
|
|
* conditions as the following snippet shows:
|
|
|
|
*
|
|
|
|
* if (!list_empty_rcu(mylist)) {
|
|
|
|
* struct foo *bar = list_first_entry_rcu(mylist, struct foo, list_member);
|
|
|
|
* do_something(bar);
|
|
|
|
* }
|
|
|
|
*
|
|
|
|
* The list may not be empty when list_empty_rcu checks it, but it may be when
|
|
|
|
* list_first_entry_rcu rereads the ->next pointer.
|
|
|
|
*
|
|
|
|
* Rereading the ->next pointer is not a problem for list_empty() and
|
|
|
|
* list_first_entry() because they would be protected by a lock that blocks
|
|
|
|
* writers.
|
|
|
|
*
|
|
|
|
* See list_first_or_null_rcu for an alternative.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* list_first_or_null_rcu - get the first element from a list
|
2009-04-14 23:33:57 +08:00
|
|
|
* @ptr: the list head to take the element from.
|
|
|
|
* @type: the type of the struct this is embedded in.
|
2014-11-14 09:09:55 +08:00
|
|
|
* @member: the name of the list_head within the struct.
|
2009-04-14 23:33:57 +08:00
|
|
|
*
|
2012-04-11 02:07:40 +08:00
|
|
|
* Note that if the list is empty, it returns NULL.
|
2009-04-14 23:33:57 +08:00
|
|
|
*
|
|
|
|
* This primitive may safely run concurrently with the _rcu list-mutation
|
|
|
|
* primitives such as list_add_rcu() as long as it's guarded by rcu_read_lock().
|
|
|
|
*/
|
2012-04-11 02:07:40 +08:00
|
|
|
#define list_first_or_null_rcu(ptr, type, member) \
|
2013-12-06 08:19:15 +08:00
|
|
|
({ \
|
|
|
|
struct list_head *__ptr = (ptr); \
|
2015-03-04 06:57:58 +08:00
|
|
|
struct list_head *__next = READ_ONCE(__ptr->next); \
|
2013-12-06 08:19:15 +08:00
|
|
|
likely(__ptr != __next) ? list_entry_rcu(__next, type, member) : NULL; \
|
|
|
|
})
|
2009-04-14 23:33:57 +08:00
|
|
|
|
2016-03-08 06:11:00 +08:00
|
|
|
/**
|
|
|
|
* list_next_or_null_rcu - get the first element from a list
|
|
|
|
* @head: the head for the list.
|
|
|
|
* @ptr: the list head to take the next element from.
|
|
|
|
* @type: the type of the struct this is embedded in.
|
|
|
|
* @member: the name of the list_head within the struct.
|
|
|
|
*
|
|
|
|
* Note that if the ptr is at the end of the list, NULL is returned.
|
|
|
|
*
|
|
|
|
* This primitive may safely run concurrently with the _rcu list-mutation
|
|
|
|
* primitives such as list_add_rcu() as long as it's guarded by rcu_read_lock().
|
|
|
|
*/
|
|
|
|
#define list_next_or_null_rcu(head, ptr, type, member) \
|
|
|
|
({ \
|
|
|
|
struct list_head *__head = (head); \
|
|
|
|
struct list_head *__ptr = (ptr); \
|
|
|
|
struct list_head *__next = READ_ONCE(__ptr->next); \
|
|
|
|
likely(__next != __head) ? list_entry_rcu(__next, type, \
|
|
|
|
member) : NULL; \
|
|
|
|
})
|
|
|
|
|
2008-05-13 03:21:05 +08:00
|
|
|
/**
|
|
|
|
* list_for_each_entry_rcu - iterate over rcu list of given type
|
|
|
|
* @pos: the type * to use as a loop cursor.
|
|
|
|
* @head: the head for your list.
|
2014-11-14 09:09:55 +08:00
|
|
|
* @member: the name of the list_head within the struct.
|
2008-05-13 03:21:05 +08:00
|
|
|
*
|
|
|
|
* This list-traversal primitive may safely run concurrently with
|
|
|
|
* the _rcu list-mutation primitives such as list_add_rcu()
|
|
|
|
* as long as the traversal is guarded by rcu_read_lock().
|
|
|
|
*/
|
|
|
|
#define list_for_each_entry_rcu(pos, head, member) \
|
2009-04-14 23:33:57 +08:00
|
|
|
for (pos = list_entry_rcu((head)->next, typeof(*pos), member); \
|
2011-05-20 05:15:29 +08:00
|
|
|
&pos->member != (head); \
|
2009-04-14 23:33:57 +08:00
|
|
|
pos = list_entry_rcu(pos->member.next, typeof(*pos), member))
|
2008-05-13 03:21:05 +08:00
|
|
|
|
2015-12-06 10:14:19 +08:00
|
|
|
/**
|
|
|
|
* list_entry_lockless - get the struct for this entry
|
|
|
|
* @ptr: the &struct list_head pointer.
|
|
|
|
* @type: the type of the struct this is embedded in.
|
|
|
|
* @member: the name of the list_head within the struct.
|
|
|
|
*
|
|
|
|
* This primitive may safely run concurrently with the _rcu list-mutation
|
|
|
|
* primitives such as list_add_rcu(), but requires some implicit RCU
|
|
|
|
* read-side guarding. One example is running within a special
|
|
|
|
* exception-time environment where preemption is disabled and where
|
|
|
|
* lockdep cannot be invoked (in which case updaters must use RCU-sched,
|
|
|
|
* as in synchronize_sched(), call_rcu_sched(), and friends). Another
|
|
|
|
* example is when items are added to the list, but never deleted.
|
|
|
|
*/
|
|
|
|
#define list_entry_lockless(ptr, type, member) \
|
2017-10-24 18:22:48 +08:00
|
|
|
container_of((typeof(ptr))READ_ONCE(ptr), type, member)
|
2015-12-06 10:14:19 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* list_for_each_entry_lockless - iterate over rcu list of given type
|
|
|
|
* @pos: the type * to use as a loop cursor.
|
|
|
|
* @head: the head for your list.
|
|
|
|
* @member: the name of the list_struct within the struct.
|
|
|
|
*
|
|
|
|
* This primitive may safely run concurrently with the _rcu list-mutation
|
|
|
|
* primitives such as list_add_rcu(), but requires some implicit RCU
|
|
|
|
* read-side guarding. One example is running within a special
|
|
|
|
* exception-time environment where preemption is disabled and where
|
|
|
|
* lockdep cannot be invoked (in which case updaters must use RCU-sched,
|
|
|
|
* as in synchronize_sched(), call_rcu_sched(), and friends). Another
|
|
|
|
* example is when items are added to the list, but never deleted.
|
|
|
|
*/
|
|
|
|
#define list_for_each_entry_lockless(pos, head, member) \
|
|
|
|
for (pos = list_entry_lockless((head)->next, typeof(*pos), member); \
|
|
|
|
&pos->member != (head); \
|
|
|
|
pos = list_entry_lockless(pos->member.next, typeof(*pos), member))
|
|
|
|
|
2009-11-10 15:54:47 +08:00
|
|
|
/**
|
|
|
|
* list_for_each_entry_continue_rcu - continue iteration over list of given type
|
|
|
|
* @pos: the type * to use as a loop cursor.
|
|
|
|
* @head: the head for your list.
|
2014-11-14 09:09:55 +08:00
|
|
|
* @member: the name of the list_head within the struct.
|
2009-11-10 15:54:47 +08:00
|
|
|
*
|
|
|
|
* Continue to iterate over list of given type, continuing after
|
2018-06-18 12:22:40 +08:00
|
|
|
* the current position which must have been in the list when the RCU read
|
|
|
|
* lock was taken.
|
|
|
|
* This would typically require either that you obtained the node from a
|
|
|
|
* previous walk of the list in the same RCU read-side critical section, or
|
|
|
|
* that you held some sort of non-RCU reference (such as a reference count)
|
|
|
|
* to keep the node alive *and* in the list.
|
|
|
|
*
|
|
|
|
* This iterator is similar to list_for_each_entry_from_rcu() except
|
|
|
|
* this starts after the given position and that one starts at the given
|
|
|
|
* position.
|
2009-11-10 15:54:47 +08:00
|
|
|
*/
|
|
|
|
#define list_for_each_entry_continue_rcu(pos, head, member) \
|
|
|
|
for (pos = list_entry_rcu(pos->member.next, typeof(*pos), member); \
|
2011-05-20 05:15:29 +08:00
|
|
|
&pos->member != (head); \
|
2009-11-10 15:54:47 +08:00
|
|
|
pos = list_entry_rcu(pos->member.next, typeof(*pos), member))
|
|
|
|
|
2018-04-30 12:31:30 +08:00
|
|
|
/**
|
|
|
|
* list_for_each_entry_from_rcu - iterate over a list from current point
|
|
|
|
* @pos: the type * to use as a loop cursor.
|
|
|
|
* @head: the head for your list.
|
|
|
|
* @member: the name of the list_node within the struct.
|
|
|
|
*
|
|
|
|
* Iterate over the tail of a list starting from a given position,
|
|
|
|
* which must have been in the list when the RCU read lock was taken.
|
2018-06-18 12:22:40 +08:00
|
|
|
* This would typically require either that you obtained the node from a
|
|
|
|
* previous walk of the list in the same RCU read-side critical section, or
|
|
|
|
* that you held some sort of non-RCU reference (such as a reference count)
|
|
|
|
* to keep the node alive *and* in the list.
|
|
|
|
*
|
|
|
|
* This iterator is similar to list_for_each_entry_continue_rcu() except
|
|
|
|
* this starts from the given position and that one starts from the position
|
|
|
|
* after the given position.
|
2018-04-30 12:31:30 +08:00
|
|
|
*/
|
|
|
|
#define list_for_each_entry_from_rcu(pos, head, member) \
|
|
|
|
for (; &(pos)->member != (head); \
|
|
|
|
pos = list_entry_rcu(pos->member.next, typeof(*(pos)), member))
|
|
|
|
|
2008-05-13 03:21:05 +08:00
|
|
|
/**
|
|
|
|
* hlist_del_rcu - deletes entry from hash list without re-initialization
|
|
|
|
* @n: the element to delete from the hash list.
|
|
|
|
*
|
|
|
|
* Note: list_unhashed() on entry does not return true after this,
|
|
|
|
* the entry is in an undefined state. It is useful for RCU based
|
|
|
|
* lockfree traversal.
|
|
|
|
*
|
|
|
|
* In particular, it means that we can not poison the forward
|
|
|
|
* pointers that may still be used for walking the hash list.
|
|
|
|
*
|
|
|
|
* The caller must take whatever precautions are necessary
|
|
|
|
* (such as holding appropriate locks) to avoid racing
|
|
|
|
* with another list-mutation primitive, such as hlist_add_head_rcu()
|
|
|
|
* or hlist_del_rcu(), running on this same list.
|
|
|
|
* However, it is perfectly legal to run concurrently with
|
|
|
|
* the _rcu list-traversal primitives, such as
|
|
|
|
* hlist_for_each_entry().
|
|
|
|
*/
|
|
|
|
static inline void hlist_del_rcu(struct hlist_node *n)
|
|
|
|
{
|
|
|
|
__hlist_del(n);
|
|
|
|
n->pprev = LIST_POISON2;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* hlist_replace_rcu - replace old entry by new one
|
|
|
|
* @old : the element to be replaced
|
|
|
|
* @new : the new element to insert
|
|
|
|
*
|
|
|
|
* The @old entry will be replaced with the @new entry atomically.
|
|
|
|
*/
|
|
|
|
static inline void hlist_replace_rcu(struct hlist_node *old,
|
|
|
|
struct hlist_node *new)
|
|
|
|
{
|
|
|
|
struct hlist_node *next = old->next;
|
|
|
|
|
|
|
|
new->next = next;
|
|
|
|
new->pprev = old->pprev;
|
2010-02-25 23:55:13 +08:00
|
|
|
rcu_assign_pointer(*(struct hlist_node __rcu **)new->pprev, new);
|
2008-05-13 03:21:05 +08:00
|
|
|
if (next)
|
|
|
|
new->next->pprev = &new->next;
|
|
|
|
old->pprev = LIST_POISON2;
|
|
|
|
}
|
|
|
|
|
2010-02-25 23:55:13 +08:00
|
|
|
/*
|
|
|
|
* return the first or the next element in an RCU protected hlist
|
|
|
|
*/
|
|
|
|
#define hlist_first_rcu(head) (*((struct hlist_node __rcu **)(&(head)->first)))
|
|
|
|
#define hlist_next_rcu(node) (*((struct hlist_node __rcu **)(&(node)->next)))
|
|
|
|
#define hlist_pprev_rcu(node) (*((struct hlist_node __rcu **)((node)->pprev)))
|
|
|
|
|
2008-05-13 03:21:05 +08:00
|
|
|
/**
|
|
|
|
* hlist_add_head_rcu
|
|
|
|
* @n: the element to add to the hash list.
|
|
|
|
* @h: the list to add to.
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Adds the specified element to the specified hlist,
|
|
|
|
* while permitting racing traversals.
|
|
|
|
*
|
|
|
|
* The caller must take whatever precautions are necessary
|
|
|
|
* (such as holding appropriate locks) to avoid racing
|
|
|
|
* with another list-mutation primitive, such as hlist_add_head_rcu()
|
|
|
|
* or hlist_del_rcu(), running on this same list.
|
|
|
|
* However, it is perfectly legal to run concurrently with
|
|
|
|
* the _rcu list-traversal primitives, such as
|
|
|
|
* hlist_for_each_entry_rcu(), used to prevent memory-consistency
|
|
|
|
* problems on Alpha CPUs. Regardless of the type of CPU, the
|
|
|
|
* list-traversal primitive must be guarded by rcu_read_lock().
|
|
|
|
*/
|
|
|
|
static inline void hlist_add_head_rcu(struct hlist_node *n,
|
|
|
|
struct hlist_head *h)
|
|
|
|
{
|
|
|
|
struct hlist_node *first = h->first;
|
2008-05-13 03:21:06 +08:00
|
|
|
|
2008-05-13 03:21:05 +08:00
|
|
|
n->next = first;
|
|
|
|
n->pprev = &h->first;
|
2010-02-25 23:55:13 +08:00
|
|
|
rcu_assign_pointer(hlist_first_rcu(h), n);
|
2008-05-13 03:21:05 +08:00
|
|
|
if (first)
|
|
|
|
first->pprev = &n->next;
|
|
|
|
}
|
|
|
|
|
2016-04-24 06:26:24 +08:00
|
|
|
/**
|
|
|
|
* hlist_add_tail_rcu
|
|
|
|
* @n: the element to add to the hash list.
|
|
|
|
* @h: the list to add to.
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Adds the specified element to the specified hlist,
|
|
|
|
* while permitting racing traversals.
|
|
|
|
*
|
|
|
|
* The caller must take whatever precautions are necessary
|
|
|
|
* (such as holding appropriate locks) to avoid racing
|
|
|
|
* with another list-mutation primitive, such as hlist_add_head_rcu()
|
|
|
|
* or hlist_del_rcu(), running on this same list.
|
|
|
|
* However, it is perfectly legal to run concurrently with
|
|
|
|
* the _rcu list-traversal primitives, such as
|
|
|
|
* hlist_for_each_entry_rcu(), used to prevent memory-consistency
|
|
|
|
* problems on Alpha CPUs. Regardless of the type of CPU, the
|
|
|
|
* list-traversal primitive must be guarded by rcu_read_lock().
|
|
|
|
*/
|
|
|
|
static inline void hlist_add_tail_rcu(struct hlist_node *n,
|
|
|
|
struct hlist_head *h)
|
|
|
|
{
|
|
|
|
struct hlist_node *i, *last = NULL;
|
|
|
|
|
2017-02-28 03:14:19 +08:00
|
|
|
/* Note: write side code, so rcu accessors are not needed. */
|
|
|
|
for (i = h->first; i; i = i->next)
|
2016-04-24 06:26:24 +08:00
|
|
|
last = i;
|
|
|
|
|
|
|
|
if (last) {
|
|
|
|
n->next = last->next;
|
|
|
|
n->pprev = &last->next;
|
|
|
|
rcu_assign_pointer(hlist_next_rcu(last), n);
|
|
|
|
} else {
|
|
|
|
hlist_add_head_rcu(n, h);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-05-13 03:21:05 +08:00
|
|
|
/**
|
|
|
|
* hlist_add_before_rcu
|
|
|
|
* @n: the new element to add to the hash list.
|
|
|
|
* @next: the existing element to add the new element before.
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Adds the specified element to the specified hlist
|
|
|
|
* before the specified node while permitting racing traversals.
|
|
|
|
*
|
|
|
|
* The caller must take whatever precautions are necessary
|
|
|
|
* (such as holding appropriate locks) to avoid racing
|
|
|
|
* with another list-mutation primitive, such as hlist_add_head_rcu()
|
|
|
|
* or hlist_del_rcu(), running on this same list.
|
|
|
|
* However, it is perfectly legal to run concurrently with
|
|
|
|
* the _rcu list-traversal primitives, such as
|
|
|
|
* hlist_for_each_entry_rcu(), used to prevent memory-consistency
|
|
|
|
* problems on Alpha CPUs.
|
|
|
|
*/
|
|
|
|
static inline void hlist_add_before_rcu(struct hlist_node *n,
|
|
|
|
struct hlist_node *next)
|
|
|
|
{
|
|
|
|
n->pprev = next->pprev;
|
|
|
|
n->next = next;
|
2010-02-25 23:55:13 +08:00
|
|
|
rcu_assign_pointer(hlist_pprev_rcu(n), n);
|
2008-05-13 03:21:05 +08:00
|
|
|
next->pprev = &n->next;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2014-08-07 07:09:16 +08:00
|
|
|
* hlist_add_behind_rcu
|
2008-05-13 03:21:05 +08:00
|
|
|
* @n: the new element to add to the hash list.
|
2014-08-07 07:09:16 +08:00
|
|
|
* @prev: the existing element to add the new element after.
|
2008-05-13 03:21:05 +08:00
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Adds the specified element to the specified hlist
|
|
|
|
* after the specified node while permitting racing traversals.
|
|
|
|
*
|
|
|
|
* The caller must take whatever precautions are necessary
|
|
|
|
* (such as holding appropriate locks) to avoid racing
|
|
|
|
* with another list-mutation primitive, such as hlist_add_head_rcu()
|
|
|
|
* or hlist_del_rcu(), running on this same list.
|
|
|
|
* However, it is perfectly legal to run concurrently with
|
|
|
|
* the _rcu list-traversal primitives, such as
|
|
|
|
* hlist_for_each_entry_rcu(), used to prevent memory-consistency
|
|
|
|
* problems on Alpha CPUs.
|
|
|
|
*/
|
2014-08-07 07:09:16 +08:00
|
|
|
static inline void hlist_add_behind_rcu(struct hlist_node *n,
|
|
|
|
struct hlist_node *prev)
|
2008-05-13 03:21:05 +08:00
|
|
|
{
|
|
|
|
n->next = prev->next;
|
|
|
|
n->pprev = &prev->next;
|
2010-02-25 23:55:13 +08:00
|
|
|
rcu_assign_pointer(hlist_next_rcu(prev), n);
|
2008-05-13 03:21:05 +08:00
|
|
|
if (n->next)
|
|
|
|
n->next->pprev = &n->next;
|
|
|
|
}
|
|
|
|
|
2010-02-25 23:55:13 +08:00
|
|
|
#define __hlist_for_each_rcu(pos, head) \
|
|
|
|
for (pos = rcu_dereference(hlist_first_rcu(head)); \
|
2011-05-20 04:50:07 +08:00
|
|
|
pos; \
|
2010-02-25 23:55:13 +08:00
|
|
|
pos = rcu_dereference(hlist_next_rcu(pos)))
|
2010-02-22 15:57:17 +08:00
|
|
|
|
2008-05-13 03:21:05 +08:00
|
|
|
/**
|
|
|
|
* hlist_for_each_entry_rcu - iterate over rcu list of given type
|
hlist: drop the node parameter from iterators
I'm not sure why, but the hlist for each entry iterators were conceived
list_for_each_entry(pos, head, member)
The hlist ones were greedy and wanted an extra parameter:
hlist_for_each_entry(tpos, pos, head, member)
Why did they need an extra pos parameter? I'm not quite sure. Not only
they don't really need it, it also prevents the iterator from looking
exactly like the list iterator, which is unfortunate.
Besides the semantic patch, there was some manual work required:
- Fix up the actual hlist iterators in linux/list.h
- Fix up the declaration of other iterators based on the hlist ones.
- A very small amount of places were using the 'node' parameter, this
was modified to use 'obj->member' instead.
- Coccinelle didn't handle the hlist_for_each_entry_safe iterator
properly, so those had to be fixed up manually.
The semantic patch which is mostly the work of Peter Senna Tschudin is here:
@@
iterator name hlist_for_each_entry, hlist_for_each_entry_continue, hlist_for_each_entry_from, hlist_for_each_entry_rcu, hlist_for_each_entry_rcu_bh, hlist_for_each_entry_continue_rcu_bh, for_each_busy_worker, ax25_uid_for_each, ax25_for_each, inet_bind_bucket_for_each, sctp_for_each_hentry, sk_for_each, sk_for_each_rcu, sk_for_each_from, sk_for_each_safe, sk_for_each_bound, hlist_for_each_entry_safe, hlist_for_each_entry_continue_rcu, nr_neigh_for_each, nr_neigh_for_each_safe, nr_node_for_each, nr_node_for_each_safe, for_each_gfn_indirect_valid_sp, for_each_gfn_sp, for_each_host;
type T;
expression a,c,d,e;
identifier b;
statement S;
@@
-T b;
<+... when != b
(
hlist_for_each_entry(a,
- b,
c, d) S
|
hlist_for_each_entry_continue(a,
- b,
c) S
|
hlist_for_each_entry_from(a,
- b,
c) S
|
hlist_for_each_entry_rcu(a,
- b,
c, d) S
|
hlist_for_each_entry_rcu_bh(a,
- b,
c, d) S
|
hlist_for_each_entry_continue_rcu_bh(a,
- b,
c) S
|
for_each_busy_worker(a, c,
- b,
d) S
|
ax25_uid_for_each(a,
- b,
c) S
|
ax25_for_each(a,
- b,
c) S
|
inet_bind_bucket_for_each(a,
- b,
c) S
|
sctp_for_each_hentry(a,
- b,
c) S
|
sk_for_each(a,
- b,
c) S
|
sk_for_each_rcu(a,
- b,
c) S
|
sk_for_each_from
-(a, b)
+(a)
S
+ sk_for_each_from(a) S
|
sk_for_each_safe(a,
- b,
c, d) S
|
sk_for_each_bound(a,
- b,
c) S
|
hlist_for_each_entry_safe(a,
- b,
c, d, e) S
|
hlist_for_each_entry_continue_rcu(a,
- b,
c) S
|
nr_neigh_for_each(a,
- b,
c) S
|
nr_neigh_for_each_safe(a,
- b,
c, d) S
|
nr_node_for_each(a,
- b,
c) S
|
nr_node_for_each_safe(a,
- b,
c, d) S
|
- for_each_gfn_sp(a, c, d, b) S
+ for_each_gfn_sp(a, c, d) S
|
- for_each_gfn_indirect_valid_sp(a, c, d, b) S
+ for_each_gfn_indirect_valid_sp(a, c, d) S
|
for_each_host(a,
- b,
c) S
|
for_each_host_safe(a,
- b,
c, d) S
|
for_each_mesh_entry(a,
- b,
c, d) S
)
...+>
[akpm@linux-foundation.org: drop bogus change from net/ipv4/raw.c]
[akpm@linux-foundation.org: drop bogus hunk from net/ipv6/raw.c]
[akpm@linux-foundation.org: checkpatch fixes]
[akpm@linux-foundation.org: fix warnings]
[akpm@linux-foudnation.org: redo intrusive kvm changes]
Tested-by: Peter Senna Tschudin <peter.senna@gmail.com>
Acked-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
Cc: Wu Fengguang <fengguang.wu@intel.com>
Cc: Marcelo Tosatti <mtosatti@redhat.com>
Cc: Gleb Natapov <gleb@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2013-02-28 09:06:00 +08:00
|
|
|
* @pos: the type * to use as a loop cursor.
|
2008-05-13 03:21:05 +08:00
|
|
|
* @head: the head for your list.
|
|
|
|
* @member: the name of the hlist_node within the struct.
|
|
|
|
*
|
|
|
|
* This list-traversal primitive may safely run concurrently with
|
|
|
|
* the _rcu list-mutation primitives such as hlist_add_head_rcu()
|
|
|
|
* as long as the traversal is guarded by rcu_read_lock().
|
|
|
|
*/
|
hlist: drop the node parameter from iterators
I'm not sure why, but the hlist for each entry iterators were conceived
list_for_each_entry(pos, head, member)
The hlist ones were greedy and wanted an extra parameter:
hlist_for_each_entry(tpos, pos, head, member)
Why did they need an extra pos parameter? I'm not quite sure. Not only
they don't really need it, it also prevents the iterator from looking
exactly like the list iterator, which is unfortunate.
Besides the semantic patch, there was some manual work required:
- Fix up the actual hlist iterators in linux/list.h
- Fix up the declaration of other iterators based on the hlist ones.
- A very small amount of places were using the 'node' parameter, this
was modified to use 'obj->member' instead.
- Coccinelle didn't handle the hlist_for_each_entry_safe iterator
properly, so those had to be fixed up manually.
The semantic patch which is mostly the work of Peter Senna Tschudin is here:
@@
iterator name hlist_for_each_entry, hlist_for_each_entry_continue, hlist_for_each_entry_from, hlist_for_each_entry_rcu, hlist_for_each_entry_rcu_bh, hlist_for_each_entry_continue_rcu_bh, for_each_busy_worker, ax25_uid_for_each, ax25_for_each, inet_bind_bucket_for_each, sctp_for_each_hentry, sk_for_each, sk_for_each_rcu, sk_for_each_from, sk_for_each_safe, sk_for_each_bound, hlist_for_each_entry_safe, hlist_for_each_entry_continue_rcu, nr_neigh_for_each, nr_neigh_for_each_safe, nr_node_for_each, nr_node_for_each_safe, for_each_gfn_indirect_valid_sp, for_each_gfn_sp, for_each_host;
type T;
expression a,c,d,e;
identifier b;
statement S;
@@
-T b;
<+... when != b
(
hlist_for_each_entry(a,
- b,
c, d) S
|
hlist_for_each_entry_continue(a,
- b,
c) S
|
hlist_for_each_entry_from(a,
- b,
c) S
|
hlist_for_each_entry_rcu(a,
- b,
c, d) S
|
hlist_for_each_entry_rcu_bh(a,
- b,
c, d) S
|
hlist_for_each_entry_continue_rcu_bh(a,
- b,
c) S
|
for_each_busy_worker(a, c,
- b,
d) S
|
ax25_uid_for_each(a,
- b,
c) S
|
ax25_for_each(a,
- b,
c) S
|
inet_bind_bucket_for_each(a,
- b,
c) S
|
sctp_for_each_hentry(a,
- b,
c) S
|
sk_for_each(a,
- b,
c) S
|
sk_for_each_rcu(a,
- b,
c) S
|
sk_for_each_from
-(a, b)
+(a)
S
+ sk_for_each_from(a) S
|
sk_for_each_safe(a,
- b,
c, d) S
|
sk_for_each_bound(a,
- b,
c) S
|
hlist_for_each_entry_safe(a,
- b,
c, d, e) S
|
hlist_for_each_entry_continue_rcu(a,
- b,
c) S
|
nr_neigh_for_each(a,
- b,
c) S
|
nr_neigh_for_each_safe(a,
- b,
c, d) S
|
nr_node_for_each(a,
- b,
c) S
|
nr_node_for_each_safe(a,
- b,
c, d) S
|
- for_each_gfn_sp(a, c, d, b) S
+ for_each_gfn_sp(a, c, d) S
|
- for_each_gfn_indirect_valid_sp(a, c, d, b) S
+ for_each_gfn_indirect_valid_sp(a, c, d) S
|
for_each_host(a,
- b,
c) S
|
for_each_host_safe(a,
- b,
c, d) S
|
for_each_mesh_entry(a,
- b,
c, d) S
)
...+>
[akpm@linux-foundation.org: drop bogus change from net/ipv4/raw.c]
[akpm@linux-foundation.org: drop bogus hunk from net/ipv6/raw.c]
[akpm@linux-foundation.org: checkpatch fixes]
[akpm@linux-foundation.org: fix warnings]
[akpm@linux-foudnation.org: redo intrusive kvm changes]
Tested-by: Peter Senna Tschudin <peter.senna@gmail.com>
Acked-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
Cc: Wu Fengguang <fengguang.wu@intel.com>
Cc: Marcelo Tosatti <mtosatti@redhat.com>
Cc: Gleb Natapov <gleb@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2013-02-28 09:06:00 +08:00
|
|
|
#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))
|
2008-05-13 03:21:05 +08:00
|
|
|
|
2013-05-29 02:38:42 +08:00
|
|
|
/**
|
|
|
|
* hlist_for_each_entry_rcu_notrace - iterate over rcu list of given type (for tracing)
|
|
|
|
* @pos: the type * to use as a loop cursor.
|
|
|
|
* @head: the head for your list.
|
|
|
|
* @member: the name of the hlist_node within the struct.
|
|
|
|
*
|
|
|
|
* This list-traversal primitive may safely run concurrently with
|
|
|
|
* the _rcu list-mutation primitives such as hlist_add_head_rcu()
|
|
|
|
* as long as the traversal is guarded by rcu_read_lock().
|
|
|
|
*
|
|
|
|
* This is the same as hlist_for_each_entry_rcu() except that it does
|
|
|
|
* not do any RCU debugging or tracing.
|
|
|
|
*/
|
|
|
|
#define hlist_for_each_entry_rcu_notrace(pos, head, member) \
|
|
|
|
for (pos = hlist_entry_safe (rcu_dereference_raw_notrace(hlist_first_rcu(head)),\
|
|
|
|
typeof(*(pos)), member); \
|
|
|
|
pos; \
|
|
|
|
pos = hlist_entry_safe(rcu_dereference_raw_notrace(hlist_next_rcu(\
|
|
|
|
&(pos)->member)), typeof(*(pos)), member))
|
|
|
|
|
2010-05-03 18:50:14 +08:00
|
|
|
/**
|
|
|
|
* hlist_for_each_entry_rcu_bh - iterate over rcu list of given type
|
hlist: drop the node parameter from iterators
I'm not sure why, but the hlist for each entry iterators were conceived
list_for_each_entry(pos, head, member)
The hlist ones were greedy and wanted an extra parameter:
hlist_for_each_entry(tpos, pos, head, member)
Why did they need an extra pos parameter? I'm not quite sure. Not only
they don't really need it, it also prevents the iterator from looking
exactly like the list iterator, which is unfortunate.
Besides the semantic patch, there was some manual work required:
- Fix up the actual hlist iterators in linux/list.h
- Fix up the declaration of other iterators based on the hlist ones.
- A very small amount of places were using the 'node' parameter, this
was modified to use 'obj->member' instead.
- Coccinelle didn't handle the hlist_for_each_entry_safe iterator
properly, so those had to be fixed up manually.
The semantic patch which is mostly the work of Peter Senna Tschudin is here:
@@
iterator name hlist_for_each_entry, hlist_for_each_entry_continue, hlist_for_each_entry_from, hlist_for_each_entry_rcu, hlist_for_each_entry_rcu_bh, hlist_for_each_entry_continue_rcu_bh, for_each_busy_worker, ax25_uid_for_each, ax25_for_each, inet_bind_bucket_for_each, sctp_for_each_hentry, sk_for_each, sk_for_each_rcu, sk_for_each_from, sk_for_each_safe, sk_for_each_bound, hlist_for_each_entry_safe, hlist_for_each_entry_continue_rcu, nr_neigh_for_each, nr_neigh_for_each_safe, nr_node_for_each, nr_node_for_each_safe, for_each_gfn_indirect_valid_sp, for_each_gfn_sp, for_each_host;
type T;
expression a,c,d,e;
identifier b;
statement S;
@@
-T b;
<+... when != b
(
hlist_for_each_entry(a,
- b,
c, d) S
|
hlist_for_each_entry_continue(a,
- b,
c) S
|
hlist_for_each_entry_from(a,
- b,
c) S
|
hlist_for_each_entry_rcu(a,
- b,
c, d) S
|
hlist_for_each_entry_rcu_bh(a,
- b,
c, d) S
|
hlist_for_each_entry_continue_rcu_bh(a,
- b,
c) S
|
for_each_busy_worker(a, c,
- b,
d) S
|
ax25_uid_for_each(a,
- b,
c) S
|
ax25_for_each(a,
- b,
c) S
|
inet_bind_bucket_for_each(a,
- b,
c) S
|
sctp_for_each_hentry(a,
- b,
c) S
|
sk_for_each(a,
- b,
c) S
|
sk_for_each_rcu(a,
- b,
c) S
|
sk_for_each_from
-(a, b)
+(a)
S
+ sk_for_each_from(a) S
|
sk_for_each_safe(a,
- b,
c, d) S
|
sk_for_each_bound(a,
- b,
c) S
|
hlist_for_each_entry_safe(a,
- b,
c, d, e) S
|
hlist_for_each_entry_continue_rcu(a,
- b,
c) S
|
nr_neigh_for_each(a,
- b,
c) S
|
nr_neigh_for_each_safe(a,
- b,
c, d) S
|
nr_node_for_each(a,
- b,
c) S
|
nr_node_for_each_safe(a,
- b,
c, d) S
|
- for_each_gfn_sp(a, c, d, b) S
+ for_each_gfn_sp(a, c, d) S
|
- for_each_gfn_indirect_valid_sp(a, c, d, b) S
+ for_each_gfn_indirect_valid_sp(a, c, d) S
|
for_each_host(a,
- b,
c) S
|
for_each_host_safe(a,
- b,
c, d) S
|
for_each_mesh_entry(a,
- b,
c, d) S
)
...+>
[akpm@linux-foundation.org: drop bogus change from net/ipv4/raw.c]
[akpm@linux-foundation.org: drop bogus hunk from net/ipv6/raw.c]
[akpm@linux-foundation.org: checkpatch fixes]
[akpm@linux-foundation.org: fix warnings]
[akpm@linux-foudnation.org: redo intrusive kvm changes]
Tested-by: Peter Senna Tschudin <peter.senna@gmail.com>
Acked-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
Cc: Wu Fengguang <fengguang.wu@intel.com>
Cc: Marcelo Tosatti <mtosatti@redhat.com>
Cc: Gleb Natapov <gleb@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2013-02-28 09:06:00 +08:00
|
|
|
* @pos: the type * to use as a loop cursor.
|
2010-05-03 18:50:14 +08:00
|
|
|
* @head: the head for your list.
|
|
|
|
* @member: the name of the hlist_node within the struct.
|
|
|
|
*
|
|
|
|
* This list-traversal primitive may safely run concurrently with
|
|
|
|
* the _rcu list-mutation primitives such as hlist_add_head_rcu()
|
|
|
|
* as long as the traversal is guarded by rcu_read_lock().
|
|
|
|
*/
|
hlist: drop the node parameter from iterators
I'm not sure why, but the hlist for each entry iterators were conceived
list_for_each_entry(pos, head, member)
The hlist ones were greedy and wanted an extra parameter:
hlist_for_each_entry(tpos, pos, head, member)
Why did they need an extra pos parameter? I'm not quite sure. Not only
they don't really need it, it also prevents the iterator from looking
exactly like the list iterator, which is unfortunate.
Besides the semantic patch, there was some manual work required:
- Fix up the actual hlist iterators in linux/list.h
- Fix up the declaration of other iterators based on the hlist ones.
- A very small amount of places were using the 'node' parameter, this
was modified to use 'obj->member' instead.
- Coccinelle didn't handle the hlist_for_each_entry_safe iterator
properly, so those had to be fixed up manually.
The semantic patch which is mostly the work of Peter Senna Tschudin is here:
@@
iterator name hlist_for_each_entry, hlist_for_each_entry_continue, hlist_for_each_entry_from, hlist_for_each_entry_rcu, hlist_for_each_entry_rcu_bh, hlist_for_each_entry_continue_rcu_bh, for_each_busy_worker, ax25_uid_for_each, ax25_for_each, inet_bind_bucket_for_each, sctp_for_each_hentry, sk_for_each, sk_for_each_rcu, sk_for_each_from, sk_for_each_safe, sk_for_each_bound, hlist_for_each_entry_safe, hlist_for_each_entry_continue_rcu, nr_neigh_for_each, nr_neigh_for_each_safe, nr_node_for_each, nr_node_for_each_safe, for_each_gfn_indirect_valid_sp, for_each_gfn_sp, for_each_host;
type T;
expression a,c,d,e;
identifier b;
statement S;
@@
-T b;
<+... when != b
(
hlist_for_each_entry(a,
- b,
c, d) S
|
hlist_for_each_entry_continue(a,
- b,
c) S
|
hlist_for_each_entry_from(a,
- b,
c) S
|
hlist_for_each_entry_rcu(a,
- b,
c, d) S
|
hlist_for_each_entry_rcu_bh(a,
- b,
c, d) S
|
hlist_for_each_entry_continue_rcu_bh(a,
- b,
c) S
|
for_each_busy_worker(a, c,
- b,
d) S
|
ax25_uid_for_each(a,
- b,
c) S
|
ax25_for_each(a,
- b,
c) S
|
inet_bind_bucket_for_each(a,
- b,
c) S
|
sctp_for_each_hentry(a,
- b,
c) S
|
sk_for_each(a,
- b,
c) S
|
sk_for_each_rcu(a,
- b,
c) S
|
sk_for_each_from
-(a, b)
+(a)
S
+ sk_for_each_from(a) S
|
sk_for_each_safe(a,
- b,
c, d) S
|
sk_for_each_bound(a,
- b,
c) S
|
hlist_for_each_entry_safe(a,
- b,
c, d, e) S
|
hlist_for_each_entry_continue_rcu(a,
- b,
c) S
|
nr_neigh_for_each(a,
- b,
c) S
|
nr_neigh_for_each_safe(a,
- b,
c, d) S
|
nr_node_for_each(a,
- b,
c) S
|
nr_node_for_each_safe(a,
- b,
c, d) S
|
- for_each_gfn_sp(a, c, d, b) S
+ for_each_gfn_sp(a, c, d) S
|
- for_each_gfn_indirect_valid_sp(a, c, d, b) S
+ for_each_gfn_indirect_valid_sp(a, c, d) S
|
for_each_host(a,
- b,
c) S
|
for_each_host_safe(a,
- b,
c, d) S
|
for_each_mesh_entry(a,
- b,
c, d) S
)
...+>
[akpm@linux-foundation.org: drop bogus change from net/ipv4/raw.c]
[akpm@linux-foundation.org: drop bogus hunk from net/ipv6/raw.c]
[akpm@linux-foundation.org: checkpatch fixes]
[akpm@linux-foundation.org: fix warnings]
[akpm@linux-foudnation.org: redo intrusive kvm changes]
Tested-by: Peter Senna Tschudin <peter.senna@gmail.com>
Acked-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
Cc: Wu Fengguang <fengguang.wu@intel.com>
Cc: Marcelo Tosatti <mtosatti@redhat.com>
Cc: Gleb Natapov <gleb@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2013-02-28 09:06:00 +08:00
|
|
|
#define hlist_for_each_entry_rcu_bh(pos, head, member) \
|
|
|
|
for (pos = hlist_entry_safe(rcu_dereference_bh(hlist_first_rcu(head)),\
|
|
|
|
typeof(*(pos)), member); \
|
|
|
|
pos; \
|
|
|
|
pos = hlist_entry_safe(rcu_dereference_bh(hlist_next_rcu(\
|
|
|
|
&(pos)->member)), typeof(*(pos)), member))
|
2010-05-03 18:50:14 +08:00
|
|
|
|
2010-03-18 04:31:11 +08:00
|
|
|
/**
|
|
|
|
* hlist_for_each_entry_continue_rcu - iterate over a hlist continuing after current point
|
hlist: drop the node parameter from iterators
I'm not sure why, but the hlist for each entry iterators were conceived
list_for_each_entry(pos, head, member)
The hlist ones were greedy and wanted an extra parameter:
hlist_for_each_entry(tpos, pos, head, member)
Why did they need an extra pos parameter? I'm not quite sure. Not only
they don't really need it, it also prevents the iterator from looking
exactly like the list iterator, which is unfortunate.
Besides the semantic patch, there was some manual work required:
- Fix up the actual hlist iterators in linux/list.h
- Fix up the declaration of other iterators based on the hlist ones.
- A very small amount of places were using the 'node' parameter, this
was modified to use 'obj->member' instead.
- Coccinelle didn't handle the hlist_for_each_entry_safe iterator
properly, so those had to be fixed up manually.
The semantic patch which is mostly the work of Peter Senna Tschudin is here:
@@
iterator name hlist_for_each_entry, hlist_for_each_entry_continue, hlist_for_each_entry_from, hlist_for_each_entry_rcu, hlist_for_each_entry_rcu_bh, hlist_for_each_entry_continue_rcu_bh, for_each_busy_worker, ax25_uid_for_each, ax25_for_each, inet_bind_bucket_for_each, sctp_for_each_hentry, sk_for_each, sk_for_each_rcu, sk_for_each_from, sk_for_each_safe, sk_for_each_bound, hlist_for_each_entry_safe, hlist_for_each_entry_continue_rcu, nr_neigh_for_each, nr_neigh_for_each_safe, nr_node_for_each, nr_node_for_each_safe, for_each_gfn_indirect_valid_sp, for_each_gfn_sp, for_each_host;
type T;
expression a,c,d,e;
identifier b;
statement S;
@@
-T b;
<+... when != b
(
hlist_for_each_entry(a,
- b,
c, d) S
|
hlist_for_each_entry_continue(a,
- b,
c) S
|
hlist_for_each_entry_from(a,
- b,
c) S
|
hlist_for_each_entry_rcu(a,
- b,
c, d) S
|
hlist_for_each_entry_rcu_bh(a,
- b,
c, d) S
|
hlist_for_each_entry_continue_rcu_bh(a,
- b,
c) S
|
for_each_busy_worker(a, c,
- b,
d) S
|
ax25_uid_for_each(a,
- b,
c) S
|
ax25_for_each(a,
- b,
c) S
|
inet_bind_bucket_for_each(a,
- b,
c) S
|
sctp_for_each_hentry(a,
- b,
c) S
|
sk_for_each(a,
- b,
c) S
|
sk_for_each_rcu(a,
- b,
c) S
|
sk_for_each_from
-(a, b)
+(a)
S
+ sk_for_each_from(a) S
|
sk_for_each_safe(a,
- b,
c, d) S
|
sk_for_each_bound(a,
- b,
c) S
|
hlist_for_each_entry_safe(a,
- b,
c, d, e) S
|
hlist_for_each_entry_continue_rcu(a,
- b,
c) S
|
nr_neigh_for_each(a,
- b,
c) S
|
nr_neigh_for_each_safe(a,
- b,
c, d) S
|
nr_node_for_each(a,
- b,
c) S
|
nr_node_for_each_safe(a,
- b,
c, d) S
|
- for_each_gfn_sp(a, c, d, b) S
+ for_each_gfn_sp(a, c, d) S
|
- for_each_gfn_indirect_valid_sp(a, c, d, b) S
+ for_each_gfn_indirect_valid_sp(a, c, d) S
|
for_each_host(a,
- b,
c) S
|
for_each_host_safe(a,
- b,
c, d) S
|
for_each_mesh_entry(a,
- b,
c, d) S
)
...+>
[akpm@linux-foundation.org: drop bogus change from net/ipv4/raw.c]
[akpm@linux-foundation.org: drop bogus hunk from net/ipv6/raw.c]
[akpm@linux-foundation.org: checkpatch fixes]
[akpm@linux-foundation.org: fix warnings]
[akpm@linux-foudnation.org: redo intrusive kvm changes]
Tested-by: Peter Senna Tschudin <peter.senna@gmail.com>
Acked-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
Cc: Wu Fengguang <fengguang.wu@intel.com>
Cc: Marcelo Tosatti <mtosatti@redhat.com>
Cc: Gleb Natapov <gleb@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2013-02-28 09:06:00 +08:00
|
|
|
* @pos: the type * to use as a loop cursor.
|
2010-03-18 04:31:11 +08:00
|
|
|
* @member: the name of the hlist_node within the struct.
|
|
|
|
*/
|
hlist: drop the node parameter from iterators
I'm not sure why, but the hlist for each entry iterators were conceived
list_for_each_entry(pos, head, member)
The hlist ones were greedy and wanted an extra parameter:
hlist_for_each_entry(tpos, pos, head, member)
Why did they need an extra pos parameter? I'm not quite sure. Not only
they don't really need it, it also prevents the iterator from looking
exactly like the list iterator, which is unfortunate.
Besides the semantic patch, there was some manual work required:
- Fix up the actual hlist iterators in linux/list.h
- Fix up the declaration of other iterators based on the hlist ones.
- A very small amount of places were using the 'node' parameter, this
was modified to use 'obj->member' instead.
- Coccinelle didn't handle the hlist_for_each_entry_safe iterator
properly, so those had to be fixed up manually.
The semantic patch which is mostly the work of Peter Senna Tschudin is here:
@@
iterator name hlist_for_each_entry, hlist_for_each_entry_continue, hlist_for_each_entry_from, hlist_for_each_entry_rcu, hlist_for_each_entry_rcu_bh, hlist_for_each_entry_continue_rcu_bh, for_each_busy_worker, ax25_uid_for_each, ax25_for_each, inet_bind_bucket_for_each, sctp_for_each_hentry, sk_for_each, sk_for_each_rcu, sk_for_each_from, sk_for_each_safe, sk_for_each_bound, hlist_for_each_entry_safe, hlist_for_each_entry_continue_rcu, nr_neigh_for_each, nr_neigh_for_each_safe, nr_node_for_each, nr_node_for_each_safe, for_each_gfn_indirect_valid_sp, for_each_gfn_sp, for_each_host;
type T;
expression a,c,d,e;
identifier b;
statement S;
@@
-T b;
<+... when != b
(
hlist_for_each_entry(a,
- b,
c, d) S
|
hlist_for_each_entry_continue(a,
- b,
c) S
|
hlist_for_each_entry_from(a,
- b,
c) S
|
hlist_for_each_entry_rcu(a,
- b,
c, d) S
|
hlist_for_each_entry_rcu_bh(a,
- b,
c, d) S
|
hlist_for_each_entry_continue_rcu_bh(a,
- b,
c) S
|
for_each_busy_worker(a, c,
- b,
d) S
|
ax25_uid_for_each(a,
- b,
c) S
|
ax25_for_each(a,
- b,
c) S
|
inet_bind_bucket_for_each(a,
- b,
c) S
|
sctp_for_each_hentry(a,
- b,
c) S
|
sk_for_each(a,
- b,
c) S
|
sk_for_each_rcu(a,
- b,
c) S
|
sk_for_each_from
-(a, b)
+(a)
S
+ sk_for_each_from(a) S
|
sk_for_each_safe(a,
- b,
c, d) S
|
sk_for_each_bound(a,
- b,
c) S
|
hlist_for_each_entry_safe(a,
- b,
c, d, e) S
|
hlist_for_each_entry_continue_rcu(a,
- b,
c) S
|
nr_neigh_for_each(a,
- b,
c) S
|
nr_neigh_for_each_safe(a,
- b,
c, d) S
|
nr_node_for_each(a,
- b,
c) S
|
nr_node_for_each_safe(a,
- b,
c, d) S
|
- for_each_gfn_sp(a, c, d, b) S
+ for_each_gfn_sp(a, c, d) S
|
- for_each_gfn_indirect_valid_sp(a, c, d, b) S
+ for_each_gfn_indirect_valid_sp(a, c, d) S
|
for_each_host(a,
- b,
c) S
|
for_each_host_safe(a,
- b,
c, d) S
|
for_each_mesh_entry(a,
- b,
c, d) S
)
...+>
[akpm@linux-foundation.org: drop bogus change from net/ipv4/raw.c]
[akpm@linux-foundation.org: drop bogus hunk from net/ipv6/raw.c]
[akpm@linux-foundation.org: checkpatch fixes]
[akpm@linux-foundation.org: fix warnings]
[akpm@linux-foudnation.org: redo intrusive kvm changes]
Tested-by: Peter Senna Tschudin <peter.senna@gmail.com>
Acked-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
Cc: Wu Fengguang <fengguang.wu@intel.com>
Cc: Marcelo Tosatti <mtosatti@redhat.com>
Cc: Gleb Natapov <gleb@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2013-02-28 09:06:00 +08:00
|
|
|
#define hlist_for_each_entry_continue_rcu(pos, member) \
|
2014-12-12 09:36:14 +08:00
|
|
|
for (pos = hlist_entry_safe(rcu_dereference_raw(hlist_next_rcu( \
|
|
|
|
&(pos)->member)), typeof(*(pos)), member); \
|
hlist: drop the node parameter from iterators
I'm not sure why, but the hlist for each entry iterators were conceived
list_for_each_entry(pos, head, member)
The hlist ones were greedy and wanted an extra parameter:
hlist_for_each_entry(tpos, pos, head, member)
Why did they need an extra pos parameter? I'm not quite sure. Not only
they don't really need it, it also prevents the iterator from looking
exactly like the list iterator, which is unfortunate.
Besides the semantic patch, there was some manual work required:
- Fix up the actual hlist iterators in linux/list.h
- Fix up the declaration of other iterators based on the hlist ones.
- A very small amount of places were using the 'node' parameter, this
was modified to use 'obj->member' instead.
- Coccinelle didn't handle the hlist_for_each_entry_safe iterator
properly, so those had to be fixed up manually.
The semantic patch which is mostly the work of Peter Senna Tschudin is here:
@@
iterator name hlist_for_each_entry, hlist_for_each_entry_continue, hlist_for_each_entry_from, hlist_for_each_entry_rcu, hlist_for_each_entry_rcu_bh, hlist_for_each_entry_continue_rcu_bh, for_each_busy_worker, ax25_uid_for_each, ax25_for_each, inet_bind_bucket_for_each, sctp_for_each_hentry, sk_for_each, sk_for_each_rcu, sk_for_each_from, sk_for_each_safe, sk_for_each_bound, hlist_for_each_entry_safe, hlist_for_each_entry_continue_rcu, nr_neigh_for_each, nr_neigh_for_each_safe, nr_node_for_each, nr_node_for_each_safe, for_each_gfn_indirect_valid_sp, for_each_gfn_sp, for_each_host;
type T;
expression a,c,d,e;
identifier b;
statement S;
@@
-T b;
<+... when != b
(
hlist_for_each_entry(a,
- b,
c, d) S
|
hlist_for_each_entry_continue(a,
- b,
c) S
|
hlist_for_each_entry_from(a,
- b,
c) S
|
hlist_for_each_entry_rcu(a,
- b,
c, d) S
|
hlist_for_each_entry_rcu_bh(a,
- b,
c, d) S
|
hlist_for_each_entry_continue_rcu_bh(a,
- b,
c) S
|
for_each_busy_worker(a, c,
- b,
d) S
|
ax25_uid_for_each(a,
- b,
c) S
|
ax25_for_each(a,
- b,
c) S
|
inet_bind_bucket_for_each(a,
- b,
c) S
|
sctp_for_each_hentry(a,
- b,
c) S
|
sk_for_each(a,
- b,
c) S
|
sk_for_each_rcu(a,
- b,
c) S
|
sk_for_each_from
-(a, b)
+(a)
S
+ sk_for_each_from(a) S
|
sk_for_each_safe(a,
- b,
c, d) S
|
sk_for_each_bound(a,
- b,
c) S
|
hlist_for_each_entry_safe(a,
- b,
c, d, e) S
|
hlist_for_each_entry_continue_rcu(a,
- b,
c) S
|
nr_neigh_for_each(a,
- b,
c) S
|
nr_neigh_for_each_safe(a,
- b,
c, d) S
|
nr_node_for_each(a,
- b,
c) S
|
nr_node_for_each_safe(a,
- b,
c, d) S
|
- for_each_gfn_sp(a, c, d, b) S
+ for_each_gfn_sp(a, c, d) S
|
- for_each_gfn_indirect_valid_sp(a, c, d, b) S
+ for_each_gfn_indirect_valid_sp(a, c, d) S
|
for_each_host(a,
- b,
c) S
|
for_each_host_safe(a,
- b,
c, d) S
|
for_each_mesh_entry(a,
- b,
c, d) S
)
...+>
[akpm@linux-foundation.org: drop bogus change from net/ipv4/raw.c]
[akpm@linux-foundation.org: drop bogus hunk from net/ipv6/raw.c]
[akpm@linux-foundation.org: checkpatch fixes]
[akpm@linux-foundation.org: fix warnings]
[akpm@linux-foudnation.org: redo intrusive kvm changes]
Tested-by: Peter Senna Tschudin <peter.senna@gmail.com>
Acked-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
Cc: Wu Fengguang <fengguang.wu@intel.com>
Cc: Marcelo Tosatti <mtosatti@redhat.com>
Cc: Gleb Natapov <gleb@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2013-02-28 09:06:00 +08:00
|
|
|
pos; \
|
2014-12-12 09:36:14 +08:00
|
|
|
pos = hlist_entry_safe(rcu_dereference_raw(hlist_next_rcu( \
|
|
|
|
&(pos)->member)), typeof(*(pos)), member))
|
2010-03-18 04:31:11 +08:00
|
|
|
|
2010-05-03 18:50:14 +08:00
|
|
|
/**
|
|
|
|
* hlist_for_each_entry_continue_rcu_bh - iterate over a hlist continuing after current point
|
hlist: drop the node parameter from iterators
I'm not sure why, but the hlist for each entry iterators were conceived
list_for_each_entry(pos, head, member)
The hlist ones were greedy and wanted an extra parameter:
hlist_for_each_entry(tpos, pos, head, member)
Why did they need an extra pos parameter? I'm not quite sure. Not only
they don't really need it, it also prevents the iterator from looking
exactly like the list iterator, which is unfortunate.
Besides the semantic patch, there was some manual work required:
- Fix up the actual hlist iterators in linux/list.h
- Fix up the declaration of other iterators based on the hlist ones.
- A very small amount of places were using the 'node' parameter, this
was modified to use 'obj->member' instead.
- Coccinelle didn't handle the hlist_for_each_entry_safe iterator
properly, so those had to be fixed up manually.
The semantic patch which is mostly the work of Peter Senna Tschudin is here:
@@
iterator name hlist_for_each_entry, hlist_for_each_entry_continue, hlist_for_each_entry_from, hlist_for_each_entry_rcu, hlist_for_each_entry_rcu_bh, hlist_for_each_entry_continue_rcu_bh, for_each_busy_worker, ax25_uid_for_each, ax25_for_each, inet_bind_bucket_for_each, sctp_for_each_hentry, sk_for_each, sk_for_each_rcu, sk_for_each_from, sk_for_each_safe, sk_for_each_bound, hlist_for_each_entry_safe, hlist_for_each_entry_continue_rcu, nr_neigh_for_each, nr_neigh_for_each_safe, nr_node_for_each, nr_node_for_each_safe, for_each_gfn_indirect_valid_sp, for_each_gfn_sp, for_each_host;
type T;
expression a,c,d,e;
identifier b;
statement S;
@@
-T b;
<+... when != b
(
hlist_for_each_entry(a,
- b,
c, d) S
|
hlist_for_each_entry_continue(a,
- b,
c) S
|
hlist_for_each_entry_from(a,
- b,
c) S
|
hlist_for_each_entry_rcu(a,
- b,
c, d) S
|
hlist_for_each_entry_rcu_bh(a,
- b,
c, d) S
|
hlist_for_each_entry_continue_rcu_bh(a,
- b,
c) S
|
for_each_busy_worker(a, c,
- b,
d) S
|
ax25_uid_for_each(a,
- b,
c) S
|
ax25_for_each(a,
- b,
c) S
|
inet_bind_bucket_for_each(a,
- b,
c) S
|
sctp_for_each_hentry(a,
- b,
c) S
|
sk_for_each(a,
- b,
c) S
|
sk_for_each_rcu(a,
- b,
c) S
|
sk_for_each_from
-(a, b)
+(a)
S
+ sk_for_each_from(a) S
|
sk_for_each_safe(a,
- b,
c, d) S
|
sk_for_each_bound(a,
- b,
c) S
|
hlist_for_each_entry_safe(a,
- b,
c, d, e) S
|
hlist_for_each_entry_continue_rcu(a,
- b,
c) S
|
nr_neigh_for_each(a,
- b,
c) S
|
nr_neigh_for_each_safe(a,
- b,
c, d) S
|
nr_node_for_each(a,
- b,
c) S
|
nr_node_for_each_safe(a,
- b,
c, d) S
|
- for_each_gfn_sp(a, c, d, b) S
+ for_each_gfn_sp(a, c, d) S
|
- for_each_gfn_indirect_valid_sp(a, c, d, b) S
+ for_each_gfn_indirect_valid_sp(a, c, d) S
|
for_each_host(a,
- b,
c) S
|
for_each_host_safe(a,
- b,
c, d) S
|
for_each_mesh_entry(a,
- b,
c, d) S
)
...+>
[akpm@linux-foundation.org: drop bogus change from net/ipv4/raw.c]
[akpm@linux-foundation.org: drop bogus hunk from net/ipv6/raw.c]
[akpm@linux-foundation.org: checkpatch fixes]
[akpm@linux-foundation.org: fix warnings]
[akpm@linux-foudnation.org: redo intrusive kvm changes]
Tested-by: Peter Senna Tschudin <peter.senna@gmail.com>
Acked-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
Cc: Wu Fengguang <fengguang.wu@intel.com>
Cc: Marcelo Tosatti <mtosatti@redhat.com>
Cc: Gleb Natapov <gleb@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2013-02-28 09:06:00 +08:00
|
|
|
* @pos: the type * to use as a loop cursor.
|
2010-05-03 18:50:14 +08:00
|
|
|
* @member: the name of the hlist_node within the struct.
|
|
|
|
*/
|
hlist: drop the node parameter from iterators
I'm not sure why, but the hlist for each entry iterators were conceived
list_for_each_entry(pos, head, member)
The hlist ones were greedy and wanted an extra parameter:
hlist_for_each_entry(tpos, pos, head, member)
Why did they need an extra pos parameter? I'm not quite sure. Not only
they don't really need it, it also prevents the iterator from looking
exactly like the list iterator, which is unfortunate.
Besides the semantic patch, there was some manual work required:
- Fix up the actual hlist iterators in linux/list.h
- Fix up the declaration of other iterators based on the hlist ones.
- A very small amount of places were using the 'node' parameter, this
was modified to use 'obj->member' instead.
- Coccinelle didn't handle the hlist_for_each_entry_safe iterator
properly, so those had to be fixed up manually.
The semantic patch which is mostly the work of Peter Senna Tschudin is here:
@@
iterator name hlist_for_each_entry, hlist_for_each_entry_continue, hlist_for_each_entry_from, hlist_for_each_entry_rcu, hlist_for_each_entry_rcu_bh, hlist_for_each_entry_continue_rcu_bh, for_each_busy_worker, ax25_uid_for_each, ax25_for_each, inet_bind_bucket_for_each, sctp_for_each_hentry, sk_for_each, sk_for_each_rcu, sk_for_each_from, sk_for_each_safe, sk_for_each_bound, hlist_for_each_entry_safe, hlist_for_each_entry_continue_rcu, nr_neigh_for_each, nr_neigh_for_each_safe, nr_node_for_each, nr_node_for_each_safe, for_each_gfn_indirect_valid_sp, for_each_gfn_sp, for_each_host;
type T;
expression a,c,d,e;
identifier b;
statement S;
@@
-T b;
<+... when != b
(
hlist_for_each_entry(a,
- b,
c, d) S
|
hlist_for_each_entry_continue(a,
- b,
c) S
|
hlist_for_each_entry_from(a,
- b,
c) S
|
hlist_for_each_entry_rcu(a,
- b,
c, d) S
|
hlist_for_each_entry_rcu_bh(a,
- b,
c, d) S
|
hlist_for_each_entry_continue_rcu_bh(a,
- b,
c) S
|
for_each_busy_worker(a, c,
- b,
d) S
|
ax25_uid_for_each(a,
- b,
c) S
|
ax25_for_each(a,
- b,
c) S
|
inet_bind_bucket_for_each(a,
- b,
c) S
|
sctp_for_each_hentry(a,
- b,
c) S
|
sk_for_each(a,
- b,
c) S
|
sk_for_each_rcu(a,
- b,
c) S
|
sk_for_each_from
-(a, b)
+(a)
S
+ sk_for_each_from(a) S
|
sk_for_each_safe(a,
- b,
c, d) S
|
sk_for_each_bound(a,
- b,
c) S
|
hlist_for_each_entry_safe(a,
- b,
c, d, e) S
|
hlist_for_each_entry_continue_rcu(a,
- b,
c) S
|
nr_neigh_for_each(a,
- b,
c) S
|
nr_neigh_for_each_safe(a,
- b,
c, d) S
|
nr_node_for_each(a,
- b,
c) S
|
nr_node_for_each_safe(a,
- b,
c, d) S
|
- for_each_gfn_sp(a, c, d, b) S
+ for_each_gfn_sp(a, c, d) S
|
- for_each_gfn_indirect_valid_sp(a, c, d, b) S
+ for_each_gfn_indirect_valid_sp(a, c, d) S
|
for_each_host(a,
- b,
c) S
|
for_each_host_safe(a,
- b,
c, d) S
|
for_each_mesh_entry(a,
- b,
c, d) S
)
...+>
[akpm@linux-foundation.org: drop bogus change from net/ipv4/raw.c]
[akpm@linux-foundation.org: drop bogus hunk from net/ipv6/raw.c]
[akpm@linux-foundation.org: checkpatch fixes]
[akpm@linux-foundation.org: fix warnings]
[akpm@linux-foudnation.org: redo intrusive kvm changes]
Tested-by: Peter Senna Tschudin <peter.senna@gmail.com>
Acked-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
Cc: Wu Fengguang <fengguang.wu@intel.com>
Cc: Marcelo Tosatti <mtosatti@redhat.com>
Cc: Gleb Natapov <gleb@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2013-02-28 09:06:00 +08:00
|
|
|
#define hlist_for_each_entry_continue_rcu_bh(pos, member) \
|
2014-12-12 09:36:14 +08:00
|
|
|
for (pos = hlist_entry_safe(rcu_dereference_bh(hlist_next_rcu( \
|
|
|
|
&(pos)->member)), typeof(*(pos)), member); \
|
hlist: drop the node parameter from iterators
I'm not sure why, but the hlist for each entry iterators were conceived
list_for_each_entry(pos, head, member)
The hlist ones were greedy and wanted an extra parameter:
hlist_for_each_entry(tpos, pos, head, member)
Why did they need an extra pos parameter? I'm not quite sure. Not only
they don't really need it, it also prevents the iterator from looking
exactly like the list iterator, which is unfortunate.
Besides the semantic patch, there was some manual work required:
- Fix up the actual hlist iterators in linux/list.h
- Fix up the declaration of other iterators based on the hlist ones.
- A very small amount of places were using the 'node' parameter, this
was modified to use 'obj->member' instead.
- Coccinelle didn't handle the hlist_for_each_entry_safe iterator
properly, so those had to be fixed up manually.
The semantic patch which is mostly the work of Peter Senna Tschudin is here:
@@
iterator name hlist_for_each_entry, hlist_for_each_entry_continue, hlist_for_each_entry_from, hlist_for_each_entry_rcu, hlist_for_each_entry_rcu_bh, hlist_for_each_entry_continue_rcu_bh, for_each_busy_worker, ax25_uid_for_each, ax25_for_each, inet_bind_bucket_for_each, sctp_for_each_hentry, sk_for_each, sk_for_each_rcu, sk_for_each_from, sk_for_each_safe, sk_for_each_bound, hlist_for_each_entry_safe, hlist_for_each_entry_continue_rcu, nr_neigh_for_each, nr_neigh_for_each_safe, nr_node_for_each, nr_node_for_each_safe, for_each_gfn_indirect_valid_sp, for_each_gfn_sp, for_each_host;
type T;
expression a,c,d,e;
identifier b;
statement S;
@@
-T b;
<+... when != b
(
hlist_for_each_entry(a,
- b,
c, d) S
|
hlist_for_each_entry_continue(a,
- b,
c) S
|
hlist_for_each_entry_from(a,
- b,
c) S
|
hlist_for_each_entry_rcu(a,
- b,
c, d) S
|
hlist_for_each_entry_rcu_bh(a,
- b,
c, d) S
|
hlist_for_each_entry_continue_rcu_bh(a,
- b,
c) S
|
for_each_busy_worker(a, c,
- b,
d) S
|
ax25_uid_for_each(a,
- b,
c) S
|
ax25_for_each(a,
- b,
c) S
|
inet_bind_bucket_for_each(a,
- b,
c) S
|
sctp_for_each_hentry(a,
- b,
c) S
|
sk_for_each(a,
- b,
c) S
|
sk_for_each_rcu(a,
- b,
c) S
|
sk_for_each_from
-(a, b)
+(a)
S
+ sk_for_each_from(a) S
|
sk_for_each_safe(a,
- b,
c, d) S
|
sk_for_each_bound(a,
- b,
c) S
|
hlist_for_each_entry_safe(a,
- b,
c, d, e) S
|
hlist_for_each_entry_continue_rcu(a,
- b,
c) S
|
nr_neigh_for_each(a,
- b,
c) S
|
nr_neigh_for_each_safe(a,
- b,
c, d) S
|
nr_node_for_each(a,
- b,
c) S
|
nr_node_for_each_safe(a,
- b,
c, d) S
|
- for_each_gfn_sp(a, c, d, b) S
+ for_each_gfn_sp(a, c, d) S
|
- for_each_gfn_indirect_valid_sp(a, c, d, b) S
+ for_each_gfn_indirect_valid_sp(a, c, d) S
|
for_each_host(a,
- b,
c) S
|
for_each_host_safe(a,
- b,
c, d) S
|
for_each_mesh_entry(a,
- b,
c, d) S
)
...+>
[akpm@linux-foundation.org: drop bogus change from net/ipv4/raw.c]
[akpm@linux-foundation.org: drop bogus hunk from net/ipv6/raw.c]
[akpm@linux-foundation.org: checkpatch fixes]
[akpm@linux-foundation.org: fix warnings]
[akpm@linux-foudnation.org: redo intrusive kvm changes]
Tested-by: Peter Senna Tschudin <peter.senna@gmail.com>
Acked-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
Cc: Wu Fengguang <fengguang.wu@intel.com>
Cc: Marcelo Tosatti <mtosatti@redhat.com>
Cc: Gleb Natapov <gleb@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2013-02-28 09:06:00 +08:00
|
|
|
pos; \
|
2014-12-12 09:36:14 +08:00
|
|
|
pos = hlist_entry_safe(rcu_dereference_bh(hlist_next_rcu( \
|
|
|
|
&(pos)->member)), typeof(*(pos)), member))
|
2010-05-03 18:50:14 +08:00
|
|
|
|
2014-12-02 15:00:30 +08:00
|
|
|
/**
|
|
|
|
* hlist_for_each_entry_from_rcu - iterate over a hlist continuing from current point
|
|
|
|
* @pos: the type * to use as a loop cursor.
|
|
|
|
* @member: the name of the hlist_node within the struct.
|
|
|
|
*/
|
|
|
|
#define hlist_for_each_entry_from_rcu(pos, member) \
|
|
|
|
for (; pos; \
|
2015-03-26 13:27:08 +08:00
|
|
|
pos = hlist_entry_safe(rcu_dereference_raw(hlist_next_rcu( \
|
|
|
|
&(pos)->member)), typeof(*(pos)), member))
|
2010-03-18 04:31:11 +08:00
|
|
|
|
2008-05-13 03:21:05 +08:00
|
|
|
#endif /* __KERNEL__ */
|
|
|
|
#endif
|