From 68ac1347b97fc90cda2873844017df679be005a1 Mon Sep 17 00:00:00 2001 From: Sebastian Sumpf Date: Wed, 13 Dec 2023 19:54:50 +0100 Subject: [PATCH] lxip: configure thash/uhash entries to 2048 The number of hash entries for TCP/UDP corresponds to the number of sockets managed by the stack. In case there are more sockets than entries available, buckets will be created to compensate for the lack of space. The default values for TCP (524288) and UDP (65536) are meant for the in kernel that manages all sockets of the user land and leads to very large hash table allocations (>20MB) during initialization. Since on Genode a component has its own instance of the IP stack or uses the VFS server, we do not need these kind of large default settings. issue #2181 --- repos/dde_linux/src/lib/lxip/dummies.cc | 1 - repos/dde_linux/src/lib/lxip/lxc_emul.c | 11 +++++++++++ repos/dde_linux/src/lib/lxip/lxcc_emul.cc | 9 +++++++++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/repos/dde_linux/src/lib/lxip/dummies.cc b/repos/dde_linux/src/lib/lxip/dummies.cc index d9aa5907de..ae1230975c 100644 --- a/repos/dde_linux/src/lib/lxip/dummies.cc +++ b/repos/dde_linux/src/lib/lxip/dummies.cc @@ -316,7 +316,6 @@ DUMMY(-1, kobject_put) DUMMY(-1, kobject_uevent) DUMMY(-1, krealloc) DUMMY(-1, kstrdup) -DUMMY(-1, kstrtoul) DUMMY(-1, ktime_equal) DUMMY(-1, ktime_to_timespec) DUMMY(-1, ktime_to_timeval) diff --git a/repos/dde_linux/src/lib/lxip/lxc_emul.c b/repos/dde_linux/src/lib/lxip/lxc_emul.c index 8b286eaba6..0d242fe0f5 100644 --- a/repos/dde_linux/src/lib/lxip/lxc_emul.c +++ b/repos/dde_linux/src/lib/lxip/lxc_emul.c @@ -485,6 +485,15 @@ void late_ip_auto_config(void); void late_tcp_congestion_default(void); +int __set_thash_entries(char *str); +int __set_uhash_entries(char *str); + +static void lxip_kernel_params(void) +{ + __set_thash_entries("2048"); + __set_uhash_entries("2048"); +} + /** * Initialize sub-systems */ @@ -498,6 +507,8 @@ void lxip_init() /* sub-systems */ subsys_net_dev_init(); + + lxip_kernel_params(); fs_inet_init(); /* enable local accepts */ diff --git a/repos/dde_linux/src/lib/lxip/lxcc_emul.cc b/repos/dde_linux/src/lib/lxip/lxcc_emul.cc index 2aa7df50cf..33d153efaf 100644 --- a/repos/dde_linux/src/lib/lxip/lxcc_emul.cc +++ b/repos/dde_linux/src/lib/lxip/lxcc_emul.cc @@ -660,3 +660,12 @@ int schedule_delayed_work(struct delayed_work *dwork, unsigned long delay) { return mod_delayed_work(0, dwork, delay); } + + +int kstrtoul(const char *s, unsigned int base, unsigned long *res) +{ + unsigned long val = 0; + Genode::ascii_to(s, val); + *res = val; + return 0; +}