From patchwork Wed Jan 3 05:06:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 184613 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:6f82:b0:100:9c79:88ff with SMTP id tb2csp4837791dyb; Tue, 2 Jan 2024 21:11:09 -0800 (PST) X-Google-Smtp-Source: AGHT+IH4zeb1mlMc6SpEkL3J+SqWFsENLqHg2mQieMBgcMYhmzLBj/RIdSdfgdrwxB3YRZT9IleE X-Received: by 2002:a17:90a:b117:b0:28c:b299:5aec with SMTP id z23-20020a17090ab11700b0028cb2995aecmr2169580pjq.73.1704258668794; Tue, 02 Jan 2024 21:11:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704258668; cv=none; d=google.com; s=arc-20160816; b=k7bvSXxe6LkdlEkNq5V7EObOrBpQTqMJZV5Cpsd8IM9Yh/ItihMu2sbzNCf9OrCkmg PGEF2Lm+EsRzTsHCwkoOh9Dhwq8+UwtWMFKnGBo7Hg4hktVX/jXIoExvK93Lm9O4LAiT GLmjqUSc+iUk4Fh/wtBDho1WT19OHdoUIiNWrId3+yxeV0qb3nZc1yHieOQ97qOoS0K1 3atUE9UV4it35biyKPbXUYrHP3uESubJyONUbbmgWQnrOVdO3DOtZB7VeceV7DeltBWa 0VAFzYFXvm6gwZ01vGhFP0y3HJB/qKv7iIWbBp0pDd11+MAkOnkufGB5pBkZ/xqHSlVX LIfA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=to:from:subject:references:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:in-reply-to:date :dkim-signature; bh=MbllDlnO3rG864Ljl3o3amAjh6guujvESwDRIjsIsd0=; fh=Io7x3OacpefNRRNKoYAzVE0aWTDwD7FRzyCdD1e3AN4=; b=W0bZFJLYt+ecE9t6EIidTqLYXY9c0PXq/OqrVTq5+rBAx729mpf9erUqQYEdbVcqFj TSRRSeB9Jc5A8uYa+nm5s/q3iTvpQc/TVc7jddvfbx/BCo2Zsl9Y6okX6ZROUBi5BWrG UM8sxFcWDiSV4lajMEFEWxTgMYWluHiEgPGv+sh/UMwAzlN888Y4PVamQqBh+xxb1Qhv 59MxMlhv2o+vWzJiUTP6ynDdTKH46cX/sEprfbx0EsT5zG7cPQEskCzN7ybJyswhlFQ3 zuURs/DMK7ayxXL10q2tM99JRbP5Y9HRt2/arrsFw65j0d96KXCYUmD68OQYAQvr8S9k PilA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=PdJHL6FX; spf=pass (google.com: domain of linux-kernel+bounces-15172-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-15172-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id c2-20020a17090abf0200b0028b76c4feb5si604738pjs.88.2024.01.02.21.11.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Jan 2024 21:11:08 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-15172-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=PdJHL6FX; spf=pass (google.com: domain of linux-kernel+bounces-15172-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-15172-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 9137F283F2B for ; Wed, 3 Jan 2024 05:11:08 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 59F5019477; Wed, 3 Jan 2024 05:07:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="PdJHL6FX" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-yw1-f201.google.com (mail-yw1-f201.google.com [209.85.128.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 929E118EC5 for ; Wed, 3 Jan 2024 05:07:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-5eef1c0fdadso53624407b3.1 for ; Tue, 02 Jan 2024 21:07:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1704258436; x=1704863236; 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=MbllDlnO3rG864Ljl3o3amAjh6guujvESwDRIjsIsd0=; b=PdJHL6FXm9mUjvkU+Rp+FGxsujYDKgrYBGnb7rHmF75miV3ClNxoXGCjUUFOBfcLYW zvD+e49q7l9tjPUrm+/bzK41mZmZPQ0E6LY7qiAjV80ALvmtmi0FoKwRcJI/q26Rjl50 OdSuXc5xNvFbJ8SDMZhvVmNfjibNKRqm5M4dJOlsBqrGfbwt+tYevxhN/Nuj3dfcEx5U 75/yiy+2vs5tpcB+D4Y10p9+37dKpjCDuTvJRr+xWMa+Vv3/W9M57T9fouTcmKgZPps5 M2acrH6IGaAsC5caFVKOjckgXOikoP04cBffQIPMQDTJnUMr6sYHLvJgY4nKAMxR2ls4 wpmA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704258436; x=1704863236; 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=MbllDlnO3rG864Ljl3o3amAjh6guujvESwDRIjsIsd0=; b=mi8SEuQRQ3AkxpUFIq9xqM+P4pYSA22LunR0Bd5lYwLmqBjDJEQDMSb9LUXPhkyiEx bdQcI8yvtPj0eagVk3kodJotHH5Z7cCe+udHJ+rLGLxHnBDmayxhk1wU7RMIi1G5TXAD f/oA33LuB4IrN0Be8cIYlMcRNMK+X31ByUU+s+b6FCRWodV8Yz9NGvmoOhDCne1Y93NT mMck0SQdLvvFq7dD0og3zzbfYYo1WEboJ+GgbI6xj1sxAJC8cwQIw+LG3BGYzAtt2xlT X3HGt2mfYG8xoZdT/TDgguP/MwP5h1Jl/8Z1JknBi8pdvOnHQcthsrHOZcPjR9q2KK0x BhUQ== X-Gm-Message-State: AOJu0YwfWyUb+qCF875fmhpAlHKz61SMFMLNNqn2cA5krAWVmW4BrRic 4SKTaEN98DYweCzQURnsHGb55ukm7M6BYUsTR/8= X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:e2bd:f1f6:8ea6:8d6c]) (user=irogers job=sendgmr) by 2002:a05:690c:a9d:b0:5e8:f747:1cb3 with SMTP id ci29-20020a05690c0a9d00b005e8f7471cb3mr6769721ywb.1.1704258436667; Tue, 02 Jan 2024 21:07:16 -0800 (PST) Date: Tue, 2 Jan 2024 21:06:23 -0800 In-Reply-To: <20240103050635.391888-1-irogers@google.com> Message-Id: <20240103050635.391888-14-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240103050635.391888-1-irogers@google.com> X-Mailer: git-send-email 2.43.0.472.g3155946c3a-goog Subject: [PATCH v7 13/25] 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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1787044737829955341 X-GMAIL-MSGID: 1787044737829955341 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 {