arch/mips/math-emu/me-debugfs.c

Source file repositories/reference/linux-study-clean/arch/mips/math-emu/me-debugfs.c

File Facts

System
Linux kernel
Corpus path
arch/mips/math-emu/me-debugfs.c
Extension
.c
Size
12184 bytes
Lines
354
Domain
Architecture Layer
Bucket
arch/mips
Inferred role
Architecture Layer: implementation source
Status
source implementation candidate

Why This File Exists

CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.

Dependency Surface

Detected Declarations

Annotated Snippet

// SPDX-License-Identifier: GPL-2.0
#include <linux/cpumask.h>
#include <linux/debugfs.h>
#include <linux/fs.h>
#include <linux/init.h>
#include <linux/percpu.h>
#include <linux/types.h>
#include <asm/debug.h>
#include <asm/fpu_emulator.h>
#include <asm/local.h>

DEFINE_PER_CPU(struct mips_fpu_emulator_stats, fpuemustats);

static int fpuemu_stat_get(void *data, u64 *val)
{
	int cpu;
	unsigned long sum = 0;

	for_each_online_cpu(cpu) {
		struct mips_fpu_emulator_stats *ps;
		local_t *pv;

		ps = &per_cpu(fpuemustats, cpu);
		pv = (void *)ps + (unsigned long)data;
		sum += local_read(pv);
	}
	*val = sum;
	return 0;
}
DEFINE_SIMPLE_ATTRIBUTE(fops_fpuemu_stat, fpuemu_stat_get, NULL, "%llu\n");

/*
 * Used to obtain names for a debugfs instruction counter, given field name
 * in fpuemustats structure. For example, for input "cmp_sueq_d", the output
 * would be "cmp.sueq.d". This is needed since dots are not allowed to be
 * used in structure field names, and are, on the other hand, desired to be
 * used in debugfs item names to be clearly associated to corresponding
 * MIPS FPU instructions.
 */
static void adjust_instruction_counter_name(char *out_name, char *in_name, size_t len)
{
	int i = 0;

	strscpy(out_name, in_name, len);
	while (in_name[i] != '\0') {
		if (out_name[i] == '_')
			out_name[i] = '.';
		i++;
	}
}

static int fpuemustats_clear_show(struct seq_file *s, void *unused)
{
	__this_cpu_write((fpuemustats).emulated, 0);
	__this_cpu_write((fpuemustats).loads, 0);
	__this_cpu_write((fpuemustats).stores, 0);
	__this_cpu_write((fpuemustats).branches, 0);
	__this_cpu_write((fpuemustats).cp1ops, 0);
	__this_cpu_write((fpuemustats).cp1xops, 0);
	__this_cpu_write((fpuemustats).errors, 0);
	__this_cpu_write((fpuemustats).ieee754_inexact, 0);
	__this_cpu_write((fpuemustats).ieee754_underflow, 0);
	__this_cpu_write((fpuemustats).ieee754_overflow, 0);
	__this_cpu_write((fpuemustats).ieee754_zerodiv, 0);
	__this_cpu_write((fpuemustats).ieee754_invalidop, 0);
	__this_cpu_write((fpuemustats).ds_emul, 0);

	__this_cpu_write((fpuemustats).abs_s, 0);
	__this_cpu_write((fpuemustats).abs_d, 0);
	__this_cpu_write((fpuemustats).add_s, 0);
	__this_cpu_write((fpuemustats).add_d, 0);
	__this_cpu_write((fpuemustats).bc1eqz, 0);
	__this_cpu_write((fpuemustats).bc1nez, 0);
	__this_cpu_write((fpuemustats).ceil_w_s, 0);
	__this_cpu_write((fpuemustats).ceil_w_d, 0);
	__this_cpu_write((fpuemustats).ceil_l_s, 0);
	__this_cpu_write((fpuemustats).ceil_l_d, 0);
	__this_cpu_write((fpuemustats).class_s, 0);
	__this_cpu_write((fpuemustats).class_d, 0);
	__this_cpu_write((fpuemustats).cmp_af_s, 0);
	__this_cpu_write((fpuemustats).cmp_af_d, 0);
	__this_cpu_write((fpuemustats).cmp_eq_s, 0);
	__this_cpu_write((fpuemustats).cmp_eq_d, 0);
	__this_cpu_write((fpuemustats).cmp_le_s, 0);
	__this_cpu_write((fpuemustats).cmp_le_d, 0);
	__this_cpu_write((fpuemustats).cmp_lt_s, 0);
	__this_cpu_write((fpuemustats).cmp_lt_d, 0);
	__this_cpu_write((fpuemustats).cmp_ne_s, 0);
	__this_cpu_write((fpuemustats).cmp_ne_d, 0);
	__this_cpu_write((fpuemustats).cmp_or_s, 0);

Annotation

Implementation Notes