Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp2389703rbb; Tue, 27 Feb 2024 23:24:36 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCX5ZfwOCUfyozskhZnjl0llbon/d8K1ryKqXrVFchJ9iG0/mf/PUeJKkDnQ/mqJBsk39a5HLTEsRU0z8Fqw/e66wADF+WFyT4DhusWhAA== X-Google-Smtp-Source: AGHT+IGMET61g29nkLrtYyz4BIkbAqIO/lI8e89VYp+/bgMaZAHe8bMg8trI6Izmccbmvl1d3QPG X-Received: by 2002:a05:6402:1354:b0:565:ec92:bece with SMTP id y20-20020a056402135400b00565ec92becemr5137450edw.27.1709105075961; Tue, 27 Feb 2024 23:24:35 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709105075; cv=pass; d=google.com; s=arc-20160816; b=uetoHkXGM+dMON4fJfucYGkvv8Sgqvg/kE17GvrwdhW1eBeuubBwi2SWJnNQV11+1W L8kgvjLoLQHBkFsCoQZ+5Ydr4nVs3gBgAKgBa72Gbc+3SCULYZxODYqy9SmmhzQXYkuB Xr1elh6N7R0V1vFlALal8vByqneUCVBYDNAve9P6DPHocFxi6/79MLKFW5C2geDkRkJv g/jPNKHLV46tQC4QUjNm6QI5cAPBWbrl4vhVIMZETBiUfBFQv61O/WJ+hMIX3Jjsa+Fm 0XgJ4GFF6RhgICUrY6eVuVQOeoMYuwHW3JBFLeGOzUlEdtnfuw0kWsi9XLyuCwm3HLzd rH/g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=WHnvaXANsC8wB5A9Pi5iZo7i69i6rzWp1vJRqsOF55o=; fh=1nRlf9jon4HbGlIYI+GCngkbeo7vgK/LEyQqvnqvBeg=; b=ZCFIpO8GyzaFhTHMWzWHeYODue+uEcSvdmRrWsD+z6xy40wzbpble6sm6Ic4T9+DcQ 6xgxRfMwxoyk4lyKwEzxc7lKEnBoghkO4td/amVij10KrV9cnV3L18xe/GWh7h8FCUiE NfMnzDsOlKIkKhf1rMn65oZkTxyu+DqOXwSKNBNEuoD828n0U/YA4Wc9wodtPh8YgarE IXxc6CTtvXNvdSgyAAj9FVwKCF1X78Dqa6PajW3Jyzp/AR2JrssdQaEQOvRQC7l/oySU Y9SQkluyJTpam1mSQkO7MYMbDnyTpvWC3Ju5/vDv3+3dmLsslW4PPPIysAA0oXJZVnVK hqWg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=DZYrrHdo; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-84603-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-84603-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id r18-20020a50c012000000b00564299247b9si1470023edb.120.2024.02.27.23.24.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Feb 2024 23:24:35 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-84603-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=DZYrrHdo; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-84603-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-84603-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 889011F24448 for ; Wed, 28 Feb 2024 07:24:35 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7726324B34; Wed, 28 Feb 2024 07:24:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="DZYrrHdo" Received: from mail-il1-f170.google.com (mail-il1-f170.google.com [209.85.166.170]) (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 F226F249E3 for ; Wed, 28 Feb 2024 07:24:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.170 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709105062; cv=none; b=tlvsUOS/Sg0Xg7dvTONavsFdcBrsVxQiO2NJDYSQcJwza44YvIDOKL86UiMHaFRE+fBTfL3B4wLUVkI/Lq5Vz9Wr7LSKd/evWQcBeJBMyDrCBW9nJnRk6qnWmWk+NOiFKSaACt9xbRhwTHvnXEDPrqQxZYjQSFAjhRPGx/28DOw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709105062; c=relaxed/simple; bh=J3BiMHmFAZRHHxjaye1fO3ickIhjsdiGhoo6deKUkG8=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=pOj24Oqh5jtGI/Nht8/+o3BeTBf4dkqSrov/YImFAvbxSIO2Gt9/dptEg+GmUIPoQFcCrT8cu+pOQL2PO8jjI5H+RL5DdGYSsMx8r3G22Si4Hk3oNxHTxybLngY9eGfdFJan8xWAAqYg22QwyauNvkTQZWBF20PZzfG4LrxRa/c= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=DZYrrHdo; arc=none smtp.client-ip=209.85.166.170 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=google.com Received: by mail-il1-f170.google.com with SMTP id e9e14a558f8ab-3653e1240e3so98235ab.0 for ; Tue, 27 Feb 2024 23:24:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1709105060; x=1709709860; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=WHnvaXANsC8wB5A9Pi5iZo7i69i6rzWp1vJRqsOF55o=; b=DZYrrHdozaK4bx3oRMsJGBZaj4ZVy8K72pUsBh8GV2oT+GN7XR/L+wKoGDAungc5iX Jkse0b3bsooq+6pdDkuLNQxe26+fHoVSATFlOBsp0EkC2ufY8iysQo8Vj+GBzeXgsjbR gdISeCY86roTbIa7WM/4MJzlaIJ01VynjlxZGARL+omgQCuwm9alWa5dr7K5BsKMq8n1 kq0R++e/uemSuaKyc8GGDCtnag2IVf9fORaL9NDdUpzTuYOT81K93fO0Xg/E7SRDc65y sEz+Zkq9Y7dYPfsgB6odwjTAdwffvpjoUFFZdeiKdGxiP1yORo8zbKc3Au83Fx6LAC8o tOig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709105060; x=1709709860; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=WHnvaXANsC8wB5A9Pi5iZo7i69i6rzWp1vJRqsOF55o=; b=jOETwSRvG7NAR7U1UeNvczlccCMYsEHHv/+TGZWj6XJyWhGUqHgeHwSx9urmYbsGWJ XntHoJzGEfClx9Bxo5hSUCltxEF59B67wM+s3MtuxF4kn+FL3kqTBxdhA/PjDa35UO4Y wCRISIDW5n3DES7muJmBiQ1FKhLbQrqadw+0g0uuaJKPHK1Nqj8FXfo0t1/UlSFFiYi3 Z+s2xboHmgcJXxDBOx+E6fj6+tTFR0oU/DTiKCxl7/bKHhvbmVbvXo0T2ervGgpblYQ0 YQiJXe4uyKtodDf9mhrR2DSTzpddzTdcLWMCJhuA/RJtqkmUSibSV7GgPVNzSuxS9iSh LPbw== X-Forwarded-Encrypted: i=1; AJvYcCVLlm8npGiyhyCZaWM+GUoCAjs0wuaSso1shNkFuJKjTn1HxlJEVZSeTe+hyxwTnFex7gY2LAHWijWfqp6yrux/e0KX5gjpvrr3BfdG X-Gm-Message-State: AOJu0YxAkBE+QBmQopVk7EwD72GFIeOq4cr4z/W+M0YVWGZ0jd2jj8E6 NlerRXRKv9R8ALhxpB3cybObWYpxXLsmY0KAsA8aclRYReEPMRGivuFbfx6OY/LFNlS6B6ErQx0 npeYluk+0HdlZw3YgzXCuIssu1gj9oh/cqXh9 X-Received: by 2002:a92:2902:0:b0:363:c7c0:49bc with SMTP id l2-20020a922902000000b00363c7c049bcmr14863ilg.27.1709105059805; Tue, 27 Feb 2024 23:24:19 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240214063708.972376-1-irogers@google.com> <20240214063708.972376-5-irogers@google.com> In-Reply-To: From: Ian Rogers Date: Tue, 27 Feb 2024 23:24:05 -0800 Message-ID: Subject: Re: [PATCH v1 4/6] perf threads: Move threads to its own files To: Namhyung Kim Cc: Arnaldo Carvalho de Melo , Peter Zijlstra , Ingo Molnar , Mark Rutland , Alexander Shishkin , Jiri Olsa , 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" Content-Transfer-Encoding: quoted-printable On Tue, Feb 27, 2024 at 10:40=E2=80=AFPM Namhyung Kim = wrote: > > On Tue, Feb 27, 2024 at 1:42=E2=80=AFPM Ian Rogers w= rote: > > > > On Tue, Feb 27, 2024 at 11:17=E2=80=AFAM Arnaldo Carvalho de Melo > > wrote: > > > > > > On Tue, Feb 27, 2024 at 09:31:33AM -0800, Namhyung Kim wrote: > > > > I can see some other differences like machine__findnew_thread() > > > > which I think is due to the locking change. Maybe we can fix the > > > > problem before moving the code and let the code move simple. > > > > > > I was going to suggest that, agreed. > > > > > > We may start doing a refactoring, then find a bug, at that point we > > > first fix the problem them go back to refactoring. > > > > Sure I do this all the time. Your typical complaint on the v+1 patch > > set is to move the bug fixes to the front of the changes. On the v+2 > > patch set the bug fixes get applied but not the rest of the patch > > series, etc. > > > > Here we are refactoring code for an rb-tree implementation of threads > > and worrying about its correctness. There's no indication it's not > > correct, it is largely copy and paste, there is also good evidence in > > the locking disciple it is more correct. The next patch deletes that > > implementation, replacing it with a hash table. Were I not trying to > > break things apart I could squash those 2 patches together, but I've > > tried to do the right thing. Now we're trying to micro correct, break > > apart, etc. a state that gets deleted. A reviewer could equally > > criticise this being 2 changes rather than 1, and the cognitive load > > of having to look at code that gets deleted. At some point it is a > > judgement call, and I think this patch is actually the right size. I > > think what is missing here is some motivation in the commit message to > > the findnew refactoring and so I'll add that. > > I'm not against your approach and actually appreciate your effort > to split rb-tree refactoring and hash table introduction. What I'm > asking is just to separate out the code moving. I think you can do > whatever you want in the current file. Once you have the final code > you can move it to its own file exactly the same. When I look at this > commit, say a few years later, I won't expect a commit that says > moving something to a new file has other changes. The problem is that the code in machine treats the threads lock as if it is a lock in machine. So there is __machine__findnew_thread which implies the thread lock is held. This change is making threads its own separate concept/collection and the lock belongs with that collection. Most of the implementation of threads__findnew matches __machine__findnew_thread, so we may be able to engineer a smaller line diff by moving "__machine__findnew_thread" code into threads.c, then renaming it to build the collection, etc. We could also build the threads collection inside of machine and then in a separate change move it to threads.[ch]. In the commit history this seems muddier than just splitting out threads as a collection. Also, some of the API design choices are motivated more by the hash table implementation of the next patch than trying to have a good rbtree abstracted collection of threads. Essentially it'd be engineering a collection of threads but only with a view to delete it in the next patch. I don't think it would be for the best and the commit history for deleted code is unlikely to be looked upon. Thanks, Ian > Thanks, > Namhyung