base-linux: boost max open fds to the hard rlimit

This patch increases the default limit of the maximum number of open
file descriptors to the hard limit of the system. This is needed for
complex scenarios, which require more FDs than the default of 1024
at core.

Related to issue #3581

Fixes #3721
This commit is contained in:
Norman Feske 2020-03-31 13:41:50 +02:00 committed by Christian Helmuth
parent 22d71d5a8b
commit 7bf47b1982
4 changed files with 26 additions and 19 deletions

View File

@ -19,6 +19,7 @@
#define size_t __SIZE_TYPE__ /* see comment in 'linux_syscalls.h' */
#include <sys/stat.h>
#include <sys/resource.h>
#include <fcntl.h>
#undef size_t
@ -72,6 +73,7 @@ inline int lx_stat(const char *path, struct stat64 *buf)
#endif
}
/***********************************************************
** Functions used by core's io port session support code **
***********************************************************/
@ -180,6 +182,27 @@ inline void lx_disable_aslr()
}
/***********************************
** Resource-limit initialization **
***********************************/
inline void lx_boost_rlimit()
{
rlimit rlimit { };
if (int const res = lx_syscall(SYS_getrlimit, RLIMIT_NOFILE, &rlimit)) {
Genode::warning("unable to obtain RLIMIT_NOFILE (", res, "), keeping limit unchanged");
return;
}
/* increase soft limit to hard limit */
rlimit.rlim_cur = rlimit.rlim_max;
if (int const res = lx_syscall(SYS_setrlimit, RLIMIT_NOFILE, &rlimit))
Genode::warning("unable to boost RLIMIT_NOFILE (", res, "), keeping limit unchanged");
}
/********************************************
** Communication over Unix-domain sockets **
********************************************/

View File

@ -94,6 +94,9 @@ Platform::Platform()
/* make 'mmap' behave deterministically */
lx_disable_aslr();
/* increase maximum number of open file descriptors to the hard limit */
lx_boost_rlimit();
/* catch control-c */
lx_sigaction(LX_SIGINT, sigint_handler, false);

View File

@ -350,15 +350,5 @@ build { server/lx_block app/menu_view app/sculpt_manager }
build_boot_image { lx_block menu_view sculpt_manager ahci-1.img }
if {[have_spec linux]} {
set max_fds [exec bash -c "ulimit -n"]
if {$max_fds < 4096} {
puts stderr "\nMaximum number of file descriptors is too low for this run script."
puts stderr "You may use the following command to increase the limit:\n"
puts stderr " ulimit -n 4096\n"
exit 1
}
}
run_genode_until forever

View File

@ -12,15 +12,6 @@ if {[have_spec odroid_xu]} {
exit 0
}
if {[have_spec linux]} {
set max_fds [exec bash -c "ulimit -n"]
if {$max_fds < 4096} {
puts stderr "\nMaximum number of file descriptors is too low for this run script."
puts stderr "You may use the following command to increase the limit:\n"
puts stderr " ulimit -n 4096\n"
exit 1
}
}
#
# Generate config