drivers/nvdimm/nd_perf.c

Source file repositories/reference/linux-study-clean/drivers/nvdimm/nd_perf.c

File Facts

System
Linux kernel
Corpus path
drivers/nvdimm/nd_perf.c
Extension
.c
Size
9083 bytes
Lines
331
Domain
Driver Families
Bucket
drivers/nvdimm
Inferred role
Driver Families: exported/initcall integration point
Status
integration implementation candidate

Why This File Exists

Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.

Dependency Surface

Detected Declarations

Annotated Snippet

// SPDX-License-Identifier: GPL-2.0-or-later
/*
 * nd_perf.c: NVDIMM Device Performance Monitoring Unit support
 *
 * Perf interface to expose nvdimm performance stats.
 *
 * Copyright (C) 2021 IBM Corporation
 */

#define pr_fmt(fmt) "nvdimm_pmu: " fmt

#include <linux/nd.h>
#include <linux/platform_device.h>

#define EVENT(_name, _code)     enum{_name = _code}

/*
 * NVDIMM Events codes.
 */

/* Controller Reset Count */
EVENT(CTL_RES_CNT,		0x1);
/* Controller Reset Elapsed Time */
EVENT(CTL_RES_TM,		0x2);
/* Power-on Seconds */
EVENT(POWERON_SECS,		0x3);
/* Life Remaining */
EVENT(MEM_LIFE,		0x4);
/* Critical Resource Utilization */
EVENT(CRI_RES_UTIL,		0x5);
/* Host Load Count */
EVENT(HOST_L_CNT,		0x6);
/* Host Store Count */
EVENT(HOST_S_CNT,		0x7);
/* Host Store Duration */
EVENT(HOST_S_DUR,		0x8);
/* Host Load Duration */
EVENT(HOST_L_DUR,		0x9);
/* Media Read Count */
EVENT(MED_R_CNT,		0xa);
/* Media Write Count */
EVENT(MED_W_CNT,		0xb);
/* Media Read Duration */
EVENT(MED_R_DUR,		0xc);
/* Media Write Duration */
EVENT(MED_W_DUR,		0xd);
/* Cache Read Hit Count */
EVENT(CACHE_RH_CNT,		0xe);
/* Cache Write Hit Count */
EVENT(CACHE_WH_CNT,		0xf);
/* Fast Write Count */
EVENT(FAST_W_CNT,		0x10);

NVDIMM_EVENT_ATTR(ctl_res_cnt,		CTL_RES_CNT);
NVDIMM_EVENT_ATTR(ctl_res_tm,		CTL_RES_TM);
NVDIMM_EVENT_ATTR(poweron_secs,		POWERON_SECS);
NVDIMM_EVENT_ATTR(mem_life,		MEM_LIFE);
NVDIMM_EVENT_ATTR(cri_res_util,		CRI_RES_UTIL);
NVDIMM_EVENT_ATTR(host_l_cnt,		HOST_L_CNT);
NVDIMM_EVENT_ATTR(host_s_cnt,		HOST_S_CNT);
NVDIMM_EVENT_ATTR(host_s_dur,		HOST_S_DUR);
NVDIMM_EVENT_ATTR(host_l_dur,		HOST_L_DUR);
NVDIMM_EVENT_ATTR(med_r_cnt,		MED_R_CNT);
NVDIMM_EVENT_ATTR(med_w_cnt,		MED_W_CNT);
NVDIMM_EVENT_ATTR(med_r_dur,		MED_R_DUR);
NVDIMM_EVENT_ATTR(med_w_dur,		MED_W_DUR);
NVDIMM_EVENT_ATTR(cache_rh_cnt,		CACHE_RH_CNT);
NVDIMM_EVENT_ATTR(cache_wh_cnt,		CACHE_WH_CNT);
NVDIMM_EVENT_ATTR(fast_w_cnt,		FAST_W_CNT);

static struct attribute *nvdimm_events_attr[] = {
	NVDIMM_EVENT_PTR(CTL_RES_CNT),
	NVDIMM_EVENT_PTR(CTL_RES_TM),
	NVDIMM_EVENT_PTR(POWERON_SECS),
	NVDIMM_EVENT_PTR(MEM_LIFE),
	NVDIMM_EVENT_PTR(CRI_RES_UTIL),
	NVDIMM_EVENT_PTR(HOST_L_CNT),
	NVDIMM_EVENT_PTR(HOST_S_CNT),
	NVDIMM_EVENT_PTR(HOST_S_DUR),
	NVDIMM_EVENT_PTR(HOST_L_DUR),
	NVDIMM_EVENT_PTR(MED_R_CNT),
	NVDIMM_EVENT_PTR(MED_W_CNT),
	NVDIMM_EVENT_PTR(MED_R_DUR),
	NVDIMM_EVENT_PTR(MED_W_DUR),
	NVDIMM_EVENT_PTR(CACHE_RH_CNT),
	NVDIMM_EVENT_PTR(CACHE_WH_CNT),
	NVDIMM_EVENT_PTR(FAST_W_CNT),
	NULL
};

Annotation

Implementation Notes