lkml.org 
[lkml]   [2023]   [Mar]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
Subject[PATCH v4 05/22] perf symbol: Sort names under write lock
From
If finding a name doesn't find the sorted names then they are
allocated and sorted. This shouldn't be done under a read lock as
another reader may access it. Release the read lock and acquire the
write lock, then release the write lock and reacquire the read lock.

Signed-off-by: Ian Rogers <irogers@google.com>
---
tools/perf/util/symbol.c | 7 +++++++
1 file changed, 7 insertions(+)

diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
index 317c0706852f..a458aa8b87bb 100644
--- a/tools/perf/util/symbol.c
+++ b/tools/perf/util/symbol.c
@@ -2018,6 +2018,9 @@ static int map__groups__sort_by_name_from_rbtree(struct maps *maps)
if (maps_by_name == NULL)
return -1;

+ up_read(&maps->lock);
+ down_write(&maps->lock);
+
maps->maps_by_name = maps_by_name;
maps->nr_maps_allocated = maps->nr_maps;

@@ -2025,6 +2028,10 @@ static int map__groups__sort_by_name_from_rbtree(struct maps *maps)
maps_by_name[i++] = map;

__maps__sort_by_name(maps);
+
+ up_write(&maps->lock);
+ down_read(&maps->lock);
+
return 0;
}

--
2.40.0.rc1.284.g88254d51c5-goog
\
 
 \ /
  Last update: 2023-03-27 01:07    [W:0.130 / U:0.564 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site