public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Sysctl interface to UNIX_INFLIGHT_TRIGGER_GC
@ 2010-12-09  3:34 Pavel Vasilyev
  2010-12-09  4:13 ` Américo Wang
  0 siblings, 1 reply; 5+ messages in thread
From: Pavel Vasilyev @ 2010-12-09  3:34 UTC (permalink / raw)
  To: LKML

Convenient for testing.
Maybe something to add in Documentation/kernel-parameters.txt ?

--- cut ---

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;

--- end of cut ---


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] Sysctl interface to UNIX_INFLIGHT_TRIGGER_GC
  2010-12-09  3:34 [PATCH] Sysctl interface to UNIX_INFLIGHT_TRIGGER_GC Pavel Vasilyev
@ 2010-12-09  4:13 ` Américo Wang
  2010-12-09 11:32   ` [PATCH] Sysctl interface to UNIX_INFLIGHT_TRIGGER_GC v.2 Pavel Vasilyev
  0 siblings, 1 reply; 5+ messages in thread
From: Américo Wang @ 2010-12-09  4:13 UTC (permalink / raw)
  To: Pavel Vasilyev; +Cc: LKML

On Thu, Dec 09, 2010 at 06:34:26AM +0300, Pavel Vasilyev wrote:
>Maybe something to add in Documentation/kernel-parameters.txt ?

No, that is for boot parameters, you need to find something like
Documentation/networking/ip-sysctl.txt.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Sysctl interface to UNIX_INFLIGHT_TRIGGER_GC v.2
  2010-12-09  4:13 ` Américo Wang
@ 2010-12-09 11:32   ` Pavel Vasilyev
  2010-12-09 17:04     ` Randy Dunlap
  0 siblings, 1 reply; 5+ messages in thread
From: Pavel Vasilyev @ 2010-12-09 11:32 UTC (permalink / raw)
  To: Américo Wang; +Cc: LKML

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

On 09.12.2010 07:13, Américo Wang wrote:
> On Thu, Dec 09, 2010 at 06:34:26AM +0300, Pavel Vasilyev wrote:
>> Maybe something to add in Documentation/kernel-parameters.txt ?
> 
> No, that is for boot parameters, you need to find something like
> Documentation/networking/ip-sysctl.txt.
> 

Thanks, added.



-- 

                                                         Pavel.

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

 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 <pavel@pavlinux.ru>

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] Sysctl interface to UNIX_INFLIGHT_TRIGGER_GC v.2
  2010-12-09 11:32   ` [PATCH] Sysctl interface to UNIX_INFLIGHT_TRIGGER_GC v.2 Pavel Vasilyev
@ 2010-12-09 17:04     ` Randy Dunlap
  2010-12-09 17:59       ` Pavel Vasilyev
  0 siblings, 1 reply; 5+ messages in thread
From: Randy Dunlap @ 2010-12-09 17:04 UTC (permalink / raw)
  To: pavel; +Cc: Américo Wang, LKML

On Thu, 09 Dec 2010 14:32:41 +0300 Pavel Vasilyev wrote:

> On 09.12.2010 07:13, Américo Wang wrote:
> > On Thu, Dec 09, 2010 at 06:34:26AM +0300, Pavel Vasilyev wrote:
> >> Maybe something to add in Documentation/kernel-parameters.txt ?
> > 
> > No, that is for boot parameters, you need to find something like
> > Documentation/networking/ip-sysctl.txt.
> > 
> 
> Thanks, added.

Now you need to send this to netdev@vger.kernel.org so that the netdev
people can review it.  Please.

---
~Randy
*** Remember to use Documentation/SubmitChecklist when testing your code ***

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Sysctl interface to UNIX_INFLIGHT_TRIGGER_GC v.2
  2010-12-09 17:04     ` Randy Dunlap
@ 2010-12-09 17:59       ` Pavel Vasilyev
  0 siblings, 0 replies; 5+ messages in thread
From: Pavel Vasilyev @ 2010-12-09 17:59 UTC (permalink / raw)
  To: Randy Dunlap; +Cc: Américo Wang, LKML

On 09.12.2010 20:04, Randy Dunlap wrote:
> On Thu, 09 Dec 2010 14:32:41 +0300 Pavel Vasilyev wrote:
>>>> Maybe something to add in Documentation/kernel-parameters.txt ?
>>> No, that is for boot parameters, you need to find something like
>>> Documentation/networking/ip-sysctl.txt.
>>
>> Thanks, added.
> 
> Now you need to send this to netdev@vger.kernel.org so that the netdev
> people can review it.  Please.
> ---
> ~Randy
> *** Remember to use Documentation/SubmitChecklist when testing your code ***

http://www.spinics.net/lists/netdev/msg149397.html

-- 

                                                         Pavel.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2010-12-09 18:01 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-12-09  3:34 [PATCH] Sysctl interface to UNIX_INFLIGHT_TRIGGER_GC Pavel Vasilyev
2010-12-09  4:13 ` Américo Wang
2010-12-09 11:32   ` [PATCH] Sysctl interface to UNIX_INFLIGHT_TRIGGER_GC v.2 Pavel Vasilyev
2010-12-09 17:04     ` Randy Dunlap
2010-12-09 17:59       ` Pavel Vasilyev

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox