]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
net: Add rtnl_lock_killable()
authorKirill Tkhai <ktkhai@virtuozzo.com>
Wed, 14 Mar 2018 19:17:20 +0000 (22:17 +0300)
committerDavid S. Miller <davem@davemloft.net>
Fri, 16 Mar 2018 16:31:19 +0000 (12:31 -0400)
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 patch 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.

Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/linux/rtnetlink.h
net/core/rtnetlink.c

index 3573b4bf2fdf68e6625b14a0b3c623b57485c508..562a175c35a9a9af40268d81c15013d1d6500d4a 100644 (file)
@@ -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;
index 67f375cfb9829806bb8beb86f15acfa3e76b8c4d..87079eaa871bb9c9de477246bd67f5aa40c2f87a 100644 (file)
@@ -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)
 {