On 13/9/21 6:51 pm, Vlastimil Babka wrote:
On 9/10/21 16:10, Imran Khan wrote:
To print stack entries into a buffer, users of stackdepot,
first get a list of stack entries using stack_depot_fetch
and then print this list into a buffer using stack_trace_snprint.
Provide a helper in stackdepot for this purpose.
Also change above mentioned users to use this helper.

Signed-off-by: Imran Khan <imran.f.k...@oracle.com>
Suggested-by: Vlastimil Babka <vba...@suse.cz>

Acked-by: Vlastimil Babka <vba...@suse.cz>


Thanks for the review.

A comment below:

--- a/lib/stackdepot.c
+++ b/lib/stackdepot.c
@@ -214,6 +214,29 @@ static inline struct stack_record *find_stack(struct 
stack_record *bucket,
        return NULL;
  }

[...]

+ */
+int stack_depot_snprint(depot_stack_handle_t handle, char *buf, size_t size,
+                      int spaces)
+{
+       unsigned long *entries;
+       unsigned int nr_entries;
+
+       nr_entries = stack_depot_fetch(handle, &entries);
+       return stack_trace_snprint(buf, size, entries, nr_entries, 0);

stack_trace_snprint() has a WARN_ON(!entries).
So maybe we should not call it if nr_entries is 0 (because e.g. handle was
0) as the warnings are not useful in that case.

Agree. I have addressed this feedback in v2 of patch.


Thanks
-- Imran

Reply via email to