diff options
author | Felix Fietkau <nbd@nbd.name> | 2021-05-25 18:07:58 +0200 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2021-06-03 08:23:31 +0200 |
commit | 6d95e8d5367b224f863fb9a823e5492e992b127f (patch) | |
tree | cf51b1c8c9994efdd3e73fd4c28bdf123ae5b0ea /tools | |
parent | 09c9e79f4c10cfb6b9e0e1b4dd355232e4b5a3b3 (diff) | |
download | linux-stable-6d95e8d5367b224f863fb9a823e5492e992b127f.tar.gz linux-stable-6d95e8d5367b224f863fb9a823e5492e992b127f.tar.bz2 linux-stable-6d95e8d5367b224f863fb9a823e5492e992b127f.zip |
perf jevents: Fix getting maximum number of fds
commit 75ea44e356b5de8c817f821c9dd68ae329e82add upstream.
On some hosts, rlim.rlim_max can be returned as RLIM_INFINITY.
By casting it to int, it is interpreted as -1, which will cause get_maxfds
to return 0, causing "Invalid argument" errors in nftw() calls.
Fix this by casting the second argument of min() to rlim_t instead.
Fixes: 80eeb67fe577 ("perf jevents: Program to convert JSON file")
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
Link: http://lore.kernel.org/lkml/20210525160758.97829-1-nbd@nbd.name
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/perf/pmu-events/jevents.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/tools/perf/pmu-events/jevents.c b/tools/perf/pmu-events/jevents.c index 0619054bd7a0..61fe3ce5862d 100644 --- a/tools/perf/pmu-events/jevents.c +++ b/tools/perf/pmu-events/jevents.c @@ -603,7 +603,7 @@ static int get_maxfds(void) struct rlimit rlim; if (getrlimit(RLIMIT_NOFILE, &rlim) == 0) - return min((int)rlim.rlim_max / 2, 512); + return min(rlim.rlim_max / 2, (rlim_t)512); return 512; } |