netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net/pppoe: make number of hash bits configurable
@ 2023-05-17  8:00 Jaco Kroon
  2023-05-17 12:10 ` patchwork-bot+netdevbpf
  0 siblings, 1 reply; 3+ messages in thread
From: Jaco Kroon @ 2023-05-17  8:00 UTC (permalink / raw)
  To: netdev

When running large numbers of pppoe connections, a bucket size of 16 may
be too small and 256 may be more appropriate.  This sacrifices some RAM
but should result in faster processing of incoming PPPoE frames.

On our systems we run upwards of 150 PPPoE connections at any point in
time, and we suspect we're starting to see the effects of this small
number of buckets.

The legal values according to pppoe.c is anything that when 8 is divided
by that results in a modulo of 0, ie, 1, 2, 4 and 8.

The size of the per-underlying-interface structure is:

sizeof(rwlock_t) + sizeof(pppox_sock*) * PPPOE_HASH_SIZE.

Assuming a 64-bit pointer this will result in just over a 2KiB structure
for PPPOE_HASH_BITS=8, which will likely result in a 4KiB allocation,
which for us at least is acceptable.

Not sure what the minimum allocation size is, and thus if values of 1
and 2 truly make sense.  Default results in historic sizing and
behaviour.

Signed-off-by: Jaco Kroon <jaco@uls.co.za>
---
 drivers/net/ppp/Kconfig | 34 ++++++++++++++++++++++++++++++++++
 drivers/net/ppp/pppoe.c |  2 +-
 2 files changed, 35 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ppp/Kconfig b/drivers/net/ppp/Kconfig
index ac4d162d9455..2fbcae31fc02 100644
--- a/drivers/net/ppp/Kconfig
+++ b/drivers/net/ppp/Kconfig
@@ -129,6 +129,40 @@ config PPPOE
 	  which contains instruction on how to use this driver (under
 	  the heading "Kernel mode PPPoE").
 
+choice
+	prompt "Number of PPPoE hash bits"
+	default PPPOE_HASH_BITS_4
+	depends on PPPOE
+	help
+		Select the number of bits used for hashing PPPoE interfaces.
+
+		Larger sizes reduces the risk of hash collisions at the cost
+		of slightly increased memory usage.
+
+		This hash table is on a per outer ethernet interface.
+
+config PPPOE_HASH_BITS_2
+	bool "1 bit (2 buckets)"
+
+config PPPOE_HASH_BITS_2
+	bool "2 bits (4 buckets)"
+
+config PPPOE_HASH_BITS_4
+	bool "4 bits (16 buckets)"
+
+config PPPOE_HASH_BITS_8
+	bool "8 bits (256 buckets)"
+
+endchoice
+
+config PPPOE_HASH_BITS
+	int
+	default 1 if PPPOE_HASH_BITS_1
+	default 2 if PPPOE_HASH_BITS_2
+	default 4 if PPPOE_HASH_BITS_4
+	default 8 if PPPOE_HASH_BITS_8
+	default 4
+
 config PPTP
 	tristate "PPP over IPv4 (PPTP)"
 	depends on PPP && NET_IPGRE_DEMUX
diff --git a/drivers/net/ppp/pppoe.c b/drivers/net/ppp/pppoe.c
index ce2cbb5903d7..3b79c603b936 100644
--- a/drivers/net/ppp/pppoe.c
+++ b/drivers/net/ppp/pppoe.c
@@ -80,7 +80,7 @@
 
 #include <linux/uaccess.h>
 
-#define PPPOE_HASH_BITS 4
+#define PPPOE_HASH_BITS CONFIG_PPPOE_HASH_BITS
 #define PPPOE_HASH_SIZE (1 << PPPOE_HASH_BITS)
 #define PPPOE_HASH_MASK	(PPPOE_HASH_SIZE - 1)
 
-- 
2.39.3


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

* Re: [PATCH] net/pppoe: make number of hash bits configurable
  2023-05-17  8:00 [PATCH] net/pppoe: make number of hash bits configurable Jaco Kroon
@ 2023-05-17 12:10 ` patchwork-bot+netdevbpf
  2023-05-17 12:35   ` Jaco Kroon
  0 siblings, 1 reply; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2023-05-17 12:10 UTC (permalink / raw)
  To: Jaco Kroon; +Cc: netdev

Hello:

This patch was applied to netdev/net-next.git (main)
by David S. Miller <davem@davemloft.net>:

On Wed, 17 May 2023 10:00:03 +0200 you wrote:
> When running large numbers of pppoe connections, a bucket size of 16 may
> be too small and 256 may be more appropriate.  This sacrifices some RAM
> but should result in faster processing of incoming PPPoE frames.
> 
> On our systems we run upwards of 150 PPPoE connections at any point in
> time, and we suspect we're starting to see the effects of this small
> number of buckets.
> 
> [...]

Here is the summary with links:
  - net/pppoe: make number of hash bits configurable
    https://git.kernel.org/netdev/net-next/c/96ba44c637b0

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



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

* Re: [PATCH] net/pppoe: make number of hash bits configurable
  2023-05-17 12:10 ` patchwork-bot+netdevbpf
@ 2023-05-17 12:35   ` Jaco Kroon
  0 siblings, 0 replies; 3+ messages in thread
From: Jaco Kroon @ 2023-05-17 12:35 UTC (permalink / raw)
  To: patchwork-bot+netdevbpf; +Cc: netdev

Wow that was quick.  Thank you for applying, much appreciated.

Kind regards,
Jaco

On 2023/05/17 14:10, patchwork-bot+netdevbpf@kernel.org wrote:

> Hello:
>
> This patch was applied to netdev/net-next.git (main)
> by David S. Miller <davem@davemloft.net>:
>
> On Wed, 17 May 2023 10:00:03 +0200 you wrote:
>> When running large numbers of pppoe connections, a bucket size of 16 may
>> be too small and 256 may be more appropriate.  This sacrifices some RAM
>> but should result in faster processing of incoming PPPoE frames.
>>
>> On our systems we run upwards of 150 PPPoE connections at any point in
>> time, and we suspect we're starting to see the effects of this small
>> number of buckets.
>>
>> [...]
> Here is the summary with links:
>    - net/pppoe: make number of hash bits configurable
>      https://git.kernel.org/netdev/net-next/c/96ba44c637b0
>
> You are awesome, thank you!

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

end of thread, other threads:[~2023-05-17 14:49 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-05-17  8:00 [PATCH] net/pppoe: make number of hash bits configurable Jaco Kroon
2023-05-17 12:10 ` patchwork-bot+netdevbpf
2023-05-17 12:35   ` Jaco Kroon

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).