Received: by 2002:ab2:3141:0:b0:1ed:23cc:44d1 with SMTP id i1csp87988lqg; Thu, 29 Feb 2024 21:37:01 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXQBrpefpU2Zt8ywXsQeQQ7BdTYjcFDCM5fiSaVidBnA8ocErsKINn6zTvVjY5ZRUpoDSIfuw3m57GV+4EeoNh0Km1iNLNbQD+qQS4Zhw== X-Google-Smtp-Source: AGHT+IFaA1UExDVqpo7VAtDCjx84I3UY+CzzAKYg6LIlY9FMsfIcCH3Ghept0iDktP7mQeWFa+6b X-Received: by 2002:a05:620a:478c:b0:787:d984:774b with SMTP id dt12-20020a05620a478c00b00787d984774bmr682729qkb.3.1709271421168; Thu, 29 Feb 2024 21:37:01 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709271421; cv=pass; d=google.com; s=arc-20160816; b=dGMrGvHmPplJ8yBSXmUpUviM6+7xBjfv8k1+sLikbeQ5wqEvVXh0J89XA+wYwJv25E Cz11URFM4MukfCZrb6X3fjwedm+SDme92gLBQ5H6yKmPwY/lPe90zy1jp2qe6kxzyO5P KKSCdpXuSHyQ82Z13sGtKOxRNA8BdDVT+OeYdTyEfE/L61tFlL3zwZ4m/HgQpqC94ugv NEiHLxorFsbonMlj+brBMwhUNUNR9M9ptAO5nlwNetG4fmZVAtEr6rcgSyoUScirL1zb O8NNs3chIAfRLlhnLz4Wd5IiMraV1KtkKrFISsY2MbUULBZQqPu3MZL/Ujl3hedWtvdH pXfA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=to:from:subject:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:message-id:date:dkim-signature; bh=lzDqYvXErE70KiqRsWc/Sm3PCB8or2RKw3JobeAHpbU=; fh=z2fk4mbn58N/tCKMgzvAVIOTTWN8Bu4MDeXg4Y0phP8=; b=pKfYC47pCiH2BkerUn0Mgk5JsBdIgEpu0xBzFa3k64gxhethu/ms+LxtiETNDxGdBD fyb1mmPShX00J95kw1fiHQv37IVfuEYgqlHjaUfTh1q0vldZLUw72WbLs4xaeUnyCWt8 FOqLrCmdMN8ddIIeJmZ1qqsv87o0QA1ZGyLMk6Cl8ntxLsrq/0NLgEVbA7efq3JJq7kC AVcEQPNtWHtvutPCkjQMNCdHoG7oAciiQzkLlLHpUTEkN/6plObSTQdmosclUd6FBE+W 9/BfVmPaWMd5LpOr2s48BlEpl2I39liEUAavaV+ORNNx8EcJ3zK8D+bVE+RM1syGTHFO 767A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=3UXrONnm; 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-87929-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-87929-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id x14-20020a05620a098e00b00787d34ebb06si2924731qkx.289.2024.02.29.21.37.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Feb 2024 21:37:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-87929-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=3UXrONnm; 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-87929-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-87929-linux.lists.archive=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 ny.mirrors.kernel.org (Postfix) with ESMTPS id DDB761C22040 for ; Fri, 1 Mar 2024 05:37:00 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1B47450A8F; Fri, 1 Mar 2024 05:36:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="3UXrONnm" Received: from mail-yb1-f201.google.com (mail-yb1-f201.google.com [209.85.219.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 C81882F53 for ; Fri, 1 Mar 2024 05:36:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709271413; cv=none; b=ajJ1zu6sTipvhf1wDjA7EyHrfYJFzL98y81E+Yj+33vdmdZtU/rboSReLZIVQosF7B5cagY2lcr8VdOSzkVaMGIvo8/yzidmPFQgQE0/7KBuhSaKO4T9QM+S6Gi0pyYtQ6bgENqkHLc1qJNxLlB6hBR9CaTZtLMVER7I2uq2b+k= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709271413; c=relaxed/simple; bh=HgQFSvlCrQADFz3kGSpi6YyQyXREUPyNAOV62rIkpi8=; h=Date:Message-Id:Mime-Version:Subject:From:To:Content-Type; b=FHFNSNhtt//Bj8u9BfZFdBP3v4MyI9uKcbl+2hNhiwdgD9uZ3wDQNJaKsN6mP4qtCywW5eRo2tS5VI44+gehfQmAIriJmTRmPd5zxCk70KSNc26qxl3Qo1UO7lFJjc52wjNfAAxrPrvUkLpWJTGOTGHkje/egVag75jb6MOZIuM= 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=3UXrONnm; arc=none smtp.client-ip=209.85.219.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-yb1-f201.google.com with SMTP id 3f1490d57ef6-dc647f65573so3175240276.2 for ; Thu, 29 Feb 2024 21:36:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1709271411; x=1709876211; darn=vger.kernel.org; h=to:from:subject:mime-version:message-id:date:from:to:cc:subject :date:message-id:reply-to; bh=lzDqYvXErE70KiqRsWc/Sm3PCB8or2RKw3JobeAHpbU=; b=3UXrONnm57dTiYjWLHke4q/85a0b5kFR0fNMFgs3Gu/2Fgu7eUfNwCaAZDy1Uq77B7 6AAgaVCs1VBlHolioHuXUHiE0luVrmC+jbX0nE+RxnjOVZ1OYRdNJ94BmPTkq0Zy9o3Y tBTYw3C7aA64W9JBzg4irQ1NJM2sZGJB3HaZtFbqGoBooABSp51XaBFhCnNxK0cp+K0U Bf1t/M9UYejKKT9i3AjiFMhlVCQ0fWn3DyCV78CHa6E9QG/badnTTvtL25nT5Mhw44b4 rl9/CKkihGvLYSdN5qml5iLHBbn3H/u24e1VbWbfu7FRb+/HlzufWjpLvyqaASy8qXQw xwHA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709271411; x=1709876211; h=to:from:subject:mime-version:message-id:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=lzDqYvXErE70KiqRsWc/Sm3PCB8or2RKw3JobeAHpbU=; b=hlR983b7OD0OpOuDWKYalfHyz0riejgjX9iBzHGOFKqcxrErufb9NPA6wUe3IYfhiE LYFl9+2nVDkOa+Y2V2QNrAv5dR7Hla00WvW0Pbw0626KxdugHJoQWQBMmFXLcMLlw3lG BUubntZIL9vLNnuxA9wnQb+34++VYp2Fy+Ye1Xu/IGkTjZZf1U/U7TM7j3O8Btf7VIQg eMBOw5qK1jvlveINnc7MTsfG1XBENMd6IYknQLpGgjM8+wk+thumFlgNLt0jBX33RMWp k72jxHyINl7qq6e4ugGxv27dIcp7W2mNaUnpRlbhtdSqJt6PS/9SPXpjgQfW2v3OKOJd Xrsg== X-Forwarded-Encrypted: i=1; AJvYcCVn4dASEy3rKORjs5moW1rW3c2WOy6+1uV8YcNeQEB7OSg66ouetiOQHyOmMLcZq2dQRGgUgwl24H8XCI959u3KNl2mheWvyLjnNj0a X-Gm-Message-State: AOJu0YyQ3SNF4BngcGcp3Cc93FtqmMhV/xZWofDYR8/3/teDUgfD84Im MiQkXlHPUNo0/AH5QkB8kdZrpuxsvcsFkVDwoPTkc+um0HC6O1VJatBId+/ZWm1Jxdhs4M2oqjX L4/fGsQ== X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:af4b:7fc1:b7be:fcb7]) (user=irogers job=sendgmr) by 2002:a05:6902:1741:b0:dc7:5c0d:f177 with SMTP id bz1-20020a056902174100b00dc75c0df177mr134040ybb.6.1709271410883; Thu, 29 Feb 2024 21:36:50 -0800 (PST) Date: Thu, 29 Feb 2024 21:36:38 -0800 Message-Id: <20240301053646.1449657-1-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 X-Mailer: git-send-email 2.44.0.278.ge034bb2e1d-goog Subject: [PATCH v4 0/7] Thread memory improvements and fixes From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Oliver Upton , Yang Jihong , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org Content-Type: text/plain; charset="UTF-8" The next 6 patches (now 7) from: https://lore.kernel.org/lkml/20240202061532.1939474-1-irogers@google.com/ now the initial maps fixes have landed: https://lore.kernel.org/all/20240210031746.4057262-1-irogers@google.com/ Separate out and reimplement threads to use a hashmap for lower memory consumption and faster look up. The fixes a regression in memory usage where reference count checking switched to using non-invasive tree nodes. Reduce threads default size by 32 times and improve locking discipline. Also, fix regressions where tids had become unordered to make `perf report --tasks` and `perf trace --summary` output easier to read. v4. Add read lock to threads__for_each_thread, Namhyung. v3. Factor threads out of machine in 1 patch, then move threads functions in a second. v2: improve comments and a commit message. Ian Rogers (7): perf report: Sort child tasks by tid perf trace: Ignore thread hashing in summary perf machine: Move fprintf to for_each loop and a callback perf machine: Move machine's threads into its own abstraction perf threads: Move threads to its own files perf threads: Switch from rbtree to hashmap perf threads: Reduce table size from 256 to 8 tools/perf/builtin-report.c | 217 +++++++++------- tools/perf/builtin-trace.c | 41 ++-- tools/perf/util/Build | 1 + tools/perf/util/bpf_lock_contention.c | 4 +- tools/perf/util/machine.c | 341 +++++++------------------- tools/perf/util/machine.h | 30 +-- tools/perf/util/rb_resort.h | 5 - tools/perf/util/thread.c | 2 +- tools/perf/util/thread.h | 6 - tools/perf/util/threads.c | 190 ++++++++++++++ tools/perf/util/threads.h | 35 +++ 11 files changed, 478 insertions(+), 394 deletions(-) create mode 100644 tools/perf/util/threads.c create mode 100644 tools/perf/util/threads.h -- 2.44.0.278.ge034bb2e1d-goog