Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp1363744rdb; Wed, 6 Dec 2023 17:22:53 -0800 (PST) X-Google-Smtp-Source: AGHT+IHCO6DFEefIBWB0DoYNN+3Gdf5bsv3MkmLLdSoxwvsSC8uceik4MCAFkpXThTsWHRkN5j1b X-Received: by 2002:a05:6a00:4305:b0:6ce:72f9:8680 with SMTP id cb5-20020a056a00430500b006ce72f98680mr1735095pfb.38.1701912173159; Wed, 06 Dec 2023 17:22:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701912173; cv=none; d=google.com; s=arc-20160816; b=DwbfN05NBD8QGpsAguz6mCpUzHsbbKIz2TTTg1J/Z2TXbaIGv7QvYDinMEwLpp7cfr ptx927hi4eFQTEcSipvTpKQB/CWsxL1e6J0d+6FshFkM3i6Wcjyn1hhXd6WwSmdfDs8o ov1MRJCYkX9kxeCCtGdIM4+/GlKUcnKTCZXfq2i/NferNnQiGkNVczcQpIJ7ZClbEQSb nvwO2r0MWZ4Y0DPnF9oV7GnGG9eJ+Rru4XJbYKpG1XKISsPqs6OXgxjZBFlt9I5P5i57 Jq3tjUsOEXzm4ZD8IadyHpzgXArMBlhatuvK55Ds3X2lvh2FRNyFx7tdrX2BGGzt5n0p P5cg== 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=HpIxg4nqFiCoM7pb7LX1eOoCjvBevBq2O8IO0Pdf/d8=; fh=Io7x3OacpefNRRNKoYAzVE0aWTDwD7FRzyCdD1e3AN4=; b=TBB3WLuXVeRMhtqLLYgjZMyal25b+t1Pqjnj7GqLDDb3cSZTSMP/9rHS5CuoXUtSoP 4CoHGMOuDi3FVry4NKTMtrc06Y0AkJhJneb+3k3sVsfnL9zk5+cs4ypSJaJ3WkKu6mOm z5FIgIw1Ld43NpyKnsCdrxLQUnOMSBl9wcGy0BPLDqn2Gp82UHd22cmVWxYHk66oqdQg YssvGEyKm+S476RzEBFgpUnSnGMfInvwtsh5M3Eul9OVFTwLP2ORCBMKiEAz3aqVQypQ 8IXoxEGdA1I2Pwl1cI8ENwLJrZPtiaT9wAM/PDGa91I84fC/x/CtXRsHfpKRh+ChzRvD Efvw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b="zFns5eF/"; 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 cb11-20020a056a02070b00b0055be9543340si200614pgb.872.2023.12.06.17.22.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Dec 2023 17:22:53 -0800 (PST) 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="zFns5eF/"; 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 2541280DECC7; Wed, 6 Dec 2023 17:20:25 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1443137AbjLGBUF (ORCPT + 99 others); Wed, 6 Dec 2023 20:20:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56708 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1442958AbjLGBTV (ORCPT ); Wed, 6 Dec 2023 20:19:21 -0500 Received: from mail-yw1-x1149.google.com (mail-yw1-x1149.google.com [IPv6:2607:f8b0:4864:20::1149]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1B70826AE for ; Wed, 6 Dec 2023 17:18:50 -0800 (PST) Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-5d988d69812so2008767b3.0 for ; Wed, 06 Dec 2023 17:18:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1701911929; x=1702516729; 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=HpIxg4nqFiCoM7pb7LX1eOoCjvBevBq2O8IO0Pdf/d8=; b=zFns5eF/J7nWm3yb3m0c7b7QTNuhSpntBvAZhyVKMBGL/6KrZkX6K3Fih1hykC7T8+ OstSZNXAMN2DDtkYIhizIGX7EyCj7Qnp3MW27OHT+mTgEK1rIUYvnRuldS3lL0kmU8gZ Fygrs5SltVxomP3tPBu2Icu0FlPBgsJsIU/iv9f28yN+Oq537Xm5T1WsXaOkRSAJ1zyX lxsLKwy/mNsRcDYB9VLG1uHuh3eXQFwoCm24WLditXnvztm+nuN5VkwvclBl67KCarPc qX3eX1A185fxBYZT1xf/5ieBfxAsq24Mdp40acCm+QK5sfJzbmXMHa8cHBt2wyta4FPu bNWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701911929; x=1702516729; 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=HpIxg4nqFiCoM7pb7LX1eOoCjvBevBq2O8IO0Pdf/d8=; b=uJcSuNHaNp2LPJWAYptGsTLtdW381mCIJ2jgl8faRN/Cv/7VH2Iyluhw61qsYBpgnM eHlv7lniBDJdJ9t9m7giz+zs+56XWpqmUUFFnLe2YcFkt0NzEZvsA+KPVVfrV0hVg4FN kM8luBxmzXU73QRZoGg9lgTSglceXCXmns1TzCApbDI0QYvztmSM4UOiY7+LBGpqZ6li LdUcEuWURrjpxBkUcdH8L/4oTq5GyZw3DyF6ps3mPza8/qF8Yi6/nJ5N09XGPku/+2N/ xJZyWyE9Hz0DWEaDo0tCmJkCazLza0j1clRN646GQbVKLRVRfU3wXbvlzRdsNDYItFa6 KFHg== X-Gm-Message-State: AOJu0YzfMcH/PYcaj9NupVIn6gKEGy7JlT6C7JlwpeIZUvLME4jc1WfH eVe1Dey3VVgVqjwdJQg1V+gqUIb2ukmM X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:35bf:293e:7696:34e9]) (user=irogers job=sendgmr) by 2002:a81:af28:0:b0:5d8:eec5:f57c with SMTP id n40-20020a81af28000000b005d8eec5f57cmr28157ywh.4.1701911928989; Wed, 06 Dec 2023 17:18:48 -0800 (PST) Date: Wed, 6 Dec 2023 17:17:09 -0800 In-Reply-To: <20231207011722.1220634-1-irogers@google.com> Message-Id: <20231207011722.1220634-36-irogers@google.com> Mime-Version: 1.0 References: <20231207011722.1220634-1-irogers@google.com> X-Mailer: git-send-email 2.43.0.rc2.451.g8631bc7472-goog Subject: [PATCH v6 35/47] perf threads: Reduce table size from 256 to 8 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, Guilherme Amadio 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]); Wed, 06 Dec 2023 17:20:25 -0800 (PST) The threads data structure is an array of hashmaps, previously rbtrees. The two levels allows for a fixed outer array where access is guarded by rw_semaphores. Commit 91e467bc568f ("perf machine: Use hashtable for machine threads") sized the outer table at 256 entries to avoid future scalability problems, however, this means the threads struct is sized at 30,720 bytes. As the hashmaps allow O(1) access for the common find/insert/remove operations, lower the number of entries to 8. This reduces the size overhead to 960 bytes. Signed-off-by: Ian Rogers --- tools/perf/util/threads.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/perf/util/threads.h b/tools/perf/util/threads.h index d03bd91a7769..da68d2223f18 100644 --- a/tools/perf/util/threads.h +++ b/tools/perf/util/threads.h @@ -7,7 +7,7 @@ struct thread; -#define THREADS__TABLE_BITS 8 +#define THREADS__TABLE_BITS 3 #define THREADS__TABLE_SIZE (1 << THREADS__TABLE_BITS) struct threads_table_entry { -- 2.43.0.rc2.451.g8631bc7472-goog