From nobody Mon Feb 9 00:55:01 2026 Received: from mail-dy1-f201.google.com (mail-dy1-f201.google.com [74.125.82.201]) (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 0806837107D for ; Thu, 22 Jan 2026 16:54:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769100877; cv=none; b=EFEuB0hAywh1HDhm2erQ/cG1jicTKzLGgc1IAQzl1KLvvce6Zn+IsS+0UUcSVrhUXj3u4FcS5vNf0f5Twt0wT/mb7n0oBkYcBZ5nCBMnSNZB+6GuWLv/27VciQxwNsSXMXyT0V3d7hnEY9ZBICkTYRGOZDixjzlgZpA/ox5WfJ4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769100877; c=relaxed/simple; bh=rD9vOzeeXzOTCD+l66o8DhGrmT+MJuoo1UTvO0WycIQ=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Content-Type; b=X8QAWcRecOzeBAVWk+xs7qZX0+fhERk1VOh9+PICDp6YSGa0hgD3KVqtMnF2bsuXcLv8r2D4LqyjAAfLFj6KPCGD5UhGy2hnWuzUAmF9nmmKA/l5/ogJvWh4UPVKGi7XBjnTiqkzyHuqytUOh82C6DuMZ+UCjEJefmMRHy2Ii68= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=kmBlCllM; arc=none smtp.client-ip=74.125.82.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="kmBlCllM" Received: by mail-dy1-f201.google.com with SMTP id 5a478bee46e88-2b704019c98so1266723eec.0 for ; Thu, 22 Jan 2026 08:54:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1769100864; x=1769705664; darn=vger.kernel.org; h=to:from:subject:message-id:references:mime-version:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=ANZB4nsW0oD2Yy9bdDZ7x29IcTZAs2bHCHMIwFReZjE=; b=kmBlCllMeIKwBJfPY14u+sz/7jEtzhhRpsN+5p5Kyd4sc67xd9rGVQK3DzsOuWpxJp u3+2APA3pAgKHoVoq79cNXsBq9G/Tc2WiHcKJW/XTsLJJj9nOJfpbOgqmEQUxFKBb1T7 f8Sx1ZVpP6YipyTwK6RQ6DjBAOr6U5CzFXhELjhNkhoEIdk7MFRkCb62pydIDrnZgQvh DC31uXd6YH+CejrZ8cnnS59C10xJR7JCk/ddmi0EFU26LJh4qA/Aco6yPzMY9rSyqCyV MwZYaBOM4il2sVrQUf/YxpxFrOPlftP8WmB9xctBwGbT8m/ylL0ziTLeppLWgF05SPVV OxfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1769100864; x=1769705664; h=to:from:subject:message-id:references:mime-version:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=ANZB4nsW0oD2Yy9bdDZ7x29IcTZAs2bHCHMIwFReZjE=; b=DR7VB2wZFn1Mz1CsNBYoBPzJESjIMKMs9jK7hjYt5g+60+2cHnJrkEjIHK+r9AecSo FucYy/hKR0PyKECZnAUtOteQu7R5BZUzoIvH8E+zrUrprHbYJ8AEMXwb3as4oKW/Xr3V HBVsrrNDk8MndtfRQk6Ng6IRX/f6q7XComMh6JaKJt6G+SF6Vxmqlz29b2/DGdv5vjAt hQJPX5lXww2b7r4R/0zWneDMyA/fW/s9XrrFPOWm6eFMUwRCIf3II3UNFzGgygpnkjAP QfbbsBMRPAMVXO8/5q/wVti4xzds2Upc1h/g8t5kifelVHCVvSb9LXJnNkMbZpLxVxfm EfmA== X-Forwarded-Encrypted: i=1; AJvYcCWZ93VVGcNuBYj23xIW2eY1IYWG24EuyRIMLOI38MwOX/96qNvnL0Aw1yWsVuZYTi641rm2YRU7wSBlIYw=@vger.kernel.org X-Gm-Message-State: AOJu0Yz+HgQbM3yt6sBLHB40zvvGoNmoeimECVz1y8MsLwRgajOlNmqu 02EYhkpIuZhfGWRE1P/0pMAkcSMFsnO0uZp0/sQ+KLPmTUFsjwlTIbBdDC6Extossp5IN0MrTfO sr+F1PVcuRg== X-Received: from dyx1.prod.google.com ([2002:a05:693c:8201:b0:2ac:2109:f65f]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a05:7300:550:b0:2b6:a622:25f5 with SMTP id 5a478bee46e88-2b6b470d64bmr12140816eec.11.1769100863572; Thu, 22 Jan 2026 08:54:23 -0800 (PST) Date: Thu, 22 Jan 2026 08:54:00 -0800 In-Reply-To: <20260122165407.561888-1-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260122165407.561888-1-irogers@google.com> X-Mailer: git-send-email 2.52.0.457.g6b5491de43-goog Message-ID: <20260122165407.561888-6-irogers@google.com> Subject: [PATCH v2 05/12] perf disasm: Constify use of struct ins_op From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , James Clark , John Garry , Will Deacon , Leo Yan , Guo Ren , Paul Walmsley , Palmer Dabbelt , Albert Ou , Alexandre Ghiti , Nathan Chancellor , Nick Desaulniers , Bill Wendling , Justin Stitt , Zecheng Li , Tianyou Li , Thomas Falcon , Julia Lawall , Suchit Karunakaran , Athira Rajeev , Aditya Bodkhe , Howard Chu , "=?UTF-8?q?Krzysztof=20=C5=81opatowski?=" , "Dr. David Alan Gilbert" , Shimin Guo , Sergei Trofimovich , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-csky@vger.kernel.org, linux-riscv@lists.infradead.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The struct ins_op holds variables to function pointers that are read but not written. Change uses to be for a "const struct ins_op *" version to capture this immutability. Signed-off-by: Ian Rogers --- tools/perf/arch/arm/annotate/instructions.c | 4 +- tools/perf/arch/arm64/annotate/instructions.c | 6 +-- tools/perf/arch/csky/annotate/instructions.c | 6 +-- .../arch/loongarch/annotate/instructions.c | 8 ++-- tools/perf/arch/mips/annotate/instructions.c | 4 +- .../perf/arch/powerpc/annotate/instructions.c | 6 +-- .../perf/arch/riscv64/annotate/instructions.c | 4 +- tools/perf/arch/s390/annotate/instructions.c | 8 ++-- tools/perf/arch/sparc/annotate/instructions.c | 4 +- tools/perf/util/disasm.c | 46 +++++++++---------- tools/perf/util/disasm.h | 6 +-- 11 files changed, 51 insertions(+), 51 deletions(-) diff --git a/tools/perf/arch/arm/annotate/instructions.c b/tools/perf/arch/= arm/annotate/instructions.c index 5e667b0f5512..b997d127fedd 100644 --- a/tools/perf/arch/arm/annotate/instructions.c +++ b/tools/perf/arch/arm/annotate/instructions.c @@ -11,10 +11,10 @@ struct arm_annotate { jump_insn; }; =20 -static struct ins_ops *arm__associate_instruction_ops(struct arch *arch, c= onst char *name) +static const struct ins_ops *arm__associate_instruction_ops(struct arch *a= rch, const char *name) { struct arm_annotate *arm =3D arch->priv; - struct ins_ops *ops; + const struct ins_ops *ops; regmatch_t match[2]; =20 if (!regexec(&arm->call_insn, name, 2, match, 0)) diff --git a/tools/perf/arch/arm64/annotate/instructions.c b/tools/perf/arc= h/arm64/annotate/instructions.c index 5099fa36180d..363af2f55122 100644 --- a/tools/perf/arch/arm64/annotate/instructions.c +++ b/tools/perf/arch/arm64/annotate/instructions.c @@ -63,15 +63,15 @@ static int arm64_mov__parse(const struct arch *arch __m= aybe_unused, static int mov__scnprintf(struct ins *ins, char *bf, size_t size, struct ins_operands *ops, int max_ins_name); =20 -static struct ins_ops arm64_mov_ops =3D { +static const struct ins_ops arm64_mov_ops =3D { .parse =3D arm64_mov__parse, .scnprintf =3D mov__scnprintf, }; =20 -static struct ins_ops *arm64__associate_instruction_ops(struct arch *arch,= const char *name) +static const struct ins_ops *arm64__associate_instruction_ops(struct arch = *arch, const char *name) { struct arm64_annotate *arm =3D arch->priv; - struct ins_ops *ops; + const struct ins_ops *ops; regmatch_t match[2]; =20 if (!regexec(&arm->jump_insn, name, 2, match, 0)) diff --git a/tools/perf/arch/csky/annotate/instructions.c b/tools/perf/arch= /csky/annotate/instructions.c index 14270311d215..4a55c84a320a 100644 --- a/tools/perf/arch/csky/annotate/instructions.c +++ b/tools/perf/arch/csky/annotate/instructions.c @@ -3,10 +3,10 @@ =20 #include =20 -static struct ins_ops *csky__associate_ins_ops(struct arch *arch, - const char *name) +static const struct ins_ops *csky__associate_ins_ops(struct arch *arch, + const char *name) { - struct ins_ops *ops =3D NULL; + const struct ins_ops *ops =3D NULL; =20 /* catch all kind of jumps */ if (!strcmp(name, "bt") || diff --git a/tools/perf/arch/loongarch/annotate/instructions.c b/tools/perf= /arch/loongarch/annotate/instructions.c index 5ebfe629ea68..5010d5d58375 100644 --- a/tools/perf/arch/loongarch/annotate/instructions.c +++ b/tools/perf/arch/loongarch/annotate/instructions.c @@ -51,7 +51,7 @@ static int loongarch_call__parse(const struct arch *arch,= struct ins_operands *o return 0; } =20 -static struct ins_ops loongarch_call_ops =3D { +static const struct ins_ops loongarch_call_ops =3D { .parse =3D loongarch_call__parse, .scnprintf =3D call__scnprintf, }; @@ -100,15 +100,15 @@ static int loongarch_jump__parse(const struct arch *a= rch, struct ins_operands *o return 0; } =20 -static struct ins_ops loongarch_jump_ops =3D { +static const struct ins_ops loongarch_jump_ops =3D { .parse =3D loongarch_jump__parse, .scnprintf =3D jump__scnprintf, }; =20 static -struct ins_ops *loongarch__associate_ins_ops(struct arch *arch, const char= *name) +const struct ins_ops *loongarch__associate_ins_ops(struct arch *arch, cons= t char *name) { - struct ins_ops *ops =3D NULL; + const struct ins_ops *ops =3D NULL; =20 if (!strcmp(name, "bl")) ops =3D &loongarch_call_ops; diff --git a/tools/perf/arch/mips/annotate/instructions.c b/tools/perf/arch= /mips/annotate/instructions.c index b50b46c613d6..0fbe0a7df95a 100644 --- a/tools/perf/arch/mips/annotate/instructions.c +++ b/tools/perf/arch/mips/annotate/instructions.c @@ -1,9 +1,9 @@ // SPDX-License-Identifier: GPL-2.0 =20 static -struct ins_ops *mips__associate_ins_ops(struct arch *arch, const char *nam= e) +const struct ins_ops *mips__associate_ins_ops(struct arch *arch, const cha= r *name) { - struct ins_ops *ops =3D NULL; + const struct ins_ops *ops =3D NULL; =20 if (!strncmp(name, "bal", 3) || !strncmp(name, "bgezal", 6) || diff --git a/tools/perf/arch/powerpc/annotate/instructions.c b/tools/perf/a= rch/powerpc/annotate/instructions.c index ca567cfdcbdb..d1be55425e35 100644 --- a/tools/perf/arch/powerpc/annotate/instructions.c +++ b/tools/perf/arch/powerpc/annotate/instructions.c @@ -1,10 +1,10 @@ // SPDX-License-Identifier: GPL-2.0 #include =20 -static struct ins_ops *powerpc__associate_instruction_ops(struct arch *arc= h, const char *name) +static const struct ins_ops *powerpc__associate_instruction_ops(struct arc= h *arch, const char *name) { int i; - struct ins_ops *ops; + const struct ins_ops *ops; =20 /* * - Interested only if instruction starts with 'b'. @@ -189,7 +189,7 @@ static int cmp_offset(const void *a, const void *b) return (val1->value - val2->value); } =20 -static struct ins_ops *check_ppc_insn(struct disasm_line *dl) +static const struct ins_ops *check_ppc_insn(struct disasm_line *dl) { int raw_insn =3D dl->raw.raw_insn; int opcode =3D PPC_OP(raw_insn); diff --git a/tools/perf/arch/riscv64/annotate/instructions.c b/tools/perf/a= rch/riscv64/annotate/instructions.c index 55cf911633f8..a34798864fab 100644 --- a/tools/perf/arch/riscv64/annotate/instructions.c +++ b/tools/perf/arch/riscv64/annotate/instructions.c @@ -1,9 +1,9 @@ // SPDX-License-Identifier: GPL-2.0 =20 static -struct ins_ops *riscv64__associate_ins_ops(struct arch *arch, const char *= name) +const struct ins_ops *riscv64__associate_ins_ops(struct arch *arch, const = char *name) { - struct ins_ops *ops =3D NULL; + const struct ins_ops *ops =3D NULL; =20 if (!strncmp(name, "jal", 3) || !strncmp(name, "jr", 2) || diff --git a/tools/perf/arch/s390/annotate/instructions.c b/tools/perf/arch= /s390/annotate/instructions.c index 37c1b62641d8..1b22e6276e7d 100644 --- a/tools/perf/arch/s390/annotate/instructions.c +++ b/tools/perf/arch/s390/annotate/instructions.c @@ -49,7 +49,7 @@ static int s390_call__parse(const struct arch *arch, stru= ct ins_operands *ops, return 0; } =20 -static struct ins_ops s390_call_ops =3D { +static const struct ins_ops s390_call_ops =3D { .parse =3D s390_call__parse, .scnprintf =3D call__scnprintf, }; @@ -103,14 +103,14 @@ static int s390_mov__parse(const struct arch *arch __= maybe_unused, } =20 =20 -static struct ins_ops s390_mov_ops =3D { +static const struct ins_ops s390_mov_ops =3D { .parse =3D s390_mov__parse, .scnprintf =3D mov__scnprintf, }; =20 -static struct ins_ops *s390__associate_ins_ops(struct arch *arch, const ch= ar *name) +static const struct ins_ops *s390__associate_ins_ops(struct arch *arch, co= nst char *name) { - struct ins_ops *ops =3D NULL; + const struct ins_ops *ops =3D NULL; =20 /* catch all kind of jumps */ if (strchr(name, 'j') || diff --git a/tools/perf/arch/sparc/annotate/instructions.c b/tools/perf/arc= h/sparc/annotate/instructions.c index 68c31580ccfc..a08d8734c883 100644 --- a/tools/perf/arch/sparc/annotate/instructions.c +++ b/tools/perf/arch/sparc/annotate/instructions.c @@ -117,9 +117,9 @@ static int is_branch_float_cond(const char *cond) return 0; } =20 -static struct ins_ops *sparc__associate_instruction_ops(struct arch *arch,= const char *name) +static const struct ins_ops *sparc__associate_instruction_ops(struct arch = *arch, const char *name) { - struct ins_ops *ops =3D NULL; + const struct ins_ops *ops =3D NULL; =20 if (!strcmp(name, "call") || !strcmp(name, "jmp") || diff --git a/tools/perf/util/disasm.c b/tools/perf/util/disasm.c index d92c0424e8fc..9bc9b1de98db 100644 --- a/tools/perf/util/disasm.c +++ b/tools/perf/util/disasm.c @@ -33,15 +33,15 @@ static regex_t file_lineno; =20 /* These can be referred from the arch-dependent code */ -static struct ins_ops call_ops; -static struct ins_ops dec_ops; -static struct ins_ops jump_ops; -static struct ins_ops mov_ops; -static struct ins_ops nop_ops; -static struct ins_ops lock_ops; -static struct ins_ops ret_ops; -static struct ins_ops load_store_ops; -static struct ins_ops arithmetic_ops; +static const struct ins_ops call_ops; +static const struct ins_ops dec_ops; +static const struct ins_ops jump_ops; +static const struct ins_ops mov_ops; +static const struct ins_ops nop_ops; +static const struct ins_ops lock_ops; +static const struct ins_ops ret_ops; +static const struct ins_ops load_store_ops; +static const struct ins_ops arithmetic_ops; =20 static int jump__scnprintf(struct ins *ins, char *bf, size_t size, struct ins_operands *ops, int max_ins_name); @@ -85,7 +85,7 @@ static int arch__grow_instructions(struct arch *arch) goto out_update_instructions; } =20 -static int arch__associate_ins_ops(struct arch* arch, const char *name, st= ruct ins_ops *ops) +static int arch__associate_ins_ops(struct arch *arch, const char *name, co= nst struct ins_ops *ops) { struct ins *ins; =20 @@ -334,7 +334,7 @@ static int call__scnprintf(struct ins *ins, char *bf, s= ize_t size, return scnprintf(bf, size, "%-*s *%" PRIx64, max_ins_name, ins->name, ops= ->target.addr); } =20 -static struct ins_ops call_ops =3D { +static const struct ins_ops call_ops =3D { .parse =3D call__parse, .scnprintf =3D call__scnprintf, }; @@ -487,7 +487,7 @@ static void jump__delete(struct ins_operands *ops __may= be_unused) */ } =20 -static struct ins_ops jump_ops =3D { +static const struct ins_ops jump_ops =3D { .free =3D jump__delete, .parse =3D jump__parse, .scnprintf =3D jump__scnprintf, @@ -579,7 +579,7 @@ static void lock__delete(struct ins_operands *ops) zfree(&ops->target.name); } =20 -static struct ins_ops lock_ops =3D { +static const struct ins_ops lock_ops =3D { .free =3D lock__delete, .parse =3D lock__parse, .scnprintf =3D lock__scnprintf, @@ -688,7 +688,7 @@ static int mov__scnprintf(struct ins *ins, char *bf, si= ze_t size, ops->target.name ?: ops->target.raw); } =20 -static struct ins_ops mov_ops =3D { +static const struct ins_ops mov_ops =3D { .parse =3D mov__parse, .scnprintf =3D mov__scnprintf, }; @@ -738,7 +738,7 @@ static int arithmetic__parse(const struct arch *arch __= maybe_unused, struct ins_ return 0; } =20 -static struct ins_ops arithmetic_ops =3D { +static const struct ins_ops arithmetic_ops =3D { .parse =3D arithmetic__parse, .scnprintf =3D arithmetic__scnprintf, }; @@ -772,7 +772,7 @@ static int load_store__parse(const struct arch *arch __= maybe_unused, struct ins_ return 0; } =20 -static struct ins_ops load_store_ops =3D { +static const struct ins_ops load_store_ops =3D { .parse =3D load_store__parse, .scnprintf =3D load_store__scnprintf, }; @@ -813,7 +813,7 @@ static int dec__scnprintf(struct ins *ins, char *bf, si= ze_t size, ops->target.name ?: ops->target.raw); } =20 -static struct ins_ops dec_ops =3D { +static const struct ins_ops dec_ops =3D { .parse =3D dec__parse, .scnprintf =3D dec__scnprintf, }; @@ -824,11 +824,11 @@ static int nop__scnprintf(struct ins *ins __maybe_unu= sed, char *bf, size_t size, return scnprintf(bf, size, "%-*s", max_ins_name, "nop"); } =20 -static struct ins_ops nop_ops =3D { +static const struct ins_ops nop_ops =3D { .scnprintf =3D nop__scnprintf, }; =20 -static struct ins_ops ret_ops =3D { +static const struct ins_ops ret_ops =3D { .scnprintf =3D ins__raw_scnprintf, }; =20 @@ -869,7 +869,7 @@ static void ins__sort(struct arch *arch) qsort(arch->instructions, nmemb, sizeof(struct ins), ins__cmp); } =20 -static struct ins_ops *__ins__find(const struct arch *arch, const char *na= me, +static const struct ins_ops *__ins__find(const struct arch *arch, const ch= ar *name, struct disasm_line *dl) { struct ins *ins; @@ -880,7 +880,7 @@ static struct ins_ops *__ins__find(const struct arch *a= rch, const char *name, * For powerpc, identify the instruction ops * from the opcode using raw_insn. */ - struct ins_ops *ops; + const struct ins_ops *ops; =20 ops =3D check_ppc_insn(dl); if (ops) @@ -916,9 +916,9 @@ static struct ins_ops *__ins__find(const struct arch *a= rch, const char *name, return ins ? ins->ops : NULL; } =20 -struct ins_ops *ins__find(const struct arch *arch, const char *name, struc= t disasm_line *dl) +const struct ins_ops *ins__find(const struct arch *arch, const char *name,= struct disasm_line *dl) { - struct ins_ops *ops =3D __ins__find(arch, name, dl); + const struct ins_ops *ops =3D __ins__find(arch, name, dl); =20 if (!ops && arch->associate_instruction_ops) ops =3D arch->associate_instruction_ops((struct arch *)arch, name); diff --git a/tools/perf/util/disasm.h b/tools/perf/util/disasm.h index 273a9c906514..dc5233f2a773 100644 --- a/tools/perf/util/disasm.h +++ b/tools/perf/util/disasm.h @@ -22,7 +22,7 @@ struct arch { struct ins *instructions; size_t nr_instructions; size_t nr_instructions_allocated; - struct ins_ops *(*associate_instruction_ops)(struct arch *arch, const ch= ar *name); + const struct ins_ops *(*associate_instruction_ops)(struct arch *arch, co= nst char *name); bool sorted_instructions; bool initialized; const char *insn_suffix; @@ -52,7 +52,7 @@ struct arch { =20 struct ins { const char *name; - struct ins_ops *ops; + const struct ins_ops *ops; }; =20 struct ins_operands { @@ -108,7 +108,7 @@ struct annotate_args { const struct arch *arch__find(const char *name); bool arch__is(const struct arch *arch, const char *name); =20 -struct ins_ops *ins__find(const struct arch *arch, const char *name, struc= t disasm_line *dl); +const struct ins_ops *ins__find(const struct arch *arch, const char *name,= struct disasm_line *dl); =20 bool ins__is_call(const struct ins *ins); bool ins__is_jump(const struct ins *ins); --=20 2.52.0.457.g6b5491de43-goog