From patchwork Thu Jun 28 02:55:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stewart Smith X-Patchwork-Id: 935867 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41GPZr4m4nz9ry1 for ; Thu, 28 Jun 2018 12:57:24 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.ibm.com Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 41GPZr3T7nzF1LZ for ; Thu, 28 Jun 2018 12:57:24 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.ibm.com X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=linux.ibm.com (client-ip=148.163.156.1; helo=mx0a-001b2d01.pphosted.com; envelope-from=stewart@linux.ibm.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.ibm.com Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 41GPXn088wzF1JL for ; Thu, 28 Jun 2018 12:55:36 +1000 (AEST) Received: from pps.filterd (m0098409.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w5S2rt9j093577 for ; Wed, 27 Jun 2018 22:55:35 -0400 Received: from e31.co.us.ibm.com (e31.co.us.ibm.com [32.97.110.149]) by mx0a-001b2d01.pphosted.com with ESMTP id 2jvndhkumf-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 27 Jun 2018 22:55:35 -0400 Received: from localhost by e31.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 27 Jun 2018 20:55:34 -0600 Received: from b03cxnp08028.gho.boulder.ibm.com (9.17.130.20) by e31.co.us.ibm.com (192.168.1.131) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Wed, 27 Jun 2018 20:55:31 -0600 Received: from b03ledav004.gho.boulder.ibm.com (b03ledav004.gho.boulder.ibm.com [9.17.130.235]) by b03cxnp08028.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w5S2tUb99765194 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 27 Jun 2018 19:55:30 -0700 Received: from b03ledav004.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 66D247805C; Wed, 27 Jun 2018 20:55:30 -0600 (MDT) Received: from b03ledav004.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9502B78060; Wed, 27 Jun 2018 20:55:29 -0600 (MDT) Received: from birb.localdomain (unknown [9.102.42.25]) by b03ledav004.gho.boulder.ibm.com (Postfix) with SMTP; Wed, 27 Jun 2018 20:55:29 -0600 (MDT) Received: by birb.localdomain (Postfix, from userid 1000) id ACAF74EC6B7; Thu, 28 Jun 2018 12:55:21 +1000 (AEST) From: Stewart Smith To: Nicholas Piggin , Stewart Smith Date: Thu, 28 Jun 2018 12:55:01 +1000 X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180628025501.20676-1-stewart@linux.ibm.com> References: <20180418135513.64817b17@roar.ozlabs.ibm.com> <20180628025501.20676-1-stewart@linux.ibm.com> In-Reply-To: <20180418135513.64817b17@roar.ozlabs.ibm.com> References: <20180418135513.64817b17@roar.ozlabs.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 18062802-8235-0000-0000-00000DC97D93 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00009267; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000266; SDB=6.01053344; UDB=6.00540074; IPR=6.00831268; MB=3.00021894; MTD=3.00000008; XFM=3.00000015; UTC=2018-06-28 02:55:32 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18062802-8236-0000-0000-000041AE629B Message-Id: <20180628025501.20676-7-stewart@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2018-06-27_08:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1806210000 definitions=main-1806280029 Subject: [Skiboot] [RFC v2 PATCH 6/6] core/flash.c: cache loaded resources X-BeenThere: skiboot@lists.ozlabs.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: Mailing list for skiboot development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: skiboot@lists.ozlabs.org MIME-Version: 1.0 Errors-To: skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot" The vast majority of fast-reboot time on BMC based systems is spent waiting for the BOOTKERNEL to be loaded off flash. If we cache it instead, we sacrifice 16MB of memory to cut 4seconds (from our previous total of 9 seconds) off fast reboot time. We don't need to do this on FSP systems as loading BOOTKERNEL and INITRAMFS from the FSP doesn't take nearly this long (typically they're around <1s). Signed-off-by: Stewart Smith --- core/fast-reboot.c | 7 ++++++- core/flash.c | 49 +++++++++++++++++++++++++++++++++++++++++----- core/init.c | 24 +++++++++++------------ include/skiboot.h | 4 +++- 4 files changed, 65 insertions(+), 19 deletions(-) diff --git a/core/fast-reboot.c b/core/fast-reboot.c index b7e518b1a492..3c920eac29b1 100644 --- a/core/fast-reboot.c +++ b/core/fast-reboot.c @@ -402,5 +402,10 @@ void __noreturn fast_reboot_entry(void) wait_mem_region_clear_unused(); /* Load and boot payload */ - load_and_boot_kernel(true); + if (!load_kernel()) { + op_display(OP_FATAL, OP_MOD_INIT, 1); + abort(); + } + load_initramfs(); + boot_kernel(true); } diff --git a/core/flash.c b/core/flash.c index e3be576137e3..c94635d4adc0 100644 --- a/core/flash.c +++ b/core/flash.c @@ -28,6 +28,7 @@ #include #include #include +#include struct flash { struct list_node list; @@ -549,12 +550,14 @@ static struct { enum resource_id id; uint32_t subid; char name[PART_NAME_MAX+1]; + void* cache; + size_t len; } part_name_map[] = { - { RESOURCE_ID_KERNEL, RESOURCE_SUBID_NONE, "BOOTKERNEL" }, - { RESOURCE_ID_INITRAMFS,RESOURCE_SUBID_NONE, "ROOTFS" }, - { RESOURCE_ID_CAPP, RESOURCE_SUBID_SUPPORTED, "CAPP" }, - { RESOURCE_ID_IMA_CATALOG, RESOURCE_SUBID_SUPPORTED, "IMA_CATALOG" }, - { RESOURCE_ID_VERSION, RESOURCE_SUBID_NONE, "VERSION" }, + { RESOURCE_ID_KERNEL, RESOURCE_SUBID_NONE, "BOOTKERNEL", NULL, 0 }, + { RESOURCE_ID_INITRAMFS,RESOURCE_SUBID_NONE, "ROOTFS", NULL, 0 }, + { RESOURCE_ID_CAPP, RESOURCE_SUBID_SUPPORTED, "CAPP", NULL, 0 }, + { RESOURCE_ID_IMA_CATALOG, RESOURCE_SUBID_SUPPORTED, "IMA_CATALOG", NULL, 0 }, + { RESOURCE_ID_VERSION, RESOURCE_SUBID_NONE, "VERSION", NULL, 0 }, }; const char *flash_map_resource_name(enum resource_id id) @@ -855,8 +858,19 @@ int flash_resource_loaded(enum resource_id id, uint32_t subid) struct flash_load_resource_item *resource = NULL; struct flash_load_resource_item *r; int rc = OPAL_BUSY; + int i; lock(&flash_load_resource_lock); + + for (i = 0; i < ARRAY_SIZE(part_name_map); i++) { + if (part_name_map[i].id == id && + subid == RESOURCE_SUBID_NONE && + part_name_map[i].cache) { + unlock(&flash_load_resource_lock); + return OPAL_SUCCESS; + } + } + list_for_each(&flash_loaded_resources, r, link) { if (r->id == id && r->subid == subid) { resource = r; @@ -884,6 +898,7 @@ static void flash_load_resources(void *data __unused) { struct flash_load_resource_item *r; int result; + int i; lock(&flash_load_resource_lock); do { @@ -901,6 +916,19 @@ static void flash_load_resources(void *data __unused) result = flash_load_resource(r->id, r->subid, r->buf, r->len); lock(&flash_load_resource_lock); + + /* Cache the resource */ + for (i = 0; i < ARRAY_SIZE(part_name_map); i++) { + if (part_name_map[i].id == r->id && + r->subid == RESOURCE_SUBID_NONE) { + part_name_map[i].cache = local_alloc(next_chip(NULL)->id, *r->len, 4); + if (!part_name_map[i].cache) + break; + memcpy(part_name_map[i].cache, r->buf, *r->len); + part_name_map[i].len = *r->len; + } + } + r = list_pop(&flash_load_resource_queue, struct flash_load_resource_item, link); r->result = result; @@ -925,6 +953,17 @@ int flash_start_preload_resource(enum resource_id id, uint32_t subid, { struct flash_load_resource_item *r; bool start_thread = false; + int i; + + for (i = 0; i < ARRAY_SIZE(part_name_map); i++) { + if (part_name_map[i].id == id && + subid == RESOURCE_SUBID_NONE && + part_name_map[i].cache) { + *len = part_name_map[i].len; + memcpy(buf, part_name_map[i].cache, *len); + return OPAL_SUCCESS; + } + } r = malloc(sizeof(struct flash_load_resource_item)); diff --git a/core/init.c b/core/init.c index b660af2d7824..d5a1c3c769a5 100644 --- a/core/init.c +++ b/core/init.c @@ -344,7 +344,7 @@ bool start_preload_kernel(void) return true; } -static bool load_kernel(void) +bool load_kernel(void) { void *stb_container = NULL; struct elf_hdr *kh; @@ -435,7 +435,7 @@ static bool load_kernel(void) return true; } -static void load_initramfs(void) +void load_initramfs(void) { uint64_t *initramfs_start; void *stb_container = NULL; @@ -476,7 +476,7 @@ static void load_initramfs(void) void *fdt; -void __noreturn load_and_boot_kernel(bool is_reboot) +void __noreturn boot_kernel(bool is_reboot) { const struct dt_property *memprop; const char *cmdline, *stdoutp; @@ -494,14 +494,6 @@ void __noreturn load_and_boot_kernel(bool is_reboot) if (platform.exit) platform.exit(); - /* Load kernel LID */ - if (!load_kernel()) { - op_display(OP_FATAL, OP_MOD_INIT, 1); - abort(); - } - - load_initramfs(); - trustedboot_exit_boot_services(); ipmi_set_fw_progress_sensor(IPMI_FW_OS_BOOT); @@ -1146,6 +1138,14 @@ void __noreturn __nomcount main_cpu_entry(const void *fdt) /* Add the list of interrupts going to OPAL */ add_opal_interrupts(); + /* Load kernel LID */ + if (!load_kernel()) { + op_display(OP_FATAL, OP_MOD_INIT, 1); + abort(); + } + + load_initramfs(); + /* Now release parts of memory nodes we haven't used ourselves... */ mem_region_release_unused(); @@ -1164,7 +1164,7 @@ void __noreturn __nomcount main_cpu_entry(const void *fdt) /* On P9, switch to radix mode by default */ cpu_set_radix_mode(); - load_and_boot_kernel(false); + boot_kernel(false); } void __noreturn __secondary_cpu_entry(void) diff --git a/include/skiboot.h b/include/skiboot.h index bba76c12c39e..432008cf1d11 100644 --- a/include/skiboot.h +++ b/include/skiboot.h @@ -184,7 +184,9 @@ extern int64_t opal_signal_system_reset(int cpu_nr); extern void disable_fast_reboot(const char *reason); extern void fast_reboot(void); extern void __noreturn __secondary_cpu_entry(void); -extern void __noreturn load_and_boot_kernel(bool is_reboot); +extern bool load_kernel(void); +extern void load_initramfs(void); +extern void __noreturn boot_kernel(bool is_reboot); extern void cleanup_local_tlb(void); extern void cleanup_global_tlb(void); extern void init_shared_sprs(void);