Skip to content

Commit fcc77f5

Browse files
hbruecknerMartin Schwidefsky
authored andcommitted
s390/cpum_sf: Atomically reset trailer entry fields of sample-data-blocks
Ensure to reset the sample-data-block full indicator and the overflow counter at the same time. This must be done atomically because the sampling hardware is still active while full sample-data-block is processed. Signed-off-by: Hendrik Brueckner <[email protected]> Signed-off-by: Martin Schwidefsky <[email protected]>
1 parent 69f239e commit fcc77f5

File tree

2 files changed

+17
-8
lines changed

2 files changed

+17
-8
lines changed

arch/s390/include/asm/cpu_mf.h

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,10 +115,15 @@ struct hws_data_entry {
115115
} __packed;
116116

117117
struct hws_trailer_entry {
118-
unsigned int f:1; /* 0 - Block Full Indicator */
119-
unsigned int a:1; /* 1 - Alert request control */
120-
unsigned int t:1; /* 2 - Timestamp format */
121-
unsigned long long:61; /* 3 - 63: Reserved */
118+
union {
119+
struct {
120+
unsigned int f:1; /* 0 - Block Full Indicator */
121+
unsigned int a:1; /* 1 - Alert request control */
122+
unsigned int t:1; /* 2 - Timestamp format */
123+
unsigned long long:61; /* 3 - 63: Reserved */
124+
};
125+
unsigned long long flags; /* 0 - 63: All indicators */
126+
};
122127
unsigned long long overflow; /* 64 - sample Overflow count */
123128
unsigned long long timestamp; /* 16 - time-stamp */
124129
unsigned long long timestamp1; /* */

arch/s390/kernel/perf_cpum_sf.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -953,7 +953,7 @@ static void hw_perf_event_update(struct perf_event *event, int flush_all)
953953
struct hw_perf_event *hwc = &event->hw;
954954
struct hws_trailer_entry *te;
955955
unsigned long *sdbt;
956-
unsigned long long event_overflow, sampl_overflow, num_sdb;
956+
unsigned long long event_overflow, sampl_overflow, num_sdb, te_flags;
957957
int done;
958958

959959
sdbt = (unsigned long *) TEAR_REG(hwc);
@@ -990,9 +990,13 @@ static void hw_perf_event_update(struct perf_event *event, int flush_all)
990990
hw_collect_samples(event, sdbt, &event_overflow);
991991
num_sdb++;
992992

993-
/* Reset trailer */
994-
xchg(&te->overflow, 0);
995-
xchg((unsigned char *) te, 0x40);
993+
/* Reset trailer (using compare-double-and-swap) */
994+
do {
995+
te_flags = te->flags & ~SDB_TE_BUFFER_FULL_MASK;
996+
te_flags |= SDB_TE_ALERT_REQ_MASK;
997+
} while (!cmpxchg_double(&te->flags, &te->overflow,
998+
te->flags, te->overflow,
999+
te_flags, 0ULL));
9961000

9971001
/* Advance to next sample-data-block */
9981002
sdbt++;

0 commit comments

Comments
 (0)