0786af6ce3ecdc36c63cb998363730b2b0c7ec42
2 * linux/ipc/ipcns_notifier.c
3 * Copyright (C) 2007 BULL SA. Nadia Derbey
5 * Notification mechanism for ipc namespaces:
6 * The callback routine registered in the memory chain invokes the ipcns
7 * notifier chain with the IPCNS_MEMCHANGED event.
8 * Each callback routine registered in the ipcns namespace recomputes msgmni
9 * for the owning namespace.
12 #include <linux/msg.h>
13 #include <linux/rcupdate.h>
14 #include <linux/notifier.h>
15 #include <linux/nsproxy.h>
16 #include <linux/ipc_namespace.h>
22 static BLOCKING_NOTIFIER_HEAD(ipcns_chain
);
25 static int ipcns_callback(struct notifier_block
*self
,
26 unsigned long action
, void *arg
)
28 struct ipc_namespace
*ns
;
31 case IPCNS_MEMCHANGED
: /* amount of lowmem has changed */
33 * It's time to recompute msgmni
35 ns
= container_of(self
, struct ipc_namespace
, ipcns_nb
);
37 * No need to get a reference on the ns: the 1st job of
38 * free_ipc_ns() is to unregister the callback routine.
39 * blocking_notifier_chain_unregister takes the wr lock to do
41 * When this callback routine is called the rd lock is held by
42 * blocking_notifier_call_chain.
43 * So the ipc ns cannot be freed while we are here.
54 int register_ipcns_notifier(struct ipc_namespace
*ns
)
56 memset(&ns
->ipcns_nb
, 0, sizeof(ns
->ipcns_nb
));
57 ns
->ipcns_nb
.notifier_call
= ipcns_callback
;
58 ns
->ipcns_nb
.priority
= IPCNS_CALLBACK_PRI
;
59 return blocking_notifier_chain_register(&ipcns_chain
, &ns
->ipcns_nb
);
62 int unregister_ipcns_notifier(struct ipc_namespace
*ns
)
64 return blocking_notifier_chain_unregister(&ipcns_chain
,
68 int ipcns_notify(unsigned long val
)
70 return blocking_notifier_call_chain(&ipcns_chain
, val
, NULL
);
This page took 0.030855 seconds and 4 git commands to generate.