Received: by 2002:a05:7412:b795:b0:e2:908c:2ebd with SMTP id iv21csp557949rdb; Thu, 2 Nov 2023 11:04:52 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFArw1BVgoQ7tbK/LJGOtqqc3yyQJ6WdF3bDJMvGKUnqbl3mLo07gv4LPv3yRMg/h43ftVW X-Received: by 2002:a17:902:db04:b0:1c6:362:3553 with SMTP id m4-20020a170902db0400b001c603623553mr545125plx.31.1698948291603; Thu, 02 Nov 2023 11:04:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698948291; cv=none; d=google.com; s=arc-20160816; b=hQm3TbTH78b2P0pmdbfJ8kjWusFMn6g97hxq6vuqmy3TYe46BMEsF8UxwzJmR8cpLU J45WQdLBOuqumEKOSCiH9ouSbm8XQh0mNs+cZ7ZdghUBb4VSq35mIHS8QtqJa5JhzjxV 2XNhD7D5nJDBTHCn3Wpmzbb9FMh6RwYx00lc+b6inuOi3Skzv3xst7xKRgeO0oH5ejDJ JqK8JXj8Xo8wVWFmHYoNmf2um253V076dLXZxwsKFI7mYemtwPNQXu8A3TNyelyphgq6 oQ97fs3ve8jcBoax4CPbGCDb9EnG7IT3rPC9osSwkOreVrEcj8TtuacgpGiJwfn/17aK 37Mg== 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=SWO5cb/JGhq0YhhkeavtzpdshUSY9BdgMbF9Q9qBiTA=; fh=z1KcSqUpYQ9oC4uLSeIkhAYTnJ2bvP0QbNW2xqV5NqA=; b=V9TQn8vENTVhlGOk/GeitfcaB+JSAPbR5mvIlgWJooaV/fW5XBIvuGg+4AV4bT8Pi2 xncDm9fbi7uNJUM5q5R5mR9keqfMV0Qh3CljMi1h0/eoJj6Qk8HFnKY+kOtRCfbKZssQ MpBPuS1o6UJNo8S4uUPI2GdRaBSSohSPnTWItBWdazJCwualSQ6/VuH8ugPSerfolsWC jUEMaNHNrLOOvz6ftalZC++t37udxaFOuQp7RCnWM23jS5gjBBwGvLlSyYdSmZOz8+s9 lBLnMIRJ1av8ORO8+rjDqp6cfo/JGKTEoBcRShm9IFphdMEK4wg4Q7sUe1DQSDehbz4l H6AQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=uRoCphS4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 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 lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id n10-20020a170902e54a00b001c61bdd8e89si70525plf.150.2023.11.02.11.04.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Nov 2023 11:04:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=uRoCphS4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 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 lipwig.vger.email (Postfix) with ESMTP id B172782157AD; Thu, 2 Nov 2023 11:04:36 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235187AbjKBSDq (ORCPT + 99 others); Thu, 2 Nov 2023 14:03:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45382 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235670AbjKBSDR (ORCPT ); Thu, 2 Nov 2023 14:03:17 -0400 Received: from mail-yw1-x114a.google.com (mail-yw1-x114a.google.com [IPv6:2607:f8b0:4864:20::114a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AE61F1FDD for ; Thu, 2 Nov 2023 10:59:28 -0700 (PDT) Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-5a8ee6a1801so17492367b3.3 for ; Thu, 02 Nov 2023 10:59:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1698947968; x=1699552768; 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=SWO5cb/JGhq0YhhkeavtzpdshUSY9BdgMbF9Q9qBiTA=; b=uRoCphS4a9ghls3sAYAX7ZAuJANZx9SSqLeMB9FiVNgB/fbH176oYzGdft8sdIpm8o wXq+z+WBKiXVhnxX3RPhsytFffanBsYX6Ta06ScOLtprRjYvR014DfYQo3eKyHs2xiU4 Tua9WqMIa4eDW9qpEKNZkEqAblO6J1vRfbJJOpCibqvWYaXcymcYIx2+gEpdvVsa7RyE 6mfd6QnBwXUhvFeKM0b08PfFraQOpGE5qnzGiFx4PJFQ+J6c/KXKhq5jT+YEfIZtYc2+ sV8TXUwGJozE55n6/j/kGWW74EwZJVpFYpI5fEH+obnqbZfbM9eHWDKoWlxtWTDnIclu nmsQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698947968; x=1699552768; 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=SWO5cb/JGhq0YhhkeavtzpdshUSY9BdgMbF9Q9qBiTA=; b=I6XLXIKy/8bAXuuoOdiL3JLq31AVbIqFTJy5rCutlv8g4t7M8MvDCV621flY8/Fza4 Ai+uXU68sCuUUQGsEUwRPtYa8lseDwrNhQKSXqb5AimR/PaptlG7LLmgxshltXckLHhX inwc3TPZyW4PJ473Zvz0558I6Zxh/2ikSbfINtHPNGc9FozsG5CBwElYGWoEMoCgFH2k Y/L3KA3UwR1bhXatO+oHdqFGt5an0Z8U4fxxsLQQRKYfI9sS/Omq45kGvs5z+tICkZHH hHzM33I/KnY74bOc4cAOcQSqPfBmTeWais36Om2nEVcuCrkMQh0C6oGt3E+FxdoC4XqZ FSSQ== X-Gm-Message-State: AOJu0Yyh39YpeaSeizVQbNahlZ17nYsRa3sqt4Kt9vCgQNve90WUFSiN qDDcGuBjytqsMrD4i89YWe6YLL2jlb6Q X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:bb34:df9c:836c:afca]) (user=irogers job=sendgmr) by 2002:a05:6902:168c:b0:da0:3e46:8ba5 with SMTP id bx12-20020a056902168c00b00da03e468ba5mr359961ybb.8.1698947967753; Thu, 02 Nov 2023 10:59:27 -0700 (PDT) Date: Thu, 2 Nov 2023 10:57:22 -0700 In-Reply-To: <20231102175735.2272696-1-irogers@google.com> Message-Id: <20231102175735.2272696-41-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 40/53] 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 Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-8.4 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email 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 (lipwig.vger.email [0.0.0.0]); Thu, 02 Nov 2023 11:04:36 -0700 (PDT) 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.42.0.869.gea05f2083d-goog