Received: by 2002:a05:7412:2a91:b0:fc:a2b0:25d7 with SMTP id u17csp382521rdh; Tue, 13 Feb 2024 22:38:04 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCX5Og1qhtUVBmcKkRYNa+kjM/5rwyd0dsJ5esfNiq5BHyV/rps1gdxXTammascGL12Tt8c0643/4GzeJKkOQAtByiASvKRXEEjC+RXmYg== X-Google-Smtp-Source: AGHT+IGCdHrogUI9Wi0AdEhHv/T45LDZtaKh03IyE3TDxauiOp4aga/WIEhazgyQo2lEVZtQbvRe X-Received: by 2002:a05:6358:4196:b0:175:ed25:d44d with SMTP id w22-20020a056358419600b00175ed25d44dmr1093447rwc.9.1707892683939; Tue, 13 Feb 2024 22:38:03 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707892683; cv=pass; d=google.com; s=arc-20160816; b=WPO59Ev2ncf35tWbaQ6XpUfN4w9CSE1t0CwLVxwIW1X4RpyMqynd5ZohmrbyvymD4N N5/uaHQRBxOaSMZrWWUs0pkqZ9W+mPkgr53k+yALnV24nNYxySirEc57fcBLBETIS1XV BJ0pqVBLVmyj+N3+sYzWQSWH6enLYdDWnUYBx0Y314VzdZUGCjcChTSuT8ajMw2d+0TS 6j440pnGrEYTGrsCKiB76bYewbpdprIxJ+82mof1FLUuBe525JnW+MvWdqjzcsnHIkEt vv+dCnJj4kqcnOgPt2QVJV5AQ8y5H1MBaJO5Av6GnVpST5GapRoi2jH0zD6HqzhuY+zR Ib0Q== 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=SjusGx6p43Fl1gAtWsqPYtqEBcBHhyA1NbBeHZWXXBk=; fh=t6rH1oAXI284Z6LUF8nCfNFBcJwM1JIMeStRHlzBuuM=; b=KGoUKydWM5tzeyNbAIzLZvbxEWjfd+L6Fd6/2CNc7n/KykLQ5Ycgmb4+qyXkx/2O3V ngJbYFFkKYqVhrGWtCEcwEQcKEYpf6e+++RyPVAiorXlpDZQZVDDBnTsUit4m2k3Ywtv 29TcxBfSUP1ULdqbSKzbH1LLhK80BAfpzNh89/O0m8hgZPmByyAZ3gP4BIIZmSiZ5gwm 7H8ibYqA8ZFMFqy7uQT0ku/h5wH+D1AQW5sZXYxfVAthsUw1PKyYRMDmnoUw5olz4WQz Kj4DAD4OD5vt+3nJM0CHowslDccP3cICWBsJVFkNTcwgG9nt1DR44QpU0DlShP1ISl7A g3AQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=aKC2p1yW; 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-64795-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-64795-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com X-Forwarded-Encrypted: i=2; AJvYcCVG9SB283I8sIOA+Knayml3pWv5YbOD6NyHcdJxLDiT60ThzVkPP5WyVTemm/C5D0EMWaKBVfl4mFPLuvzk/gWn8ARqW+UdzMC+1SDTPA== Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id w16-20020a639350000000b005dc42fd8c40si3154503pgm.404.2024.02.13.22.38.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Feb 2024 22:38:03 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-64795-linux.lists.archive=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=aKC2p1yW; 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-64795-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-64795-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 93E34285B44 for ; Wed, 14 Feb 2024 06:38:03 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 24E7411CB1; Wed, 14 Feb 2024 06:37:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="aKC2p1yW" Received: from mail-yw1-f202.google.com (mail-yw1-f202.google.com [209.85.128.202]) (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 BF21B11729 for ; Wed, 14 Feb 2024 06:37:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.202 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707892643; cv=none; b=eK9s9BaptwrQese/M4UxySBRiPkZ1Xg412DT9W8lyNYdn4XenggxCmv0v/+RT+hmsxlRdvuqomTn2itHPe5rsyy8dfL74MrHzy2GAxrp5Y9WEAEok3imp5sfebPzKIiFnZcTZkpjTjV10yY39Ibzlc2pTl8pIXPSz/iBPh+j5X4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707892643; c=relaxed/simple; bh=G/2siGEslfhIe2PbP6r2MxvFbe+8RJMIG2S2/Tjz5Sk=; h=Date:Message-Id:Mime-Version:Subject:From:To:Content-Type; b=LXx1TAkJIFG7WTzhvkxVyDedDx3USrmEpg4W/TK5X0ssIcGWMJOhWHBeGb6w2fkEu+PV4iM1MT8u5uVH05yENvUKWc4V6o4rbTQH+E7mjosCc9RMk2PMKLE8yGSknGl+t4Vd1dQRJno4pHlzNa3qF+B2fDj/R9cxWNYjwW0GBig= 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=aKC2p1yW; arc=none smtp.client-ip=209.85.128.202 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-f202.google.com with SMTP id 00721157ae682-6079cf3541bso19270477b3.2 for ; Tue, 13 Feb 2024 22:37:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1707892641; x=1708497441; darn=vger.kernel.org; h=to:from:subject:mime-version:message-id:date:from:to:cc:subject :date:message-id:reply-to; bh=SjusGx6p43Fl1gAtWsqPYtqEBcBHhyA1NbBeHZWXXBk=; b=aKC2p1yW+k+f204eXYynN0DphVe+dqAkLQgK3xLaZ6jmJk+jt1IS3vh7gEDIi8QM0K tpS4zebZHOjfqUlZglRnc4FuUKJTF37LacDuO7Wf+nXddVip3XOdJWVdfy7HUXRjFyj6 f7SSiSEMPDkEQMTt80tRSFXkVwGY6dU9HLvH9WIgmbMnTPpCnVgkurEac7gWFR75ZxzG GHaSgyvZl79Ucno+D2W7HhpzrIMCf4lFiVmrc5Zubofm6iBJ5bEFSd1woVA+29jKKgqa tUEMPNC1d67NHBHb0kEaQ1NlhZnxyTMWTjlL3Y8RINxrpyclw0e3tFD/zguCkxF9l0XT ZMrw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707892641; x=1708497441; h=to:from:subject:mime-version:message-id:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=SjusGx6p43Fl1gAtWsqPYtqEBcBHhyA1NbBeHZWXXBk=; b=tR/Wtlq94drdt4po0yhSNadoKst/Xo3huyORKOEdhqkNtaDIfa2ElMLYICe92XV7C0 0llCNpG7064N6+p967UF/uwWOpn+2a64OknC5NqP/lVSZeRMk38GmlwkWKJD5LK9RO64 TRUudF/etUpO/V2PlD8RdjT2VVLHjSGBGU9MLj7H43TYGfQ0pH3Y1EfbEyrQgsH3PtoM gdQzi3+JhpJeaJmKqEjc8LW3vOb4tF5Idxj3+xtTn967QcoWxuYiAKOJOe3cgWTPb/Ow Yd/W5+iasZFVo7aFhMYIj+H3pwkFzZLevt4dp2gAkdMJylJS89l2CbuAVekU951N//f5 vy5g== X-Forwarded-Encrypted: i=1; AJvYcCUYUobSLGhn8o736E0dOE78reeMNfqRwWQNggdecWjf66RrIB2v62Law4BWwsyHa+g80NVVX1nX2J4Xfbt6dAy4u30TFoGc2NTkzuPs X-Gm-Message-State: AOJu0YyNZ1GCBScW1ZtcqKkAjO+M/WNQQioX3ct4i9NMIqLNFlJQjiLy PFROl0JdRe7S7/tcRSbMMJYkLf7r8K3+474g/Kr4Op98ZquVEnJMjHibryg7aPBUZ6kBdTN2E3O ATrQCyw== X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:6d92:85eb:9adc:66dd]) (user=irogers job=sendgmr) by 2002:a81:a105:0:b0:603:ea10:c37c with SMTP id y5-20020a81a105000000b00603ea10c37cmr360558ywg.7.1707892640759; Tue, 13 Feb 2024 22:37:20 -0800 (PST) Date: Tue, 13 Feb 2024 22:37:02 -0800 Message-Id: <20240214063708.972376-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.43.0.687.g38aa6559b0-goog Subject: [PATCH v1 0/6] 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, bpf@vger.kernel.org Content-Type: text/plain; charset="UTF-8" The next 6 patches 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. Ian Rogers (6): 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 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 | 203 ++++++++------- tools/perf/builtin-trace.c | 41 +-- tools/perf/util/Build | 1 + tools/perf/util/bpf_lock_contention.c | 8 +- tools/perf/util/machine.c | 344 +++++++------------------- 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 | 186 ++++++++++++++ tools/perf/util/threads.h | 35 +++ 11 files changed, 464 insertions(+), 397 deletions(-) create mode 100644 tools/perf/util/threads.c create mode 100644 tools/perf/util/threads.h -- 2.43.0.687.g38aa6559b0-goog