提交 cf813db0 编写于 作者: H Heiko Carstens 提交者: Martin Schwidefsky

s390/smp: limit number of cpus in possible cpu mask

Limit the number of bits to the maximum number of cpus a machine
can have.
possible_cpu_mask typically will have more bits set than a machine
may physically have. This results in wasted memory during per-cpu
memory allocations, if the possible mask contains more cpus than
physically possible for a given configuration.
Signed-off-by: NHeiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: NMartin Schwidefsky <schwidefsky@de.ibm.com>
上级 36a55402
...@@ -46,6 +46,7 @@ int sclp_cpu_configure(u8 cpu); ...@@ -46,6 +46,7 @@ int sclp_cpu_configure(u8 cpu);
int sclp_cpu_deconfigure(u8 cpu); int sclp_cpu_deconfigure(u8 cpu);
unsigned long long sclp_get_rnmax(void); unsigned long long sclp_get_rnmax(void);
unsigned long long sclp_get_rzm(void); unsigned long long sclp_get_rzm(void);
unsigned int sclp_get_max_cpu(void);
int sclp_sdias_blk_count(void); int sclp_sdias_blk_count(void);
int sclp_sdias_copy(void *dest, int blk_num, int nr_blks); int sclp_sdias_copy(void *dest, int blk_num, int nr_blks);
int sclp_chp_configure(struct chp_id chpid); int sclp_chp_configure(struct chp_id chpid);
......
...@@ -773,11 +773,11 @@ void __noreturn cpu_die(void) ...@@ -773,11 +773,11 @@ void __noreturn cpu_die(void)
void __init smp_fill_possible_mask(void) void __init smp_fill_possible_mask(void)
{ {
unsigned int possible, cpu; unsigned int possible, sclp, cpu;
possible = setup_possible_cpus; sclp = sclp_get_max_cpu() ?: nr_cpu_ids;
if (!possible) possible = setup_possible_cpus ?: nr_cpu_ids;
possible = MACHINE_IS_VM ? 64 : nr_cpu_ids; possible = min(possible, sclp);
for (cpu = 0; cpu < possible && cpu < nr_cpu_ids; cpu++) for (cpu = 0; cpu < possible && cpu < nr_cpu_ids; cpu++)
set_cpu_possible(cpu, true); set_cpu_possible(cpu, true);
} }
......
...@@ -20,7 +20,9 @@ struct read_info_sccb { ...@@ -20,7 +20,9 @@ struct read_info_sccb {
struct sccb_header header; /* 0-7 */ struct sccb_header header; /* 0-7 */
u16 rnmax; /* 8-9 */ u16 rnmax; /* 8-9 */
u8 rnsize; /* 10 */ u8 rnsize; /* 10 */
u8 _reserved0[24 - 11]; /* 11-15 */ u8 _reserved0[16 - 11]; /* 11-15 */
u16 ncpurl; /* 16-17 */
u8 _reserved7[24 - 18]; /* 18-23 */
u8 loadparm[8]; /* 24-31 */ u8 loadparm[8]; /* 24-31 */
u8 _reserved1[48 - 32]; /* 32-47 */ u8 _reserved1[48 - 32]; /* 32-47 */
u64 facilities; /* 48-55 */ u64 facilities; /* 48-55 */
...@@ -32,13 +34,16 @@ struct read_info_sccb { ...@@ -32,13 +34,16 @@ struct read_info_sccb {
u8 _reserved4[100 - 92]; /* 92-99 */ u8 _reserved4[100 - 92]; /* 92-99 */
u32 rnsize2; /* 100-103 */ u32 rnsize2; /* 100-103 */
u64 rnmax2; /* 104-111 */ u64 rnmax2; /* 104-111 */
u8 _reserved5[4096 - 112]; /* 112-4095 */ u8 _reserved5[120 - 112]; /* 112-119 */
u16 hcpua; /* 120-121 */
u8 _reserved6[4096 - 122]; /* 122-4095 */
} __packed __aligned(PAGE_SIZE); } __packed __aligned(PAGE_SIZE);
static char sccb_early[PAGE_SIZE] __aligned(PAGE_SIZE) __initdata; static char sccb_early[PAGE_SIZE] __aligned(PAGE_SIZE) __initdata;
static unsigned int sclp_con_has_vt220 __initdata; static unsigned int sclp_con_has_vt220 __initdata;
static unsigned int sclp_con_has_linemode __initdata; static unsigned int sclp_con_has_linemode __initdata;
static unsigned long sclp_hsa_size; static unsigned long sclp_hsa_size;
static unsigned int sclp_max_cpu;
static struct sclp_ipl_info sclp_ipl_info; static struct sclp_ipl_info sclp_ipl_info;
u64 sclp_facilities; u64 sclp_facilities;
...@@ -102,6 +107,15 @@ static void __init sclp_facilities_detect(struct read_info_sccb *sccb) ...@@ -102,6 +107,15 @@ static void __init sclp_facilities_detect(struct read_info_sccb *sccb)
sclp_rzm = sccb->rnsize ? sccb->rnsize : sccb->rnsize2; sclp_rzm = sccb->rnsize ? sccb->rnsize : sccb->rnsize2;
sclp_rzm <<= 20; sclp_rzm <<= 20;
if (!sccb->hcpua) {
if (MACHINE_IS_VM)
sclp_max_cpu = 64;
else
sclp_max_cpu = sccb->ncpurl;
} else {
sclp_max_cpu = sccb->hcpua + 1;
}
/* Save IPL information */ /* Save IPL information */
sclp_ipl_info.is_valid = 1; sclp_ipl_info.is_valid = 1;
if (sccb->flags & 0x2) if (sccb->flags & 0x2)
...@@ -129,6 +143,11 @@ unsigned long long sclp_get_rzm(void) ...@@ -129,6 +143,11 @@ unsigned long long sclp_get_rzm(void)
return sclp_rzm; return sclp_rzm;
} }
unsigned int sclp_get_max_cpu(void)
{
return sclp_max_cpu;
}
/* /*
* This function will be called after sclp_facilities_detect(), which gets * This function will be called after sclp_facilities_detect(), which gets
* called from early.c code. The sclp_facilities_detect() function retrieves * called from early.c code. The sclp_facilities_detect() function retrieves
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册