Skip to content

Commit 255acee

Browse files
heicarstLinus Torvalds
authored andcommitted
[PATCH] s390: additional_cpus parameter
Introduce additional_cpus command line option. By default no additional cpu can be attached to the system anymore. Only the cpus present at IPL time can be switched on/off. If it is desired that additional cpus can be attached to the system the maximum number of additional cpus needs to be specified with this option. This change is necessary in order to limit the waste of per_cpu data structures. Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
1 parent 1fca251 commit 255acee

4 files changed

Lines changed: 49 additions & 23 deletions

File tree

‎Documentation/cpu-hotplug.txt‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
Joel Schopp <jschopp@austin.ibm.com>
1212
ia64/x86_64:
1313
Ashok Raj <ashok.raj@intel.com>
14+
s390:
15+
Heiko Carstens <heiko.carstens@de.ibm.com>
1416

1517
Authors: Ashok Raj <ashok.raj@intel.com>
1618
Lots of feedback: Nathan Lynch <nathanl@austin.ibm.com>,
@@ -44,11 +46,9 @@ maxcpus=n Restrict boot time cpus to n. Say if you have 4 cpus, using
4446
maxcpus=2 will only boot 2. You can choose to bring the
4547
other cpus later online, read FAQ's for more info.
4648

47-
additional_cpus*=n Use this to limit hotpluggable cpus. This option sets
48-
cpu_possible_map = cpu_present_map + additional_cpus
49-
50-
(*) Option valid only for following architectures
51-
- x86_64, ia64
49+
additional_cpus=n [x86_64, s390 only] use this to limit hotpluggable cpus.
50+
This option sets
51+
cpu_possible_map = cpu_present_map + additional_cpus
5252

5353
ia64 and x86_64 use the number of disabled local apics in ACPI tables MADT
5454
to determine the number of potentially hot-pluggable cpus. The implementation

‎arch/s390/kernel/setup.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -600,13 +600,15 @@ setup_arch(char **cmdline_p)
600600
init_mm.brk = (unsigned long) &_end;
601601

602602
parse_cmdline_early(cmdline_p);
603+
parse_early_param();
603604

604605
setup_memory();
605606
setup_resources();
606607
setup_lowcore();
607608

608609
cpu_init();
609610
__cpu_logical_map[0] = S390_lowcore.cpu_data.cpu_addr;
611+
smp_setup_cpu_possible_map();
610612

611613
/*
612614
* Create kernel page tables and switch to virtual addressing.

‎arch/s390/kernel/smp.c‎

Lines changed: 40 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
/*
22
* arch/s390/kernel/smp.c
33
*
4-
* S390 version
5-
* Copyright (C) 1999,2000 IBM Deutschland Entwicklung GmbH, IBM Corporation
4+
* Copyright (C) IBM Corp. 1999,2006
65
* Author(s): Denis Joseph Barrow (djbarrow@de.ibm.com,barrow_dj@yahoo.com),
76
* Martin Schwidefsky (schwidefsky@de.ibm.com)
87
* Heiko Carstens (heiko.carstens@de.ibm.com)
@@ -41,8 +40,6 @@
4140
#include <asm/cpcmd.h>
4241
#include <asm/tlbflush.h>
4342

44-
/* prototypes */
45-
4643
extern volatile int __cpu_logical_map[];
4744

4845
/*
@@ -51,13 +48,11 @@ extern volatile int __cpu_logical_map[];
5148

5249
struct _lowcore *lowcore_ptr[NR_CPUS];
5350

54-
cpumask_t cpu_online_map;
55-
cpumask_t cpu_possible_map = CPU_MASK_ALL;
51+
cpumask_t cpu_online_map = CPU_MASK_NONE;
52+
cpumask_t cpu_possible_map = CPU_MASK_NONE;
5653

5754
static struct task_struct *current_set[NR_CPUS];
5855

59-
EXPORT_SYMBOL(cpu_online_map);
60-
6156
/*
6257
* Reboot, halt and power_off routines for SMP.
6358
*/
@@ -490,10 +485,10 @@ void smp_ctl_clear_bit(int cr, int bit) {
490485
* Lets check how many CPUs we have.
491486
*/
492487

493-
void
494-
__init smp_check_cpus(unsigned int max_cpus)
488+
static unsigned int
489+
__init smp_count_cpus(void)
495490
{
496-
int cpu, num_cpus;
491+
unsigned int cpu, num_cpus;
497492
__u16 boot_cpu_addr;
498493

499494
/*
@@ -503,19 +498,20 @@ __init smp_check_cpus(unsigned int max_cpus)
503498
boot_cpu_addr = S390_lowcore.cpu_data.cpu_addr;
504499
current_thread_info()->cpu = 0;
505500
num_cpus = 1;
506-
for (cpu = 0; cpu <= 65535 && num_cpus < max_cpus; cpu++) {
501+
for (cpu = 0; cpu <= 65535; cpu++) {
507502
if ((__u16) cpu == boot_cpu_addr)
508503
continue;
509-
__cpu_logical_map[num_cpus] = (__u16) cpu;
510-
if (signal_processor(num_cpus, sigp_sense) ==
504+
__cpu_logical_map[1] = (__u16) cpu;
505+
if (signal_processor(1, sigp_sense) ==
511506
sigp_not_operational)
512507
continue;
513-
cpu_set(num_cpus, cpu_present_map);
514508
num_cpus++;
515509
}
516510

517511
printk("Detected %d CPU's\n",(int) num_cpus);
518512
printk("Boot cpu address %2X\n", boot_cpu_addr);
513+
514+
return num_cpus;
519515
}
520516

521517
/*
@@ -676,6 +672,32 @@ __cpu_up(unsigned int cpu)
676672
return 0;
677673
}
678674

675+
static unsigned int __initdata additional_cpus;
676+
677+
void __init smp_setup_cpu_possible_map(void)
678+
{
679+
unsigned int pcpus, cpu;
680+
681+
pcpus = smp_count_cpus() + additional_cpus;
682+
683+
if (pcpus > NR_CPUS)
684+
pcpus = NR_CPUS;
685+
686+
for (cpu = 0; cpu < pcpus; cpu++)
687+
cpu_set(cpu, cpu_possible_map);
688+
689+
cpu_present_map = cpu_possible_map;
690+
}
691+
692+
#ifdef CONFIG_HOTPLUG_CPU
693+
694+
static int __init setup_additional_cpus(char *s)
695+
{
696+
additional_cpus = simple_strtoul(s, NULL, 0);
697+
return 0;
698+
}
699+
early_param("additional_cpus", setup_additional_cpus);
700+
679701
int
680702
__cpu_disable(void)
681703
{
@@ -744,6 +766,8 @@ cpu_die(void)
744766
for(;;);
745767
}
746768

769+
#endif /* CONFIG_HOTPLUG_CPU */
770+
747771
/*
748772
* Cycle through the processors and setup structures.
749773
*/
@@ -757,7 +781,6 @@ void __init smp_prepare_cpus(unsigned int max_cpus)
757781
/* request the 0x1201 emergency signal external interrupt */
758782
if (register_external_interrupt(0x1201, do_ext_call_interrupt) != 0)
759783
panic("Couldn't request external interrupt 0x1201");
760-
smp_check_cpus(max_cpus);
761784
memset(lowcore_ptr,0,sizeof(lowcore_ptr));
762785
/*
763786
* Initialize prefix pages and stacks for all possible cpus
@@ -806,14 +829,12 @@ void __devinit smp_prepare_boot_cpu(void)
806829
BUG_ON(smp_processor_id() != 0);
807830

808831
cpu_set(0, cpu_online_map);
809-
cpu_set(0, cpu_present_map);
810832
S390_lowcore.percpu_offset = __per_cpu_offset[0];
811833
current_set[0] = current;
812834
}
813835

814836
void smp_cpus_done(unsigned int max_cpus)
815837
{
816-
cpu_present_map = cpu_possible_map;
817838
}
818839

819840
/*
@@ -845,6 +866,7 @@ static int __init topology_init(void)
845866

846867
subsys_initcall(topology_init);
847868

869+
EXPORT_SYMBOL(cpu_online_map);
848870
EXPORT_SYMBOL(cpu_possible_map);
849871
EXPORT_SYMBOL(lowcore_ptr);
850872
EXPORT_SYMBOL(smp_ctl_set_bit);

‎include/asm-s390/smp.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ typedef struct
3131
__u16 cpu;
3232
} sigp_info;
3333

34+
extern void smp_setup_cpu_possible_map(void);
3435
extern int smp_call_function_on(void (*func) (void *info), void *info,
3536
int nonatomic, int wait, int cpu);
3637
#define NO_PROC_ID 0xFF /* No processor magic marker */
@@ -104,6 +105,7 @@ smp_call_function_on(void (*func) (void *info), void *info,
104105
#define smp_cpu_not_running(cpu) 1
105106
#define smp_get_cpu(cpu) ({ 0; })
106107
#define smp_put_cpu(cpu) ({ 0; })
108+
#define smp_setup_cpu_possible_map()
107109
#endif
108110

109111
#endif

0 commit comments

Comments
 (0)