From patchwork Thu Dec 9 17:26:14 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Vasilyev X-Patchwork-Id: 74950 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id A875DB6EF1 for ; Fri, 10 Dec 2010 04:31:17 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756070Ab0LIRaz (ORCPT ); Thu, 9 Dec 2010 12:30:55 -0500 Received: from imp03.mtu.ru ([62.5.255.20]:52185 "EHLO imp03.mtu.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755901Ab0LIRay (ORCPT ); Thu, 9 Dec 2010 12:30:54 -0500 Received: from imp02.mtu.ru ([62.5.255.19]) by imp03.mtu.ru with bizsmtp id h5XL1f0030Rt8vS015XLhG; Thu, 09 Dec 2010 20:31:20 +0300 Received: from ss27-so02.mtu.ru ([195.34.34.250]) by imp02.mtu.ru with bizsmtp id h5Tc1f01U5PoRs3015Tc8f; Thu, 09 Dec 2010 20:27:36 +0300 Received: from imp02.mtu.ru (alt-proxy-1.mtu.ru [62.5.255.74]) by ss27-so02.mtu.ru (Postfix) with ESMTP id 82D88228571 for ; Thu, 9 Dec 2010 20:27:31 +0300 (MSK) Received: from [192.168.1.2] ([91.76.5.135]) by imp02.mtu.ru with bizsmtp id h5Tc1f00P2unN37015Tc8F; Thu, 09 Dec 2010 20:27:36 +0300 Message-ID: <4D011136.8030404@pavlinux.ru> Date: Thu, 09 Dec 2010 20:26:14 +0300 From: Pavel Vasilyev Reply-To: pavel@pavlinux.ru User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.12) Gecko/20101026 SUSE/3.1.6 Thunderbird/3.1.6 MIME-Version: 1.0 To: netdev@vger.kernel.org Subject: [PATCH] Sysctl interface to UNIX_INFLIGHT_TRIGGER_GC v.2 X-Spam-Flag: NO X-Spam-Yversion: Spamooborona-3.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Sysctl interface to UNIX_INFLIGHT_TRIGGER_GC. IMHO convenient for testing. Documentation/networking/ip-sysctl.txt | 4 ++++ include/net/af_unix.h | 1 + net/unix/garbage.c | 5 ++--- net/unix/sysctl_net_unix.c | 9 +++++++++ 4 files changed, 16 insertions(+), 3 deletions(-) diff --git a/Documentation/networking/ip-sysctl.txt b/Documentation/networking/ip-sysctl.txt index 3c5e465..11e6adf 100644 --- a/Documentation/networking/ip-sysctl.txt +++ b/Documentation/networking/ip-sysctl.txt @@ -1463,6 +1463,10 @@ max_dgram_qlen - INTEGER Default: 10 +inflight_trigger_gc - INTEGER + The maximal number of inflight sockets for force garbage collect. + + Default: 16000 UNDOCUMENTED: diff --git a/include/net/af_unix.h b/include/net/af_unix.h index 18e5c3f..ea580e4 100644 --- a/include/net/af_unix.h +++ b/include/net/af_unix.h @@ -15,6 +15,7 @@ extern struct sock *unix_get_socket(struct file *filp); #define UNIX_HASH_SIZE 256 extern unsigned int unix_tot_inflight; +extern unsigned int sysctl_inflight_trigger_gc; struct unix_address { atomic_t refcnt; diff --git a/net/unix/garbage.c b/net/unix/garbage.c index f89f83b..c646c6b 100644 --- a/net/unix/garbage.c +++ b/net/unix/garbage.c @@ -94,7 +94,7 @@ static DEFINE_SPINLOCK(unix_gc_lock); static DECLARE_WAIT_QUEUE_HEAD(unix_gc_wait); unsigned int unix_tot_inflight; - +unsigned int sysctl_inflight_trigger_gc = 16000; struct sock *unix_get_socket(struct file *filp) { @@ -259,7 +259,6 @@ static void inc_inflight_move_tail(struct unix_sock *u) } static bool gc_in_progress = false; -#define UNIX_INFLIGHT_TRIGGER_GC 16000 void wait_for_unix_gc(void) { @@ -267,7 +266,7 @@ void wait_for_unix_gc(void) * If number of inflight sockets is insane, * force a garbage collect right now. */ - if (unix_tot_inflight > UNIX_INFLIGHT_TRIGGER_GC && !gc_in_progress) + if (unix_tot_inflight > sysctl_inflight_trigger_gc && !gc_in_progress) unix_gc(); wait_event(unix_gc_wait, gc_in_progress == false); } diff --git a/net/unix/sysctl_net_unix.c b/net/unix/sysctl_net_unix.c index 397cffe..c807235 100644 --- a/net/unix/sysctl_net_unix.c +++ b/net/unix/sysctl_net_unix.c @@ -23,6 +23,13 @@ static ctl_table unix_table[] = { .mode = 0644, .proc_handler = proc_dointvec }, + { + .procname = "inflight_trigger_gc", + .data = &sysctl_inflight_trigger_gc, + .maxlen = sizeof(int), + .mode = 0644, + .proc_handler = proc_dointvec + }, { } }; @@ -41,6 +48,8 @@ int __net_init unix_sysctl_register(struct net *net) goto err_alloc; table[0].data = &net->unx.sysctl_max_dgram_qlen; + table[1].data = &sysctl_inflight_trigger_gc; + net->unx.ctl = register_net_sysctl_table(net, unix_path, table); if (net->unx.ctl == NULL) goto err_reg; --- Signed-off-by: Pavel Vasilyev