2009-07-27 09:08:51

by Hannes Eder

[permalink] [raw]
Subject: [PATCH] IPVS: logging sizeof(struct ip_vs_conn) on startup

No more guessing, how much memory is used by IPVS for a connection.

Signed-off-by: Hannes Eder <[email protected]>
---
net/netfilter/ipvs/ip_vs_core.c | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/net/netfilter/ipvs/ip_vs_core.c b/net/netfilter/ipvs/ip_vs_core.c
index b021464..5b0997c 100644
--- a/net/netfilter/ipvs/ip_vs_core.c
+++ b/net/netfilter/ipvs/ip_vs_core.c
@@ -1475,7 +1475,8 @@ static int __init ip_vs_init(void)
goto cleanup_conn;
}

- IP_VS_INFO("ipvs loaded.\n");
+ IP_VS_INFO("ipvs loaded (using %Zd bytes/connection).\n",
+ sizeof(struct ip_vs_conn));
return ret;

cleanup_conn:


2009-07-27 09:22:26

by Simon Horman

[permalink] [raw]
Subject: Re: [PATCH] IPVS: logging sizeof(struct ip_vs_conn) on startup

On Mon, Jul 27, 2009 at 11:08:34AM +0200, Hannes Eder wrote:
> No more guessing, how much memory is used by IPVS for a connection.

I like that.

> Signed-off-by: Hannes Eder <[email protected]>

Signed-off-by: Simon Horman <[email protected]>

> ---
> net/netfilter/ipvs/ip_vs_core.c | 3 ++-
> 1 files changed, 2 insertions(+), 1 deletions(-)
>
> diff --git a/net/netfilter/ipvs/ip_vs_core.c b/net/netfilter/ipvs/ip_vs_core.c
> index b021464..5b0997c 100644
> --- a/net/netfilter/ipvs/ip_vs_core.c
> +++ b/net/netfilter/ipvs/ip_vs_core.c
> @@ -1475,7 +1475,8 @@ static int __init ip_vs_init(void)
> goto cleanup_conn;
> }
>
> - IP_VS_INFO("ipvs loaded.\n");
> + IP_VS_INFO("ipvs loaded (using %Zd bytes/connection).\n",
> + sizeof(struct ip_vs_conn));
> return ret;
>
> cleanup_conn:
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/

2009-07-27 09:25:35

by Eric Dumazet

[permalink] [raw]
Subject: Re: [PATCH] IPVS: logging sizeof(struct ip_vs_conn) on startup

Hannes Eder a écrit :
> No more guessing, how much memory is used by IPVS for a connection.
>
> Signed-off-by: Hannes Eder <[email protected]>
> ---
> net/netfilter/ipvs/ip_vs_core.c | 3 ++-
> 1 files changed, 2 insertions(+), 1 deletions(-)
>
> diff --git a/net/netfilter/ipvs/ip_vs_core.c b/net/netfilter/ipvs/ip_vs_core.c
> index b021464..5b0997c 100644
> --- a/net/netfilter/ipvs/ip_vs_core.c
> +++ b/net/netfilter/ipvs/ip_vs_core.c
> @@ -1475,7 +1475,8 @@ static int __init ip_vs_init(void)
> goto cleanup_conn;
> }
>
> - IP_VS_INFO("ipvs loaded.\n");
> + IP_VS_INFO("ipvs loaded (using %Zd bytes/connection).\n",
> + sizeof(struct ip_vs_conn));
> return ret;
>
> cleanup_conn:

Well, ip_vs_conn_cache uses SLAB_HWCACHE_ALIGN, so this should be rounded up
to L1 cache size. Or add "at least" like in line 1080
of net/netfilter/ipvs/ip_vs_conn.c :

IP_VS_DBG(0, "Each connection entry needs %Zd bytes at least\n",
sizeof(struct ip_vs_conn));

2009-07-27 10:34:49

by Hannes Eder

[permalink] [raw]
Subject: Re: [PATCH] IPVS: logging sizeof(struct ip_vs_conn) on startup

On Mon, Jul 27, 2009 at 11:25, Eric Dumazet<[email protected]> wrote:
> Well, ip_vs_conn_cache uses SLAB_HWCACHE_ALIGN, so this should be rounded up
> to L1 cache size. Or add "at least" like in line 1080
> of net/netfilter/ipvs/ip_vs_conn.c :
>
> IP_VS_DBG(0, "Each connection entry needs %Zd bytes at least\n",
> sizeof(struct ip_vs_conn));

Good point. Is there an easy way to figure out how much memory is
wasted for alignment by the slab allocator? Otherwise I vote for the
"at least" approach.

-Hannes

2009-07-27 13:15:53

by Hannes Eder

[permalink] [raw]
Subject: [PATCH v2] IPVS: logging sizeof(struct ip_vs_conn) on startup

No more guessing, how much memory used by IPVS for a connection.

[ The number printed is a lower bound, as ip_vs_conn_cache uses
SLAB_HWCACHE_ALIGN. ]

Signed-off-by: Hannes Eder <[email protected]>
Signed-off-by: Simon Horman <[email protected]>

net/netfilter/ipvs/ip_vs_core.c | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/net/netfilter/ipvs/ip_vs_core.c b/net/netfilter/ipvs/ip_vs_core.c
index b021464..b6bb4a0 100644
--- a/net/netfilter/ipvs/ip_vs_core.c
+++ b/net/netfilter/ipvs/ip_vs_core.c
@@ -1475,7 +1475,8 @@ static int __init ip_vs_init(void)
goto cleanup_conn;
}

- IP_VS_INFO("ipvs loaded.\n");
+ IP_VS_INFO("ipvs loaded (using at least %Zd bytes/connection).\n",
+ sizeof(struct ip_vs_conn));
return ret;

cleanup_conn:

2009-07-27 18:48:39

by David Miller

[permalink] [raw]
Subject: Re: [PATCH v2] IPVS: logging sizeof(struct ip_vs_conn) on startup

From: Hannes Eder <[email protected]>
Date: Mon, 27 Jul 2009 15:13:57 +0200

> No more guessing, how much memory used by IPVS for a connection.
>
> [ The number printed is a lower bound, as ip_vs_conn_cache uses
> SLAB_HWCACHE_ALIGN. ]
>
> Signed-off-by: Hannes Eder <[email protected]>
> Signed-off-by: Simon Horman <[email protected]>

Who needs to know this? A developer?

They can run tools such as 'pahole' et al. to fish out this
information even when only a kernel binary is available.

For the user, it's just noise.

I'm not applying this, sorry.

2009-07-28 00:19:29

by Simon Horman

[permalink] [raw]
Subject: Re: [PATCH v2] IPVS: logging sizeof(struct ip_vs_conn) on startup

On Mon, Jul 27, 2009 at 11:48:45AM -0700, David Miller wrote:
> From: Hannes Eder <[email protected]>
> Date: Mon, 27 Jul 2009 15:13:57 +0200
>
> > No more guessing, how much memory used by IPVS for a connection.
> >
> > [ The number printed is a lower bound, as ip_vs_conn_cache uses
> > SLAB_HWCACHE_ALIGN. ]
> >
> > Signed-off-by: Hannes Eder <[email protected]>
> > Signed-off-by: Simon Horman <[email protected]>
>
> Who needs to know this? A developer?
>
> They can run tools such as 'pahole' et al. to fish out this
> information even when only a kernel binary is available.
>
> For the user, it's just noise.
>
> I'm not applying this, sorry.

Surprisingly its a very common question amongst users,
because they want to know how much memory they need.
It is of course all a bit silly, because the amount of
memory used by the connection table is usually very small,
but people still ask.

2009-07-28 05:39:10

by Eric Dumazet

[permalink] [raw]
Subject: Re: [PATCH v2] IPVS: logging sizeof(struct ip_vs_conn) on startup

Simon Horman a ?crit :
>
> Surprisingly its a very common question amongst users,
> because they want to know how much memory they need.
> It is of course all a bit silly, because the amount of
> memory used by the connection table is usually very small,
> but people still ask.
>

If SLUB is used

$ cat /sys/kernel/slab/ip_vs_conn/object_size

If SLAB is used, take fourth column of :

$ grep ip_vs_conn /proc/slabinfo

BTW these take into account L1 cache size alignment