Skip to content

Commit 6056415

Browse files
Kirill Tkhaidavem330
authored andcommitted
net: Add comment about pernet_operations methods and synchronization
Make locking scheme be visible for users, and provide a comment what for we are need exit_batch() methods, and when it should be used. Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 8b4e6b3 commit 6056415

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

include/net/net_namespace.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,20 @@ struct net *get_net_ns_by_id(struct net *net, int id);
312312

313313
struct pernet_operations {
314314
struct list_head list;
315+
/*
316+
* Below methods are called without any exclusive locks.
317+
* More than one net may be constructed and destructed
318+
* in parallel on several cpus. Every pernet_operations
319+
* have to keep in mind all other pernet_operations and
320+
* to introduce a locking, if they share common resources.
321+
*
322+
* Exit methods using blocking RCU primitives, such as
323+
* synchronize_rcu(), should be implemented via exit_batch.
324+
* Then, destruction of a group of net requires single
325+
* synchronize_rcu() related to these pernet_operations,
326+
* instead of separate synchronize_rcu() for every net.
327+
* Please, avoid synchronize_rcu() at all, where it's possible.
328+
*/
315329
int (*init)(struct net *net);
316330
void (*exit)(struct net *net);
317331
void (*exit_batch)(struct list_head *net_exit_list);

0 commit comments

Comments
 (0)