From patchwork Fri Feb 2 06:15:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 195596 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:9bc1:b0:106:209c:c626 with SMTP id op1csp238874dyc; Thu, 1 Feb 2024 22:20:01 -0800 (PST) X-Google-Smtp-Source: AGHT+IFJpb9QmMxEM1xlTdeukHAmD4Ho8yyM3rFm6H5aK81eOZePgJXfBjkFqmhX89QYHXj+mzCh X-Received: by 2002:a05:6808:1528:b0:3be:a790:3456 with SMTP id u40-20020a056808152800b003bea7903456mr8607976oiw.21.1706854798764; Thu, 01 Feb 2024 22:19:58 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706854798; cv=pass; d=google.com; s=arc-20160816; b=nQ6UmMm9XJfu+i8BxIiEJzNSBqIomu004KSSQ0e054qV4Grk7tqSuYCdcgTd8FBo+k TpslFibDnPn4mzlNxoqFjRZPdCUTZPrkpwvwku9eKZoiE+MOHBs1qJ1qzqbx30qjyQ6R ravBeZUc04W1SCtMVTzlUvC+s1hXFYAUvY5FGI6+u3YqyMwbXqYJrH0HTOdarguxVAuw GAZ407/l/Eg8ZbcVwEMrtueQut3vbZqkEUrdqHE6DMnuZj/ymy2zcjv7XPayUbuQSGon ZJcTRNELB+cLxW0/V7uscJluVF6mcpcIxMXHblzXh6JXecrPa+gPnUVZhtvGppf0ivcA qEkw== ARC-Message-Signature: i=2; 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=Rt20z4T5VPT3LRcytD9SJzsjA7tToX3uHX4SxOAPIZ4=; fh=yIzt92Mi0+yF5NODp+htzBAg/ItYvj75LZzmw6qaOnk=; b=iTrEwL8raUbEEAHKgukPK+qb2/u9WCaoo2hFBNy85s6q7kKOdef0Sf0GA5oVog1vFa tbuSu5qCDt4TMXvu+mRARyYIolG6AxAqrMmXlfX3q+MfiEpeReSti0TEaR97joV9MXAx w3eq76Jl312ivJl0tVQgmd6QDEbvh0vL2WpazNAP0bOWQbruFd/lEr+XCbha6N0k1boE QT+dOkT/+8qcQnhTawwCvztrhnGdmc8o2b9VGZNUGRX1zwqa6fAzGj801sIeU41V0q6z PJ0ca6ZwPPhV5XkuJ0R8mla9MFCYxBltkYNslUVlXYvT0lPyB2LCBp1XByNHUs/+QtzB YtCQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=gtwdmomx; arc=pass (i=1 spf=pass spfdomain=flex--irogers.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-49252-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-49252-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com X-Forwarded-Encrypted: i=1; AJvYcCV18qzuUnHlQZYtBqiFKxBNq0VNCfzdimS8iLMyQPz6rn24+/i6AicGjsXcz9NAJaktxI8CdggJXzhtN9w0uTESacU0jA== Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id i16-20020a635410000000b005b91536981csi1118557pgb.11.2024.02.01.22.19.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Feb 2024 22:19:58 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-49252-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=gtwdmomx; arc=pass (i=1 spf=pass spfdomain=flex--irogers.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-49252-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-49252-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 15FFD28489A for ; Fri, 2 Feb 2024 06:19:22 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 800A63986E; Fri, 2 Feb 2024 06:16:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="gtwdmomx" 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 7C8751AAD2 for ; Fri, 2 Feb 2024 06:16:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706854579; cv=none; b=YXTAm53w5C2bsBCLZ4aT1uZrQGHEvLqF1tJAk7RyWpzKwSwXZCpiR0TxBm8lumgiSzcSjMo3V5xa8CNjYQ3M2HuCFnMubxrWUjVVjqZXNNFXsShzahoFQY6EdDuZNPC62Y/ZkTY8MlDytuDBX0y2OFu3Iz/+5Zfn5ktuL0d13qw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706854579; c=relaxed/simple; bh=x/5fHTR183S/2RfEcYCstWfa0bGQ3QCOM8/PnsO9ubE=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=be9JDWWSnZflCjqxCiX9QnQv0pLyY7cmyrDiT53HjYLH6SJpyQANF5pIesHAXBAYpb4qawNYVc61b5GjAvx4lpLfqv/tNhrgEsBPRVMpDf6PaqTyyypGgKZ0OAECzvMRwRC545Q+akXMVogNO3h3HAjKn5ClPIT4JmpbuLHVzm0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=gtwdmomx; arc=none smtp.client-ip=209.85.128.201 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-6041dbb7a78so25540717b3.0 for ; Thu, 01 Feb 2024 22:16:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1706854576; x=1707459376; 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=Rt20z4T5VPT3LRcytD9SJzsjA7tToX3uHX4SxOAPIZ4=; b=gtwdmomx2Cp+Mp32uFL94bep/cCR2gYlgs/3O7l6drunD0zB5E+ROXF0LAJg4mS7td V9c1sye0U63OOIwjoCg66JjJRdDIjyPXQhYVe4to8pYXthL4/fNelEVEUny1BOeaEBHz GkVvGREGlPESkavGdja3hKtySNT4g1Qk8bb1UlvO2r+nHOc5sCJd/8n8gVLULZMXBr3y inXC6NNB0s7nNUBUC6gBIV2aruABwj9vrdgmpOEH9ZZmeCsBiwd2PUyb8A7g9rE1nZ8m +xqFUYScUgWJpOCs2vZX9yctlGhVsb262klCmEGP59BtKoYS/tbl6kOM2t3lwCmlymnk 3RvQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706854576; x=1707459376; 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=Rt20z4T5VPT3LRcytD9SJzsjA7tToX3uHX4SxOAPIZ4=; b=KEcRDAanDMbrVtuXsDXqayJxb02PwsfrEIc+ABqBTil9XDaK9vHnC/Z8VJxYT+kPh0 2xPRRv8qFeQTD9SxrFcQoGXfq1RpgzLuuLL1118C3qEBTSTjs/seCl7KUpoR9wrJcdBu r2b7ey5hpy4jpDPZXrktXlCXKm/E/Mm1joL8PtdkWSF9xSIeYgqkd6dqEviIpS1N2lYg T9WoUVnPlQo99N7HgPJk+tLEaUgX7VBhK00Hoc3LFEob35itanImbnJN61TKdN0bocvT CM5dJgeWdCtdkYR2jvPN8+zWA2yEL87LpljfR6F4x9/04HenDjI/hJ2FV59W+CBriTdo TQiA== X-Gm-Message-State: AOJu0YyxUvd18hhmxSQji3/1/J9Ww3yNrSv591VfGVED4hJuZB3HKy+C u01Y7V1+t2hZ4pLy6JhmmdKG7UmSXq74wncsJYLk0iAaqVaeTe9qcF4JkvJm12hoHyYfyNxz/+Y D7i06hw== X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:a85f:db1d:a66b:7f53]) (user=irogers job=sendgmr) by 2002:a81:9b4d:0:b0:604:5ca:5ab2 with SMTP id s74-20020a819b4d000000b0060405ca5ab2mr1614230ywg.9.1706854576529; Thu, 01 Feb 2024 22:16:16 -0800 (PST) Date: Thu, 1 Feb 2024 22:15:20 -0800 In-Reply-To: <20240202061532.1939474-1-irogers@google.com> Message-Id: <20240202061532.1939474-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: <20240202061532.1939474-1-irogers@google.com> X-Mailer: git-send-email 2.43.0.594.gd9cf4e227d-goog Subject: [PATCH v8 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 , "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 , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Guilherme Amadio X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789766977290715858 X-GMAIL-MSGID: 1789766977290715858 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 {