tools/perf/builtin-kwork.c

Source file repositories/reference/linux-study-clean/tools/perf/builtin-kwork.c

File Facts

System
Linux kernel
Corpus path
tools/perf/builtin-kwork.c
Extension
.c
Size
65155 bytes
Lines
2547
Domain
Support Tooling And Documentation
Bucket
tools
Inferred role
Support Tooling And Documentation: implementation source
Status
source implementation candidate

Why This File Exists

Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.

Dependency Surface

Detected Declarations

Annotated Snippet

struct sort_dimension {
	const char      *name;
	int             (*cmp)(struct kwork_work *l, struct kwork_work *r);
	struct          list_head list;
};

static int id_cmp(struct kwork_work *l, struct kwork_work *r)
{
	if (l->cpu > r->cpu)
		return 1;
	if (l->cpu < r->cpu)
		return -1;

	if (l->id > r->id)
		return 1;
	if (l->id < r->id)
		return -1;

	return 0;
}

static int count_cmp(struct kwork_work *l, struct kwork_work *r)
{
	if (l->nr_atoms > r->nr_atoms)
		return 1;
	if (l->nr_atoms < r->nr_atoms)
		return -1;

	return 0;
}

static int runtime_cmp(struct kwork_work *l, struct kwork_work *r)
{
	if (l->total_runtime > r->total_runtime)
		return 1;
	if (l->total_runtime < r->total_runtime)
		return -1;

	return 0;
}

static int max_runtime_cmp(struct kwork_work *l, struct kwork_work *r)
{
	if (l->max_runtime > r->max_runtime)
		return 1;
	if (l->max_runtime < r->max_runtime)
		return -1;

	return 0;
}

static int avg_latency_cmp(struct kwork_work *l, struct kwork_work *r)
{
	u64 avgl, avgr;

	if (!r->nr_atoms)
		return 1;
	if (!l->nr_atoms)
		return -1;

	avgl = l->total_latency / l->nr_atoms;
	avgr = r->total_latency / r->nr_atoms;

	if (avgl > avgr)
		return 1;
	if (avgl < avgr)
		return -1;

	return 0;
}

static int max_latency_cmp(struct kwork_work *l, struct kwork_work *r)
{
	if (l->max_latency > r->max_latency)
		return 1;
	if (l->max_latency < r->max_latency)
		return -1;

	return 0;
}

static int cpu_usage_cmp(struct kwork_work *l, struct kwork_work *r)
{
	if (l->cpu_usage > r->cpu_usage)
		return 1;
	if (l->cpu_usage < r->cpu_usage)
		return -1;

	return 0;
}

Annotation

Implementation Notes