mirror of
https://github.com/torvalds/linux.git
synced 2026-04-18 14:53:58 -04:00
lib, stackdepot: add helper to print stack entries into buffer
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. [imran.f.khan@oracle.com: fix build error] Link: https://lkml.kernel.org/r/20210915175321.3472770-4-imran.f.khan@oracle.com [imran.f.khan@oracle.com: export stack_depot_snprint() to modules] Link: https://lkml.kernel.org/r/20210916133535.3592491-4-imran.f.khan@oracle.com Link: https://lkml.kernel.org/r/20210915014806.3206938-4-imran.f.khan@oracle.com Signed-off-by: Imran Khan <imran.f.khan@oracle.com> Suggested-by: Vlastimil Babka <vbabka@suse.cz> Acked-by: Vlastimil Babka <vbabka@suse.cz> Acked-by: Jani Nikula <jani.nikula@intel.com> [i915] Cc: Alexander Potapenko <glider@google.com> Cc: Andrey Konovalov <andreyknvl@gmail.com> Cc: Andrey Ryabinin <ryabinin.a.a@gmail.com> Cc: Daniel Vetter <daniel@ffwll.ch> Cc: David Airlie <airlied@linux.ie> Cc: Dmitry Vyukov <dvyukov@google.com> Cc: Geert Uytterhoeven <geert@linux-m68k.org> Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com> Cc: Maxime Ripard <mripard@kernel.org> Cc: Thomas Zimmermann <tzimmermann@suse.de> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
committed by
Linus Torvalds
parent
505be48165
commit
0f68d45ef4
@@ -65,16 +65,6 @@ static noinline depot_stack_handle_t __save_depot_stack(void)
|
||||
return stack_depot_save(entries, n, GFP_NOWAIT | __GFP_NOWARN);
|
||||
}
|
||||
|
||||
static void __print_depot_stack(depot_stack_handle_t stack,
|
||||
char *buf, int sz, int indent)
|
||||
{
|
||||
unsigned long *entries;
|
||||
unsigned int nr_entries;
|
||||
|
||||
nr_entries = stack_depot_fetch(stack, &entries);
|
||||
stack_trace_snprint(buf, sz, entries, nr_entries, indent);
|
||||
}
|
||||
|
||||
static void init_intel_runtime_pm_wakeref(struct intel_runtime_pm *rpm)
|
||||
{
|
||||
spin_lock_init(&rpm->debug.lock);
|
||||
@@ -146,12 +136,12 @@ static void untrack_intel_runtime_pm_wakeref(struct intel_runtime_pm *rpm,
|
||||
if (!buf)
|
||||
return;
|
||||
|
||||
__print_depot_stack(stack, buf, PAGE_SIZE, 2);
|
||||
stack_depot_snprint(stack, buf, PAGE_SIZE, 2);
|
||||
DRM_DEBUG_DRIVER("wakeref %x from\n%s", stack, buf);
|
||||
|
||||
stack = READ_ONCE(rpm->debug.last_release);
|
||||
if (stack) {
|
||||
__print_depot_stack(stack, buf, PAGE_SIZE, 2);
|
||||
stack_depot_snprint(stack, buf, PAGE_SIZE, 2);
|
||||
DRM_DEBUG_DRIVER("wakeref last released at\n%s", buf);
|
||||
}
|
||||
|
||||
@@ -183,12 +173,12 @@ __print_intel_runtime_pm_wakeref(struct drm_printer *p,
|
||||
return;
|
||||
|
||||
if (dbg->last_acquire) {
|
||||
__print_depot_stack(dbg->last_acquire, buf, PAGE_SIZE, 2);
|
||||
stack_depot_snprint(dbg->last_acquire, buf, PAGE_SIZE, 2);
|
||||
drm_printf(p, "Wakeref last acquired:\n%s", buf);
|
||||
}
|
||||
|
||||
if (dbg->last_release) {
|
||||
__print_depot_stack(dbg->last_release, buf, PAGE_SIZE, 2);
|
||||
stack_depot_snprint(dbg->last_release, buf, PAGE_SIZE, 2);
|
||||
drm_printf(p, "Wakeref last released:\n%s", buf);
|
||||
}
|
||||
|
||||
@@ -203,7 +193,7 @@ __print_intel_runtime_pm_wakeref(struct drm_printer *p,
|
||||
rep = 1;
|
||||
while (i + 1 < dbg->count && dbg->owners[i + 1] == stack)
|
||||
rep++, i++;
|
||||
__print_depot_stack(stack, buf, PAGE_SIZE, 2);
|
||||
stack_depot_snprint(stack, buf, PAGE_SIZE, 2);
|
||||
drm_printf(p, "Wakeref x%lu taken at:\n%s", rep, buf);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user