Skip to content

Commit c43e1c5

Browse files
Thomas RichterMartin Schwidefsky
Thomas Richter
authored and
Martin Schwidefsky
committed
s390/cpum_sf: Rework attribute definition for diagnostic sampling
Previously, the attribute entry for diagnostic sampling was added if authorized. Otherwise, the array of struct attribute contains two NULL values. Change this logic and reserve space for the attribute for diagnostic sampling. If diagnostic sampling is authorized, add an entry in the respective position in the array of struct attribute. Signed-off-by: Thomas Richter <[email protected]> Reviewed-by: Hendrik Brueckner <[email protected]> Suggested-by: Heiko Carstens <[email protected]> Signed-off-by: Martin Schwidefsky <[email protected]>
1 parent e12e404 commit c43e1c5

File tree

1 file changed

+28
-5
lines changed

1 file changed

+28
-5
lines changed

arch/s390/kernel/perf_cpum_sf.c

+28-5
Original file line numberDiff line numberDiff line change
@@ -1842,10 +1842,30 @@ static void cpumsf_pmu_del(struct perf_event *event, int flags)
18421842
CPUMF_EVENT_ATTR(SF, SF_CYCLES_BASIC, PERF_EVENT_CPUM_SF);
18431843
CPUMF_EVENT_ATTR(SF, SF_CYCLES_BASIC_DIAG, PERF_EVENT_CPUM_SF_DIAG);
18441844

1845-
static struct attribute *cpumsf_pmu_events_attr[] = {
1846-
CPUMF_EVENT_PTR(SF, SF_CYCLES_BASIC),
1847-
NULL,
1848-
NULL,
1845+
/* Attribute list for CPU_SF.
1846+
*
1847+
* The availablitiy depends on the CPU_MF sampling facility authorization
1848+
* for basic + diagnositic samples. This is determined at initialization
1849+
* time by the sampling facility device driver.
1850+
* If the authorization for basic samples is turned off, it should be
1851+
* also turned off for diagnostic sampling.
1852+
*
1853+
* During initialization of the device driver, check the authorization
1854+
* level for diagnostic sampling and installs the attribute
1855+
* file for diagnostic sampling if necessary.
1856+
*
1857+
* For now install a placeholder to reference all possible attributes:
1858+
* SF_CYCLES_BASIC and SF_CYCLES_BASIC_DIAG.
1859+
* Add another entry for the final NULL pointer.
1860+
*/
1861+
enum {
1862+
SF_CYCLES_BASIC_ATTR_IDX = 0,
1863+
SF_CYCLES_BASIC_DIAG_ATTR_IDX,
1864+
SF_CYCLES_ATTR_MAX
1865+
};
1866+
1867+
static struct attribute *cpumsf_pmu_events_attr[SF_CYCLES_ATTR_MAX + 1] = {
1868+
[SF_CYCLES_BASIC_ATTR_IDX] = CPUMF_EVENT_PTR(SF, SF_CYCLES_BASIC)
18491869
};
18501870

18511871
PMU_FORMAT_ATTR(event, "config:0-63");
@@ -2040,7 +2060,10 @@ static int __init init_cpum_sampling_pmu(void)
20402060

20412061
if (si.ad) {
20422062
sfb_set_limits(CPUM_SF_MIN_SDB, CPUM_SF_MAX_SDB);
2043-
cpumsf_pmu_events_attr[1] =
2063+
/* Sampling of diagnostic data authorized,
2064+
* install event into attribute list of PMU device.
2065+
*/
2066+
cpumsf_pmu_events_attr[SF_CYCLES_BASIC_DIAG_ATTR_IDX] =
20442067
CPUMF_EVENT_PTR(SF, SF_CYCLES_BASIC_DIAG);
20452068
}
20462069

0 commit comments

Comments
 (0)