Skip to content

Commit fda9d86

Browse files
antonblanchardozbenh
authored andcommitted
powerpc: Reduce footprint of xics_ipi_struct
Right now we allocate a cacheline sized NR_CPUS array for xics IPI communication. Use DECLARE_PER_CPU_SHARED_ALIGNED to put it in percpu data in its own cacheline since it is written to by other cpus. On a kernel with NR_CPUS=1024, this saves quite a lot of memory: text data bss dec hex filename 8767779 2944260 1505724 13217763 c9afe3 vmlinux.irq_cpustat 8767555 2813444 1505724 13086723 c7b003 vmlinux.xics A saving of around 128kB. Signed-off-by: Anton Blanchard <anton@samba.org> Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
1 parent 8c007bf commit fda9d86

1 file changed

Lines changed: 11 additions & 15 deletions

File tree

  • arch/powerpc/platforms/pseries

‎arch/powerpc/platforms/pseries/xics.c‎

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -510,15 +510,13 @@ static void __init xics_init_host(void)
510510
/*
511511
* XICS only has a single IPI, so encode the messages per CPU
512512
*/
513-
struct xics_ipi_struct {
514-
unsigned long value;
515-
} ____cacheline_aligned;
516-
517-
static struct xics_ipi_struct xics_ipi_message[NR_CPUS] __cacheline_aligned;
513+
static DEFINE_PER_CPU_SHARED_ALIGNED(unsigned long, xics_ipi_message);
518514

519515
static inline void smp_xics_do_message(int cpu, int msg)
520516
{
521-
set_bit(msg, &xics_ipi_message[cpu].value);
517+
unsigned long *tgt = &per_cpu(xics_ipi_message, cpu);
518+
519+
set_bit(msg, tgt);
522520
mb();
523521
if (firmware_has_feature(FW_FEATURE_LPAR))
524522
lpar_qirr_info(cpu, IPI_PRIORITY);
@@ -544,25 +542,23 @@ void smp_xics_message_pass(int target, int msg)
544542

545543
static irqreturn_t xics_ipi_dispatch(int cpu)
546544
{
545+
unsigned long *tgt = &per_cpu(xics_ipi_message, cpu);
546+
547547
WARN_ON(cpu_is_offline(cpu));
548548

549549
mb(); /* order mmio clearing qirr */
550-
while (xics_ipi_message[cpu].value) {
551-
if (test_and_clear_bit(PPC_MSG_CALL_FUNCTION,
552-
&xics_ipi_message[cpu].value)) {
550+
while (*tgt) {
551+
if (test_and_clear_bit(PPC_MSG_CALL_FUNCTION, tgt)) {
553552
smp_message_recv(PPC_MSG_CALL_FUNCTION);
554553
}
555-
if (test_and_clear_bit(PPC_MSG_RESCHEDULE,
556-
&xics_ipi_message[cpu].value)) {
554+
if (test_and_clear_bit(PPC_MSG_RESCHEDULE, tgt)) {
557555
smp_message_recv(PPC_MSG_RESCHEDULE);
558556
}
559-
if (test_and_clear_bit(PPC_MSG_CALL_FUNC_SINGLE,
560-
&xics_ipi_message[cpu].value)) {
557+
if (test_and_clear_bit(PPC_MSG_CALL_FUNC_SINGLE, tgt)) {
561558
smp_message_recv(PPC_MSG_CALL_FUNC_SINGLE);
562559
}
563560
#if defined(CONFIG_DEBUGGER) || defined(CONFIG_KEXEC)
564-
if (test_and_clear_bit(PPC_MSG_DEBUGGER_BREAK,
565-
&xics_ipi_message[cpu].value)) {
561+
if (test_and_clear_bit(PPC_MSG_DEBUGGER_BREAK, tgt)) {
566562
smp_message_recv(PPC_MSG_DEBUGGER_BREAK);
567563
}
568564
#endif

0 commit comments

Comments
 (0)