Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

perf dsos: Remove __dsos__findnew_link_by_longname_id()

Function was only called in dsos.c with the dso parameter as
NULL. Remove the function and specialize for the dso being NULL case
removing other unused functions along the way.

Signed-off-by: Ian Rogers <irogers@google.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
Cc: Ben Gainey <ben.gainey@arm.com>
Cc: Changbin Du <changbin.du@huawei.com>
Cc: Chengen Du <chengen.du@canonical.com>
Cc: Colin Ian King <colin.i.king@gmail.com>
Cc: Dima Kogan <dima@secretsauce.net>
Cc: Ilkka Koskinen <ilkka@os.amperecomputing.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: James Clark <james.clark@arm.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: K Prateek Nayak <kprateek.nayak@amd.com>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Leo Yan <leo.yan@linux.dev>
Cc: Li Dong <lidong@vivo.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paran Lee <p4ranlee@gmail.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Song Liu <song@kernel.org>
Cc: Sun Haiyong <sunhaiyong@loongson.cn>
Cc: Thomas Richter <tmricht@linux.ibm.com>
Cc: Tiezhu Yang <yangtiezhu@loongson.cn>
Cc: Yanteng Si <siyanteng@loongson.cn>
Cc: zhaimingbing <zhaimingbing@cmss.chinamobile.com>
Link: https://lore.kernel.org/r/20240504213803.218974-4-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Ian Rogers and committed by
Arnaldo Carvalho de Melo
7410d600 dfd48165

+10 -47
+10 -41
tools/perf/util/dsos.c
··· 119 119 return rc ?: dso_id__cmp(id, &b->id); 120 120 } 121 121 122 - static int dso__cmp_short_name(struct dso *a, struct dso *b) 123 - { 124 - return __dso__cmp_short_name(a->short_name, &a->id, b); 125 - } 126 - 127 122 static int dsos__cmp_long_name_id_short_name(const void *va, const void *vb) 128 123 { 129 124 const struct dso *a = *((const struct dso **)va); ··· 138 143 * Either one of the dso or name parameter must be non-NULL or the 139 144 * function will not work. 140 145 */ 141 - struct dso *__dsos__findnew_link_by_longname_id(struct dsos *dsos, 142 - struct dso *dso, 143 - const char *name, 144 - struct dso_id *id, 145 - bool write_locked) 146 + static struct dso *__dsos__find_by_longname_id(struct dsos *dsos, 147 + const char *name, 148 + struct dso_id *id, 149 + bool write_locked) 146 150 { 147 151 int low = 0, high = dsos->cnt - 1; 148 152 149 153 if (!dsos->sorted) { 150 154 if (!write_locked) { 155 + struct dso *dso; 156 + 151 157 up_read(&dsos->lock); 152 158 down_write(&dsos->lock); 153 - dso = __dsos__findnew_link_by_longname_id(dsos, dso, name, id, 154 - /*write_locked=*/true); 159 + dso = __dsos__find_by_longname_id(dsos, name, id, 160 + /*write_locked=*/true); 155 161 up_write(&dsos->lock); 156 162 down_read(&dsos->lock); 157 163 return dso; ··· 161 165 dsos__cmp_long_name_id_short_name); 162 166 dsos->sorted = true; 163 167 } 164 - 165 - if (!name) 166 - name = dso->long_name; 167 168 168 169 /* 169 170 * Find node with the matching name ··· 171 178 int rc = __dso__cmp_long_name(name, id, this); 172 179 173 180 if (rc == 0) { 174 - /* 175 - * In case the new DSO is a duplicate of an existing 176 - * one, print a one-time warning & put the new entry 177 - * at the end of the list of duplicates. 178 - */ 179 - if (!dso || (dso == this)) 180 - return dso__get(this); /* Find matching dso */ 181 - /* 182 - * The core kernel DSOs may have duplicated long name. 183 - * In this case, the short name should be different. 184 - * Comparing the short names to differentiate the DSOs. 185 - */ 186 - rc = dso__cmp_short_name(dso, this); 187 - if (rc == 0) { 188 - pr_err("Duplicated dso name: %s\n", name); 189 - return NULL; 190 - } 181 + return dso__get(this); /* Find matching dso */ 191 182 } 192 183 if (rc < 0) 193 184 high = mid - 1; 194 185 else 195 186 low = mid + 1; 196 187 } 197 - if (dso) 198 - __dsos__add(dsos, dso); 199 188 return NULL; 200 189 } 201 190 ··· 215 240 return ret; 216 241 } 217 242 218 - static struct dso *__dsos__findnew_by_longname_id(struct dsos *dsos, const char *name, 219 - struct dso_id *id, bool write_locked) 220 - { 221 - return __dsos__findnew_link_by_longname_id(dsos, NULL, name, id, write_locked); 222 - } 223 - 224 243 struct dsos__find_id_cb_args { 225 244 const char *name; 226 245 struct dso_id *id; ··· 248 279 __dsos__for_each_dso(dsos, dsos__find_id_cb, &args); 249 280 return args.res; 250 281 } 251 - res = __dsos__findnew_by_longname_id(dsos, name, id, write_locked); 282 + res = __dsos__find_by_longname_id(dsos, name, id, write_locked); 252 283 return res; 253 284 } 254 285
-6
tools/perf/util/dsos.h
··· 36 36 37 37 bool dsos__read_build_ids(struct dsos *dsos, bool with_hits); 38 38 39 - struct dso *__dsos__findnew_link_by_longname_id(struct dsos *dsos, 40 - struct dso *dso, 41 - const char *name, 42 - struct dso_id *id, 43 - bool write_locked); 44 - 45 39 size_t dsos__fprintf_buildid(struct dsos *dsos, FILE *fp, 46 40 bool (skip)(struct dso *dso, int parm), int parm); 47 41 size_t dsos__fprintf(struct dsos *dsos, FILE *fp);