msm: kgsl: Add tracepoints for process reclaim

Add trace points to track credit and debit of pages during
KGSL process reclaim.

Change-Id: I1c77f574ad5905cb65c336ebe08b74f90024a1dc
Signed-off-by: Rohan Sethi <quic_rohsethi@quicinc.com>
This commit is contained in:
Rohan Sethi 2022-06-01 16:46:16 +05:30
parent 875f168094
commit 32e25b4ec0
2 changed files with 78 additions and 1 deletions

View File

@ -1,6 +1,7 @@
// SPDX-License-Identifier: GPL-2.0-only
/*
* Copyright (c) 2021, The Linux Foundation. All rights reserved.
* Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
*/
#include <linux/kthread.h>
@ -9,6 +10,7 @@
#include "kgsl_reclaim.h"
#include "kgsl_sharedmem.h"
#include "kgsl_trace.h"
/*
* Reclaiming excessive number of pages from a process will impact launch
@ -61,6 +63,8 @@ static int kgsl_memdesc_get_reclaimed_pages(struct kgsl_mem_entry *entry)
if (ret)
return ret;
trace_kgsl_reclaim_memdesc(entry, false);
memdesc->priv &= ~KGSL_MEMDESC_RECLAIMED;
memdesc->priv &= ~KGSL_MEMDESC_SKIP_RECLAIM;
@ -71,13 +75,15 @@ int kgsl_reclaim_to_pinned_state(
struct kgsl_process_private *process)
{
struct kgsl_mem_entry *entry, *valid_entry;
int next = 0, ret = 0;
int next = 0, ret = 0, count;
mutex_lock(&process->reclaim_lock);
if (test_bit(KGSL_PROC_PINNED_STATE, &process->state))
goto done;
count = atomic_read(&process->unpinned_page_count);
for ( ; ; ) {
valid_entry = NULL;
spin_lock(&process->mem_lock);
@ -101,6 +107,7 @@ int kgsl_reclaim_to_pinned_state(
next++;
}
trace_kgsl_reclaim_process(process, count, false);
set_bit(KGSL_PROC_PINNED_STATE, &process->state);
done:
mutex_unlock(&process->reclaim_lock);
@ -278,14 +285,19 @@ static u32 kgsl_reclaim_process(struct kgsl_process_private *process,
reclaim_shmem_address_space(memdesc->shmem_filp->f_mapping);
memdesc->priv |= KGSL_MEMDESC_RECLAIMED;
trace_kgsl_reclaim_memdesc(entry, true);
}
kgsl_mem_entry_put(entry);
next++;
}
if (next)
clear_bit(KGSL_PROC_PINNED_STATE, &process->state);
trace_kgsl_reclaim_process(process, pages_to_reclaim - remaining, true);
mutex_unlock(&process->reclaim_lock);
return (pages_to_reclaim - remaining);
}

View File

@ -1517,6 +1517,71 @@ TRACE_EVENT(kgsl_pool_free_page,
)
);
TRACE_EVENT(kgsl_reclaim_memdesc,
TP_PROTO(
struct kgsl_mem_entry *mem_entry,
bool swapout
),
TP_ARGS(mem_entry, swapout
),
TP_STRUCT__entry(
__field(uint64_t, gpuaddr)
__field(uint64_t, size)
__field(unsigned int, page_count)
__field(unsigned int, tgid)
__field(unsigned int, id)
__field(uint64_t, flags)
__field(bool, swapout)
),
TP_fast_assign(
__entry->gpuaddr = mem_entry->memdesc.gpuaddr;
__entry->size = mem_entry->memdesc.size;
__entry->page_count = mem_entry->memdesc.page_count;
__entry->tgid = pid_nr(mem_entry->priv->pid);
__entry->id = mem_entry->id;
__entry->flags = mem_entry->memdesc.flags;
__entry->swapout = swapout;
),
TP_printk(
"gpuaddr=0x%llx size=%llu page_count=%u tgid=%u id=%u flags=0x%llx swap=%s",
__entry->gpuaddr, __entry->size, __entry->page_count, __entry->tgid,
__entry->id, __entry->flags, __entry->swapout ? "out" : "in"
)
);
TRACE_EVENT(kgsl_reclaim_process,
TP_PROTO(
struct kgsl_process_private *process,
u32 swap_count,
bool swapout
),
TP_ARGS(process, swap_count, swapout
),
TP_STRUCT__entry(
__field(unsigned int, pid)
__field(u32, swap_count)
__field(u32, unpinned_page_count)
__field(bool, swapout)
),
TP_fast_assign(
__entry->pid = pid_nr(process->pid);
__entry->swap_count = swap_count;
__entry->unpinned_page_count = atomic_read(&process->unpinned_page_count);
__entry->swapout = swapout;
),
TP_printk(
"tgid=%u swapped=%u swapped_out_total=%u swap=%s",
__entry->pid, __entry->swap_count, __entry->unpinned_page_count,
__entry->swapout ? "out" : "in"
)
);
#endif /* _KGSL_TRACE_H */
/* This part must be outside protection */