Message ID | 20231127220902.1315692-20-irogers@google.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:ce62:0:b0:403:3b70:6f57 with SMTP id o2csp3499264vqx; Mon, 27 Nov 2023 14:11:20 -0800 (PST) X-Google-Smtp-Source: AGHT+IExGTA347qkdkIwJrGAJTGavr5YjLF3YlClwFvZzm2gSpMspr90wN4O0Hfoqk6O1OprxPvT X-Received: by 2002:a17:90a:e7c1:b0:285:b8d2:cadf with SMTP id kb1-20020a17090ae7c100b00285b8d2cadfmr5929435pjb.5.1701123080185; Mon, 27 Nov 2023 14:11:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701123080; cv=none; d=google.com; s=arc-20160816; b=p16nh/FKJLzMjq6s8pNzsJ+CED4MGntJVKK77+F8ozHTl2JXkVSCqfI51YzKH2yJMu c32RGNUj9GvGYCgp36G9TBRXjbcwGC/7UUZJpX5RXt4156vBBc5N+NPyprzJcgYKeBCU UcsaJcgLaNN8PjV5ZVE5WbhUKXUuMYRTIrxlHRza7+L5WXE6Ba8mkhbs5sIhHMCv5By6 ltGFANaWcZ2V8UrPTiQPNCcOc7VRPwIk72nG272DTk+GhbS9+iZ4wI4544Ms67S+7MJd DGQO1CSwvwi0AMnOqxlZ85XS0pw1n3e5FxCD7EQQn8XloA7jhmwg0hN9JreCxUWN472t RWIw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:from:subject:references:mime-version :message-id:in-reply-to:date:dkim-signature; bh=uAs9xJJ0NlEB/osgBnOQ+CItqjWbP34nP1iWUwmaFSk=; fh=Io7x3OacpefNRRNKoYAzVE0aWTDwD7FRzyCdD1e3AN4=; b=Javl27+SFlrAp7FmRpwWOtGvRyRgvAAj1LRr3DOnVVIMuKzKSTQ2Tnr/bNnGhjLR2D xrc5hR+JQ5EitzQr0YhaT5DF0D/kZ3gZN6wA5S9KwGVyIFu/W3nzDxFaafJv9wvZRTQv 4DqmSk5uCD+nbO+ualTtKp2xP27AnO6N3U3A97cs3y9JnE+emggEP5pYbjpL9T4iDu7i 1o67Q5EdLHhUsjEzG3uSvYauVS+kvEauXDA1gMv5YybJFwdwKw7ldrCIECR5chodacgJ +naau4dUOjB7bJLg7NaHQyYxCwqvpS2wnpRJBqcXaq9PoAmurrpqbhd19i6Hjn2U45qc U1Kg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=Ou5kncoO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id ot16-20020a17090b3b5000b00285baead549si4389023pjb.157.2023.11.27.14.11.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Nov 2023 14:11:20 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=Ou5kncoO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id CDA10810756D; Mon, 27 Nov 2023 14:11:16 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234180AbjK0WLC (ORCPT <rfc822;toshivichauhan@gmail.com> + 99 others); Mon, 27 Nov 2023 17:11:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39240 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233855AbjK0WKc (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 27 Nov 2023 17:10:32 -0500 Received: from mail-yw1-x114a.google.com (mail-yw1-x114a.google.com [IPv6:2607:f8b0:4864:20::114a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A6C922103 for <linux-kernel@vger.kernel.org>; Mon, 27 Nov 2023 14:10:08 -0800 (PST) Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-5cef61289fdso38427937b3.1 for <linux-kernel@vger.kernel.org>; Mon, 27 Nov 2023 14:10:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1701123008; x=1701727808; 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=uAs9xJJ0NlEB/osgBnOQ+CItqjWbP34nP1iWUwmaFSk=; b=Ou5kncoOrxfYfVuvym4yMip8yo+PgBMeoms+79MdyYq6I6GUngQSVDEBECX97ZHBMQ wwRakzunprC5rB914GbqG7eDAK9q4rHR9iWScZEVoOzbI2FoGEA96OuJd3NGb7aIbixI lsBoN/H17MSLdJ7SHnivj5uNn8I8r7ecDRslQKoh2P56d1zrCDw3WQ26usbn+ng3P3U8 hhI3+V/c9hT+a2pTgq+8TGvoN+4lDJQ5bVLTP82Fq+PTLpFPbyV2JDfyjJL/KFpcSXVt LwIlOnXP/oKWiZzp2G0Dc3mShtZQiUOoSP4eiAIZiLGYfQ7CoNkcj6kORIws6vy1lZ9R qG6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701123008; x=1701727808; 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=uAs9xJJ0NlEB/osgBnOQ+CItqjWbP34nP1iWUwmaFSk=; b=NcZUi0wghBwKGy3wE7FizNWioBB4cg3/7O5y7JUdQdKAydrvF3/bx+md7jtJXTQSi4 U5mN1ITW8prlSyT1WBKQCYHSUZeE1VFFEJXFvUTiwYj1pk7CuPpUW+T8qmNogHkA1uu+ ozchSw42ZgUe+FMb8JHu1D0P8KyTHddNzvGSK3Rj6WufeoJN6H833nSpJjdAxbNU40TO vANtKtubdDlLAUKnO/2nGVKy7Tknv4ZDabD1p1mtwbHjJduto21iz1jYGQ/zvO5zRQus b4z8sn8rjHZI3ajDe66SK00ZQiTCwL2BJB9TlwohXbYYZAhQXY1DuB73F3TGjXw38KkE /hLA== X-Gm-Message-State: AOJu0YyOXWV8ZOEU+V7AQK9I4v5LbkfoAdAmSccTegywG/eyFPV4mrsH 4Jm1nwDP1lDmhZ/bP07QnxcTuc8fuvfu X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:829:6e77:9093:f39b]) (user=irogers job=sendgmr) by 2002:a05:690c:811:b0:5ca:f8cb:181d with SMTP id bx17-20020a05690c081100b005caf8cb181dmr425161ywb.3.1701123007777; Mon, 27 Nov 2023 14:10:07 -0800 (PST) Date: Mon, 27 Nov 2023 14:08:31 -0800 In-Reply-To: <20231127220902.1315692-1-irogers@google.com> Message-Id: <20231127220902.1315692-20-irogers@google.com> Mime-Version: 1.0 References: <20231127220902.1315692-1-irogers@google.com> X-Mailer: git-send-email 2.43.0.rc1.413.gea7ed67945-goog Subject: [PATCH v5 19/50] perf maps: Do simple merge if given map doesn't overlap From: Ian Rogers <irogers@google.com> To: Peter Zijlstra <peterz@infradead.org>, Ingo Molnar <mingo@redhat.com>, Arnaldo Carvalho de Melo <acme@kernel.org>, Mark Rutland <mark.rutland@arm.com>, Alexander Shishkin <alexander.shishkin@linux.intel.com>, Jiri Olsa <jolsa@kernel.org>, Namhyung Kim <namhyung@kernel.org>, Ian Rogers <irogers@google.com>, Adrian Hunter <adrian.hunter@intel.com>, Nick Terrell <terrelln@fb.com>, Kan Liang <kan.liang@linux.intel.com>, Andi Kleen <ak@linux.intel.com>, Kajol Jain <kjain@linux.ibm.com>, Athira Rajeev <atrajeev@linux.vnet.ibm.com>, Huacai Chen <chenhuacai@kernel.org>, Masami Hiramatsu <mhiramat@kernel.org>, Vincent Whitchurch <vincent.whitchurch@axis.com>, "Steinar H. Gunderson" <sesse@google.com>, Liam Howlett <liam.howlett@oracle.com>, Miguel Ojeda <ojeda@kernel.org>, Colin Ian King <colin.i.king@gmail.com>, Dmitrii Dolgov <9erthalion6@gmail.com>, Yang Jihong <yangjihong1@huawei.com>, Ming Wang <wangming01@loongson.cn>, James Clark <james.clark@arm.com>, K Prateek Nayak <kprateek.nayak@amd.com>, Sean Christopherson <seanjc@google.com>, Leo Yan <leo.yan@linaro.org>, Ravi Bangoria <ravi.bangoria@amd.com>, German Gomez <german.gomez@arm.com>, Changbin Du <changbin.du@huawei.com>, Paolo Bonzini <pbonzini@redhat.com>, Li Dong <lidong@vivo.com>, Sandipan Das <sandipan.das@amd.com>, liuwenyu <liuwenyu7@huawei.com>, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Guilherme Amadio <amadio@gentoo.org> Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-8.4 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Mon, 27 Nov 2023 14:11:17 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783756834891756234 X-GMAIL-MSGID: 1783756834891756234 |
Series |
Improvements to memory use
|
|
Commit Message
Ian Rogers
Nov. 27, 2023, 10:08 p.m. UTC
Simplify merge in for the simple case of a non-overlapping map.
Signed-off-by: Ian Rogers <irogers@google.com>
---
tools/perf/util/maps.c | 11 +++++++++++
1 file changed, 11 insertions(+)
Comments
On Mon, Nov 27, 2023 at 2:10 PM Ian Rogers <irogers@google.com> wrote: > > Simplify merge in for the simple case of a non-overlapping map. > > Signed-off-by: Ian Rogers <irogers@google.com> A nitpick below. > --- > tools/perf/util/maps.c | 11 +++++++++++ > 1 file changed, 11 insertions(+) > > diff --git a/tools/perf/util/maps.c b/tools/perf/util/maps.c > index 40df08dd9bf3..14e1a169433d 100644 > --- a/tools/perf/util/maps.c > +++ b/tools/perf/util/maps.c > @@ -696,9 +696,20 @@ void maps__fixup_end(struct maps *maps) > int maps__merge_in(struct maps *kmaps, struct map *new_map) > { > struct map_rb_node *rb_node; > + struct rb_node *first; > + bool overlaps; > LIST_HEAD(merged); > int err = 0; > > + down_read(maps__lock(kmaps)); > + first = first_ending_after(kmaps, new_map); > + overlaps = first && > + map__start(rb_entry(first, struct map_rb_node, rb_node)->map) < map__end(new_map); Can you please break this like below? rb_node = first ? rb_entry(first, struct map_rb_node, rb_node) : NULL; overlap = rb_node && map__start(rb_node->map) < map_end(new_map); Thanks, Namhyung > + up_read(maps__lock(kmaps)); > + > + if (!overlaps) > + return maps__insert(kmaps, new_map); > + > maps__for_each_entry(kmaps, rb_node) { > struct map *old_map = rb_node->map; > > -- > 2.43.0.rc1.413.gea7ed67945-goog >
On Mon, Dec 4, 2023 at 4:06 PM Namhyung Kim <namhyung@kernel.org> wrote: > > On Mon, Nov 27, 2023 at 2:10 PM Ian Rogers <irogers@google.com> wrote: > > > > Simplify merge in for the simple case of a non-overlapping map. > > > > Signed-off-by: Ian Rogers <irogers@google.com> > > A nitpick below. > > > --- > > tools/perf/util/maps.c | 11 +++++++++++ > > 1 file changed, 11 insertions(+) > > > > diff --git a/tools/perf/util/maps.c b/tools/perf/util/maps.c > > index 40df08dd9bf3..14e1a169433d 100644 > > --- a/tools/perf/util/maps.c > > +++ b/tools/perf/util/maps.c > > @@ -696,9 +696,20 @@ void maps__fixup_end(struct maps *maps) > > int maps__merge_in(struct maps *kmaps, struct map *new_map) > > { > > struct map_rb_node *rb_node; > > + struct rb_node *first; > > + bool overlaps; > > LIST_HEAD(merged); > > int err = 0; > > > > + down_read(maps__lock(kmaps)); > > + first = first_ending_after(kmaps, new_map); > > + overlaps = first && > > + map__start(rb_entry(first, struct map_rb_node, rb_node)->map) < map__end(new_map); > > Can you please break this like below? > > rb_node = first ? rb_entry(first, struct map_rb_node, rb_node) : NULL; > overlap = rb_node && map__start(rb_node->map) < map_end(new_map); Done in v6. Thanks, Ian > Thanks, > Namhyung > > > > + up_read(maps__lock(kmaps)); > > + > > + if (!overlaps) > > + return maps__insert(kmaps, new_map); > > + > > maps__for_each_entry(kmaps, rb_node) { > > struct map *old_map = rb_node->map; > > > > -- > > 2.43.0.rc1.413.gea7ed67945-goog > >
diff --git a/tools/perf/util/maps.c b/tools/perf/util/maps.c index 40df08dd9bf3..14e1a169433d 100644 --- a/tools/perf/util/maps.c +++ b/tools/perf/util/maps.c @@ -696,9 +696,20 @@ void maps__fixup_end(struct maps *maps) int maps__merge_in(struct maps *kmaps, struct map *new_map) { struct map_rb_node *rb_node; + struct rb_node *first; + bool overlaps; LIST_HEAD(merged); int err = 0; + down_read(maps__lock(kmaps)); + first = first_ending_after(kmaps, new_map); + overlaps = first && + map__start(rb_entry(first, struct map_rb_node, rb_node)->map) < map__end(new_map); + up_read(maps__lock(kmaps)); + + if (!overlaps) + return maps__insert(kmaps, new_map); + maps__for_each_entry(kmaps, rb_node) { struct map *old_map = rb_node->map;