summaryrefslogtreecommitdiffstats
path: root/meta-agl-profile-core/recipes-devtools/rpm/files/0003-rpmSetCloseOnExec-use-getrlimit.patch
diff options
context:
space:
mode:
authorTadao Tanikawa <tanikawa.tadao@jp.panasonic.com>2018-07-27 03:54:43 +0000
committerStéphane Desneux <stephane.desneux@iot.bzh>2018-09-10 21:29:43 +0000
commita8bf787b4232beef67a3643d858166f776bb829d (patch)
treed80291eea2e15c7068069975bf27f7b74c3bfe11 /meta-agl-profile-core/recipes-devtools/rpm/files/0003-rpmSetCloseOnExec-use-getrlimit.patch
parent1ac6af91ece51cfd170920d602aa476a2ad2ec9c (diff)
Fix do_rootfs eats huge time on docker environment
RPM is causing a serious performance regression on Docker. Docker can set ulimit -n to 1048576 but it causes huge time consumption when thousands of packages are installed like bitbake agl-demo-platform. This issue is already resolved in upstream of RPM and yocto follows it at sumo, so backporting it into Flounder. (From OE-Core rev: 6ecb10e3952af4a77bc79160ecd81117e97d022a) Bug-AGL: SPEC-1622 Change-Id: Ia8d97daea663f9682928a14ab84199ed6fda6d61 Signed-off-by: Tadao Tanikawa <tanikawa.tadao@jp.panasonic.com>
Diffstat (limited to 'meta-agl-profile-core/recipes-devtools/rpm/files/0003-rpmSetCloseOnExec-use-getrlimit.patch')
-rw-r--r--meta-agl-profile-core/recipes-devtools/rpm/files/0003-rpmSetCloseOnExec-use-getrlimit.patch55
1 files changed, 55 insertions, 0 deletions
diff --git a/meta-agl-profile-core/recipes-devtools/rpm/files/0003-rpmSetCloseOnExec-use-getrlimit.patch b/meta-agl-profile-core/recipes-devtools/rpm/files/0003-rpmSetCloseOnExec-use-getrlimit.patch
new file mode 100644
index 000000000..d9b813ece
--- /dev/null
+++ b/meta-agl-profile-core/recipes-devtools/rpm/files/0003-rpmSetCloseOnExec-use-getrlimit.patch
@@ -0,0 +1,55 @@
+From 1f5438d677dca330642158ec0b1c0366c6a65725 Mon Sep 17 00:00:00 2001
+From: Kir Kolyshkin <kolyshkin@gmail.com>
+Date: Tue, 29 May 2018 18:09:27 -0700
+Subject: [PATCH 3/3] rpmSetCloseOnExec: use getrlimit()
+
+In case /proc is not available to get the actual list of opened fds,
+we fall back to iterating through the list of all possible fds.
+
+It is possible that during the course of the program execution the limit
+on number of open file descriptors might be lowered, so using the
+current limit, as returned by sysconf(_SC_OPEN_MAX), might omit some
+fds. Therefore, it is better to use rlim_max from the structure
+filled in by gertlimit(RLIMIT_NOFILE) to make sure we're checking
+all fds.
+
+This slows down the function, but only in the case /proc is not
+available, which should be rare in practice.
+
+Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
+(cherry picked from commit 307e28b4cb08b05bc044482058eeebc9f59bb9a9)
+---
+ rpmio/rpmio.c | 10 +++++++++-
+ 1 file changed, 9 insertions(+), 1 deletion(-)
+
+diff --git a/rpmio/rpmio.c b/rpmio/rpmio.c
+index 8148aa2..0698e53 100644
+--- a/rpmio/rpmio.c
++++ b/rpmio/rpmio.c
+@@ -10,6 +10,7 @@
+ #include <sys/personality.h>
+ #endif
+ #include <sys/utsname.h>
++#include <sys/resource.h>
+
+ #include <rpm/rpmlog.h>
+ #include <rpm/rpmmacro.h>
+@@ -1495,7 +1496,14 @@ void rpmSetCloseOnExec(void)
+ DIR *dir = opendir("/proc/self/fd");
+ if (dir == NULL) { /* /proc not available */
+ /* iterate over all possible fds, might be slow */
+- int open_max = sysconf(_SC_OPEN_MAX);
++ struct rlimit rl;
++ int open_max;
++
++ if (getrlimit(RLIMIT_NOFILE, &rl) == 0 && rl.rlim_max != RLIM_INFINITY)
++ open_max = rl.rlim_max;
++ else
++ open_max = sysconf(_SC_OPEN_MAX);
++
+ if (open_max == -1)
+ open_max = 1024;
+
+--
+2.7.4
+