Re: [PATCH v4 2/3] perf tool: add PERF_RECORD_NAMESPACES to include namespaces related info

From: Hari Bathini
Date: Wed Dec 21 2016 - 08:19:03 EST


Hi Jiri,


On Saturday 17 December 2016 11:10 PM, Jiri Olsa wrote:
On Fri, Dec 16, 2016 at 12:07:20AM +0530, Hari Bathini wrote:

SNIP

+
+int thread__set_namespaces(struct thread *thread, u64 timestamp,
+ struct namespaces_event *event)
+{
+ struct namespaces *new, *curr = thread__namespaces(thread);
+
+ new = namespaces__new(event);
+ if (!new)
+ return -ENOMEM;
+
+ list_add(&new->list, &thread->namespaces_list);
+
+ if (timestamp && curr) {
+ /*
+ * setns syscall must have changed few or all the namespaces
+ * of this thread. Update end time for the namespaces
+ * previously used.
+ */
+ curr = list_next_entry(new, list);
+ curr->end_time = timestamp;
hi,
couldn't you use just the curr you got from thread__namespaces?
why to retrieve it again via 'new' pointer?


Adding the new namespaces info to the list while keeping the old ones
along with the change timestamp to retain the multiple changes made
for the namespaces of each thread.

Thanks
Hari