Skip to content

Commit 1c428cc

Browse files
authored
tokio: fix cache line size for RISC-V (#5994)
1 parent 61f095f commit 1c428cc

File tree

3 files changed

+10
-28
lines changed

3 files changed

+10
-28
lines changed

tokio/src/runtime/io/scheduled_io.rs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,25 +44,20 @@ use std::task::{Context, Poll, Waker};
4444
),
4545
repr(align(128))
4646
)]
47-
// arm, mips, mips64, riscv64, sparc, and hexagon have 32-byte cache line size.
47+
// arm, mips, mips64, sparc, and hexagon have 32-byte cache line size.
4848
//
4949
// Sources:
5050
// - https://github.com/golang/go/blob/3dd58676054223962cd915bb0934d1f9f489d4d2/src/internal/cpu/cpu_arm.go#L7
5151
// - https://github.com/golang/go/blob/3dd58676054223962cd915bb0934d1f9f489d4d2/src/internal/cpu/cpu_mips.go#L7
5252
// - https://github.com/golang/go/blob/3dd58676054223962cd915bb0934d1f9f489d4d2/src/internal/cpu/cpu_mipsle.go#L7
5353
// - https://github.com/golang/go/blob/3dd58676054223962cd915bb0934d1f9f489d4d2/src/internal/cpu/cpu_mips64x.go#L9
54-
// - https://github.com/golang/go/blob/3dd58676054223962cd915bb0934d1f9f489d4d2/src/internal/cpu/cpu_riscv64.go#L7
5554
// - https://github.com/torvalds/linux/blob/3516bd729358a2a9b090c1905bd2a3fa926e24c6/arch/sparc/include/asm/cache.h#L17
5655
// - https://github.com/torvalds/linux/blob/3516bd729358a2a9b090c1905bd2a3fa926e24c6/arch/hexagon/include/asm/cache.h#L12
57-
//
58-
// riscv32 is assumed not to exceed the cache line size of riscv64.
5956
#[cfg_attr(
6057
any(
6158
target_arch = "arm",
6259
target_arch = "mips",
6360
target_arch = "mips64",
64-
target_arch = "riscv32",
65-
target_arch = "riscv64",
6661
target_arch = "sparc",
6762
target_arch = "hexagon",
6863
),
@@ -79,12 +74,13 @@ use std::task::{Context, Poll, Waker};
7974
// - https://github.com/golang/go/blob/3dd58676054223962cd915bb0934d1f9f489d4d2/src/internal/cpu/cpu_s390x.go#L7
8075
// - https://github.com/torvalds/linux/blob/3516bd729358a2a9b090c1905bd2a3fa926e24c6/arch/s390/include/asm/cache.h#L13
8176
#[cfg_attr(target_arch = "s390x", repr(align(256)))]
82-
// x86, wasm, and sparc64 have 64-byte cache line size.
77+
// x86, riscv, wasm, and sparc64 have 64-byte cache line size.
8378
//
8479
// Sources:
8580
// - https://github.com/golang/go/blob/dda2991c2ea0c5914714469c4defc2562a907230/src/internal/cpu/cpu_x86.go#L9
8681
// - https://github.com/golang/go/blob/3dd58676054223962cd915bb0934d1f9f489d4d2/src/internal/cpu/cpu_wasm.go#L7
8782
// - https://github.com/torvalds/linux/blob/3516bd729358a2a9b090c1905bd2a3fa926e24c6/arch/sparc/include/asm/cache.h#L19
83+
// - https://github.com/torvalds/linux/blob/3516bd729358a2a9b090c1905bd2a3fa926e24c6/arch/riscv/include/asm/cache.h#L10
8884
//
8985
// All others are assumed to have 64-byte cache line size.
9086
#[cfg_attr(
@@ -95,8 +91,6 @@ use std::task::{Context, Poll, Waker};
9591
target_arch = "arm",
9692
target_arch = "mips",
9793
target_arch = "mips64",
98-
target_arch = "riscv32",
99-
target_arch = "riscv64",
10094
target_arch = "sparc",
10195
target_arch = "hexagon",
10296
target_arch = "m68k",

tokio/src/runtime/task/core.rs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -57,25 +57,20 @@ use std::task::{Context, Poll, Waker};
5757
),
5858
repr(align(128))
5959
)]
60-
// arm, mips, mips64, riscv64, sparc, and hexagon have 32-byte cache line size.
60+
// arm, mips, mips64, sparc, and hexagon have 32-byte cache line size.
6161
//
6262
// Sources:
6363
// - https://github.com/golang/go/blob/3dd58676054223962cd915bb0934d1f9f489d4d2/src/internal/cpu/cpu_arm.go#L7
6464
// - https://github.com/golang/go/blob/3dd58676054223962cd915bb0934d1f9f489d4d2/src/internal/cpu/cpu_mips.go#L7
6565
// - https://github.com/golang/go/blob/3dd58676054223962cd915bb0934d1f9f489d4d2/src/internal/cpu/cpu_mipsle.go#L7
6666
// - https://github.com/golang/go/blob/3dd58676054223962cd915bb0934d1f9f489d4d2/src/internal/cpu/cpu_mips64x.go#L9
67-
// - https://github.com/golang/go/blob/3dd58676054223962cd915bb0934d1f9f489d4d2/src/internal/cpu/cpu_riscv64.go#L7
6867
// - https://github.com/torvalds/linux/blob/3516bd729358a2a9b090c1905bd2a3fa926e24c6/arch/sparc/include/asm/cache.h#L17
6968
// - https://github.com/torvalds/linux/blob/3516bd729358a2a9b090c1905bd2a3fa926e24c6/arch/hexagon/include/asm/cache.h#L12
70-
//
71-
// riscv32 is assumed not to exceed the cache line size of riscv64.
7269
#[cfg_attr(
7370
any(
7471
target_arch = "arm",
7572
target_arch = "mips",
7673
target_arch = "mips64",
77-
target_arch = "riscv32",
78-
target_arch = "riscv64",
7974
target_arch = "sparc",
8075
target_arch = "hexagon",
8176
),
@@ -92,12 +87,13 @@ use std::task::{Context, Poll, Waker};
9287
// - https://github.com/golang/go/blob/3dd58676054223962cd915bb0934d1f9f489d4d2/src/internal/cpu/cpu_s390x.go#L7
9388
// - https://github.com/torvalds/linux/blob/3516bd729358a2a9b090c1905bd2a3fa926e24c6/arch/s390/include/asm/cache.h#L13
9489
#[cfg_attr(target_arch = "s390x", repr(align(256)))]
95-
// x86, wasm, and sparc64 have 64-byte cache line size.
90+
// x86, riscv, wasm, and sparc64 have 64-byte cache line size.
9691
//
9792
// Sources:
9893
// - https://github.com/golang/go/blob/dda2991c2ea0c5914714469c4defc2562a907230/src/internal/cpu/cpu_x86.go#L9
9994
// - https://github.com/golang/go/blob/3dd58676054223962cd915bb0934d1f9f489d4d2/src/internal/cpu/cpu_wasm.go#L7
10095
// - https://github.com/torvalds/linux/blob/3516bd729358a2a9b090c1905bd2a3fa926e24c6/arch/sparc/include/asm/cache.h#L19
96+
// - https://github.com/torvalds/linux/blob/3516bd729358a2a9b090c1905bd2a3fa926e24c6/arch/riscv/include/asm/cache.h#L10
10197
//
10298
// All others are assumed to have 64-byte cache line size.
10399
#[cfg_attr(
@@ -108,8 +104,6 @@ use std::task::{Context, Poll, Waker};
108104
target_arch = "arm",
109105
target_arch = "mips",
110106
target_arch = "mips64",
111-
target_arch = "riscv32",
112-
target_arch = "riscv64",
113107
target_arch = "sparc",
114108
target_arch = "hexagon",
115109
target_arch = "m68k",

tokio/src/util/cacheline.rs

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,33 +27,28 @@ use std::ops::{Deref, DerefMut};
2727
),
2828
repr(align(128))
2929
)]
30-
// arm, mips, mips64, and riscv64 have 32-byte cache line size.
30+
// arm, mips and mips64 have 32-byte cache line size.
3131
//
3232
// Sources:
3333
// - https://github.com/golang/go/blob/3dd58676054223962cd915bb0934d1f9f489d4d2/src/internal/cpu/cpu_arm.go#L7
3434
// - https://github.com/golang/go/blob/3dd58676054223962cd915bb0934d1f9f489d4d2/src/internal/cpu/cpu_mips.go#L7
3535
// - https://github.com/golang/go/blob/3dd58676054223962cd915bb0934d1f9f489d4d2/src/internal/cpu/cpu_mipsle.go#L7
3636
// - https://github.com/golang/go/blob/3dd58676054223962cd915bb0934d1f9f489d4d2/src/internal/cpu/cpu_mips64x.go#L9
37-
// - https://github.com/golang/go/blob/3dd58676054223962cd915bb0934d1f9f489d4d2/src/internal/cpu/cpu_riscv64.go#L7
3837
#[cfg_attr(
39-
any(
40-
target_arch = "arm",
41-
target_arch = "mips",
42-
target_arch = "mips64",
43-
target_arch = "riscv64",
44-
),
38+
any(target_arch = "arm", target_arch = "mips", target_arch = "mips64",),
4539
repr(align(32))
4640
)]
4741
// s390x has 256-byte cache line size.
4842
//
4943
// Sources:
5044
// - https://github.com/golang/go/blob/3dd58676054223962cd915bb0934d1f9f489d4d2/src/internal/cpu/cpu_s390x.go#L7
5145
#[cfg_attr(target_arch = "s390x", repr(align(256)))]
52-
// x86 and wasm have 64-byte cache line size.
46+
// x86, riscv and wasm have 64-byte cache line size.
5347
//
5448
// Sources:
5549
// - https://github.com/golang/go/blob/dda2991c2ea0c5914714469c4defc2562a907230/src/internal/cpu/cpu_x86.go#L9
5650
// - https://github.com/golang/go/blob/3dd58676054223962cd915bb0934d1f9f489d4d2/src/internal/cpu/cpu_wasm.go#L7
51+
// - https://github.com/torvalds/linux/blob/3516bd729358a2a9b090c1905bd2a3fa926e24c6/arch/riscv/include/asm/cache.h#L10
5752
//
5853
// All others are assumed to have 64-byte cache line size.
5954
#[cfg_attr(
@@ -64,7 +59,6 @@ use std::ops::{Deref, DerefMut};
6459
target_arch = "arm",
6560
target_arch = "mips",
6661
target_arch = "mips64",
67-
target_arch = "riscv64",
6862
target_arch = "s390x",
6963
)),
7064
repr(align(64))

0 commit comments

Comments
 (0)