netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pavel Vasilyev <pavel@pavlinux.ru>
To: Shan Wei <shanwei@cn.fujitsu.com>
Cc: netdev@vger.kernel.org
Subject: Re: [PATCH] Sysctl interface to UNIX_INFLIGHT_TRIGGER_GC v.3
Date: Fri, 10 Dec 2010 15:48:34 +0300	[thread overview]
Message-ID: <4D0221A2.4010602@pavlinux.ru> (raw)
In-Reply-To: <4D01A26C.8060608@cn.fujitsu.com>

[-- Attachment #1: Type: text/plain, Size: 641 bytes --]

On 10.12.2010 06:45, Shan Wei wrote:
> Pavel Vasilyev wrote, at 12/10/2010 01:26 AM:
>> Sysctl interface to UNIX_INFLIGHT_TRIGGER_GC.
>> IMHO convenient for testing.
>>
>> +inflight_trigger_gc - INTEGER
>> +	The maximal number of inflight sockets for force garbage collect.
>> +
>> +	Default: 16000
> 
> 1) For lower payload and enough memory, it's not necessary to force garbage collection.
> So set it to 0, disable gc.


May be, set default to 2000, and zero to disable


> 2) Copy your patch to the mail, for other guys to review it.

 Where me find other guys? :)



-- 

                                                         Pavel.

[-- Attachment #2: sysctl.inflight_trigger_gc.patch --]
[-- Type: text/x-patch, Size: 2897 bytes --]

 
 Documentation/networking/ip-sysctl.txt |    6 ++++++
 include/net/af_unix.h                  |    1 +
 net/unix/garbage.c    	                |    8 +++++---
 net/unix/sysctl_net_unix.c             |    9 +++++++++
 4 files changed, 21 insertions(+), 3 deletions(-)

diff --git a/Documentation/networking/ip-sysctl.txt b/Documentation/networking/ip-sysctl.txt
index 3c5e465..f0c4b6b 100644
--- a/Documentation/networking/ip-sysctl.txt
+++ b/Documentation/networking/ip-sysctl.txt
@@ -1463,6 +1463,12 @@ max_dgram_qlen - INTEGER
 
 	Default: 10
 
+inflight_trigger_gc - INTEGER
+	The maximal number of inflight sockets for force garbage collect.
+
+	0 - disable force garbage collection.
+
+	Default: 2000
 
 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..c2f3e98 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 = 2000;
 
 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,8 +266,11 @@ 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 (!sysctl_inflight_trigger_gc && 
+		    (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 <pavel@pavlinux.ru>


  reply	other threads:[~2010-12-10 12:49 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-12-09 17:26 [PATCH] Sysctl interface to UNIX_INFLIGHT_TRIGGER_GC v.2 Pavel Vasilyev
2010-12-10  3:45 ` Shan Wei
2010-12-10 12:48   ` Pavel Vasilyev [this message]
2010-12-10 13:04     ` [PATCH] Sysctl interface to UNIX_INFLIGHT_TRIGGER_GC v.3 Eric Dumazet
2010-12-10 20:56       ` David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4D0221A2.4010602@pavlinux.ru \
    --to=pavel@pavlinux.ru \
    --cc=netdev@vger.kernel.org \
    --cc=shanwei@cn.fujitsu.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).