forked from TencentOS/TencentOS-kernel
net: sched when reading tcp proc
cat /proc/net/tcp may cause long latency. Add cond_resched() when reading this proc file. Signed-off-by: Hongbo Li <herberthbli@tencent.com>
This commit is contained in:
parent
fcf7481192
commit
61d7e2b266
|
|
@ -278,6 +278,7 @@ extern int sysctl_tcp_loss_init_cwnd;
|
|||
extern int sysctl_tcp_init_cwnd;
|
||||
extern int sysctl_tcp_rto_min;
|
||||
extern int sysctl_tcp_rto_max;
|
||||
extern int sysctl_tcp_proc_sched;
|
||||
|
||||
extern atomic_long_t tcp_memory_allocated;
|
||||
extern struct percpu_counter tcp_sockets_allocated;
|
||||
|
|
|
|||
|
|
@ -771,6 +771,13 @@ static struct ctl_table ipv4_table[] = {
|
|||
.mode = 0644,
|
||||
.proc_handler = proc_dointvec,
|
||||
},
|
||||
{
|
||||
.procname = "tcp_proc_sched",
|
||||
.data = &sysctl_tcp_proc_sched,
|
||||
.maxlen = sizeof(int),
|
||||
.mode = 0644,
|
||||
.proc_handler = proc_dointvec,
|
||||
},
|
||||
{ }
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -85,6 +85,8 @@
|
|||
#include <crypto/hash.h>
|
||||
#include <linux/scatterlist.h>
|
||||
|
||||
int sysctl_tcp_proc_sched __read_mostly = 1;
|
||||
|
||||
#ifdef CONFIG_TCP_MD5SIG
|
||||
static int tcp_v4_md5_hash_hdr(char *md5_hash, const struct tcp_md5sig_key *key,
|
||||
__be32 daddr, __be32 saddr, const struct tcphdr *th);
|
||||
|
|
@ -1966,6 +1968,8 @@ get_sk:
|
|||
return sk;
|
||||
}
|
||||
spin_unlock(&ilb->lock);
|
||||
if (sysctl_tcp_proc_sched)
|
||||
cond_resched();
|
||||
st->offset = 0;
|
||||
if (++st->bucket < INET_LHTABLE_SIZE)
|
||||
goto get_head;
|
||||
|
|
@ -2023,6 +2027,8 @@ static void *established_get_first(struct seq_file *seq)
|
|||
goto out;
|
||||
}
|
||||
spin_unlock_bh(lock);
|
||||
if (sysctl_tcp_proc_sched)
|
||||
cond_resched();
|
||||
}
|
||||
out:
|
||||
return rc;
|
||||
|
|
|
|||
Loading…
Reference in New Issue