[PATCH 2/8] mdev: increase netlink buffer sizes
Jan Klötzke
jan at kloetzke.net
Mon Dec 16 21:56:50 UTC 2019
The socket receive buffer turned out to be too small for real world
systems. Use the same size as udevd to be on the safe side. As this is
just a limit and the memory is not allocated by the kernel until really
needed there is actually no memory wasted.
Signed-off-by: Jan Klötzke <jan at kloetzke.net>
---
util-linux/mdev.c | 18 +++++++++++++++---
1 file changed, 15 insertions(+), 3 deletions(-)
diff --git a/util-linux/mdev.c b/util-linux/mdev.c
index 207a112c1..4e3299d22 100644
--- a/util-linux/mdev.c
+++ b/util-linux/mdev.c
@@ -1155,9 +1155,21 @@ static void initial_scan(char *temp)
#if ENABLE_FEATURE_MDEV_DAEMON
-/* uevent applet uses 16k buffer, and mmaps it before every read */
-# define BUFFER_SIZE (2 * 1024)
-# define RCVBUF (2 * 1024 * 1024)
+/*
+ * The kernel (as of v5.4) will pass up to 32 environment variables with a
+ * total of 2kiB on each event. On top of that the action string and device
+ * path are added. Using a 3kiB buffer for the event should suffice in any
+ * case.
+ *
+ * As far as the socket receive buffer size is concerned 2MiB proved to be too
+ * small (see [1]). Udevd seems to use a whooping 128MiB. The socket receive
+ * buffer size is just a resource limit. The buffers are allocated lazily so
+ * the memory is not wasted.
+ *
+ * [1] http://lists.busybox.net/pipermail/busybox/2019-December/087665.html
+ */
+# define BUFFER_SIZE (3 * 1024)
+# define RCVBUF (128 * 1024 * 1024)
# define MAX_ENV 32
static void daemon_loop(char *temp, int fd)
--
2.20.1
More information about the busybox
mailing list