Skip to content

Commit 1f52888

Browse files
evangreenpalmer-dabbelt
authored andcommitted
RISC-V: hwprobe: Add SCALAR to misaligned perf defines
In preparation for misaligned vector performance hwprobe keys, rename the hwprobe key values associated with misaligned scalar accesses to include the term SCALAR. Leave the old defines in place to maintain source compatibility. This change is intended to be a functional no-op. Signed-off-by: Evan Green <[email protected]> Reviewed-by: Charlie Jenkins <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Palmer Dabbelt <[email protected]>
1 parent c42e2f0 commit 1f52888

File tree

5 files changed

+34
-27
lines changed

5 files changed

+34
-27
lines changed

Documentation/arch/riscv/hwprobe.rst

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -247,23 +247,25 @@ The following keys are defined:
247247
the performance of misaligned scalar native word accesses on the selected set
248248
of processors.
249249

250-
* :c:macro:`RISCV_HWPROBE_MISALIGNED_UNKNOWN`: The performance of misaligned
251-
accesses is unknown.
250+
* :c:macro:`RISCV_HWPROBE_MISALIGNED_SCALAR_UNKNOWN`: The performance of
251+
misaligned scalar accesses is unknown.
252252

253-
* :c:macro:`RISCV_HWPROBE_MISALIGNED_EMULATED`: Misaligned accesses are
254-
emulated via software, either in or below the kernel. These accesses are
255-
always extremely slow.
253+
* :c:macro:`RISCV_HWPROBE_MISALIGNED_SCALAR_EMULATED`: Misaligned scalar
254+
accesses are emulated via software, either in or below the kernel. These
255+
accesses are always extremely slow.
256256

257-
* :c:macro:`RISCV_HWPROBE_MISALIGNED_SLOW`: Misaligned native word
258-
sized accesses are slower than the equivalent quantity of byte accesses.
259-
Misaligned accesses may be supported directly in hardware, or trapped and
260-
emulated by software.
257+
* :c:macro:`RISCV_HWPROBE_MISALIGNED_SCALAR_SLOW`: Misaligned scalar native
258+
word sized accesses are slower than the equivalent quantity of byte
259+
accesses. Misaligned accesses may be supported directly in hardware, or
260+
trapped and emulated by software.
261261

262-
* :c:macro:`RISCV_HWPROBE_MISALIGNED_FAST`: Misaligned native word
263-
sized accesses are faster than the equivalent quantity of byte accesses.
262+
* :c:macro:`RISCV_HWPROBE_MISALIGNED_SCALAR_FAST`: Misaligned scalar native
263+
word sized accesses are faster than the equivalent quantity of byte
264+
accesses.
264265

265-
* :c:macro:`RISCV_HWPROBE_MISALIGNED_UNSUPPORTED`: Misaligned accesses are
266-
not supported at all and will generate a misaligned address fault.
266+
* :c:macro:`RISCV_HWPROBE_MISALIGNED_SCALAR_UNSUPPORTED`: Misaligned scalar
267+
accesses are not supported at all and will generate a misaligned address
268+
fault.
267269

268270
* :c:macro:`RISCV_HWPROBE_KEY_ZICBOZ_BLOCK_SIZE`: An unsigned int which
269271
represents the size of the Zicboz block in bytes.

arch/riscv/include/uapi/asm/hwprobe.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,11 @@ struct riscv_hwprobe {
8383
#define RISCV_HWPROBE_KEY_HIGHEST_VIRT_ADDRESS 7
8484
#define RISCV_HWPROBE_KEY_TIME_CSR_FREQ 8
8585
#define RISCV_HWPROBE_KEY_MISALIGNED_SCALAR_PERF 9
86+
#define RISCV_HWPROBE_MISALIGNED_SCALAR_UNKNOWN 0
87+
#define RISCV_HWPROBE_MISALIGNED_SCALAR_EMULATED 1
88+
#define RISCV_HWPROBE_MISALIGNED_SCALAR_SLOW 2
89+
#define RISCV_HWPROBE_MISALIGNED_SCALAR_FAST 3
90+
#define RISCV_HWPROBE_MISALIGNED_SCALAR_UNSUPPORTED 4
8691
/* Increase RISCV_HWPROBE_MAX_KEY when adding items. */
8792

8893
/* Flags */

arch/riscv/kernel/sys_hwprobe.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -178,26 +178,26 @@ static u64 hwprobe_misaligned(const struct cpumask *cpus)
178178
perf = this_perf;
179179

180180
if (perf != this_perf) {
181-
perf = RISCV_HWPROBE_MISALIGNED_UNKNOWN;
181+
perf = RISCV_HWPROBE_MISALIGNED_SCALAR_UNKNOWN;
182182
break;
183183
}
184184
}
185185

186186
if (perf == -1ULL)
187-
return RISCV_HWPROBE_MISALIGNED_UNKNOWN;
187+
return RISCV_HWPROBE_MISALIGNED_SCALAR_UNKNOWN;
188188

189189
return perf;
190190
}
191191
#else
192192
static u64 hwprobe_misaligned(const struct cpumask *cpus)
193193
{
194194
if (IS_ENABLED(CONFIG_RISCV_EFFICIENT_UNALIGNED_ACCESS))
195-
return RISCV_HWPROBE_MISALIGNED_FAST;
195+
return RISCV_HWPROBE_MISALIGNED_SCALAR_FAST;
196196

197197
if (IS_ENABLED(CONFIG_RISCV_EMULATED_UNALIGNED_ACCESS) && unaligned_ctl_available())
198-
return RISCV_HWPROBE_MISALIGNED_EMULATED;
198+
return RISCV_HWPROBE_MISALIGNED_SCALAR_EMULATED;
199199

200-
return RISCV_HWPROBE_MISALIGNED_SLOW;
200+
return RISCV_HWPROBE_MISALIGNED_SCALAR_SLOW;
201201
}
202202
#endif
203203

arch/riscv/kernel/traps_misaligned.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ int handle_misaligned_load(struct pt_regs *regs)
338338
perf_sw_event(PERF_COUNT_SW_ALIGNMENT_FAULTS, 1, regs, addr);
339339

340340
#ifdef CONFIG_RISCV_PROBE_UNALIGNED_ACCESS
341-
*this_cpu_ptr(&misaligned_access_speed) = RISCV_HWPROBE_MISALIGNED_EMULATED;
341+
*this_cpu_ptr(&misaligned_access_speed) = RISCV_HWPROBE_MISALIGNED_SCALAR_EMULATED;
342342
#endif
343343

344344
if (!unaligned_enabled)
@@ -532,13 +532,13 @@ static bool check_unaligned_access_emulated(int cpu)
532532
unsigned long tmp_var, tmp_val;
533533
bool misaligned_emu_detected;
534534

535-
*mas_ptr = RISCV_HWPROBE_MISALIGNED_UNKNOWN;
535+
*mas_ptr = RISCV_HWPROBE_MISALIGNED_SCALAR_UNKNOWN;
536536

537537
__asm__ __volatile__ (
538538
" "REG_L" %[tmp], 1(%[ptr])\n"
539539
: [tmp] "=r" (tmp_val) : [ptr] "r" (&tmp_var) : "memory");
540540

541-
misaligned_emu_detected = (*mas_ptr == RISCV_HWPROBE_MISALIGNED_EMULATED);
541+
misaligned_emu_detected = (*mas_ptr == RISCV_HWPROBE_MISALIGNED_SCALAR_EMULATED);
542542
/*
543543
* If unaligned_ctl is already set, this means that we detected that all
544544
* CPUS uses emulated misaligned access at boot time. If that changed

arch/riscv/kernel/unaligned_access_speed.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ static int check_unaligned_access(void *param)
3434
struct page *page = param;
3535
void *dst;
3636
void *src;
37-
long speed = RISCV_HWPROBE_MISALIGNED_SLOW;
37+
long speed = RISCV_HWPROBE_MISALIGNED_SCALAR_SLOW;
3838

39-
if (per_cpu(misaligned_access_speed, cpu) != RISCV_HWPROBE_MISALIGNED_UNKNOWN)
39+
if (per_cpu(misaligned_access_speed, cpu) != RISCV_HWPROBE_MISALIGNED_SCALAR_UNKNOWN)
4040
return 0;
4141

4242
/* Make an unaligned destination buffer. */
@@ -95,22 +95,22 @@ static int check_unaligned_access(void *param)
9595
}
9696

9797
if (word_cycles < byte_cycles)
98-
speed = RISCV_HWPROBE_MISALIGNED_FAST;
98+
speed = RISCV_HWPROBE_MISALIGNED_SCALAR_FAST;
9999

100100
ratio = div_u64((byte_cycles * 100), word_cycles);
101101
pr_info("cpu%d: Ratio of byte access time to unaligned word access is %d.%02d, unaligned accesses are %s\n",
102102
cpu,
103103
ratio / 100,
104104
ratio % 100,
105-
(speed == RISCV_HWPROBE_MISALIGNED_FAST) ? "fast" : "slow");
105+
(speed == RISCV_HWPROBE_MISALIGNED_SCALAR_FAST) ? "fast" : "slow");
106106

107107
per_cpu(misaligned_access_speed, cpu) = speed;
108108

109109
/*
110110
* Set the value of fast_misaligned_access of a CPU. These operations
111111
* are atomic to avoid race conditions.
112112
*/
113-
if (speed == RISCV_HWPROBE_MISALIGNED_FAST)
113+
if (speed == RISCV_HWPROBE_MISALIGNED_SCALAR_FAST)
114114
cpumask_set_cpu(cpu, &fast_misaligned_access);
115115
else
116116
cpumask_clear_cpu(cpu, &fast_misaligned_access);
@@ -188,7 +188,7 @@ static int riscv_online_cpu(unsigned int cpu)
188188
static struct page *buf;
189189

190190
/* We are already set since the last check */
191-
if (per_cpu(misaligned_access_speed, cpu) != RISCV_HWPROBE_MISALIGNED_UNKNOWN)
191+
if (per_cpu(misaligned_access_speed, cpu) != RISCV_HWPROBE_MISALIGNED_SCALAR_UNKNOWN)
192192
goto exit;
193193

194194
buf = alloc_pages(GFP_KERNEL, MISALIGNED_BUFFER_ORDER);

0 commit comments

Comments
 (0)