From patchwork Tue Aug 27 00:42:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Ruffell X-Patchwork-Id: 1977069 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ubuntu.com (client-ip=185.125.189.65; helo=lists.ubuntu.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=patchwork.ozlabs.org) Received: from lists.ubuntu.com (lists.ubuntu.com [185.125.189.65]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Wt80D5kn3z1yh3 for ; Tue, 27 Aug 2024 10:42:51 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=lists.ubuntu.com) by lists.ubuntu.com with esmtp (Exim 4.86_2) (envelope-from ) id 1sikIC-0002Oh-Ep; Tue, 27 Aug 2024 00:42:40 +0000 Received: from smtp-relay-internal-1.internal ([10.131.114.114] helo=smtp-relay-internal-1.canonical.com) by lists.ubuntu.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1sikIB-0002O8-5z for kernel-team@lists.ubuntu.com; Tue, 27 Aug 2024 00:42:39 +0000 Received: from mail-pg1-f197.google.com (mail-pg1-f197.google.com [209.85.215.197]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-1.canonical.com (Postfix) with ESMTPS id 15F7E3F285 for ; Tue, 27 Aug 2024 00:42:39 +0000 (UTC) Received: by mail-pg1-f197.google.com with SMTP id 41be03b00d2f7-7cd98f27becso4837775a12.3 for ; Mon, 26 Aug 2024 17:42:39 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724719357; x=1725324157; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=fmL6l/hlGnmsfBGOz2fxZvIgmlP7DJHF08FaUqcK5T8=; b=WxsnWDWudLLTu3GJdz4w0kVy+vKnyvDS0T8M87XAP3pPMwT75/gnN5s4GwlqwxuVbs kyqbXQkeS9ujDBSUyfi4LSWrzSDDpirE2/MpC3JiEyXr2EQtBwaG1UiOozjLPwsAR2/S AmyLLl2i8/WHWECKX1VLGUtVklKZ6BjgRg56Krr+uGZbKgCg/6WwWU7ItJzoA7UXxK5J eTqqi7pfgZKdxlHqoL5Tupbd9pb0Vy60mIAPEsc4NGfphIc7pyS7noCnDeJQ+/oMyD3S 3COu9fvfNGf1SMx1tHpSdATgw/iyzpip1WLFe9+RZcHm0iF/dIFdid/kN5vq+aVuR541 pkrg== X-Gm-Message-State: AOJu0Yyxgo6j/oLPgEkLjE1XDt+pc2u9xuWeMABMrS874H8LRKKkrgTs wyKK2EaWRw2hRa7s/fMkn3FKzy8AZdO1gEtOFamoTmk/QilCyKFnz2ODIfkigQ2p44bzwhE5BVa FpaJ5tzLxb91wImO3qh7pl/s78RuVrqBDddsuw9doS16sHijn6Ck3OwePzYXELZy/OJBaDLMZ/5 GpOv3ZJevuVg== X-Received: by 2002:a05:6a21:b8b:b0:1c6:a57a:159c with SMTP id adf61e73a8af0-1ccc09ad03amr1680468637.52.1724719357674; Mon, 26 Aug 2024 17:42:37 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEQcqikjywezUplcKzbqdRihFv+XMmYIFCoqUSmUpE7P0GThx3PpMuyjTqtJRXQEykG737LjA== X-Received: by 2002:a05:6a21:b8b:b0:1c6:a57a:159c with SMTP id adf61e73a8af0-1ccc09ad03amr1680443637.52.1724719357150; Mon, 26 Aug 2024 17:42:37 -0700 (PDT) Received: from ThinkPad-X1.. (125-239-191-70-fibre.sparkbb.co.nz. [125.239.191.70]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-71434340419sm7540177b3a.205.2024.08.26.17.42.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Aug 2024 17:42:36 -0700 (PDT) From: Matthew Ruffell To: kernel-team@lists.ubuntu.com Subject: [SRU][Jammy][PATCH 1/1] tools/power turbostat: Increase the limit for fd opened Date: Tue, 27 Aug 2024 12:42:06 +1200 Message-ID: <20240827004228.16253-2-matthew.ruffell@canonical.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240827004228.16253-1-matthew.ruffell@canonical.com> References: <20240827004228.16253-1-matthew.ruffell@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Wyes Karny BugLink: https://bugs.launchpad.net/bugs/2069961 When running turbostat, a system with 512 cpus reaches the limit for maximum number of file descriptors that can be opened. To solve this problem, the limit is raised to 2^15, which is a large enough number. Below data is collected from AMD server systems while running turbostat: |-----------+-------------------------------| | # of cpus | # of opened fds for turbostat | |-----------+-------------------------------| | 128 | 260 | |-----------+-------------------------------| | 192 | 388 | |-----------+-------------------------------| | 512 | 1028 | |-----------+-------------------------------| So, the new max limit would be sufficient up to 2^14 cpus (but this also depends on how many counters are enabled). Reviewed-by: Doug Smythies Tested-by: Doug Smythies Signed-off-by: Wyes Karny Signed-off-by: Len Brown (backported from commit 3ac1d14d0583a2de75d49a5234d767e2590384dd) [mruffell: minor context adjustment in first hunk] Signed-off-by: Matthew Ruffell --- tools/power/x86/turbostat/turbostat.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/tools/power/x86/turbostat/turbostat.c b/tools/power/x86/turbostat/turbostat.c index 550c6dfc4f04..84a138266ed7 100644 --- a/tools/power/x86/turbostat/turbostat.c +++ b/tools/power/x86/turbostat/turbostat.c @@ -166,6 +166,8 @@ int ignore_stdin; #define NAME_BYTES 20 #define PATH_BYTES 128 +#define MAX_NOFILE 0x8000 + int backwards_count; char *progname; @@ -6430,6 +6432,22 @@ void cmdline(int argc, char **argv) } } +void set_rlimit(void) +{ + struct rlimit limit; + + if (getrlimit(RLIMIT_NOFILE, &limit) < 0) + err(1, "Failed to get rlimit"); + + if (limit.rlim_max < MAX_NOFILE) + limit.rlim_max = MAX_NOFILE; + if (limit.rlim_cur < MAX_NOFILE) + limit.rlim_cur = MAX_NOFILE; + + if (setrlimit(RLIMIT_NOFILE, &limit) < 0) + err(1, "Failed to set rlimit"); +} + int main(int argc, char **argv) { outf = stderr; @@ -6440,6 +6458,9 @@ int main(int argc, char **argv) probe_sysfs(); + if (!getuid()) + set_rlimit(); + turbostat_init(); /* dump counters and exit */