diff options
author | David S. Miller <davem@davemloft.net> | 2018-03-16 19:31:19 +0300 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2018-03-16 19:31:19 +0300 |
commit | ce627a1b10e6dd506fad4655588d7d75cd86e41c (patch) | |
tree | 4c627299436d5e6218cbb07d6bd28ca45e8a4f4e | |
parent | 320bd6de79ef0de1ece7c184469a722de690ccb0 (diff) | |
parent | b0f3debc9a1284d6b861e3f7cce0d119e6cd601d (diff) | |
download | linux-ce627a1b10e6dd506fad4655588d7d75cd86e41c.tar.xz |
Merge branch 'rtnl_lock_killable'
Kirill Tkhai says:
====================
Introduce rtnl_lock_killable()
rtnl_lock() is widely used mutex in kernel. Some of kernel code
does memory allocations under it. In case of memory deficit this
may invoke OOM killer, but the problem is a killed task can't
exit if it's waiting for the mutex. This may be a reason of deadlock
and panic.
This patchset adds a new primitive, which responds on SIGKILL,
and it allows to use it in the places, where we don't want
to sleep forever. Also, the first place is made to use it.
====================
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | include/linux/rtnetlink.h | 1 | ||||
-rw-r--r-- | net/core/dev.c | 3 | ||||
-rw-r--r-- | net/core/rtnetlink.c | 6 |
3 files changed, 9 insertions, 1 deletions
diff --git a/include/linux/rtnetlink.h b/include/linux/rtnetlink.h index 3573b4bf2fdf..562a175c35a9 100644 --- a/include/linux/rtnetlink.h +++ b/include/linux/rtnetlink.h @@ -33,6 +33,7 @@ extern void rtnl_lock(void); extern void rtnl_unlock(void); extern int rtnl_trylock(void); extern int rtnl_is_locked(void); +extern int rtnl_lock_killable(void); extern wait_queue_head_t netdev_unregistering_wq; extern struct rw_semaphore net_sem; diff --git a/net/core/dev.c b/net/core/dev.c index 12a9aad0b057..d8887cc38e7b 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -8018,7 +8018,8 @@ int register_netdev(struct net_device *dev) { int err; - rtnl_lock(); + if (rtnl_lock_killable()) + return -EINTR; err = register_netdevice(dev); rtnl_unlock(); return err; diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c index 67f375cfb982..87079eaa871b 100644 --- a/net/core/rtnetlink.c +++ b/net/core/rtnetlink.c @@ -75,6 +75,12 @@ void rtnl_lock(void) } EXPORT_SYMBOL(rtnl_lock); +int rtnl_lock_killable(void) +{ + return mutex_lock_killable(&rtnl_mutex); +} +EXPORT_SYMBOL(rtnl_lock_killable); + static struct sk_buff *defer_kfree_skb_list; void rtnl_kfree_skbs(struct sk_buff *head, struct sk_buff *tail) { |