From nobody Sat Feb 7 10:08:40 2026 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6092A156F55; Thu, 28 Nov 2024 09:44:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=90.155.50.34 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732787048; cv=none; b=a4W2eB5FyuHZatsRlTXX5r93q7D0f/bKeEmZFinMsdiKQZxWh7YK7yq105ViGz+PU7aC8dNlRAw96NO8kU7OPbabrm5GJplfai6ngL84CrLhbda9H2tHdij+NCUeymdbnZ91NpVCDUKocoMfjWktUeR85tg5mAtylJ0DWbtkdHg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732787048; c=relaxed/simple; bh=QqoGUswWnCATEHYv3H6l0MFwT5RLbh6t4mujW8kXHsw=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=mzttXnK2JCatfGDcv73dCmwspHCe/gg3g8fv5bsurFkI+9voyBjSpp3Vm19aj843e6WSHt0yaq7TBtEi4tD1P9Jw+/qTyDg0ZOUtI4cNKLHATuVEJ1KXBIVJBwIsX+JP096kWn5kRVDMiApU8k4wi1hxGk6GB2WL/45bqcJgxqE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org; spf=none smtp.mailfrom=infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=gTFkEPMQ; arc=none smtp.client-ip=90.155.50.34 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=infradead.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="gTFkEPMQ" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Type:MIME-Version:References: Subject:Cc:To:From:Date:Message-ID:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:In-Reply-To; bh=FDckB11/j3OVAfIOhlTnymsn2RpaHfCKYThx7MpzQSQ=; b=gTFkEPMQ3LOpkRjIU3kXwsHG+J /t6XIvFleqXxjnx3GbWbI8ttFinZXdN26R88TuPmgn/rzhcXEMzHJI/lge9Ag9Dme96jOIcK67z0x Ai+ZyjtbC4jG7vXI/EB2d5dqWGSWCBQZkgdeYL9QJZCcZNIN3byvEQ6pqe9fi4r39Oc6o/ei8N0di xjCvv3vSrNlUOjtzbUntPf2w1byj4UJGhQZ69+p5Qb3J6XA5ZKCS8d/82gjgWN2fAdIZbED8yaCW8 NdJPHyNXIuA65dyrzfmNeJ/KM8Bv3rbgHo6g34gdOLDUaCUnq8kobt5lPkndNCV4QpdyhyeyPfsWo 8FjrcZiA==; Received: from 77-249-17-89.cable.dynamic.v4.ziggo.nl ([77.249.17.89] helo=noisy.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.98 #2 (Red Hat Linux)) id 1tGb47-00000002Tpt-0Rvh; Thu, 28 Nov 2024 09:44:04 +0000 Received: by noisy.programming.kicks-ass.net (Postfix, from userid 0) id 1CCA0301171; Thu, 28 Nov 2024 10:44:03 +0100 (CET) Message-ID: <20241128094311.688871544@infradead.org> User-Agent: quilt/0.66 Date: Thu, 28 Nov 2024 10:38:59 +0100 From: Peter Zijlstra To: jpoimboe@kernel.org Cc: chenhuacai@kernel.org, kernel@xen0n.name, x86@kernel.org, peterz@infradead.org, loongarch@lists.linux.dev, linux-kernel@vger.kernel.org Subject: [PATCH v2 08/16] objtool: Collapse annotate sequences References: <20241128093851.469225872@infradead.org> 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" Reduce read_annotate() runs by collapsing subsequent runs into a single call. Signed-off-by: Peter Zijlstra (Intel) --- tools/objtool/check.c | 87 ++++++++++++++++++---------------------------= ----- 1 file changed, 32 insertions(+), 55 deletions(-) --- a/tools/objtool/check.c +++ b/tools/objtool/check.c @@ -2381,21 +2381,24 @@ static int read_annotate(struct objtool_ return 0; } =20 -static int __annotate_ignore_alts(struct objtool_file *file, int type, str= uct instruction *insn) +static int __annotate_early(struct objtool_file *file, int type, struct in= struction *insn) { - if (type !=3D ANNOTYPE_IGNORE_ALTS) - return 0; + switch (type) { + case ANNOTYPE_IGNORE_ALTS: + insn->ignore_alts =3D true; + break; =20 - insn->ignore_alts =3D true; - return 0; -} + /* + * Must be before read_unwind_hints() since that needs insn->noendbr. + */ + case ANNOTYPE_NOENDBR: + insn->noendbr =3D 1; + break; =20 -static int __annotate_noendbr(struct objtool_file *file, int type, struct = instruction *insn) -{ - if (type !=3D ANNOTYPE_NOENDBR) - return 0; + default: + break; + } =20 - insn->noendbr =3D 1; return 0; } =20 @@ -2429,26 +2432,21 @@ static int __annotate_ifc(struct objtool return 0; } =20 -static int __annotate_retpoline_safe(struct objtool_file *file, int type, = struct instruction *insn) +static int __annotate_late(struct objtool_file *file, int type, struct ins= truction *insn) { - if (type !=3D ANNOTYPE_RETPOLINE_SAFE) - return 0; - - if (insn->type !=3D INSN_JUMP_DYNAMIC && - insn->type !=3D INSN_CALL_DYNAMIC && - insn->type !=3D INSN_RETURN && - insn->type !=3D INSN_NOP) { - WARN_INSN(insn, "retpoline_safe hint not an indirect jump/call/ret/nop"); - return -1; - } + switch (type) { + case ANNOTYPE_RETPOLINE_SAFE: + if (insn->type !=3D INSN_JUMP_DYNAMIC && + insn->type !=3D INSN_CALL_DYNAMIC && + insn->type !=3D INSN_RETURN && + insn->type !=3D INSN_NOP) { + WARN_INSN(insn, "retpoline_safe hint not an indirect jump/call/ret/nop"= ); + return -1; + } =20 - insn->retpoline_safe =3D true; - return 0; -} + insn->retpoline_safe =3D true; + break; =20 -static int __annotate_instr(struct objtool_file *file, int type, struct in= struction *insn) -{ - switch (type) { case ANNOTYPE_INSTR_BEGIN: insn->instr++; break; @@ -2457,6 +2455,10 @@ static int __annotate_instr(struct objto insn->instr--; break; =20 + case ANNOTYPE_UNRET_BEGIN: + insn->unret =3D 1; + break; + default: break; } @@ -2464,16 +2466,6 @@ static int __annotate_instr(struct objto return 0; } =20 -static int __annotate_unret(struct objtool_file *file, int type, struct in= struction *insn) -{ - if (type !=3D ANNOTYPE_UNRET_BEGIN) - return 0; - - insn->unret =3D 1; - return 0; - -} - /* * Return true if name matches an instrumentation function, where calls to= that * function from noinstr code can safely be removed, but compilers won't d= o so. @@ -2583,14 +2575,7 @@ static int decode_sections(struct objtoo add_ignores(file); add_uaccess_safe(file); =20 - ret =3D read_annotate(file, __annotate_ignore_alts); - if (ret) - return ret; - - /* - * Must be before read_unwind_hints() since that needs insn->noendbr. - */ - ret =3D read_annotate(file, __annotate_noendbr); + ret =3D read_annotate(file, __annotate_early); if (ret) return ret; =20 @@ -2636,15 +2621,7 @@ static int decode_sections(struct objtoo if (ret) return ret; =20 - ret =3D read_annotate(file, __annotate_retpoline_safe); - if (ret) - return ret; - - ret =3D read_annotate(file, __annotate_instr); - if (ret) - return ret; - - ret =3D read_annotate(file, __annotate_unret); + ret =3D read_annotate(file, __annotate_late); if (ret) return ret;