Get rid of the __call_single_node union and cleanup the API a little to avoid external code relying on the structure layout as much.
Showing the changes to kernel (3 of 13 files). Show all
Unified · Split
| @@ -225,8 +225,6 @@ NOKPROBE_SYMBOL(kgdb_skipexception); · 224 unmodified lines | ||
| 225 | 225 | * Default (weak) implementation for kgdb_roundup_cpus |
| 226 | 226 | */ |
| 227 | 227 | |
| 228 | −static DEFINE_PER_CPU(call_single_data_t, kgdb_roundup_csd); | |
| 229 | − | |
| 230 | 228 | void __weak kgdb_call_nmi_hook(void *ignored) |
| 231 | 229 | { |
| 232 | 230 | /* |
| @@ -241,6 +239,9 @@ void __weak kgdb_call_nmi_hook(void *ignored) · 8 unmodified lines | ||
| 241 | 239 | } |
| 242 | 240 | NOKPROBE_SYMBOL(kgdb_call_nmi_hook); |
| 243 | 241 | |
| 242 | +static DEFINE_PER_CPU(call_single_data_t, kgdb_roundup_csd) = | |
| 243 | + CSD_INIT(kgdb_call_nmi_hook, NULL); | |
| 244 | + | |
| 244 | 245 | void __weak kgdb_roundup_cpus(void) |
| 245 | 246 | { |
| 246 | 247 | call_single_data_t *csd; |
| @@ -267,7 +268,6 @@ void __weak kgdb_roundup_cpus(void) · 20 unmodified lines | ||
| 267 | 268 | continue; |
| 268 | 269 | kgdb_info[cpu].rounding_up = true; |
| 269 | 270 | |
| 270 | − csd->func = kgdb_call_nmi_hook; | |
| 271 | 271 | ret = smp_call_function_single_async(cpu, csd); |
| 272 | 272 | if (ret) |
| 273 | 273 | kgdb_info[cpu].rounding_up = false; |
| @@ -320,14 +320,6 @@ void update_rq_clock(struct rq *rq) · 319 unmodified lines | ||
| 320 | 320 | update_rq_clock_task(rq, delta); |
| 321 | 321 | } |
| 322 | 322 | |
| 323 | −static inline void | |
| 324 | −rq_csd_init(struct rq *rq, call_single_data_t *csd, smp_call_func_t func) | |
| 325 | −{ | |
| 326 | − csd->flags = 0; | |
| 327 | − csd->func = func; | |
| 328 | − csd->info = rq; | |
| 329 | −} | |
| 330 | − | |
| 331 | 323 | #ifdef CONFIG_SCHED_HRTICK |
| 332 | 324 | /* |
| 333 | 325 | * Use HR-timers to deliver accurate preemption points. |
| @@ -428,7 +420,7 @@ void hrtick_start(struct rq *rq, u64 delay) · 94 unmodified lines | ||
| 428 | 420 | static void hrtick_rq_init(struct rq *rq) |
| 429 | 421 | { |
| 430 | 422 | #ifdef CONFIG_SMP |
| 431 | − rq_csd_init(rq, &rq->hrtick_csd, __hrtick_start); | |
| 423 | + INIT_CSD(&rq->hrtick_csd, __hrtick_start, rq); | |
| 432 | 424 | #endif |
| 433 | 425 | hrtimer_init(&rq->hrtick_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL_HARD); |
| 434 | 426 | rq->hrtick_timer.function = hrtick; |
| @@ -7774,7 +7766,7 @@ void __init sched_init(void) · 7339 unmodified lines | ||
| 7774 | 7766 | rq->last_blocked_load_update_tick = jiffies; |
| 7775 | 7767 | atomic_set(&rq->nohz_flags, 0); |
| 7776 | 7768 | |
| 7777 | − rq_csd_init(rq, &rq->nohz_csd, nohz_csd_func); | |
| 7769 | + INIT_CSD(&rq->nohz_csd, nohz_csd_func, rq); | |
| 7778 | 7770 | #endif |
| 7779 | 7771 | #ifdef CONFIG_HOTPLUG_CPU |
| 7780 | 7772 | rcuwait_init(&rq->hotplug_wait); |
| @@ -27,7 +27,7 @@ · 26 unmodified lines | ||
| 27 | 27 | #include "smpboot.h" |
| 28 | 28 | #include "sched/smp.h" |
| 29 | 29 | |
| 30 | −#define CSD_TYPE(_csd) ((_csd)->flags & CSD_FLAG_TYPE_MASK) | |
| 30 | +#define CSD_TYPE(_csd) ((_csd)->node.u_flags & CSD_FLAG_TYPE_MASK) | |
| 31 | 31 | |
| 32 | 32 | struct call_function_data { |
| 33 | 33 | call_single_data_t __percpu *csd; |
| @@ -146,7 +146,7 @@ static __always_inline bool csd_lock_wait_toolong(call_single_data_t *csd, u64 t · 112 unmodified lines | ||
| 146 | 146 | bool firsttime; |
| 147 | 147 | u64 ts2, ts_delta; |
| 148 | 148 | call_single_data_t *cpu_cur_csd; |
| 149 | − unsigned int flags = READ_ONCE(csd->flags); | |
| 149 | + unsigned int flags = READ_ONCE(csd->node.u_flags); | |
| 150 | 150 | |
| 151 | 151 | if (!(flags & CSD_FLAG_LOCK)) { |
| 152 | 152 | if (!unlikely(*bug_id)) |
| @@ -224,14 +224,14 @@ static void csd_lock_record(call_single_data_t *csd) · 71 unmodified lines | ||
| 224 | 224 | |
| 225 | 225 | static __always_inline void csd_lock_wait(call_single_data_t *csd) |
| 226 | 226 | { |
| 227 | − smp_cond_load_acquire(&csd->flags, !(VAL & CSD_FLAG_LOCK)); | |
| 227 | + smp_cond_load_acquire(&csd->node.u_flags, !(VAL & CSD_FLAG_LOCK)); | |
| 228 | 228 | } |
| 229 | 229 | #endif |
| 230 | 230 | |
| 231 | 231 | static __always_inline void csd_lock(call_single_data_t *csd) |
| 232 | 232 | { |
| 233 | 233 | csd_lock_wait(csd); |
| 234 | − csd->flags |= CSD_FLAG_LOCK; | |
| 234 | + csd->node.u_flags |= CSD_FLAG_LOCK; | |
| 235 | 235 | |
| 236 | 236 | /* |
| 237 | 237 | * prevent CPU from reordering the above assignment |
| @@ -243,12 +243,12 @@ static __always_inline void csd_lock(call_single_data_t *csd) · 5 unmodified lines | ||
| 243 | 243 | |
| 244 | 244 | static __always_inline void csd_unlock(call_single_data_t *csd) |
| 245 | 245 | { |
| 246 | − WARN_ON(!(csd->flags & CSD_FLAG_LOCK)); | |
| 246 | + WARN_ON(!(csd->node.u_flags & CSD_FLAG_LOCK)); | |
| 247 | 247 | |
| 248 | 248 | /* |
| 249 | 249 | * ensure we're all done before releasing data: |
| 250 | 250 | */ |
| 251 | − smp_store_release(&csd->flags, 0); | |
| 251 | + smp_store_release(&csd->node.u_flags, 0); | |
| 252 | 252 | } |
| 253 | 253 | |
| 254 | 254 | static DEFINE_PER_CPU_SHARED_ALIGNED(call_single_data_t, csd_data); |
| @@ -300,7 +300,7 @@ static int generic_exec_single(int cpu, call_single_data_t *csd) · 45 unmodified lines | ||
| 300 | 300 | return -ENXIO; |
| 301 | 301 | } |
| 302 | 302 | |
| 303 | − __smp_call_single_queue(cpu, &csd->llist); | |
| 303 | + __smp_call_single_queue(cpu, &csd->node.llist); | |
| 304 | 304 | |
| 305 | 305 | return 0; |
| 306 | 306 | } |
| @@ -353,7 +353,7 @@ static void flush_smp_call_function_queue(bool warn_cpu_offline) · 46 unmodified lines | ||
| 353 | 353 | * We don't have to use the _safe() variant here |
| 354 | 354 | * because we are not invoking the IPI handlers yet. |
| 355 | 355 | */ |
| 356 | − llist_for_each_entry(csd, entry, llist) { | |
| 356 | + llist_for_each_entry(csd, entry, node.llist) { | |
| 357 | 357 | switch (CSD_TYPE(csd)) { |
| 358 | 358 | case CSD_TYPE_ASYNC: |
| 359 | 359 | case CSD_TYPE_SYNC: |
| @@ -378,16 +378,16 @@ static void flush_smp_call_function_queue(bool warn_cpu_offline) · 18 unmodified lines | ||
| 378 | 378 | * First; run all SYNC callbacks, people are waiting for us. |
| 379 | 379 | */ |
| 380 | 380 | prev = NULL; |
| 381 | − llist_for_each_entry_safe(csd, csd_next, entry, llist) { | |
| 381 | + llist_for_each_entry_safe(csd, csd_next, entry, node.llist) { | |
| 382 | 382 | /* Do we wait until *after* callback? */ |
| 383 | 383 | if (CSD_TYPE(csd) == CSD_TYPE_SYNC) { |
| 384 | 384 | smp_call_func_t func = csd->func; |
| 385 | 385 | void *info = csd->info; |
| 386 | 386 | |
| 387 | 387 | if (prev) { |
| 388 | − prev->next = &csd_next->llist; | |
| 388 | + prev->next = &csd_next->node.llist; | |
| 389 | 389 | } else { |
| 390 | − entry = &csd_next->llist; | |
| 390 | + entry = &csd_next->node.llist; | |
| 391 | 391 | } |
| 392 | 392 | |
| 393 | 393 | csd_lock_record(csd); |
| @@ -395,7 +395,7 @@ static void flush_smp_call_function_queue(bool warn_cpu_offline) · 1 unmodified line | ||
| 395 | 395 | csd_unlock(csd); |
| 396 | 396 | csd_lock_record(NULL); |
| 397 | 397 | } else { |
| 398 | − prev = &csd->llist; | |
| 398 | + prev = &csd->node.llist; | |
| 399 | 399 | } |
| 400 | 400 | } |
| 401 | 401 | |
| @@ -406,14 +406,14 @@ static void flush_smp_call_function_queue(bool warn_cpu_offline) · 4 unmodified lines | ||
| 406 | 406 | * Second; run all !SYNC callbacks. |
| 407 | 407 | */ |
| 408 | 408 | prev = NULL; |
| 409 | − llist_for_each_entry_safe(csd, csd_next, entry, llist) { | |
| 409 | + llist_for_each_entry_safe(csd, csd_next, entry, node.llist) { | |
| 410 | 410 | int type = CSD_TYPE(csd); |
| 411 | 411 | |
| 412 | 412 | if (type != CSD_TYPE_TTWU) { |
| 413 | 413 | if (prev) { |
| 414 | − prev->next = &csd_next->llist; | |
| 414 | + prev->next = &csd_next->node.llist; | |
| 415 | 415 | } else { |
| 416 | − entry = &csd_next->llist; | |
| 416 | + entry = &csd_next->node.llist; | |
| 417 | 417 | } |
| 418 | 418 | |
| 419 | 419 | if (type == CSD_TYPE_ASYNC) { |
| @@ -429,7 +429,7 @@ static void flush_smp_call_function_queue(bool warn_cpu_offline) · 9 unmodified lines | ||
| 429 | 429 | } |
| 430 | 430 | |
| 431 | 431 | } else { |
| 432 | − prev = &csd->llist; | |
| 432 | + prev = &csd->node.llist; | |
| 433 | 433 | } |
| 434 | 434 | } |
| 435 | 435 | |
| @@ -465,7 +465,7 @@ int smp_call_function_single(int cpu, smp_call_func_t func, void *info, · 29 unmodified lines | ||
| 465 | 465 | { |
| 466 | 466 | call_single_data_t *csd; |
| 467 | 467 | call_single_data_t csd_stack = { |
| 468 | − .flags = CSD_FLAG_LOCK | CSD_TYPE_SYNC, | |
| 468 | + .node = { .u_flags = CSD_FLAG_LOCK | CSD_TYPE_SYNC, }, | |
| 469 | 469 | }; |
| 470 | 470 | int this_cpu; |
| 471 | 471 | int err; |
| @@ -502,8 +502,8 @@ int smp_call_function_single(int cpu, smp_call_func_t func, void *info, · 30 unmodified lines | ||
| 502 | 502 | csd->func = func; |
| 503 | 503 | csd->info = info; |
| 504 | 504 | #ifdef CONFIG_CSD_LOCK_WAIT_DEBUG |
| 505 | − csd->src = smp_processor_id(); | |
| 506 | − csd->dst = cpu; | |
| 505 | + csd->node.src = smp_processor_id(); | |
| 506 | + csd->node.dst = cpu; | |
| 507 | 507 | #endif |
| 508 | 508 | |
| 509 | 509 | err = generic_exec_single(cpu, csd); |
| @@ -544,12 +544,12 @@ int smp_call_function_single_async(int cpu, call_single_data_t *csd) · 34 unmodified lines | ||
| 544 | 544 | |
| 545 | 545 | preempt_disable(); |
| 546 | 546 | |
| 547 | − if (csd->flags & CSD_FLAG_LOCK) { | |
| 547 | + if (csd->node.u_flags & CSD_FLAG_LOCK) { | |
| 548 | 548 | err = -EBUSY; |
| 549 | 549 | goto out; |
| 550 | 550 | } |
| 551 | 551 | |
| 552 | − csd->flags = CSD_FLAG_LOCK; | |
| 552 | + csd->node.u_flags = CSD_FLAG_LOCK; | |
| 553 | 553 | smp_wmb(); |
| 554 | 554 | |
| 555 | 555 | err = generic_exec_single(cpu, csd); |
| @@ -667,14 +667,14 @@ static void smp_call_function_many_cond(const struct cpumask *mask, · 111 unmodified lines | ||
| 667 | 667 | |
| 668 | 668 | csd_lock(csd); |
| 669 | 669 | if (wait) |
| 670 | − csd->flags |= CSD_TYPE_SYNC; | |
| 670 | + csd->node.u_flags |= CSD_TYPE_SYNC; | |
| 671 | 671 | csd->func = func; |
| 672 | 672 | csd->info = info; |
| 673 | 673 | #ifdef CONFIG_CSD_LOCK_WAIT_DEBUG |
| 674 | − csd->src = smp_processor_id(); | |
| 675 | − csd->dst = cpu; | |
| 674 | + csd->node.src = smp_processor_id(); | |
| 675 | + csd->node.dst = cpu; | |
| 676 | 676 | #endif |
| 677 | − if (llist_add(&csd->llist, &per_cpu(call_single_queue, cpu))) | |
| 677 | + if (llist_add(&csd->node.llist, &per_cpu(call_single_queue, cpu))) | |
| 678 | 678 | __cpumask_set_cpu(cpu, cfd->cpumask_ipi); |
| 679 | 679 | } |
| 680 | 680 | |