[<prev] [next>] [day] [month] [year] [list]
Message-ID: <CY1PR11MB0491FD9134088601302F87B5AAAE0@CY1PR11MB0491.namprd11.prod.outlook.com>
Date: Wed, 17 Feb 2016 07:50:12 +0000
From: Xianpeng Zhao <xpzhao@...ohive.com>
To: "davem@...emloft.net" <davem@...emloft.net>,
"kuznet@....inr.ac.ru" <kuznet@....inr.ac.ru>,
"jmorris@...ei.org" <jmorris@...ei.org>,
"yoshfuji@...ux-ipv6.org" <yoshfuji@...ux-ipv6.org>,
"kaber@...sh.net" <kaber@...sh.net>,
"netdev@...r.kernel.org" <netdev@...r.kernel.org>
Subject: [PATCH] When rtnl_trylock failed, wait a time to start another try;
It can avoid the dead lock caused by the priority reverse
Hi,
I have find a problem in my system, I found there have a chance that cause the system enter dead loop when try to get the rtnl lock in the sysctl function in net/ipv6/addrconf.c
The situation should like this, there are 2 processes may need get the rtnl lock, we call them process A and process B, A have high priority than B.
B need get the rtnl lock to do something, when B schedule out without release the lock; At this time, the A start to run "echo 1 > /proc/sys/net/ipv6/conf/<ifname>/disable_ipv6", the echo process will run to this code:
if (!rtnl_trylock())
return restart_syscall();
Because the rtnl lock was hold by process B, so here the try will be failure, and run the restart_syscall to let the sys_write do again, even try many times, because the B have very lower priority, the lock was hard to be released, so the echo process created by A will enter a loop of restart system call.
In my case it is the wireless_nlevent_process in process kworker taken the rtnl lock, and another higher priority process need use echo to disable IPv6 met this problem.
I am not very sure, but I think it is better to let the process sleep a while instead of try it again and again without any delay.
Expects, what's your opinions?
Signed-off-by: Xianpeng Zhao <xpzhao@...ohive.com>
---
net/ipv6/addrconf.c | 20 +++++++++++++++-----
1 files changed, 15 insertions(+), 5 deletions(-)
diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index 38eedde..f06a520 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -754,8 +754,10 @@ static int addrconf_fixup_forwarding(struct ctl_table *table, int *p, int newf)
struct net *net;
int old;
- if (!rtnl_trylock())
+ if (!rtnl_trylock()) {
+ schedule_timeout_uninterruptible(1);
return restart_syscall();
+ }
net = (struct net *)table->extra2;
old = *p;
@@ -811,8 +813,10 @@ static int addrconf_fixup_linkdown(struct ctl_table *table, int *p, int newf)
struct net *net;
int old;
- if (!rtnl_trylock())
+ if (!rtnl_trylock()) {
+ schedule_timeout_uninterruptible(1);
return restart_syscall();
+ }
net = (struct net *)table->extra2;
old = *p;
@@ -5304,8 +5308,10 @@ static int addrconf_disable_ipv6(struct ctl_table *table, int *p, int newf)
struct net *net;
int old;
- if (!rtnl_trylock())
+ if (!rtnl_trylock()) {
+ schedule_timeout_uninterruptible(1);
return restart_syscall();
+ }
net = (struct net *)table->extra2;
old = *p;
@@ -5367,8 +5373,10 @@ int addrconf_sysctl_proxy_ndp(struct ctl_table *ctl, int write,
if (write && old != new) {
struct net *net = ctl->extra2;
- if (!rtnl_trylock())
+ if (!rtnl_trylock()) {
+ schedule_timeout_uninterruptible(1);
return restart_syscall();
+ }
if (valp == &net->ipv6.devconf_dflt->proxy_ndp)
inet6_netconf_notify_devconf(net, NETCONFA_PROXY_NEIGH,
@@ -5408,8 +5416,10 @@ static int addrconf_sysctl_stable_secret(struct ctl_table *ctl, int write,
lctl.maxlen = IPV6_MAX_STRLEN;
lctl.data = str;
- if (!rtnl_trylock())
+ if (!rtnl_trylock()) {
+ schedule_timeout_uninterruptible(1);
return restart_syscall();
+ }
if (!write && !secret->initialized) {
err = -EIO;
--
1.7.1
Powered by blists - more mailing lists