Commit 75ea44e3 authored by Felix Fietkau's avatar Felix Fietkau Committed by Arnaldo Carvalho de Melo

perf jevents: Fix getting maximum number of fds

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: 80eeb67f ("perf jevents: Program to convert JSON file")
Signed-off-by: default avatarFelix 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.nameSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent a050a6d2
...@@ -960,7 +960,7 @@ static int get_maxfds(void) ...@@ -960,7 +960,7 @@ static int get_maxfds(void)
struct rlimit rlim; struct rlimit rlim;
if (getrlimit(RLIMIT_NOFILE, &rlim) == 0) 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; return 512;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment