From nobody Mon Feb 9 19:05:26 2026 Received: from mail-wm1-f49.google.com (mail-wm1-f49.google.com [209.85.128.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 34F2C19992C for ; Thu, 16 Jan 2025 23:10:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737069031; cv=none; b=YBtiC8JQ+vVtWnHR28fIpE44Xil12/QbJVqUnAq19zNURjmn5wwED4TC9B97fyGL0VL+WT5MzImxz3lEMYHYJU48WNmfsBo4pxq8NHt8OzjdLCkTO5QmEzJZaaYfYuxJlkfUyvUyUGJwzdwk3Fv2JZPG2c7TGXKNnvu+wWHaJ1k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737069031; c=relaxed/simple; bh=bF/cdbPvyjz0FfZNx2ey9irVZg4a8yyfWpE7AZtnRxM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=K4P0CugcV5tKKLqDMDRAXrbrH9he9RCewHmq0NAEKDFgqZRXx8TiUFURBOTooT7280CGcSv7kSCXZuEb3OOVEvyMYYdLnz3ue9MzrMX6TPOsGYTvyZUacHskfxzsawXdi6AjeDyEu2UmBUlksCEIf3O7RkAiD0+keJPf5qY7pis= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=rivosinc.com; spf=pass smtp.mailfrom=rivosinc.com; dkim=pass (2048-bit key) header.d=rivosinc-com.20230601.gappssmtp.com header.i=@rivosinc-com.20230601.gappssmtp.com header.b=BpGfvkRW; arc=none smtp.client-ip=209.85.128.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=rivosinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=rivosinc.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=rivosinc-com.20230601.gappssmtp.com header.i=@rivosinc-com.20230601.gappssmtp.com header.b="BpGfvkRW" Received: by mail-wm1-f49.google.com with SMTP id 5b1f17b1804b1-43675b1155bso15688695e9.2 for ; Thu, 16 Jan 2025 15:10:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1737069028; x=1737673828; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ih0D7I8XCBuUn8cwCzLwA9EVpPglV1xp5bSahtqmwB0=; b=BpGfvkRWn9kpf0xiC6LnrTpHJCPPft5iWuctLPwOPCconJJVRoQxJNEOk5Nz3LN9nm QfcRK6C3G3My22pjoel2v/kkeVy08qsfRPrAAAvnaW7ypHM8fStIqGe+8Taabu5FHHN8 4ysAGmUlTpAX60CrSe/K3f0BflhltF845bpHF7dLY3IYLLgSbp+Gnvsx4fydS7IcENbl pjqbG7TyC7tYmQ3ZT5YJ0t2zvv86hEgGF6CrBa3fI4vtWuRvtoGB211wm+TjuzPyr1iZ VyNCpaZU1ybG/5Wky5tGE5UgkUJV9kdOfDyf7qYiTkk4pt+sDBOg/RzYn9OhJcjQTkUX dzgg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737069028; x=1737673828; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ih0D7I8XCBuUn8cwCzLwA9EVpPglV1xp5bSahtqmwB0=; b=BdhCfnbTXetsemCxoPjl3gY+43zdFYINsp7QrJ93DOuBuBEcFTNA8IJwxhiVBw6VmU nmcGj7gzx99joNPOxi+MSqiFYcjLkugsKyO2TwZ9WpEiIDVU2cl+tCkTAA1F0wWGGPSQ VLxZUNFfrUzWjTB9XZYe+2MkWvaog94ygyrgy45hVdGhrUlcu2gCGfCCCNoaAlL7aAJu 6mlUU+rXCIAUwU5EzPYALVv/BItx7IKTx6qQoEjCR9ICI77jJ0FQi5HA4nUc1qenu1i0 nPsIFQLAvNZwap+315xxTpYQOCaiceZHeTDjyj30qNkWoKKJthEMzg/WJHgGyvcRFgVf BKSA== X-Gm-Message-State: AOJu0Yw8+HT6KFe5eM5Ke4zJcP3D6PZIS9urqeMkRzFuv4oeaLBFqU3F ouJSgnbpbuVmKTQskcM9Y3bW9FhGYmWHaSZ2K+67n0DcY2/ZWKvCHICMMf6vYCcdoieWXuBIeXb d X-Gm-Gg: ASbGnctor1HEZwzfjSsTkFIg13P8DyTIodimzOcp2potQv0ohn5tGObpd7a3p01e2/k hQuYQZEgFH4A+5+0M2iVhka09H9D9y0HaNvwmNfelQew56tGMFQEQpsbNuBldkAdfTRpHEdHNFt RUo57Xcc76yG/zQZYZd7I/+UFqYs9CIz8Vy7V8vobplnAw4U1poGSOoR/P8BD2DSqARGrUCDSMq iB6u9yYRBwM8IaZMmfO2FyKhpdyNXIaVRYzMu5W9jLESQSN6OZLdnHEJqnA4ieSko6fgMMSRWJs 7NyPjOajeHTAcRDX X-Google-Smtp-Source: AGHT+IGZkSeIeWLg78b7QIySnUPbuLbB0vhAavzUj7u+Y4mZGnlfT+raQ/EoGquZ508s9+cVypWC2g== X-Received: by 2002:adf:ffca:0:b0:38a:88e2:e6aa with SMTP id ffacd0b85a97d-38bf56745bcmr243859f8f.29.1737069028398; Thu, 16 Jan 2025 15:10:28 -0800 (PST) Received: from rkanwal-XPS-15-9520.uk.rivosinc.com ([2a02:c7c:75ac:6300:b3f2:3a24:1767:7db0]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38bf322b337sm974991f8f.59.2025.01.16.15.10.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Jan 2025 15:10:28 -0800 (PST) From: Rajnesh Kanwal To: linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org Cc: linux-perf-users@vger.kernel.org, adrian.hunter@intel.com, alexander.shishkin@linux.intel.com, ajones@ventanamicro.com, anup@brainfault.org, acme@kernel.org, atishp@rivosinc.com, beeman@rivosinc.com, brauner@kernel.org, conor@kernel.org, heiko@sntech.de, irogers@google.com, mingo@redhat.com, james.clark@arm.com, renyu.zj@linux.alibaba.com, jolsa@kernel.org, jisheng.teoh@starfivetech.com, palmer@dabbelt.com, will@kernel.org, kaiwenxue1@gmail.com, vincent.chen@sifive.com, Rajnesh Kanwal Subject: [PATCH v2 1/7] perf: Increase the maximum number of samples to 256. Date: Thu, 16 Jan 2025 23:09:49 +0000 Message-Id: <20250116230955.867152-2-rkanwal@rivosinc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250116230955.867152-1-rkanwal@rivosinc.com> References: <20250116230955.867152-1-rkanwal@rivosinc.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" RISCV CTR extension support a maximum depth of 256 last branch records. The 127 entries limit results in corrupting CTR entries for RISC-V if configured to be 256 entries. This will not impact any other architectures as it is just increasing maximum limit of possible entries. Signed-off-by: Rajnesh Kanwal --- tools/perf/util/machine.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c index 27d5345d2b30..f2eb3c20274e 100644 --- a/tools/perf/util/machine.c +++ b/tools/perf/util/machine.c @@ -2174,25 +2174,32 @@ static void save_iterations(struct iterations *iter, iter->cycles +=3D be[i].flags.cycles; } =20 -#define CHASHSZ 127 -#define CHASHBITS 7 -#define NO_ENTRY 0xff +#define CHASHBITS 8 +#define NO_ENTRY 0xffU =20 -#define PERF_MAX_BRANCH_DEPTH 127 +#define PERF_MAX_BRANCH_DEPTH 256 =20 /* Remove loops. */ +/* Note: Last entry (i=3D=3Dff) will never be checked against NO_ENTRY + * so it's safe to have an unsigned char array to process 256 entries + * without causing clash between last entry and NO_ENTRY value. + */ static int remove_loops(struct branch_entry *l, int nr, struct iterations *iter) { int i, j, off; - unsigned char chash[CHASHSZ]; + unsigned char chash[PERF_MAX_BRANCH_DEPTH]; =20 memset(chash, NO_ENTRY, sizeof(chash)); =20 - BUG_ON(PERF_MAX_BRANCH_DEPTH > 255); + BUG_ON(PERF_MAX_BRANCH_DEPTH > 256); =20 for (i =3D 0; i < nr; i++) { - int h =3D hash_64(l[i].from, CHASHBITS) % CHASHSZ; + /* Remainder division by PERF_MAX_BRANCH_DEPTH is not + * needed as hash_64 will anyway limit the hash + * to CHASHBITS + */ + int h =3D hash_64(l[i].from, CHASHBITS); =20 /* no collision handling for now */ if (chash[h] =3D=3D NO_ENTRY) { --=20 2.34.1