Skip to contentSkip to conversation

kernel-shark-qt: Define Data collections

PATCH New Yordan Karadzhov (VMware) 1 participant 1 message Aug 7, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 4/6 kernel-shark-qt: Define Data collections

Data collections are used to optimize the search for an entry having an abstract property, defined by a Matching condition function and a value.

When a collection is processed, the data which is relevant for the collection is enclosed in "Data intervals", defined by pairs of "Resume" and "Break" points. It is guaranteed that the data outside of the intervals contains no entries satisfying the abstract matching condition. In the same time the interval may (will) contain data that do not satisfy the matching condition. Keep in mind that the Collection is defined over an array of kshark_entries, sorted in time. Each interval will start (resume) at the index of the first appearance of an entry satisfying the matching condition. The definition of the Break point of the interval is a bit more complicated. The interval will be closed when we have an entry which still satisfies the condition, but the next entry on the same CPU no longer satisfies this condition.

Once defined, the Data collection can be used when searching for an entry having the same (ore related) abstract property. The collection allows to ignore the irrelevant data, thus it eliminates the linear worst-case time complexity of the search.

The user has the possibility to inflate each of the interval, by appending additional data which do not satisfy the matching condition (margin data). This data will be added to each interval at the beginning and at the end of the data which is relevant for the collection, as well as at the beginning and at the end of data-set. The margin data can be useful in the case when the user wants to be able to see what is happening before and after the appearance of his data of interest.

---
 kernel-shark-qt/src/CMakeLists.txt         |   3 +-
 kernel-shark-qt/src/libkshark-collection.c | 830 +++++++++++++++++++++
 kernel-shark-qt/src/libkshark.c            |  16 +
 kernel-shark-qt/src/libkshark.h            |  80 ++
 4 files changed, 928 insertions(+), 1 deletion(-)
 create mode 100644 kernel-shark-qt/src/libkshark-collection.c
kernel-shark-qt/src/CMakeLists.txt +2 -1
index ec22f63..cd42920 100644
@@ -2,7 +2,8 @@ message("\n src ...")
 
 message(STATUS "libkshark")
 add_library(kshark SHARED libkshark.c
-                          libkshark-model.c)
+                          libkshark-model.c
+                          libkshark-collection.c)
 
 target_link_libraries(kshark ${CMAKE_DL_LIBS}
                              ${TRACEEVENT_LIBRARY}
kernel-shark-qt/src/libkshark-collection.c new file +830 -0

830 lines not on this page · raw message

kernel-shark-qt/src/libkshark.c +16 -0
index 879946b..58287e9 100644
@@ -1067,6 +1067,7 @@ kshark_entry_request_alloc(size_t first, size_t n,
 		return NULL;
 	}
 
+	req->next = NULL;
 	req->first = first;
 	req->n = n;
 	req->cond = cond;
@@ -1077,6 +1078,21 @@ kshark_entry_request_alloc(size_t first, size_t n,
 	return req;
 }
 
+/**
+ * @brief Free all Data requests in a given list.
+ * @param req: Intput location for the Data request list.
+ */
+void kshark_free_entry_request(struct kshark_entry_request *req)
+{
+	struct kshark_entry_request *last;
+
+	while (req) {
+		last = req;
+		req = req->next;
+		free(last);
+	}
+}
+
 /** Dummy entry, used to indicate the existence of filtered entries. */
 const struct kshark_entry dummy_entry = {
 	.next		= NULL,
kernel-shark-qt/src/libkshark.h +80 -0

104 lines not on this page · raw message

Signature · 1 line
2.17.1