162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
262306a36Sopenharmony_ci#undef TRACE_SYSTEM
362306a36Sopenharmony_ci#define TRACE_SYSTEM vmalloc
462306a36Sopenharmony_ci
562306a36Sopenharmony_ci#if !defined(_TRACE_VMALLOC_H) || defined(TRACE_HEADER_MULTI_READ)
662306a36Sopenharmony_ci#define _TRACE_VMALLOC_H
762306a36Sopenharmony_ci
862306a36Sopenharmony_ci#include <linux/tracepoint.h>
962306a36Sopenharmony_ci
1062306a36Sopenharmony_ci/**
1162306a36Sopenharmony_ci * alloc_vmap_area - called when a new vmap allocation occurs
1262306a36Sopenharmony_ci * @addr:	an allocated address
1362306a36Sopenharmony_ci * @size:	a requested size
1462306a36Sopenharmony_ci * @align:	a requested alignment
1562306a36Sopenharmony_ci * @vstart:	a requested start range
1662306a36Sopenharmony_ci * @vend:	a requested end range
1762306a36Sopenharmony_ci * @failed:	an allocation failed or not
1862306a36Sopenharmony_ci *
1962306a36Sopenharmony_ci * This event is used for a debug purpose, it can give an extra
2062306a36Sopenharmony_ci * information for a developer about how often it occurs and which
2162306a36Sopenharmony_ci * parameters are passed for further validation.
2262306a36Sopenharmony_ci */
2362306a36Sopenharmony_ciTRACE_EVENT(alloc_vmap_area,
2462306a36Sopenharmony_ci
2562306a36Sopenharmony_ci	TP_PROTO(unsigned long addr, unsigned long size, unsigned long align,
2662306a36Sopenharmony_ci		unsigned long vstart, unsigned long vend, int failed),
2762306a36Sopenharmony_ci
2862306a36Sopenharmony_ci	TP_ARGS(addr, size, align, vstart, vend, failed),
2962306a36Sopenharmony_ci
3062306a36Sopenharmony_ci	TP_STRUCT__entry(
3162306a36Sopenharmony_ci		__field(unsigned long, addr)
3262306a36Sopenharmony_ci		__field(unsigned long, size)
3362306a36Sopenharmony_ci		__field(unsigned long, align)
3462306a36Sopenharmony_ci		__field(unsigned long, vstart)
3562306a36Sopenharmony_ci		__field(unsigned long, vend)
3662306a36Sopenharmony_ci		__field(int, failed)
3762306a36Sopenharmony_ci	),
3862306a36Sopenharmony_ci
3962306a36Sopenharmony_ci	TP_fast_assign(
4062306a36Sopenharmony_ci		__entry->addr = addr;
4162306a36Sopenharmony_ci		__entry->size = size;
4262306a36Sopenharmony_ci		__entry->align = align;
4362306a36Sopenharmony_ci		__entry->vstart = vstart;
4462306a36Sopenharmony_ci		__entry->vend = vend;
4562306a36Sopenharmony_ci		__entry->failed = failed;
4662306a36Sopenharmony_ci	),
4762306a36Sopenharmony_ci
4862306a36Sopenharmony_ci	TP_printk("va_start: %lu size=%lu align=%lu vstart=0x%lx vend=0x%lx failed=%d",
4962306a36Sopenharmony_ci		__entry->addr, __entry->size, __entry->align,
5062306a36Sopenharmony_ci		__entry->vstart, __entry->vend, __entry->failed)
5162306a36Sopenharmony_ci);
5262306a36Sopenharmony_ci
5362306a36Sopenharmony_ci/**
5462306a36Sopenharmony_ci * purge_vmap_area_lazy - called when vmap areas were lazily freed
5562306a36Sopenharmony_ci * @start:		purging start address
5662306a36Sopenharmony_ci * @end:		purging end address
5762306a36Sopenharmony_ci * @npurged:	numbed of purged vmap areas
5862306a36Sopenharmony_ci *
5962306a36Sopenharmony_ci * This event is used for a debug purpose. It gives some
6062306a36Sopenharmony_ci * indication about start:end range and how many objects
6162306a36Sopenharmony_ci * are released.
6262306a36Sopenharmony_ci */
6362306a36Sopenharmony_ciTRACE_EVENT(purge_vmap_area_lazy,
6462306a36Sopenharmony_ci
6562306a36Sopenharmony_ci	TP_PROTO(unsigned long start, unsigned long end,
6662306a36Sopenharmony_ci		unsigned int npurged),
6762306a36Sopenharmony_ci
6862306a36Sopenharmony_ci	TP_ARGS(start, end, npurged),
6962306a36Sopenharmony_ci
7062306a36Sopenharmony_ci	TP_STRUCT__entry(
7162306a36Sopenharmony_ci		__field(unsigned long, start)
7262306a36Sopenharmony_ci		__field(unsigned long, end)
7362306a36Sopenharmony_ci		__field(unsigned int, npurged)
7462306a36Sopenharmony_ci	),
7562306a36Sopenharmony_ci
7662306a36Sopenharmony_ci	TP_fast_assign(
7762306a36Sopenharmony_ci		__entry->start = start;
7862306a36Sopenharmony_ci		__entry->end = end;
7962306a36Sopenharmony_ci		__entry->npurged = npurged;
8062306a36Sopenharmony_ci	),
8162306a36Sopenharmony_ci
8262306a36Sopenharmony_ci	TP_printk("start=0x%lx end=0x%lx num_purged=%u",
8362306a36Sopenharmony_ci		__entry->start, __entry->end, __entry->npurged)
8462306a36Sopenharmony_ci);
8562306a36Sopenharmony_ci
8662306a36Sopenharmony_ci/**
8762306a36Sopenharmony_ci * free_vmap_area_noflush - called when a vmap area is freed
8862306a36Sopenharmony_ci * @va_start:		a start address of VA
8962306a36Sopenharmony_ci * @nr_lazy:		number of current lazy pages
9062306a36Sopenharmony_ci * @nr_lazy_max:	number of maximum lazy pages
9162306a36Sopenharmony_ci *
9262306a36Sopenharmony_ci * This event is used for a debug purpose. It gives some
9362306a36Sopenharmony_ci * indication about a VA that is released, number of current
9462306a36Sopenharmony_ci * outstanding areas and a maximum allowed threshold before
9562306a36Sopenharmony_ci * dropping all of them.
9662306a36Sopenharmony_ci */
9762306a36Sopenharmony_ciTRACE_EVENT(free_vmap_area_noflush,
9862306a36Sopenharmony_ci
9962306a36Sopenharmony_ci	TP_PROTO(unsigned long va_start, unsigned long nr_lazy,
10062306a36Sopenharmony_ci		unsigned long nr_lazy_max),
10162306a36Sopenharmony_ci
10262306a36Sopenharmony_ci	TP_ARGS(va_start, nr_lazy, nr_lazy_max),
10362306a36Sopenharmony_ci
10462306a36Sopenharmony_ci	TP_STRUCT__entry(
10562306a36Sopenharmony_ci		__field(unsigned long, va_start)
10662306a36Sopenharmony_ci		__field(unsigned long, nr_lazy)
10762306a36Sopenharmony_ci		__field(unsigned long, nr_lazy_max)
10862306a36Sopenharmony_ci	),
10962306a36Sopenharmony_ci
11062306a36Sopenharmony_ci	TP_fast_assign(
11162306a36Sopenharmony_ci		__entry->va_start = va_start;
11262306a36Sopenharmony_ci		__entry->nr_lazy = nr_lazy;
11362306a36Sopenharmony_ci		__entry->nr_lazy_max = nr_lazy_max;
11462306a36Sopenharmony_ci	),
11562306a36Sopenharmony_ci
11662306a36Sopenharmony_ci	TP_printk("va_start=0x%lx nr_lazy=%lu nr_lazy_max=%lu",
11762306a36Sopenharmony_ci		__entry->va_start, __entry->nr_lazy, __entry->nr_lazy_max)
11862306a36Sopenharmony_ci);
11962306a36Sopenharmony_ci
12062306a36Sopenharmony_ci#endif /*  _TRACE_VMALLOC_H */
12162306a36Sopenharmony_ci
12262306a36Sopenharmony_ci/* This part must be outside protection */
12362306a36Sopenharmony_ci#include <trace/define_trace.h>
124