Received: by 2002:ab2:6991:0:b0:1f7:f6c3:9cb1 with SMTP id v17csp783765lqo; Wed, 8 May 2024 15:06:50 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVgWbsnkl25nfWDp33uAkGbWzjhfFHsrHWWsLbuQljoxI7c9k2HxeLRJdUx3sMugoGr5vpFarzrkF3UlRQ5FhNboo/vb/fTgY6nIICGoA== X-Google-Smtp-Source: AGHT+IEcMpuyJ2Mkwut5gZ0fasveqF7vL3uvGf8SzGT4wmZdfNvoZuwJWsIArTzJP4GSx5hTyWvg X-Received: by 2002:a05:6214:dcb:b0:6a0:e5cd:a66a with SMTP id 6a1803df08f44-6a15cc4e365mr17745846d6.24.1715206010674; Wed, 08 May 2024 15:06:50 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715206010; cv=pass; d=google.com; s=arc-20160816; b=KdO7VCEmlJkcNQcTWWvY+PTOcOt//BQJashCke3KY2oq8ATsWQ97uckKeQxZrOqzja 8Lccmi68pINguSX5HZmrFgroSU2f/kPcnR5+qlnPWUu99hZJU/8r4vLhds4l3vLCZ3nx LQ2GnzcYc7oOKOIpQ8ej0ZyKGQaihRmjpMXmT840kXX4M2QgCmXvnV5kBbaD+jXvYKW9 /aki7+nGuwY8TTN/9Z5wf0Y5424z4GTGfLPYoe6lcaRTaRpPcCJCLI39SrAqWRlYo9CG 5gmkavOkA7NL+5rnaTGhoHXGnjf9R4W2yPNaSaku9LzuL5vDcS4P2XtZYJX/2DMbLxO0 2f1A== 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=aldqJPzGArxjZEpKLgm9s+1EdgolTnnhV+Hb3JyH5UE=; fh=tZ/jvBfTGE8C/75HMHJL8llxFqKV/sfzQPqxxyTUOlg=; b=M3rBZvBa3t9UhWsbb3SlRScZNi8XBI2J7nBF6vpFshjOJ1DafU7i04kmYtTzQR7Wuh TW3ZmC3ML2HumUGyybUVDdGLnShxL9c1NssWf7F9JEKT0ljnfFKKMSw5U0qtVtY3s+sj sw7jxAg5MoCUR8jTt3UpzqUkwea45CwbDSHBpf1M4Gui40sM7OauO6FguZJVCtduPSRt +y9L2jB8MCDirJhVGe/rE2OQkc+smMKbwp016TTbYrF7OeofPdFNTK16q4zhWWQO8uxG zbjtT6RegmAfiGVtAITnwJim4QSXI147aI1axtPLrjhfP97GAkeAtUgEvbIynzsWMdbe HVgg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=eIwHpyNh; 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-173880-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-173880-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 6a1803df08f44-6a15f2f6e2esi503566d6.534.2024.05.08.15.06.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 May 2024 15:06:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-173880-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=eIwHpyNh; 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-173880-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-173880-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 5AA891C21398 for ; Wed, 8 May 2024 22:06:50 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 51491132C37; Wed, 8 May 2024 22:06:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="eIwHpyNh" Received: from mail-qt1-f178.google.com (mail-qt1-f178.google.com [209.85.160.178]) (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 E5985D530 for ; Wed, 8 May 2024 22:06:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.178 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715206003; cv=none; b=QMW42sAo1qQDO3rziKfvUVRH0e4h13bHEqTuc3uMUlVBx24uSy1TeLS6I2QgYsq4+R2eq5AvLX/X5p/NH1P48smz2XW/zYbPkV8BTgvE58T30TFe+dBkOjqd7ZgdduP0Ql6Teoxx4YlAHyoRUz2b8daSL8tzHxUNTm8tv3ETaL0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715206003; c=relaxed/simple; bh=qOFm3ZKV69A7H4pqw5T6HTz2Dm7/9XTvjCo9AdNg4zo=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=tJlW1vR2zyQ6RiBh75Prx2hnVsfiHdSbbYJq089Bhy6GN4zmw1toAa3yUDSqHcqCFPMBRvHaSSZZEbt2kGpC3eHuIZkyaBONY7E9fHaiLme4WaWxPQZmT6drG2AXyuvUs15EgOp3ATibuz1j24QQ1pXrHsYwfDm+vowmoj5F28I= 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=eIwHpyNh; arc=none smtp.client-ip=209.85.160.178 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-qt1-f178.google.com with SMTP id d75a77b69052e-43ae23431fbso65041cf.0 for ; Wed, 08 May 2024 15:06:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1715206001; x=1715810801; 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=aldqJPzGArxjZEpKLgm9s+1EdgolTnnhV+Hb3JyH5UE=; b=eIwHpyNhRTL5NTj3bT7NnoSy0UN08HsremfMJdvPQCKnbmWzcF9wZEkbV+64RpgzdH V7WTEuhEJdcJYj11KAV7zkcDBl7dTKESywKH30Dho98Y5wnyagQXgh1ZBfZU7ZFUVRmB voNyunxhwZHG7Ph5huuSgJqciQPCms8Qs6cb96L/3rfiHlAXkydy5midxUhg79NFOlDD WMLxiA+SKQXXH5Jwvyd6vGtT4R1cNsCDJhkF+n0W1hGqxYw9UTNuKtTKJL4/QnAMhhqL qJjajVE1uhdP3anXX/2CDX+CjRTUGKqh9n1sbIB/QbJYxu2SFB0AIvAq3pNEj4QuRSdH emTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715206001; x=1715810801; 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=aldqJPzGArxjZEpKLgm9s+1EdgolTnnhV+Hb3JyH5UE=; b=GFoQ/vrzh6uN4Zb+HZMBexk8sd9JKnZwY3RSDFCb+X+DWsi+ic2B6ftDkX/nwSOAwG xUaHWGj9v1BoslrtUx08Yo5A+P6B10fLZybVqItayMYi3xZMXJWiMvAcVzVfGAh8zSHc Sa30RXAm6bsrsTX+hn7bsqxSlmkcbU3Ja6pvPjCdL6qAy1tU+aGpNw7fu5oXMBZ2f0IF RRDBKczlZTX7gqgHU2Qs3/8Ju2K9AuJQHe62H5WbCWlMpluXZA3fmSgVL6QNOhC9SdgI 8n2Z1ETPzWz/9wcRw7HRNp8ItglYPXCK5GVaQddRGbuP3R9JaZDLIjWwleGxcCSIUxGy cmzA== X-Forwarded-Encrypted: i=1; AJvYcCXhzbL2LShILrT2/1i+dfKJGaCR7XNZzaz92SpQ2IG5ID1A1GyjAkanTJxXpdauFdABWYpd8d5EQI+wGypHKu/lkLu2i1+gWNMTAX7m X-Gm-Message-State: AOJu0Yw8MjTJNdl+g48bFH71aDkZBVot8tvZ9rb2xpExVRJ7UT4Xn3UX bIw3AD6mThuAi/2p4ZTz8L4VNO9Twau/XGRlaksUIm6ESOKtrg6rQDfwPshFopnAbpKKYt1aVbM aLh3yGICIGbRKmJyY4dJ2mGXYgJgnqzjV0gpSLm/b5YxssO/YClX7 X-Received: by 2002:a05:622a:98d:b0:43a:e258:8fed with SMTP id d75a77b69052e-43def9611ccmr1330191cf.18.1715206000605; Wed, 08 May 2024 15:06:40 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240507141210.195939-1-james.clark@arm.com> <20240507141210.195939-3-james.clark@arm.com> In-Reply-To: <20240507141210.195939-3-james.clark@arm.com> From: Ian Rogers Date: Wed, 8 May 2024 15:06:29 -0700 Message-ID: Subject: Re: [PATCH 2/4] perf maps: Re-use __maps__free_maps_by_name() To: James Clark Cc: linux-perf-users@vger.kernel.org, atrajeev@linux.vnet.ibm.com, Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Adrian Hunter , "Liang, Kan" , linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Tue, May 7, 2024 at 7:13=E2=80=AFAM James Clark wr= ote: > > maps__merge_in() hard codes the steps to free the maps_by_name list. It > seems to not map__put() each element before freeing, and it sets > maps_by_name_sorted to true after freeing, which may be harmless but > is inconsistent with maps__init() and other functions. > > maps__maps_by_name_addr() is also quite hard to read because we already > have maps__maps_by_name() and maps__maps_by_address(), but the function > is only used in that place so delete it. > > Signed-off-by: James Clark > --- > tools/perf/util/maps.c | 14 +++++++------- > 1 file changed, 7 insertions(+), 7 deletions(-) > > diff --git a/tools/perf/util/maps.c b/tools/perf/util/maps.c > index 61eb742d91e3..16b39db594f4 100644 > --- a/tools/perf/util/maps.c > +++ b/tools/perf/util/maps.c > @@ -124,11 +124,6 @@ static void maps__set_maps_by_address(struct maps *m= aps, struct map **new) > > } > > -static struct map ***maps__maps_by_name_addr(struct maps *maps) > -{ > - return &RC_CHK_ACCESS(maps)->maps_by_name; > -} > - > static void maps__set_nr_maps_allocated(struct maps *maps, unsigned int = nr_maps_allocated) > { > RC_CHK_ACCESS(maps)->nr_maps_allocated =3D nr_maps_allocated; > @@ -284,6 +279,9 @@ void maps__put(struct maps *maps) > > static void __maps__free_maps_by_name(struct maps *maps) > { > + if (!maps__maps_by_name(maps)) > + return; > + > /* > * Free everything to try to do it from the rbtree in the next se= arch nit: this comment is stale, it should be maps_by_address rather than the rb= tree. Reviewed-by: Ian Rogers Thanks, Ian > */ > @@ -291,6 +289,9 @@ static void __maps__free_maps_by_name(struct maps *ma= ps) > map__put(maps__maps_by_name(maps)[i]); > > zfree(&RC_CHK_ACCESS(maps)->maps_by_name); > + > + /* Consistent with maps__init(). When maps_by_name =3D=3D NULL, m= aps_by_name_sorted =3D=3D false */ > + maps__set_maps_by_name_sorted(maps, false); > } > > static int map__start_cmp(const void *a, const void *b) > @@ -1167,8 +1168,7 @@ int maps__merge_in(struct maps *kmaps, struct map *= new_map) > } > maps__set_maps_by_address(kmaps, merged_maps_by_address); > maps__set_maps_by_address_sorted(kmaps, true); > - zfree(maps__maps_by_name_addr(kmaps)); > - maps__set_maps_by_name_sorted(kmaps, true); > + __maps__free_maps_by_name(kmaps); > maps__set_nr_maps_allocated(kmaps, merged_nr_maps_allocated); > > /* Copy entries before the new_map that can't overlap. */ > -- > 2.34.1 >