From patchwork Thu Feb 23 08:32:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: tip-bot2 for Thomas Gleixner X-Patchwork-Id: 60841 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp204086wrd; Thu, 23 Feb 2023 00:41:18 -0800 (PST) X-Google-Smtp-Source: AK7set9B0JnDpvNZ9IUUy+3eP/ZSobtKsfrN5L2oXnI+ugr7doCaAMgQJccM9UKlx9TtLxlHXu24 X-Received: by 2002:a05:6a20:7f97:b0:be:f5f3:a195 with SMTP id d23-20020a056a207f9700b000bef5f3a195mr12740682pzj.3.1677141678454; Thu, 23 Feb 2023 00:41:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677141678; cv=none; d=google.com; s=arc-20160816; b=rWzk28LT/AjoLCZOutZulRXwbFm5oboDe6jNGV3GpWZhzturV2aw/wfEz6OO4cunjV VhbB6gWGUFxS0xk5P2V+NpdYA5RhmCq/DklI2uCRpWDmfinej5HWOX4Hd0NwJHJiHzjK pWI6jRPaeZJrpI0lweLi2/K+efWn9bke+3OD0Am02kovLVTOKQOHsl11PNuKRLR9Wfwh WlRJgbzqKxsYySMTjJGDhsrSEnv6Qx4cMWZdZhx7A3TNMcls0pC+Tw9Ga8Hbjrp96LT5 uejlN9XwyKo0rcr7T/1jdjzdwbkEamMDC11tYLbWVg4XVezYSBU8hjsIvvY02vmqfg/P FI/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:references:in-reply-to:cc:subject :to:reply-to:sender:from:dkim-signature:dkim-signature:date; bh=7Kmj1/w+vickLd/6DB3c4kjCP73tN9o7hiQD9n5AzZo=; b=Lfk4X2VcziB561eN6He7GcvvSXLZN8XpQyh6XZPNIbSrwOpxXeMfs1dNoaUwp8l6yu AxgOgZv9nPzG8G8abvt6HgttrOpXuN2z7Riv8EE87hF3miD3A/CmXXF/lNJ/fazRO+MB 0HX7aFEiHzR018jTrTS+FOwOU0HL5nXh84gwuRRU49kgUuEPItUoXxYrU38QqR/EC/DG +gFN5NI9EwYQR4mok8G4L8biC47ahEIxh9+pCgcf8Nd/+D78zeF7fXhyoUVssK0VLMox Ovq7axgeomp0c/+hUEehPAKLVkF+Do6EkWCtVL+QNYKA6+WHo6oGlL+H3v5itBWgxCoQ 62mg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b="khwCOBQ/"; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l185-20020a6388c2000000b00502d650cfa2si8497330pgd.811.2023.02.23.00.41.04; Thu, 23 Feb 2023 00:41:18 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b="khwCOBQ/"; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233620AbjBWIcn (ORCPT + 99 others); Thu, 23 Feb 2023 03:32:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55840 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233363AbjBWIcO (ORCPT ); Thu, 23 Feb 2023 03:32:14 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5EE0B4D627; Thu, 23 Feb 2023 00:32:12 -0800 (PST) Date: Thu, 23 Feb 2023 08:32:08 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1677141128; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=7Kmj1/w+vickLd/6DB3c4kjCP73tN9o7hiQD9n5AzZo=; b=khwCOBQ/tX1B9s/qHTZeq/3OT4eNI014Grz8Wm4UVZqqVq2YRZA2mguOy0IgpqbKysrqiF F1qTnm5u4Siyf9/gRPI1xGou9FTyfX+nTkAIu8/yMsD0Q6VeHLnwBaw6t2s7kg6qgogZIa viAGp3ox5eQ2i+CceJv1jffC/fSOEr2I/qjBFTBBn41+MwXLhK7k85AybqdcYbLAUBJGau i5XP1o/Kb/c50fh1C8+DuBnyHEYmd7aARrg3gNHcCkUSQ7wZgHsNtxfQTd4LZu8Zm3lY2d UhFhf4iMs6MCjbgvZa9RtySDkvKhiKvgO7NfLNKoGUdXig/fmpU6ZLNJAQw3CA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1677141128; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=7Kmj1/w+vickLd/6DB3c4kjCP73tN9o7hiQD9n5AzZo=; b=wKoEtkjOH3IL/lVB+PA5soK686Xpn61XQT1vCNVuH+juZZc3eRUYSsKTIAtRvQ8xKdvb2E 19+xYBqGdmnB1MAA== From: "tip-bot2 for Peter Zijlstra" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: objtool/core] objtool: Make instruction::stack_ops a single-linked list Cc: "Peter Zijlstra (Intel)" , Ingo Molnar , Josh Poimboeuf , Nathan Chancellor , linux@weissschuh.net, x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20230208172245.362196959@infradead.org> References: <20230208172245.362196959@infradead.org> MIME-Version: 1.0 Message-ID: <167714112801.5837.11298340280066463263.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1757285087343064601?= X-GMAIL-MSGID: =?utf-8?q?1758610512625389918?= The following commit has been merged into the objtool/core branch of tip: Commit-ID: 3ee88df1b063962e39d7798ccc3b18fd10cea813 Gitweb: https://git.kernel.org/tip/3ee88df1b063962e39d7798ccc3b18fd10cea813 Author: Peter Zijlstra AuthorDate: Wed, 08 Feb 2023 18:17:58 +01:00 Committer: Ingo Molnar CommitterDate: Thu, 23 Feb 2023 09:20:59 +01:00 objtool: Make instruction::stack_ops a single-linked list struct instruction { struct list_head list; /* 0 16 */ struct hlist_node hash; /* 16 16 */ struct list_head call_node; /* 32 16 */ struct section * sec; /* 48 8 */ long unsigned int offset; /* 56 8 */ /* --- cacheline 1 boundary (64 bytes) --- */ unsigned int len; /* 64 4 */ enum insn_type type; /* 68 4 */ long unsigned int immediate; /* 72 8 */ u16 dead_end:1; /* 80: 0 2 */ u16 ignore:1; /* 80: 1 2 */ u16 ignore_alts:1; /* 80: 2 2 */ u16 hint:1; /* 80: 3 2 */ u16 save:1; /* 80: 4 2 */ u16 restore:1; /* 80: 5 2 */ u16 retpoline_safe:1; /* 80: 6 2 */ u16 noendbr:1; /* 80: 7 2 */ u16 entry:1; /* 80: 8 2 */ /* XXX 7 bits hole, try to pack */ s8 instr; /* 82 1 */ u8 visited; /* 83 1 */ /* XXX 4 bytes hole, try to pack */ struct alt_group * alt_group; /* 88 8 */ struct symbol * call_dest; /* 96 8 */ struct instruction * jump_dest; /* 104 8 */ struct instruction * first_jump_src; /* 112 8 */ struct reloc * jump_table; /* 120 8 */ /* --- cacheline 2 boundary (128 bytes) --- */ struct reloc * reloc; /* 128 8 */ struct list_head alts; /* 136 16 */ struct symbol * sym; /* 152 8 */ - struct list_head stack_ops; /* 160 16 */ - struct cfi_state * cfi; /* 176 8 */ + struct stack_op * stack_ops; /* 160 8 */ + struct cfi_state * cfi; /* 168 8 */ - /* size: 184, cachelines: 3, members: 29 */ - /* sum members: 178, holes: 1, sum holes: 4 */ + /* size: 176, cachelines: 3, members: 29 */ + /* sum members: 170, holes: 1, sum holes: 4 */ /* sum bitfield members: 9 bits, bit holes: 1, sum bit holes: 7 bits */ - /* last cacheline: 56 bytes */ + /* last cacheline: 48 bytes */ }; pre: 5:58.22 real, 226.69 user, 131.22 sys, 26221520 mem post: 5:58.50 real, 229.64 user, 128.65 sys, 26221520 mem Signed-off-by: Peter Zijlstra (Intel) Signed-off-by: Ingo Molnar Acked-by: Josh Poimboeuf Tested-by: Nathan Chancellor # build only Tested-by: Thomas Weißschuh # compile and run Link: https://lore.kernel.org/r/20230208172245.362196959@infradead.org --- tools/objtool/arch/x86/decode.c | 4 ++-- tools/objtool/check.c | 11 +++++------ tools/objtool/include/objtool/arch.h | 2 +- tools/objtool/include/objtool/check.h | 2 +- 4 files changed, 9 insertions(+), 10 deletions(-) diff --git a/tools/objtool/arch/x86/decode.c b/tools/objtool/arch/x86/decode.c index c5c4927..9ef024f 100644 --- a/tools/objtool/arch/x86/decode.c +++ b/tools/objtool/arch/x86/decode.c @@ -105,7 +105,7 @@ bool arch_pc_relative_reloc(struct reloc *reloc) #define ADD_OP(op) \ if (!(op = calloc(1, sizeof(*op)))) \ return -1; \ - else for (list_add_tail(&op->list, ops_list); op; op = NULL) + else for (*ops_list = op, ops_list = &op->next; op; op = NULL) /* * Helpers to decode ModRM/SIB: @@ -148,7 +148,7 @@ int arch_decode_instruction(struct objtool_file *file, const struct section *sec unsigned long offset, unsigned int maxlen, struct instruction *insn) { - struct list_head *ops_list = &insn->stack_ops; + struct stack_op **ops_list = &insn->stack_ops; const struct elf *elf = file->elf; struct insn ins; int x86_64, ret; diff --git a/tools/objtool/check.c b/tools/objtool/check.c index b3b423d..8109d74 100644 --- a/tools/objtool/check.c +++ b/tools/objtool/check.c @@ -398,7 +398,6 @@ static int decode_instructions(struct objtool_file *file) } memset(insn, 0, sizeof(*insn)); INIT_LIST_HEAD(&insn->alts); - INIT_LIST_HEAD(&insn->stack_ops); INIT_LIST_HEAD(&insn->call_node); insn->sec = sec; @@ -1331,12 +1330,13 @@ static struct reloc *insn_reloc(struct objtool_file *file, struct instruction *i static void remove_insn_ops(struct instruction *insn) { - struct stack_op *op, *tmp; + struct stack_op *op, *next; - list_for_each_entry_safe(op, tmp, &insn->stack_ops, list) { - list_del(&op->list); + for (op = insn->stack_ops; op; op = next) { + next = op->next; free(op); } + insn->stack_ops = NULL; } static void annotate_call_site(struct objtool_file *file, @@ -1781,7 +1781,6 @@ static int handle_group_alt(struct objtool_file *file, } memset(nop, 0, sizeof(*nop)); INIT_LIST_HEAD(&nop->alts); - INIT_LIST_HEAD(&nop->stack_ops); nop->sec = special_alt->new_sec; nop->offset = special_alt->new_off + special_alt->new_len; @@ -3226,7 +3225,7 @@ static int handle_insn_ops(struct instruction *insn, { struct stack_op *op; - list_for_each_entry(op, &insn->stack_ops, list) { + for (op = insn->stack_ops; op; op = op->next) { if (update_cfi_state(insn, next_insn, &state->cfi, op)) return 1; diff --git a/tools/objtool/include/objtool/arch.h b/tools/objtool/include/objtool/arch.h index 73149f8..2b6d2ce 100644 --- a/tools/objtool/include/objtool/arch.h +++ b/tools/objtool/include/objtool/arch.h @@ -62,9 +62,9 @@ struct op_src { }; struct stack_op { + struct stack_op *next; struct op_dest dest; struct op_src src; - struct list_head list; }; struct instruction; diff --git a/tools/objtool/include/objtool/check.h b/tools/objtool/include/objtool/check.h index acd7fae..23e9819 100644 --- a/tools/objtool/include/objtool/check.h +++ b/tools/objtool/include/objtool/check.h @@ -68,7 +68,7 @@ struct instruction { struct reloc *reloc; struct list_head alts; struct symbol *sym; - struct list_head stack_ops; + struct stack_op *stack_ops; struct cfi_state *cfi; };