Received: by 2002:a05:7412:b795:b0:e2:908c:2ebd with SMTP id iv21csp556407rdb; Thu, 2 Nov 2023 11:02:48 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGm61O/+Jp6LPy7kk8gxj69mxkwFjYDNau2yi+OcMqPMeDEIjMO5j+KBi3HaGjnmmWAjIct X-Received: by 2002:a17:903:18b:b0:1cc:665d:f818 with SMTP id z11-20020a170903018b00b001cc665df818mr9167781plg.68.1698948167720; Thu, 02 Nov 2023 11:02:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698948167; cv=none; d=google.com; s=arc-20160816; b=Sy8smxZ6X/GFse4cKosFyi3/UotOD9hWNB67Zc6IRNk27hOF6s8I3CjULdB/LONdrF vts6jTfTn6hxveZZ4JIIjD3VRMnqu5wJOkgQ+/umVFVDgoyOqadeZitWbD935DhAW5Dq l8UTy7jb2E9bdMe8fJ7mVND/CQ9DXqVOONWz0bpQxxllDCfYGDj9fGWxCsaz1cbkGIRK hZNH/lXKa87ZdbYS4+1/TFxu2+mSctjYEFFSZ8jX5/5WgR40vcnZn2/0g7iWdfGYuiud lNIpoH9TJ7tgE6EUBmAvJug+vfMec4W2BoSI8R4iobin1YrjQooEdp9CExkRCfpXLyj4 CxzA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:from:subject:references:mime-version :message-id:in-reply-to:date:dkim-signature; bh=k3TtAg+I2R6K8AopfIE6/ORtNyu4pjlALtW9HfSnMIY=; fh=z1KcSqUpYQ9oC4uLSeIkhAYTnJ2bvP0QbNW2xqV5NqA=; b=pY3hkvMAJNiQUb9+RtMLBfJ9c75v7Xn26PhBHc9F8FaDqb/xEiEC5ip/hiVd/eSO4g 7mZqU0ChOVnOmB0b130EoGy8o9aksEl77uUC1HWUAeYp6wnAleB9iFjsKtv2VEJcSz/g /2EtcsM4bjqdRGhXWHUcY1EXmB6aABwWvdVZdlxh9tMkNRSdW1q8li3ehP6tQNdnAeEj 8L+xbRLQRS+W9SEmoU88/vBPgEU+NG2hpfGb5Dgvl3s5EIj+2WlwbPYJtog+9CC/D4XE i8S7aAadNJThscKpQrlJ/3IG7OOsMgz+HD54a5tRt84OJMnhfxzxtOst0TfEnqcP6bob 3NTA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b="r0UJ/usL"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id v7-20020a170903238700b001bb9375b349si46883plh.536.2023.11.02.11.02.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Nov 2023 11:02:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b="r0UJ/usL"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id A75E481BDF37; Thu, 2 Nov 2023 11:01:25 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346483AbjKBSBM (ORCPT + 99 others); Thu, 2 Nov 2023 14:01:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59624 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235273AbjKBSAQ (ORCPT ); Thu, 2 Nov 2023 14:00:16 -0400 Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4961619AB for ; Thu, 2 Nov 2023 10:59:15 -0700 (PDT) Received: by mail-yb1-xb4a.google.com with SMTP id 3f1490d57ef6-da03390793fso1415227276.3 for ; Thu, 02 Nov 2023 10:59:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1698947954; x=1699552754; darn=vger.kernel.org; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=k3TtAg+I2R6K8AopfIE6/ORtNyu4pjlALtW9HfSnMIY=; b=r0UJ/usL62rK6RvtG0XyeOfNnOz4J2LzTXszYVxUnqn1dREgwHAqaG/0jQly610ngD a4BCxXGrew7a9pFJHXENdCVCHy36PfdRpAYNXxlGxdrsZIKyRmlWljoxgHSgbrmFC9q3 PM/b5l6v+V0JurcPCjiiwTxnIpouGZLPbZzXy/qwhIoB/oT6E978+QSgdKQ8AJ8vSfaz NTU3BtDHBmpjcgjU0p/3+h25a2hhWFLCLVICvgs6zX1reCF4GdSyTmT4bOO71GSr9hKf MmTLgAN8j9IYivVLIbjYAPpkD7cSN9rfBwsz6ARH9Ljg2UK8H2EZ1VLhmAGQ76z2FVZ3 JguQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698947954; x=1699552754; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=k3TtAg+I2R6K8AopfIE6/ORtNyu4pjlALtW9HfSnMIY=; b=VNyzCSMne6SZ1QRZfl/etzMLADZnDhELWkOYOheR1ZFJbZvp/ooCJHjQnNt6rwoaRe ajLZY0w9l4hM5+gmjiWoNEfObFT3fUbFqHFe5e2aSk3EqETMQY0Y75v/afg5BZEU9SKk 1rGoPmnJ7m8JwUzMCkeG/wm+b3qgGJw++IyDOP4k4ZkYvsaRQxVzE/E8Qfc1wMkrHYTX MO+8DhYOHfD0QPRcqx3LmWlTghwDcZk3yTrI220GaBtJm/4GV9h46aaQcUhMED2Y3SUb O62/a+6TaSX9fLDon5i2873nxbmN0SJIUo+7L/h4K1KapRERzynE7WilfI34U8wg+CdX /Ulw== X-Gm-Message-State: AOJu0YyHySC0VN+VwFHKxClzOY9fzRMlmFW0zg9Yth6WRpzVdTowzht2 1cB/fEakffuNkc2vwy9BsIxV9EWwaffF X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:bb34:df9c:836c:afca]) (user=irogers job=sendgmr) by 2002:a25:8088:0:b0:da3:723b:b298 with SMTP id n8-20020a258088000000b00da3723bb298mr165996ybk.7.1698947954372; Thu, 02 Nov 2023 10:59:14 -0700 (PDT) Date: Thu, 2 Nov 2023 10:57:16 -0700 In-Reply-To: <20231102175735.2272696-1-irogers@google.com> Message-Id: <20231102175735.2272696-35-irogers@google.com> Mime-Version: 1.0 References: <20231102175735.2272696-1-irogers@google.com> X-Mailer: git-send-email 2.42.0.869.gea05f2083d-goog Subject: [PATCH v4 34/53] perf dso: Reorder variables to save space in struct dso From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Ian Rogers , Adrian Hunter , Nick Terrell , Kan Liang , Andi Kleen , Kajol Jain , Athira Rajeev , Huacai Chen , Masami Hiramatsu , Vincent Whitchurch , "Steinar H. Gunderson" , Liam Howlett , Miguel Ojeda , Colin Ian King , Dmitrii Dolgov <9erthalion6@gmail.com>, Yang Jihong , Ming Wang , James Clark , K Prateek Nayak , Sean Christopherson , Leo Yan , Ravi Bangoria , German Gomez , Changbin Du , Paolo Bonzini , Li Dong , Sandipan Das , liuwenyu , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, USER_IN_DEF_DKIM_WL 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-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Thu, 02 Nov 2023 11:01:25 -0700 (PDT) Save 40 bytes and move from 8 to 7 cache lines. Make variable dwfl dependent on being a powerpc build. Squeeze bits of int/enum types when appropriate. Remove holes/padding by reordering variables. Before: ``` struct dso { struct mutex lock; /* 0 40 */ struct list_head node; /* 40 16 */ struct rb_node rb_node __attribute__((__aligned__(8))); /* 56 24 */ /* --- cacheline 1 boundary (64 bytes) was 16 bytes ago --- */ struct rb_root * root; /* 80 8 */ struct rb_root_cached symbols; /* 88 16 */ struct symbol * * symbol_names; /* 104 8 */ size_t symbol_names_len; /* 112 8 */ struct rb_root_cached inlined_nodes; /* 120 16 */ /* --- cacheline 2 boundary (128 bytes) was 8 bytes ago --- */ struct rb_root_cached srclines; /* 136 16 */ struct { u64 addr; /* 152 8 */ struct symbol * symbol; /* 160 8 */ } last_find_result; /* 152 16 */ void * a2l; /* 168 8 */ char * symsrc_filename; /* 176 8 */ unsigned int a2l_fails; /* 184 4 */ enum dso_space_type kernel; /* 188 4 */ /* --- cacheline 3 boundary (192 bytes) --- */ _Bool is_kmod; /* 192 1 */ /* XXX 3 bytes hole, try to pack */ enum dso_swap_type needs_swap; /* 196 4 */ enum dso_binary_type symtab_type; /* 200 4 */ enum dso_binary_type binary_type; /* 204 4 */ enum dso_load_errno load_errno; /* 208 4 */ u8 adjust_symbols:1; /* 212: 0 1 */ u8 has_build_id:1; /* 212: 1 1 */ u8 header_build_id:1; /* 212: 2 1 */ u8 has_srcline:1; /* 212: 3 1 */ u8 hit:1; /* 212: 4 1 */ u8 annotate_warned:1; /* 212: 5 1 */ u8 auxtrace_warned:1; /* 212: 6 1 */ u8 short_name_allocated:1; /* 212: 7 1 */ u8 long_name_allocated:1; /* 213: 0 1 */ u8 is_64_bit:1; /* 213: 1 1 */ /* XXX 6 bits hole, try to pack */ _Bool sorted_by_name; /* 214 1 */ _Bool loaded; /* 215 1 */ u8 rel; /* 216 1 */ /* XXX 7 bytes hole, try to pack */ struct build_id bid; /* 224 32 */ /* --- cacheline 4 boundary (256 bytes) --- */ u64 text_offset; /* 256 8 */ u64 text_end; /* 264 8 */ const char * short_name; /* 272 8 */ const char * long_name; /* 280 8 */ u16 long_name_len; /* 288 2 */ u16 short_name_len; /* 290 2 */ /* XXX 4 bytes hole, try to pack */ void * dwfl; /* 296 8 */ struct auxtrace_cache * auxtrace_cache; /* 304 8 */ int comp; /* 312 4 */ /* XXX 4 bytes hole, try to pack */ /* --- cacheline 5 boundary (320 bytes) --- */ struct { struct rb_root cache; /* 320 8 */ int fd; /* 328 4 */ int status; /* 332 4 */ u32 status_seen; /* 336 4 */ /* XXX 4 bytes hole, try to pack */ u64 file_size; /* 344 8 */ struct list_head open_entry; /* 352 16 */ u64 elf_base_addr; /* 368 8 */ u64 debug_frame_offset; /* 376 8 */ /* --- cacheline 6 boundary (384 bytes) --- */ u64 eh_frame_hdr_addr; /* 384 8 */ u64 eh_frame_hdr_offset; /* 392 8 */ } data; /* 320 80 */ struct { u32 id; /* 400 4 */ u32 sub_id; /* 404 4 */ struct perf_env * env; /* 408 8 */ } bpf_prog; /* 400 16 */ union { void * priv; /* 416 8 */ u64 db_id; /* 416 8 */ }; /* 416 8 */ struct nsinfo * nsinfo; /* 424 8 */ struct dso_id id; /* 432 24 */ /* --- cacheline 7 boundary (448 bytes) was 8 bytes ago --- */ refcount_t refcnt; /* 456 4 */ char name[]; /* 460 0 */ /* size: 464, cachelines: 8, members: 49 */ /* sum members: 440, holes: 4, sum holes: 18 */ /* sum bitfield members: 10 bits, bit holes: 1, sum bit holes: 6 bits */ /* padding: 4 */ /* forced alignments: 1 */ /* last cacheline: 16 bytes */ } __attribute__((__aligned__(8))); ``` After: ``` struct dso { struct mutex lock; /* 0 40 */ struct list_head node; /* 40 16 */ struct rb_node rb_node __attribute__((__aligned__(8))); /* 56 24 */ /* --- cacheline 1 boundary (64 bytes) was 16 bytes ago --- */ struct rb_root * root; /* 80 8 */ struct rb_root_cached symbols; /* 88 16 */ struct symbol * * symbol_names; /* 104 8 */ size_t symbol_names_len; /* 112 8 */ struct rb_root_cached inlined_nodes; /* 120 16 */ /* --- cacheline 2 boundary (128 bytes) was 8 bytes ago --- */ struct rb_root_cached srclines; /* 136 16 */ struct { u64 addr; /* 152 8 */ struct symbol * symbol; /* 160 8 */ } last_find_result; /* 152 16 */ struct build_id bid; /* 168 32 */ /* --- cacheline 3 boundary (192 bytes) was 8 bytes ago --- */ u64 text_offset; /* 200 8 */ u64 text_end; /* 208 8 */ const char * short_name; /* 216 8 */ const char * long_name; /* 224 8 */ void * a2l; /* 232 8 */ char * symsrc_filename; /* 240 8 */ struct nsinfo * nsinfo; /* 248 8 */ /* --- cacheline 4 boundary (256 bytes) --- */ struct auxtrace_cache * auxtrace_cache; /* 256 8 */ union { void * priv; /* 264 8 */ u64 db_id; /* 264 8 */ }; /* 264 8 */ struct { struct perf_env * env; /* 272 8 */ u32 id; /* 280 4 */ u32 sub_id; /* 284 4 */ } bpf_prog; /* 272 16 */ struct { struct rb_root cache; /* 288 8 */ struct list_head open_entry; /* 296 16 */ u64 file_size; /* 312 8 */ /* --- cacheline 5 boundary (320 bytes) --- */ u64 elf_base_addr; /* 320 8 */ u64 debug_frame_offset; /* 328 8 */ u64 eh_frame_hdr_addr; /* 336 8 */ u64 eh_frame_hdr_offset; /* 344 8 */ int fd; /* 352 4 */ int status; /* 356 4 */ u32 status_seen; /* 360 4 */ } data; /* 288 80 */ /* XXX last struct has 4 bytes of padding */ struct dso_id id; /* 368 24 */ /* --- cacheline 6 boundary (384 bytes) was 8 bytes ago --- */ unsigned int a2l_fails; /* 392 4 */ int comp; /* 396 4 */ refcount_t refcnt; /* 400 4 */ enum dso_load_errno load_errno; /* 404 4 */ u16 long_name_len; /* 408 2 */ u16 short_name_len; /* 410 2 */ enum dso_binary_type symtab_type:8; /* 412: 0 4 */ enum dso_binary_type binary_type:8; /* 412: 8 4 */ enum dso_space_type kernel:2; /* 412:16 4 */ enum dso_swap_type needs_swap:2; /* 412:18 4 */ /* Bitfield combined with next fields */ _Bool is_kmod:1; /* 414: 4 1 */ u8 adjust_symbols:1; /* 414: 5 1 */ u8 has_build_id:1; /* 414: 6 1 */ u8 header_build_id:1; /* 414: 7 1 */ u8 has_srcline:1; /* 415: 0 1 */ u8 hit:1; /* 415: 1 1 */ u8 annotate_warned:1; /* 415: 2 1 */ u8 auxtrace_warned:1; /* 415: 3 1 */ u8 short_name_allocated:1; /* 415: 4 1 */ u8 long_name_allocated:1; /* 415: 5 1 */ u8 is_64_bit:1; /* 415: 6 1 */ /* XXX 1 bit hole, try to pack */ _Bool sorted_by_name; /* 416 1 */ _Bool loaded; /* 417 1 */ u8 rel; /* 418 1 */ char name[]; /* 419 0 */ /* size: 424, cachelines: 7, members: 48 */ /* sum members: 415 */ /* sum bitfield members: 31 bits, bit holes: 1, sum bit holes: 1 bits */ /* padding: 5 */ /* paddings: 1, sum paddings: 4 */ /* forced alignments: 1 */ /* last cacheline: 40 bytes */ } __attribute__((__aligned__(8))); ``` Signed-off-by: Ian Rogers --- tools/perf/util/dso.h | 84 +++++++++++++++++++++---------------------- 1 file changed, 42 insertions(+), 42 deletions(-) diff --git a/tools/perf/util/dso.h b/tools/perf/util/dso.h index 3759de8c2267..8bdc17d78b02 100644 --- a/tools/perf/util/dso.h +++ b/tools/perf/util/dso.h @@ -158,66 +158,66 @@ struct dso { u64 addr; struct symbol *symbol; } last_find_result; - void *a2l; - char *symsrc_filename; - unsigned int a2l_fails; - enum dso_space_type kernel; - bool is_kmod; - enum dso_swap_type needs_swap; - enum dso_binary_type symtab_type; - enum dso_binary_type binary_type; - enum dso_load_errno load_errno; - u8 adjust_symbols:1; - u8 has_build_id:1; - u8 header_build_id:1; - u8 has_srcline:1; - u8 hit:1; - u8 annotate_warned:1; - u8 auxtrace_warned:1; - u8 short_name_allocated:1; - u8 long_name_allocated:1; - u8 is_64_bit:1; - bool sorted_by_name; - bool loaded; - u8 rel; struct build_id bid; u64 text_offset; u64 text_end; const char *short_name; const char *long_name; - u16 long_name_len; - u16 short_name_len; + void *a2l; + char *symsrc_filename; +#if defined(__powerpc__) void *dwfl; /* DWARF debug info */ +#endif + struct nsinfo *nsinfo; struct auxtrace_cache *auxtrace_cache; - int comp; - + union { /* Tool specific area */ + void *priv; + u64 db_id; + }; + /* bpf prog information */ + struct { + struct perf_env *env; + u32 id; + u32 sub_id; + } bpf_prog; /* dso data file */ struct { struct rb_root cache; - int fd; - int status; - u32 status_seen; - u64 file_size; struct list_head open_entry; + u64 file_size; u64 elf_base_addr; u64 debug_frame_offset; u64 eh_frame_hdr_addr; u64 eh_frame_hdr_offset; + int fd; + int status; + u32 status_seen; } data; - /* bpf prog information */ - struct { - u32 id; - u32 sub_id; - struct perf_env *env; - } bpf_prog; - - union { /* Tool specific area */ - void *priv; - u64 db_id; - }; - struct nsinfo *nsinfo; struct dso_id id; + unsigned int a2l_fails; + int comp; refcount_t refcnt; + enum dso_load_errno load_errno; + u16 long_name_len; + u16 short_name_len; + enum dso_binary_type symtab_type:8; + enum dso_binary_type binary_type:8; + enum dso_space_type kernel:2; + enum dso_swap_type needs_swap:2; + bool is_kmod:1; + u8 adjust_symbols:1; + u8 has_build_id:1; + u8 header_build_id:1; + u8 has_srcline:1; + u8 hit:1; + u8 annotate_warned:1; + u8 auxtrace_warned:1; + u8 short_name_allocated:1; + u8 long_name_allocated:1; + u8 is_64_bit:1; + bool sorted_by_name; + bool loaded; + u8 rel; char name[]; }; -- 2.42.0.869.gea05f2083d-goog