Skip to contentSkip to conversation

kcsan: use u64 instead of cycles_t

PATCH In review Heiko Carstens 3 participants 4 messages Jul 29, 2021

Subsystems (2)
lore
Share & tools
lore

Heiko Carstens

author maintainer
#0 lore raw

PATCH 1/1 kcsan: use u64 instead of cycles_t

cycles_t has a different type across architectures: unsigned int, unsinged long, or unsigned long long. Depending on architecture this will generate this warning:

kernel/kcsan/debugfs.c: In function ‘microbenchmark’:
./include/linux/kern_levels.h:5:25: warning: format ‘%llu’ expects argument of type ‘long long unsigned int’, but argument 3 has type ‘cycles_t’ {aka ‘long unsigned int’} [-Wformat=]

To avoid this simple change the type of cycle to u64 in microbenchmark(), since u64 is of type unsigned long long for all architectures.

---
 kernel/kcsan/debugfs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/kcsan/debugfs.c +1 -1
index e65de172ccf7..1d1d1b0e4248 100644
@@ -64,7 +64,7 @@ static noinline void microbenchmark(unsigned long iters)
 {
 	const struct kcsan_ctx ctx_save = current->kcsan_ctx;
 	const bool was_enabled = READ_ONCE(kcsan_enabled);
-	cycles_t cycles;
+	u64 cycles;
 
 	/* We may have been called from an atomic region; reset context. */
 	memset(&current->kcsan_ctx, 0, sizeof(current->kcsan_ctx));
Signature · 1 line
2.25.1
maintainer Acked-by on v1 1/1
#1 lore raw

+Cc: Paul

Quoted 5 lines · Heiko Carstens

cycles_t has a different type across architectures: unsigned int, unsinged long, or unsigned long long. Depending on architecture this will generate this warning:

Quoted 8 lines

kernel/kcsan/debugfs.c: In function ‘microbenchmark’:
./include/linux/kern_levels.h:5:25: warning: format ‘%llu’ expects argument of type ‘long long unsigned int’, but argument 3 has type ‘cycles_t’ {aka ‘long unsigned int’} [-Wformat=]

To avoid this simple change the type of cycle to u64 in microbenchmark(), since u64 is of type unsigned long long for all architectures.

Do you have a series adding KCSAN support for s390, i.e. would you like to keep it together with those changes?

Otherwise this would go the usual route through Paul's -rcu tree.

Thanks,
-- Marco

Quoted 24 lines
---
 kernel/kcsan/debugfs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/kcsan/debugfs.c +1 -2
index e65de172ccf7..1d1d1b0e4248 100644
@@ -64,7 +64,7 @@ static noinline void microbenchmark(unsigned long iters)
 {
        const struct kcsan_ctx ctx_save = current->kcsan_ctx;
        const bool was_enabled = READ_ONCE(kcsan_enabled);
-       cycles_t cycles;
+       u64 cycles;
 
        /* We may have been called from an atomic region; reset context. */
        memset(&current->kcsan_ctx, 0, sizeof(current->kcsan_ctx));
--

2.25.1

--
You received this message because you are subscribed to the Google Groups "kasan-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/kasan-dev/20210729142811.1309391-1-hca%40linux.ibm.com.

#2 lore raw
Quoted 15 lines · Marco Elver

+Cc: Paul

Quoted 12 lines · Heiko Carstens

cycles_t has a different type across architectures: unsigned int, unsinged long, or unsigned long long. Depending on architecture this will generate this warning:

kernel/kcsan/debugfs.c: In function ‘microbenchmark’:
./include/linux/kern_levels.h:5:25: warning: format ‘%llu’ expects argument of type ‘long long unsigned int’, but argument 3 has type ‘cycles_t’ {aka ‘long unsigned int’} [-Wformat=]

To avoid this simple change the type of cycle to u64 in microbenchmark(), since u64 is of type unsigned long long for all architectures.

Quoted 8 lines
Quoted 1 line

Do you have a series adding KCSAN support for s390, i.e. would you like to keep it together with those changes?

Otherwise this would go the usual route through Paul's -rcu tree.

Either way, please let me know!

Thanx, Paul

Quoted 27 lines

Thanks,
-- Marco

Quoted 24 lines
---
 kernel/kcsan/debugfs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/kcsan/debugfs.c +1 -2
index e65de172ccf7..1d1d1b0e4248 100644
@@ -64,7 +64,7 @@ static noinline void microbenchmark(unsigned long iters)
 {
        const struct kcsan_ctx ctx_save = current->kcsan_ctx;
        const bool was_enabled = READ_ONCE(kcsan_enabled);
-       cycles_t cycles;
+       u64 cycles;
 
        /* We may have been called from an atomic region; reset context. */
        memset(&current->kcsan_ctx, 0, sizeof(current->kcsan_ctx));
--

2.25.1

--
You received this message because you are subscribed to the Google Groups "kasan-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/kasan-dev/20210729142811.1309391-1-hca%40linux.ibm.com.

author maintainer
#3 lore raw
Quoted 18 lines · Paul E. McKenney
Quoted 17 lines · Marco Elver

+Cc: Paul

Quoted 13 lines · Heiko Carstens

cycles_t has a different type across architectures: unsigned int, unsinged long, or unsigned long long. Depending on architecture this will generate this warning:

kernel/kcsan/debugfs.c: In function ‘microbenchmark’:
./include/linux/kern_levels.h:5:25: warning: format ‘%llu’ expects argument of type ‘long long unsigned int’, but argument 3 has type ‘cycles_t’ {aka ‘long unsigned int’} [-Wformat=]

To avoid this simple change the type of cycle to u64 in microbenchmark(), since u64 is of type unsigned long long for all architectures.

Quoted 8 lines
Quoted 6 lines

Do you have a series adding KCSAN support for s390, i.e. would you like to keep it together with those changes?

Otherwise this would go the usual route through Paul's -rcu tree.

Either way, please let me know!

We will enable KCSAN support for s390 with the next merge window, so I'll queue this patch also on the s390 tree.

Thanks!