Received: by 2002:a05:6a10:a852:0:0:0:0 with SMTP id d18csp1684254pxy; Thu, 6 May 2021 13:13:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwpcLLCkhPnWKrFWd6aXg7zLdPJMPQyoc5vL0iIOCVrZYQjrprEPFUXAklBoyWSIu/34sSj X-Received: by 2002:a17:90a:fed:: with SMTP id 100mr6598275pjz.89.1620332018491; Thu, 06 May 2021 13:13:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620332018; cv=none; d=google.com; s=arc-20160816; b=f5J9TOa9uieWP3+VWr+sIHLN6IZtxI+QYeowwCWYjTSLfbKj93FTcgso8JdQy9TOUg c1N8onG00C1PAJLOPvWSmUwXtE/QP6KkK50B8Gpfqjh23BO3Dt5OKjm1ACwThsMK9t3K f3z2LoU1xz7fK0tyUVNX++Ytallx2jFC7XlAsbhblrE6b+zK9RvxShbWfjNxJpoJC8On u+8OnJOLyDjY1/IOaULC6Tj3sK8CjbHhFdg9Au+VfXa2/9hOoAhV6pO1+7XnKJElANfX jChfqDbU1a2Pau8+d0ClKp/UlST4MCSAsVW9OAm8uFmBf6guzflULOSyG8K3x7RK57Xx A8nQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:subject:cc:to:from:date :user-agent:message-id:dkim-signature; bh=4/Kg4dI+18FY0Fs01of1GO1sfd1Na4+Q4lbePNnqLrE=; b=Ws3raiE+aU75Wtxfe2/A4W639lYcEJgDbldDAZs3/snI27X39TC0tfTXsut2F1mOEW HRnnGRVQlHEGub4CN4sBgD97Oa2nvwjY49zIsMn8MtPOc4gDO2m0KFZD8xQx2mCgcpvR zR7CWWk/2zx1Kddq5kAZVCa4dHpWUgjI0tMLaZE0vbym6IhHq5DKEvqJmsm3NFccOwnH DuhB4zvjpc8iHAZ2dswZLDKcTqHS87kIo12LVk40wBJEZ4DKnqZaf/zRf9tVYHjJyQM/ JG3ZckdVsWNjOcgG2+jLc0ECHKulksAqEuJ9iDOFTmBWHRCmDo7b5Cb+PEHhgei7u1dO dVcA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=desiato.20200630 header.b=G80oCrU9; 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 c13si4623251pfl.283.2021.05.06.13.13.25; Thu, 06 May 2021 13:13:38 -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=pass header.i=@infradead.org header.s=desiato.20200630 header.b=G80oCrU9; 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 S235734AbhEFTn6 (ORCPT + 99 others); Thu, 6 May 2021 15:43:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33278 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235634AbhEFTnu (ORCPT ); Thu, 6 May 2021 15:43:50 -0400 Received: from desiato.infradead.org (desiato.infradead.org [IPv6:2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 126E4C0613ED for ; Thu, 6 May 2021 12:42:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; 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=4/Kg4dI+18FY0Fs01of1GO1sfd1Na4+Q4lbePNnqLrE=; b=G80oCrU9/4hgbYUKt7h4dBj4DG aXbgll7J/2vaDZ7chwTHauHQHlxBbmqYi0xJmf4R9MjlY12SNf8cPAlW7+oI6X3f1cAyOf2Y7bh/9 K3c6KY+WcW9DbeDdzLC0eZGpa7EVYn4fES3aCHi+yjIbB0aGk+OCQCz/LIhSOV+rup02ms1/ehZIq BReZ8Rq+yXk97nrvUZVVZSBpi5dUEvvjRpA4p0SWsKyxgAI+2ZCcYohF9Fnb/4oypn3cr7jmVBS6r wnaV2DoyoAfTn+2T+3DSqsPqkDAaTDNn65uU5C/lzwEpOlknLGj83vdKjQSnSVHxF5R0GefPsrNP8 euZEujhg==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by desiato.infradead.org with esmtpsa (Exim 4.94 #2 (Red Hat Linux)) id 1lejtT-005BMC-9e; Thu, 06 May 2021 19:42:43 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 2870B300386; Thu, 6 May 2021 21:42:39 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 0) id D2CDE20B96F92; Thu, 6 May 2021 21:42:38 +0200 (CEST) Message-ID: <20210506194158.153101906@infradead.org> User-Agent: quilt/0.66 Date: Thu, 06 May 2021 21:34:04 +0200 From: Peter Zijlstra To: x86@kernel.org, jpoimboe@redhat.com, jbaron@akamai.com, rostedt@goodmis.org, ardb@kernel.org Cc: linux-kernel@vger.kernel.org, peterz@infradead.org Subject: [PATCH 12/13] objtool: Provide stats for jump_labels References: <20210506193352.719596001@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add objtool --stats to count the jump_label sites it encounters. Signed-off-by: Peter Zijlstra (Intel) --- tools/objtool/check.c | 22 ++++++++++++++++++++-- tools/objtool/include/objtool/objtool.h | 3 +++ 2 files changed, 23 insertions(+), 2 deletions(-) --- a/tools/objtool/check.c +++ b/tools/objtool/check.c @@ -1225,8 +1225,15 @@ static int handle_jump_alt(struct objtoo struct instruction *orig_insn, struct instruction **new_insn) { - if (orig_insn->type == INSN_NOP) + if (orig_insn->type == INSN_NOP) { +do_nop: + if (orig_insn->len == 2) + file->jl_nop_short++; + else + file->jl_nop_long++; + return 0; + } if (orig_insn->type != INSN_JUMP_UNCONDITIONAL) { WARN_FUNC("unsupported instruction at jump label", @@ -1245,9 +1252,14 @@ static int handle_jump_alt(struct objtoo orig_insn->offset, orig_insn->len, arch_nop_insn(orig_insn->len)); orig_insn->type = INSN_NOP; - return 0; + goto do_nop; } + if (orig_insn->len == 2) + file->jl_short++; + else + file->jl_long++; + *new_insn = list_next_entry(orig_insn, list); return 0; } @@ -1328,6 +1340,12 @@ static int add_special_section_alts(stru free(special_alt); } + if (stats) { + printf("jl\\\tNOP\tJMP\n"); + printf("short:\t%ld\t%ld\n", file->jl_nop_short, file->jl_short); + printf("long:\t%ld\t%ld\n", file->jl_nop_long, file->jl_long); + } + out: return ret; } --- a/tools/objtool/include/objtool/objtool.h +++ b/tools/objtool/include/objtool/objtool.h @@ -22,6 +22,9 @@ struct objtool_file { struct list_head static_call_list; struct list_head mcount_loc_list; bool ignore_unreachables, c_file, hints, rodata; + + unsigned long jl_short, jl_long; + unsigned long jl_nop_short, jl_nop_long; }; struct objtool_file *objtool_open_read(const char *_objname);