Skip to content

Commit a1f1066

Browse files
a-darwishPeter Zijlstra
authored andcommitted
x86/tsc: Use seqcount_latch_t
Latch sequence counters have unique read and write APIs, and thus seqcount_latch_t was recently introduced at seqlock.h. Use that new data type instead of plain seqcount_t. This adds the necessary type-safety and ensures that only latching-safe seqcount APIs are to be used. Signed-off-by: Ahmed S. Darwish <a.darwish@linutronix.de> [peterz: unwreck cyc2ns_read_begin()] Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Link: https://lkml.kernel.org/r/20200827114044.11173-7-a.darwish@linutronix.de
1 parent 249d053 commit a1f1066

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

arch/x86/kernel/tsc.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ struct clocksource *art_related_clocksource;
5454

5555
struct cyc2ns {
5656
struct cyc2ns_data data[2]; /* 0 + 2*16 = 32 */
57-
seqcount_t seq; /* 32 + 4 = 36 */
57+
seqcount_latch_t seq; /* 32 + 4 = 36 */
5858

5959
}; /* fits one cacheline */
6060

@@ -73,14 +73,14 @@ __always_inline void cyc2ns_read_begin(struct cyc2ns_data *data)
7373
preempt_disable_notrace();
7474

7575
do {
76-
seq = this_cpu_read(cyc2ns.seq.sequence);
76+
seq = this_cpu_read(cyc2ns.seq.seqcount.sequence);
7777
idx = seq & 1;
7878

7979
data->cyc2ns_offset = this_cpu_read(cyc2ns.data[idx].cyc2ns_offset);
8080
data->cyc2ns_mul = this_cpu_read(cyc2ns.data[idx].cyc2ns_mul);
8181
data->cyc2ns_shift = this_cpu_read(cyc2ns.data[idx].cyc2ns_shift);
8282

83-
} while (unlikely(seq != this_cpu_read(cyc2ns.seq.sequence)));
83+
} while (unlikely(seq != this_cpu_read(cyc2ns.seq.seqcount.sequence)));
8484
}
8585

8686
__always_inline void cyc2ns_read_end(void)
@@ -186,7 +186,7 @@ static void __init cyc2ns_init_boot_cpu(void)
186186
{
187187
struct cyc2ns *c2n = this_cpu_ptr(&cyc2ns);
188188

189-
seqcount_init(&c2n->seq);
189+
seqcount_latch_init(&c2n->seq);
190190
__set_cyc2ns_scale(tsc_khz, smp_processor_id(), rdtsc());
191191
}
192192

@@ -203,7 +203,7 @@ static void __init cyc2ns_init_secondary_cpus(void)
203203

204204
for_each_possible_cpu(cpu) {
205205
if (cpu != this_cpu) {
206-
seqcount_init(&c2n->seq);
206+
seqcount_latch_init(&c2n->seq);
207207
c2n = per_cpu_ptr(&cyc2ns, cpu);
208208
c2n->data[0] = data[0];
209209
c2n->data[1] = data[1];

0 commit comments

Comments
 (0)