History

tracing: Remove code which merges duplicates

We now have the logic to detect and remove duplicates in the tracing_map hash table. The code which merges duplicates in the histogram is redundant now. So, modify this code just to detect duplicates. The duplication detection code is still kept to ensure that any rare race condition which might cause duplicates does not go unnoticed. Link: http://lkml.kernel.org/r/55215cf59e2674391bdaf772fdafc4c393352b03.1516069914.git.tom.zanussi@linux.intel.com

Vedang Patel committed 8 years ago

Commit c1937071 parent cbf41003 files · +6 −95Browse files

Showing the changes to kernel/trace/tracing_map.c (1 of 3 files). Show all

Unified · Split

kernel/trace/tracing_map.c+6−77
@@ -847,67 +847,15 @@ create_sort_entry(void *key, struct tracing_map_elt *elt) · 846 unmodified lines
847847 return sort_entry;
848848 }
849849
850−static struct tracing_map_elt *copy_elt(struct tracing_map_elt *elt)
851−{
852− struct tracing_map_elt *dup_elt;
853− unsigned int i;
854−
855− dup_elt = tracing_map_elt_alloc(elt->map);
856− if (IS_ERR(dup_elt))
857− return NULL;
858−
859− if (elt->map->ops && elt->map->ops->elt_copy)
860− elt->map->ops->elt_copy(dup_elt, elt);
861−
862− dup_elt->private_data = elt->private_data;
863− memcpy(dup_elt->key, elt->key, elt->map->key_size);
864−
865− for (i = 0; i < elt->map->n_fields; i++) {
866− atomic64_set(&dup_elt->fields[i].sum,
867− atomic64_read(&elt->fields[i].sum));
868− dup_elt->fields[i].cmp_fn = elt->fields[i].cmp_fn;
869− }
870−
871− return dup_elt;
872−}
873−
874−static int merge_dup(struct tracing_map_sort_entry **sort_entries,
875− unsigned int target, unsigned int dup)
876−{
877− struct tracing_map_elt *target_elt, *elt;
878− bool first_dup = (target - dup) == 1;
879− int i;
880−
881− if (first_dup) {
882− elt = sort_entries[target]->elt;
883− target_elt = copy_elt(elt);
884− if (!target_elt)
885− return -ENOMEM;
886− sort_entries[target]->elt = target_elt;
887− sort_entries[target]->elt_copied = true;
888− } else
889− target_elt = sort_entries[target]->elt;
890−
891− elt = sort_entries[dup]->elt;
892−
893− for (i = 0; i < elt->map->n_fields; i++)
894− atomic64_add(atomic64_read(&elt->fields[i].sum),
895− &target_elt->fields[i].sum);
896−
897− sort_entries[dup]->dup = true;
898−
899− return 0;
900−}
901−
902−static int merge_dups(struct tracing_map_sort_entry **sort_entries,
850+static void detect_dups(struct tracing_map_sort_entry **sort_entries,
903851 int n_entries, unsigned int key_size)
904852 {
905853 unsigned int dups = 0, total_dups = 0;
906− int err, i, j;
854+ int i;
907855 void *key;
908856
909857 if (n_entries < 2)
910− return total_dups;
858+ return;
911859
912860 sort(sort_entries, n_entries, sizeof(struct tracing_map_sort_entry *),
913861 (int (*)(const void *, const void *))cmp_entries_dup, NULL);
@@ -916,30 +864,14 @@ static int merge_dups(struct tracing_map_sort_entry **sort_entries, · 2 unmodified lines
916864 for (i = 1; i < n_entries; i++) {
917865 if (!memcmp(sort_entries[i]->key, key, key_size)) {
918866 dups++; total_dups++;
919− err = merge_dup(sort_entries, i - dups, i);
920− if (err)
921− return err;
922867 continue;
923868 }
924869 key = sort_entries[i]->key;
925870 dups = 0;
926871 }
927872
928− if (!total_dups)
929− return total_dups;
930−
931− for (i = 0, j = 0; i < n_entries; i++) {
932− if (!sort_entries[i]->dup) {
933− sort_entries[j] = sort_entries[i];
934− if (j++ != i)
935− sort_entries[i] = NULL;
936− } else {
937− destroy_sort_entry(sort_entries[i]);
938− sort_entries[i] = NULL;
939− }
940− }
941−
942− return total_dups;
873+ WARN_ONCE(total_dups > 0,
874+ "Duplicates detected: %d\n", total_dups);
943875 }
944876
945877 static bool is_key(struct tracing_map *map, unsigned int field_idx)
@@ -1065,10 +997,7 @@ int tracing_map_sort_entries(struct tracing_map *map, · 119 unmodified lines
1065997 return 1;
1066998 }
1067999
1068− ret = merge_dups(entries, n_entries, map->key_size);
1069− if (ret < 0)
1070− goto free;
1071− n_entries -= ret;
1000+ detect_dups(entries, n_entries, map->key_size);
10721001
10731002 if (is_key(map, sort_keys[0].field_idx))
10741003 cmp_entries_fn = cmp_entries_key;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t