Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4684403pxj; Tue, 25 May 2021 13:56:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxOE2mUfXJRixf9OCW+vN34bJ33rF98vGQqjJAAO6qONQxkwwE31rWf8ovCjqnmCPORb4Zy X-Received: by 2002:a17:907:82a6:: with SMTP id mr38mr30287177ejc.540.1621976206067; Tue, 25 May 2021 13:56:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621976206; cv=none; d=google.com; s=arc-20160816; b=V27EOpXMYYFwYTwplf4HSOZ41Wh7KMQkIw9PkSUd2IBzfpWh3fWCYqd7c3oKqa2Ine AdgWpr6Kh9C/wnm2XU8cCZ28vV3TsXJ+kgHQZmo6Qu8DlSJ/tf+nCzRsJ9jLIw+7QYV0 ADle5kTQgtMLYC9QgLtCDgDPMmoUFlORyhivgwHO/66nVWEP+9KBeQSxKyykMNQEVk2Q YwTHIhV9SCB6qAfVoIYOOcTPqGTOPY8o1v19CxkUpMPxYXnKpjrWhB13a3KXw+HBwm0j t9V9i1/4jqYd7uMHmx2jDJkciNVUXIT55JCsmPgvbxOSIHOTyuIpdj79y/arrSxdln4O +Hbg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=nbSDM8JefRc8OvYh1pCNpmTBA1KFb7T/8MPpBSggPqk=; b=MuaQIRVv+xnz8Aihb1m2bAy8L16wGhzrLlWpSmt5Qd7MieTtsGRypFt1Ys1Djl+lwe QguZkXRS3IqOsn0IED8kIO7iQfLB9i16ncM2gH7r31Q8fUzJf/5/VvOSLSdPxNkfzmZg cZ/vpXYAs2eI93pm92F5k8MI5YyIPfs53F8yTHLtwfYWF6bnKj/qLxiol2jkJjPLy2C1 zEyJNVe+mhuh1xebbScmmaUnNlq0O/ewfGVelrE+p1ql3UiFZFhdGCClcrPa2jkHxOD2 ILTA3S+B32ze+Y/ky6LEgDBE98nAYairNq+sp4lkgq4JQXeWSgryKv/rNxtw80bzBL9W bc5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@nbd.name header.s=20160729 header.b=VjaNLPg4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b26si13424568eds.88.2021.05.25.13.56.23; Tue, 25 May 2021 13:56:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=fail header.i=@nbd.name header.s=20160729 header.b=VjaNLPg4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231906AbhEYQLq (ORCPT + 99 others); Tue, 25 May 2021 12:11:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42166 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230150AbhEYQLp (ORCPT ); Tue, 25 May 2021 12:11:45 -0400 Received: from nbd.name (nbd.name [IPv6:2a01:4f8:221:3d45::2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BAF88C061574; Tue, 25 May 2021 09:10:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=nbd.name; s=20160729; h=Content-Transfer-Encoding:MIME-Version:Message-Id:Date:Subject :Cc:To:From:Sender:Reply-To:Content-Type:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=nbSDM8JefRc8OvYh1pCNpmTBA1KFb7T/8MPpBSggPqk=; b=VjaNLPg4qVr5DU+63xuwtcXxrl 1f6KeVcRAWlodcm0hye8l5fanLdk8z7eCZYz7t/6lD9Z/F9TsMyMA9hRFuVz0LCQGfRexn7ea/DG/ sbFSQSmpDUPfq+R+PkTDCWmJGClwsDfdebkhY8cdLsmVLM5CZ7SqtrNWJnqeFa10FgSY=; Received: from p54ae9ff2.dip0.t-ipconnect.de ([84.174.159.242] helo=localhost.localdomain) by ds12 with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.89) (envelope-from ) id 1llZd3-0001Mu-11; Tue, 25 May 2021 18:10:01 +0200 From: Felix Fietkau To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Andi Kleen , Sukadev Bhattiprolu Cc: Ingo Molnar , Arnaldo Carvalho de Melo , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] perf jevents: fix getting maximum number of fds Date: Tue, 25 May 2021 18:07:58 +0200 Message-Id: <20210525160758.97829-1-nbd@nbd.name> X-Mailer: git-send-email 2.30.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- tools/perf/pmu-events/jevents.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/perf/pmu-events/jevents.c b/tools/perf/pmu-events/jevents.c index ed4f0bd72e5a..412565027fbb 100644 --- a/tools/perf/pmu-events/jevents.c +++ b/tools/perf/pmu-events/jevents.c @@ -960,7 +960,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; } -- 2.30.1