Skip to contentSkip to conversation

kernel-shark-qt: Change the type of the fields in struct kshark_entry

PATCH In review Yordan Karadzhov (VMware) 2 participants 4 messages Aug 3, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 kernel-shark-qt: Change the type of the fields in struct kshark_entry

This patch aims to increase the max value limits of the "pid" and "cpu" fields of struct kshark_entry. The type of the field "visible" is changed as well, but this is done just to provide optimal packing.

---
 kernel-shark-qt/src/libkshark.h | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
kernel-shark-qt/src/libkshark.h +4 -4
index 2e26552..0ad31c0 100644
@@ -42,16 +42,16 @@ struct kshark_entry {
 	 * kshark_filter_masks to check the level of visibility/invisibility
 	 * of the entry.
 	 */
-	uint8_t		visible;
+	uint16_t	visible;
 
 	/** The CPU core of the record. */
-	uint8_t		cpu;
+	int16_t		cpu;
 
 	/** The PID of the task the record was generated. */
-	int16_t		pid;
+	int32_t		pid;
 
 	/** Unique Id ot the trace event type. */
-	int		event_id;
+	int32_t		event_id;
 
 	/** The offset into the trace file, used to find the record. */
 	uint64_t	offset;
Signature · 1 line
2.17.1
#1 lore raw

PATCH 2/3 kernel-shark-qt: Change the input argument of kshark_dump_entry() to const.

kshark_dump_entry() should not be able to modify the content of its input argument (kshark_entry) which is being dumped to a string. The type of the argument is changed from "struct kshark_entry*" to "const struct kshark_entry*"

---
 kernel-shark-qt/src/libkshark.c | 2 +-
 kernel-shark-qt/src/libkshark.h | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
kernel-shark-qt/src/libkshark.c +1 -1
index 3299752..847c10f 100644
@@ -861,7 +861,7 @@ static const char *kshark_get_info(struct pevent *pe,
  * @returns The returned string contains a semicolon-separated list of data
  *	    fields.
  */
-char* kshark_dump_entry(struct kshark_entry *entry)
+char* kshark_dump_entry(const struct kshark_entry *entry)
 {
 	const char *event_name, *task, *lat, *info;
 	struct kshark_context *kshark_ctx;
kernel-shark-qt/src/libkshark.h +1 -1
index 0ad31c0..eda0a83 100644
@@ -133,7 +133,7 @@ void kshark_close(struct kshark_context *kshark_ctx);
 
 void kshark_free(struct kshark_context *kshark_ctx);
 
-char* kshark_dump_entry(struct kshark_entry *entry);
+char* kshark_dump_entry(const struct kshark_entry *entry);
 
 /** Bit masks used to control the visibility of the entry after filtering. */
 enum kshark_filter_masks {
Signature · 1 line
2.17.1
#2 lore raw

PATCH 3/3 kernel-shark-qt: In the Doxygen doc. add spacing after @brief and @param.

In reply to Yordan Karadzhov (VMware)

This patch adds a blank comment line after @brief, and after the last @param in the Doxygen documentation of each function. This makes it easier to read.

---
 kernel-shark-qt/src/libkshark.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
kernel-shark-qt/src/libkshark.c +17 -0
index 847c10f..c829aa9 100644
@@ -65,11 +65,13 @@ static bool init_thread_seq(void)
  *	  calling any other kshark function. If the session has been
  *	  initialized, this function can be used to obtain the session's
  *	  context.
+ *
  * @param kshark_ctx: Optional input/output location for context pointer.
  *		      If it points to a context, that context will become
  *		      the new session. If it points to NULL, it will obtain
  *		      the current (or new) session. The result is only
  *		      valid on return of true.
+ *
  * @returns True on success, or false on failure.
  */
 bool kshark_instance(struct kshark_context **kshark_ctx)
@@ -121,8 +123,10 @@ static void kshark_free_task_list(struct kshark_context *kshark_ctx)
  * @brief Open and prepare for reading a trace data file specified by "file".
  *	  If the specified file does not exist, or contains no trace data,
  *	  the function returns false.
+ *
  * @param kshark_ctx: Input location for context pointer.
  * @param file: The file to load.
+ *
  * @returns True on success, or false on failure.
  */
 bool kshark_open(struct kshark_context *kshark_ctx, const char *file)
@@ -158,6 +162,7 @@ bool kshark_open(struct kshark_context *kshark_ctx, const char *file)
 
 /**
  * @brief Close the trace data file and free the trace data handle.
+ *
  * @param kshark_ctx: Input location for the session context pointer.
  */
 void kshark_close(struct kshark_context *kshark_ctx)
@@ -190,6 +195,7 @@ void kshark_close(struct kshark_context *kshark_ctx)
 /**
  * @brief Deinitialize kshark session. Should be called after closing all
  *	  open trace data files and before your application terminates.
+ *
  * @param kshark_ctx: Optional input location for session context pointer.
  *		      If it points to a context of a sessuin, that sessuin
  *		      will be deinitialize. If it points to NULL, it will
@@ -271,9 +277,11 @@ kshark_add_task(struct kshark_context *kshark_ctx, int pid)
 /**
  * @brief Get an array containing the Process Ids of all tasks presented in
  *	  the loaded trace data file.
+ *
  * @param kshark_ctx: Input location for context pointer.
  * @param pids: Output location for the Pids of the tasks. The user is
  *		responsible for freeing the elements of the outputted array.
+ *
  * @returns The size of the outputted array of Pids in the case of success,
  *	    or a negative error code on failure.
  */
@@ -346,6 +354,7 @@ static bool kshark_show_event(struct kshark_context *kshark_ctx, int pid)
 
 /**
  * @brief Add an Id value to the filster specified by "filter_id".
+ *
  * @param kshark_ctx: Input location for the session context pointer.
  * @param filter_id: Identifier of the filter.
  * @param id: Id value to be added to the filter.
@@ -377,6 +386,7 @@ void kshark_filter_add_id(struct kshark_context *kshark_ctx,
 
 /**
  * @brief Clear (reset) the filster specified by "filter_id".
+ *
  * @param kshark_ctx: Input location for the session context pointer.
  * @param filter_id: Identifier of the filter.
  */
@@ -443,6 +453,7 @@ static void unset_event_filter_flag(struct kshark_context *kshark_ctx,
  *	  WARNING: Do not use this function if the advanced filter is set.
  *	  Applying the advanced filter requires access to prevent_record,
  *	  hence the data has to be reloaded using kshark_load_data_entries().
+ *
  * @param kshark_ctx: Input location for the session context pointer.
  * @param data: Input location for the trace data to be filtered.
  * @param n_entries: The size of the inputted data.
@@ -681,10 +692,12 @@ static int pick_next_cpu(struct rec_list **rec_list, int n_cpus,
  *	  is updated according to the criteria provided by the filters. The
  *	  field "filter_mask" of the session's context is used to control the
  *	  level of visibility/invisibility of the filtered entries.
+ *
  * @param kshark_ctx: Input location for context pointer.
  * @param data_rows: Output location for the trace data. The user is
  *		     responsible for freeing the elements of the outputted
  *		     array.
+ *
  * @returns The size of the outputted data in the case of success, or a
  *	    negative error code on failure.
  */
@@ -749,9 +762,11 @@ ssize_t kshark_load_data_entries(struct kshark_context *kshark_ctx,
  * @brief Load the content of the trace data file into an array of
  *	  pevent_records. Use this function only if you need fast access
  *	  to all fields of the record.
+ *
  * @param kshark_ctx: Input location for the session context pointer.
  * @param data_rows: Output location for the trace data. Use free_record()
  *	 	     to free the elements of the outputted array.
+ *
  * @returns The size of the outputted data in the case of success, or a
  *	    negative error code on failure.
  */
@@ -857,7 +872,9 @@ static const char *kshark_get_info(struct pevent *pe,
  * @brief Dump into a string the content of one entry. The function allocates
  *	  a null terminated string and returns a pointer to this string. The
  *	  user has to free the returned string.
+ *
  * @param entry: A Kernel Shark entry to be printed.
+ *
  * @returns The returned string contains a semicolon-separated list of data
  *	    fields.
  */
Signature · 1 line
2.17.1
#3 lore raw

Re: [PATCH 3/3] kernel-shark-qt: In the Doxygen doc. add spacing after @brief and @param.

Quoted 5 lines · On Fri, 3 Aug 2018 16:07:59 +0300 "Yordan Karadzhov (VMware)"…

This patch adds a blank comment line after @brief, and after the last @param in the Doxygen documentation of each function. This makes it easier to read.

---

I applied these three patches (as well as your other update) and pushed them to my repo on kernel.org.

-- Steve