Skip to content

Commit d090ec0

Browse files
Leonardo BrasIngo Molnar
Leonardo Bras
authored and
Ingo Molnar
committed
smp: Change function signatures to use call_single_data_t
call_single_data_t is a size-aligned typedef of struct __call_single_data. This alignment is desirable in order to have smp_call_function*() avoid bouncing an extra cacheline in case of an unaligned csd, given this would hurt performance. Since the removal of struct request->csd in commit 660e802 ("blk-mq: use percpu csd to remote complete instead of per-rq csd") there are no current users of smp_call_function*() with unaligned csd. Change every 'struct __call_single_data' function parameter to 'call_single_data_t', so we have warnings if any new code tries to introduce an smp_call_function*() call with unaligned csd. Signed-off-by: Leonardo Bras <[email protected]> Reviewed-by: Guo Ren <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Signed-off-by: Ingo Molnar <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent e0a99a8 commit d090ec0

File tree

4 files changed

+19
-19
lines changed

4 files changed

+19
-19
lines changed

include/linux/smp.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ int smp_call_function_single(int cpuid, smp_call_func_t func, void *info,
5353
void on_each_cpu_cond_mask(smp_cond_func_t cond_func, smp_call_func_t func,
5454
void *info, bool wait, const struct cpumask *mask);
5555

56-
int smp_call_function_single_async(int cpu, struct __call_single_data *csd);
56+
int smp_call_function_single_async(int cpu, call_single_data_t *csd);
5757

5858
/*
5959
* Cpus stopping functions in panic. All have default weak definitions.

include/trace/events/csd.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ TRACE_EVENT(csd_queue_cpu,
1212
TP_PROTO(const unsigned int cpu,
1313
unsigned long callsite,
1414
smp_call_func_t func,
15-
struct __call_single_data *csd),
15+
call_single_data_t *csd),
1616

1717
TP_ARGS(cpu, callsite, func, csd),
1818

@@ -39,7 +39,7 @@ TRACE_EVENT(csd_queue_cpu,
3939
*/
4040
DECLARE_EVENT_CLASS(csd_function,
4141

42-
TP_PROTO(smp_call_func_t func, struct __call_single_data *csd),
42+
TP_PROTO(smp_call_func_t func, call_single_data_t *csd),
4343

4444
TP_ARGS(func, csd),
4545

@@ -57,12 +57,12 @@ DECLARE_EVENT_CLASS(csd_function,
5757
);
5858

5959
DEFINE_EVENT(csd_function, csd_function_entry,
60-
TP_PROTO(smp_call_func_t func, struct __call_single_data *csd),
60+
TP_PROTO(smp_call_func_t func, call_single_data_t *csd),
6161
TP_ARGS(func, csd)
6262
);
6363

6464
DEFINE_EVENT(csd_function, csd_function_exit,
65-
TP_PROTO(smp_call_func_t func, struct __call_single_data *csd),
65+
TP_PROTO(smp_call_func_t func, call_single_data_t *csd),
6666
TP_ARGS(func, csd)
6767
);
6868

kernel/smp.c

+13-13
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ send_call_function_ipi_mask(struct cpumask *mask)
125125
}
126126

127127
static __always_inline void
128-
csd_do_func(smp_call_func_t func, void *info, struct __call_single_data *csd)
128+
csd_do_func(smp_call_func_t func, void *info, call_single_data_t *csd)
129129
{
130130
trace_csd_function_entry(func, csd);
131131
func(info);
@@ -172,7 +172,7 @@ module_param(csd_lock_timeout, ulong, 0444);
172172
static atomic_t csd_bug_count = ATOMIC_INIT(0);
173173

174174
/* Record current CSD work for current CPU, NULL to erase. */
175-
static void __csd_lock_record(struct __call_single_data *csd)
175+
static void __csd_lock_record(call_single_data_t *csd)
176176
{
177177
if (!csd) {
178178
smp_mb(); /* NULL cur_csd after unlock. */
@@ -187,13 +187,13 @@ static void __csd_lock_record(struct __call_single_data *csd)
187187
/* Or before unlock, as the case may be. */
188188
}
189189

190-
static __always_inline void csd_lock_record(struct __call_single_data *csd)
190+
static __always_inline void csd_lock_record(call_single_data_t *csd)
191191
{
192192
if (static_branch_unlikely(&csdlock_debug_enabled))
193193
__csd_lock_record(csd);
194194
}
195195

196-
static int csd_lock_wait_getcpu(struct __call_single_data *csd)
196+
static int csd_lock_wait_getcpu(call_single_data_t *csd)
197197
{
198198
unsigned int csd_type;
199199

@@ -208,7 +208,7 @@ static int csd_lock_wait_getcpu(struct __call_single_data *csd)
208208
* the CSD_TYPE_SYNC/ASYNC types provide the destination CPU,
209209
* so waiting on other types gets much less information.
210210
*/
211-
static bool csd_lock_wait_toolong(struct __call_single_data *csd, u64 ts0, u64 *ts1, int *bug_id)
211+
static bool csd_lock_wait_toolong(call_single_data_t *csd, u64 ts0, u64 *ts1, int *bug_id)
212212
{
213213
int cpu = -1;
214214
int cpux;
@@ -272,7 +272,7 @@ static bool csd_lock_wait_toolong(struct __call_single_data *csd, u64 ts0, u64 *
272272
* previous function call. For multi-cpu calls its even more interesting
273273
* as we'll have to ensure no other cpu is observing our csd.
274274
*/
275-
static void __csd_lock_wait(struct __call_single_data *csd)
275+
static void __csd_lock_wait(call_single_data_t *csd)
276276
{
277277
int bug_id = 0;
278278
u64 ts0, ts1;
@@ -286,7 +286,7 @@ static void __csd_lock_wait(struct __call_single_data *csd)
286286
smp_acquire__after_ctrl_dep();
287287
}
288288

289-
static __always_inline void csd_lock_wait(struct __call_single_data *csd)
289+
static __always_inline void csd_lock_wait(call_single_data_t *csd)
290290
{
291291
if (static_branch_unlikely(&csdlock_debug_enabled)) {
292292
__csd_lock_wait(csd);
@@ -296,17 +296,17 @@ static __always_inline void csd_lock_wait(struct __call_single_data *csd)
296296
smp_cond_load_acquire(&csd->node.u_flags, !(VAL & CSD_FLAG_LOCK));
297297
}
298298
#else
299-
static void csd_lock_record(struct __call_single_data *csd)
299+
static void csd_lock_record(call_single_data_t *csd)
300300
{
301301
}
302302

303-
static __always_inline void csd_lock_wait(struct __call_single_data *csd)
303+
static __always_inline void csd_lock_wait(call_single_data_t *csd)
304304
{
305305
smp_cond_load_acquire(&csd->node.u_flags, !(VAL & CSD_FLAG_LOCK));
306306
}
307307
#endif
308308

309-
static __always_inline void csd_lock(struct __call_single_data *csd)
309+
static __always_inline void csd_lock(call_single_data_t *csd)
310310
{
311311
csd_lock_wait(csd);
312312
csd->node.u_flags |= CSD_FLAG_LOCK;
@@ -319,7 +319,7 @@ static __always_inline void csd_lock(struct __call_single_data *csd)
319319
smp_wmb();
320320
}
321321

322-
static __always_inline void csd_unlock(struct __call_single_data *csd)
322+
static __always_inline void csd_unlock(call_single_data_t *csd)
323323
{
324324
WARN_ON(!(csd->node.u_flags & CSD_FLAG_LOCK));
325325

@@ -372,7 +372,7 @@ void __smp_call_single_queue(int cpu, struct llist_node *node)
372372
* for execution on the given CPU. data must already have
373373
* ->func, ->info, and ->flags set.
374374
*/
375-
static int generic_exec_single(int cpu, struct __call_single_data *csd)
375+
static int generic_exec_single(int cpu, call_single_data_t *csd)
376376
{
377377
if (cpu == smp_processor_id()) {
378378
smp_call_func_t func = csd->func;
@@ -658,7 +658,7 @@ EXPORT_SYMBOL(smp_call_function_single);
658658
*
659659
* Return: %0 on success or negative errno value on error
660660
*/
661-
int smp_call_function_single_async(int cpu, struct __call_single_data *csd)
661+
int smp_call_function_single_async(int cpu, call_single_data_t *csd)
662662
{
663663
int err = 0;
664664

kernel/up.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ int smp_call_function_single(int cpu, void (*func) (void *info), void *info,
2525
}
2626
EXPORT_SYMBOL(smp_call_function_single);
2727

28-
int smp_call_function_single_async(int cpu, struct __call_single_data *csd)
28+
int smp_call_function_single_async(int cpu, call_single_data_t *csd)
2929
{
3030
unsigned long flags;
3131

0 commit comments

Comments
 (0)