From patchwork Thu Jun 28 02:54:56 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stewart Smith X-Patchwork-Id: 935862 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 41GPYH0q05z9ry1 for ; Thu, 28 Jun 2018 12:56:03 +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 41GPYG3MbfzF1LJ for ; Thu, 28 Jun 2018 12:56:02 +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.158.5; 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 (mx0b-001b2d01.pphosted.com [148.163.158.5]) (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 41GPXk1R1hzF1KD for ; Thu, 28 Jun 2018 12:55:33 +1000 (AEST) Received: from pps.filterd (m0098416.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w5S2rugZ128733 for ; Wed, 27 Jun 2018 22:55:31 -0400 Received: from e31.co.us.ibm.com (e31.co.us.ibm.com [32.97.110.149]) by mx0b-001b2d01.pphosted.com with ESMTP id 2jvjy5ghg1-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 27 Jun 2018 22:55:31 -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:30 -0600 Received: from b03cxnp07029.gho.boulder.ibm.com (9.17.130.16) 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:27 -0600 Received: from b03ledav006.gho.boulder.ibm.com (b03ledav006.gho.boulder.ibm.com [9.17.130.237]) by b03cxnp07029.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w5S2tQ4V5374264 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 27 Jun 2018 19:55:26 -0700 Received: from b03ledav006.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 86F43C6061; Wed, 27 Jun 2018 20:55:26 -0600 (MDT) Received: from b03ledav006.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A9EDBC6059; Wed, 27 Jun 2018 20:55:25 -0600 (MDT) Received: from birb.localdomain (unknown [9.102.42.25]) by b03ledav006.gho.boulder.ibm.com (Postfix) with SMTP; Wed, 27 Jun 2018 20:55:25 -0600 (MDT) Received: by birb.localdomain (Postfix, from userid 1000) id 8BB284EC69D; Thu, 28 Jun 2018 12:55:21 +1000 (AEST) From: Stewart Smith To: Nicholas Piggin , Stewart Smith Date: Thu, 28 Jun 2018 12:54:56 +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-00000DC97D91 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:28 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18062802-8236-0000-0000-000041AE6293 Message-Id: <20180628025501.20676-2-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=2 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 1/6] Add cpu_queue_job_on_node() to do node local jobs 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" From: Nicholas Piggin For things like clearing memory on fast reboot, running these node local is a good idea. I made it strict (run on this chip_id or return NULL) because I figured firmware might get some particular requirements like that. But it's easy to make it a fallback, just test if (!cpu) cpu = cpu_find_job_target(-1); -- you'd have to put a fallback into the caller otherwise. From Nick Piggin, and I haven't really looked at/reviewed yet, but hey, it seems to work :) --- core/cpu.c | 77 ++++++++++++++++++++++++++++++++++++++++----------- include/cpu.h | 4 +++ 2 files changed, 65 insertions(+), 16 deletions(-) diff --git a/core/cpu.c b/core/cpu.c index a8936fab0fe2..ede966b356e8 100644 --- a/core/cpu.c +++ b/core/cpu.c @@ -106,7 +106,11 @@ static void cpu_wake(struct cpu_thread *cpu) } } -static struct cpu_thread *cpu_find_job_target(void) +/* + * If chip_id is >= 0, schedule the job on that node. + * Otherwise schedule the job anywhere. + */ +static struct cpu_thread *cpu_find_job_target(int32_t chip_id) { struct cpu_thread *cpu, *best, *me = this_cpu(); uint32_t best_count; @@ -126,6 +130,8 @@ static struct cpu_thread *cpu_find_job_target(void) for_each_available_cpu(cpu) { if (cpu == me || !cpu_is_thread0(cpu) || cpu->job_has_no_return) continue; + if (chip_id >= 0 && cpu->chip_id != chip_id) + continue; if (cpu->job_count) continue; lock(&cpu->job_lock); @@ -145,6 +151,8 @@ static struct cpu_thread *cpu_find_job_target(void) for_each_available_cpu(cpu) { if (cpu == me || cpu->job_has_no_return) continue; + if (chip_id >= 0 && cpu->chip_id != chip_id) + continue; if (!best || cpu->job_count < best_count) { best = cpu; best_count = cpu->job_count; @@ -167,6 +175,26 @@ static struct cpu_thread *cpu_find_job_target(void) return NULL; } +/* job_lock is held, returns with it released */ +static void queue_job_on_cpu(struct cpu_thread *cpu, struct cpu_job *job) +{ + /* That's bad, the job will never run */ + if (cpu->job_has_no_return) { + prlog(PR_WARNING, "WARNING ! Job %s scheduled on CPU 0x%x" + " which has a no-return job on its queue !\n", + job->name, cpu->pir); + backtrace(); + } + list_add_tail(&cpu->job_queue, &job->link); + if (job->no_return) + cpu->job_has_no_return = true; + else + cpu->job_count++; + if (pm_enabled) + cpu_wake(cpu); + unlock(&cpu->job_lock); +} + struct cpu_job *__cpu_queue_job(struct cpu_thread *cpu, const char *name, void (*func)(void *data), void *data, @@ -196,7 +224,7 @@ struct cpu_job *__cpu_queue_job(struct cpu_thread *cpu, /* Pick a candidate. Returns with target queue locked */ if (cpu == NULL) - cpu = cpu_find_job_target(); + cpu = cpu_find_job_target(-1); else if (cpu != this_cpu()) lock(&cpu->job_lock); else @@ -209,21 +237,38 @@ struct cpu_job *__cpu_queue_job(struct cpu_thread *cpu, return job; } - /* That's bad, the job will never run */ - if (cpu->job_has_no_return) { - prlog(PR_WARNING, "WARNING ! Job %s scheduled on CPU 0x%x" - " which has a no-return job on its queue !\n", - job->name, cpu->pir); - backtrace(); + queue_job_on_cpu(cpu, job); + + return job; +} + +struct cpu_job *cpu_queue_job_on_node(uint32_t chip_id, + const char *name, + void (*func)(void *data), void *data) +{ + struct cpu_thread *cpu; + struct cpu_job *job; + + job = zalloc(sizeof(struct cpu_job)); + if (!job) + return NULL; + job->func = func; + job->data = data; + job->name = name; + job->complete = false; + job->no_return = false; + + /* Pick a candidate. Returns with target queue locked */ + cpu = cpu_find_job_target(chip_id); + + /* Can't be scheduled, run it now */ + if (cpu == NULL) { + unlock(&cpu->job_lock); + free(job); + return NULL; } - list_add_tail(&cpu->job_queue, &job->link); - if (no_return) - cpu->job_has_no_return = true; - else - cpu->job_count++; - if (pm_enabled) - cpu_wake(cpu); - unlock(&cpu->job_lock); + + queue_job_on_cpu(cpu, job); return job; } diff --git a/include/cpu.h b/include/cpu.h index 2ca59b9648fa..ae3185723673 100644 --- a/include/cpu.h +++ b/include/cpu.h @@ -280,6 +280,10 @@ static inline struct cpu_job *cpu_queue_job(struct cpu_thread *cpu, return __cpu_queue_job(cpu, name, func, data, false); } +extern struct cpu_job *cpu_queue_job_on_node(uint32_t chip_id, + const char *name, + void (*func)(void *data), void *data); + /* Poll job status, returns true if completed */ extern bool cpu_poll_job(struct cpu_job *job); From patchwork Thu Jun 28 02:54:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stewart Smith X-Patchwork-Id: 935863 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41GPYY29ZZz9ry1 for ; Thu, 28 Jun 2018 12:56:17 +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 41GPYY0fyJzF1KD for ; Thu, 28 Jun 2018 12:56:17 +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 41GPXk1q32zF1KG for ; Thu, 28 Jun 2018 12:55:33 +1000 (AEST) Received: from pps.filterd (m0098394.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w5S2rvIE038554 for ; Wed, 27 Jun 2018 22:55:31 -0400 Received: from e32.co.us.ibm.com (e32.co.us.ibm.com [32.97.110.150]) by mx0a-001b2d01.pphosted.com with ESMTP id 2jvk4wrgd3-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 27 Jun 2018 22:55:31 -0400 Received: from localhost by e32.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 27 Jun 2018 20:55:30 -0600 Received: from b03cxnp07029.gho.boulder.ibm.com (9.17.130.16) by e32.co.us.ibm.com (192.168.1.132) 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:27 -0600 Received: from b03ledav004.gho.boulder.ibm.com (b03ledav004.gho.boulder.ibm.com [9.17.130.235]) by b03cxnp07029.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w5S2tQ7K9503096 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 27 Jun 2018 19:55:27 -0700 Received: from b03ledav004.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id DC99778067; Wed, 27 Jun 2018 20:55:26 -0600 (MDT) Received: from b03ledav004.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id DC80B78060; Wed, 27 Jun 2018 20:55:25 -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:25 -0600 (MDT) Received: by birb.localdomain (Postfix, from userid 1000) id 942944EC6A0; Thu, 28 Jun 2018 12:55:21 +1000 (AEST) From: Stewart Smith To: Nicholas Piggin , Stewart Smith Date: Thu, 28 Jun 2018 12:54:57 +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-0004-0000-0000-0000145AFE3C 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.00540073; IPR=6.00831268; MB=3.00021894; MTD=3.00000008; XFM=3.00000015; UTC=2018-06-28 02:55:29 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18062802-0005-0000-0000-000087E477FA Message-Id: <20180628025501.20676-3-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=2 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 2/6] fast-reboot: parallel memory clearing 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" Arbitrarily pick 16GB as the unit of parallelism, and split up clearing memory into jobs and schedule them node-local to the memory (or on node 0 if we can't work that out because it's the memory up to SKIBOOT_BASE) This seems to cut at least ~40% time from memory zeroing on fast-reboot on a 256GB Boston system. Signed-off-by: Stewart Smith --- core/device.c | 2 +- core/mem_region.c | 94 ++++++++++++++++++- core/test/dummy-cpu.h | 40 ++++++++ core/test/run-malloc-speed.c | 7 +- core/test/run-malloc.c | 7 +- core/test/run-mem_range_is_reserved.c | 8 +- core/test/run-mem_region.c | 10 +- core/test/run-mem_region_init.c | 8 +- core/test/run-mem_region_next.c | 8 +- core/test/run-mem_region_release_unused.c | 8 +- .../run-mem_region_release_unused_noalloc.c | 8 +- core/test/run-mem_region_reservations.c | 8 +- core/test/stubs.c | 44 +++++++++ hdata/test/hdata_to_dt.c | 9 ++ hdata/test/stubs.c | 47 ++++++++++ include/device.h | 5 +- 16 files changed, 255 insertions(+), 58 deletions(-) create mode 100644 core/test/dummy-cpu.h diff --git a/core/device.c b/core/device.c index 38dbdfc09f30..19a8d8d60cd2 100644 --- a/core/device.c +++ b/core/device.c @@ -955,7 +955,7 @@ u64 dt_get_address(const struct dt_node *node, unsigned int index, return dt_get_number(p->prop + pos, na); } -static u32 __dt_get_chip_id(const struct dt_node *node) +u32 __dt_get_chip_id(const struct dt_node *node) { const struct dt_property *prop; diff --git a/core/mem_region.c b/core/mem_region.c index 8ae49bb790fd..a8f18b01a17b 100644 --- a/core/mem_region.c +++ b/core/mem_region.c @@ -1206,19 +1206,52 @@ static void mem_clear_range(uint64_t s, uint64_t e) return; } - prlog(PR_NOTICE, "Clearing region %llx-%llx\n", + prlog(PR_DEBUG, "Clearing region %llx-%llx\n", (long long)s, (long long)e); memset((void *)s, 0, e - s); } +struct mem_region_clear_job_args { + char *job_name; + uint64_t s,e; +}; + +static void mem_region_clear_job(void *data) +{ + struct mem_region_clear_job_args *arg = (struct mem_region_clear_job_args*)data; + mem_clear_range(arg->s, arg->e); +} + +#define MEM_REGION_CLEAR_JOB_SIZE (16ULL*(1<<30)) + void mem_region_clear_unused(void) { + int njobs = 0; + struct cpu_job **jobs; struct mem_region *r; + struct mem_region_clear_job_args *job_args; + uint64_t s,l; + uint64_t total = 0; + uint32_t chip_id; + char *path; + int i; lock(&mem_region_lock); assert(mem_regions_finalised); + list_for_each(®ions, r, list) { + if (!(r->type == REGION_OS)) + continue; + njobs++; + /* One job per 16GB */ + njobs += r->len / MEM_REGION_CLEAR_JOB_SIZE; + } + + jobs = malloc(njobs * sizeof(struct cpu_job*)); + job_args = malloc(njobs * sizeof(struct mem_region_clear_job_args)); + prlog(PR_NOTICE, "Clearing unused memory:\n"); + i = 0; list_for_each(®ions, r, list) { /* If it's not unused, ignore it. */ if (!(r->type == REGION_OS)) @@ -1226,9 +1259,66 @@ void mem_region_clear_unused(void) assert(r != &skiboot_heap); - mem_clear_range(r->start, r->start + r->len); + s = r->start; + l = r->len; + while(l > MEM_REGION_CLEAR_JOB_SIZE) { + job_args[i].s = s+l - MEM_REGION_CLEAR_JOB_SIZE; + job_args[i].e = s+l; + l-=MEM_REGION_CLEAR_JOB_SIZE; + job_args[i].job_name = malloc(sizeof(char)*100); + total+=MEM_REGION_CLEAR_JOB_SIZE; + chip_id = __dt_get_chip_id(r->node); + if (chip_id == -1) + chip_id = 0; + path = dt_get_path(r->node); + snprintf(job_args[i].job_name, 100, + "clear %s, %s 0x%"PRIx64" len: %"PRIx64" on %d", + r->name, path, + job_args[i].s, + (job_args[i].e - job_args[i].s), + chip_id); + free(path); + printf("job: %s\n", job_args[i].job_name); + jobs[i] = cpu_queue_job_on_node(chip_id, + job_args[i].job_name, + mem_region_clear_job, + &job_args[i]); + i++; + } + job_args[i].s = s; + job_args[i].e = s+l; + job_args[i].job_name = malloc(sizeof(char)*100); + total+=l; + chip_id = __dt_get_chip_id(r->node); + if (chip_id == -1) + chip_id = 0; + path = dt_get_path(r->node); + snprintf(job_args[i].job_name,100, + "clear %s, %s 0x%"PRIx64" len: 0x%"PRIx64" on %d", + r->name, path, + job_args[i].s, + (job_args[i].e - job_args[i].s), + chip_id); + free(path); + printf("job: %s\n", job_args[i].job_name); + jobs[i] = cpu_queue_job_on_node(chip_id, + job_args[i].job_name, + mem_region_clear_job, + &job_args[i]); + i++; + } + cpu_process_local_jobs(); + l = 0; + for(i=0; i < njobs; i++) { + cpu_wait_job(jobs[i], true); + l += (job_args[i].e - job_args[i].s); + printf("Clearing memory... %"PRIu64"/%"PRIu64"GB done\n", + l>>30, total>>30); + free(job_args[i].job_name); } unlock(&mem_region_lock); + free(jobs); + free(job_args); } static void mem_region_add_dt_reserved_node(struct dt_node *parent, diff --git a/core/test/dummy-cpu.h b/core/test/dummy-cpu.h new file mode 100644 index 000000000000..46f180cde1e8 --- /dev/null +++ b/core/test/dummy-cpu.h @@ -0,0 +1,40 @@ +/* Copyright 2013-2018 IBM Corp. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + * implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* A dummy cpu.h for tests. + * We don't want to include the real skiboot cpu.h, it's PPC-specific + */ + +#ifndef __CPU_H +#define __CPU_H + +#include +#include + +static unsigned int cpu_max_pir = 1; +struct cpu_thread { + unsigned int chip_id; +}; +struct cpu_job *__cpu_queue_job(struct cpu_thread *cpu, + const char *name, + void (*func)(void *data), void *data, + bool no_return); +void cpu_wait_job(struct cpu_job *job, bool free_it); +void cpu_process_local_jobs(void); +struct cpu_job *cpu_queue_job_on_node(uint32_t chip_id, + const char *name, + void (*func)(void *data), void *data); +#endif /* __CPU_H */ diff --git a/core/test/run-malloc-speed.c b/core/test/run-malloc-speed.c index d842bd6432c4..8ecef3a09f24 100644 --- a/core/test/run-malloc-speed.c +++ b/core/test/run-malloc-speed.c @@ -17,12 +17,7 @@ #include #define BITS_PER_LONG (sizeof(long) * 8) -/* Don't include this, it's PPC-specific */ -#define __CPU_H -static unsigned int cpu_max_pir = 1; -struct cpu_thread { - unsigned int chip_id; -}; +#include "dummy-cpu.h" #include diff --git a/core/test/run-malloc.c b/core/test/run-malloc.c index 2feaacb95974..0204e77d6326 100644 --- a/core/test/run-malloc.c +++ b/core/test/run-malloc.c @@ -18,12 +18,7 @@ #define BITS_PER_LONG (sizeof(long) * 8) -/* Don't include this, it's PPC-specific */ -#define __CPU_H -static unsigned int cpu_max_pir = 1; -struct cpu_thread { - unsigned int chip_id; -}; +#include "dummy-cpu.h" #include diff --git a/core/test/run-mem_range_is_reserved.c b/core/test/run-mem_range_is_reserved.c index 37f7db3f744c..f44f1c2db6fd 100644 --- a/core/test/run-mem_range_is_reserved.c +++ b/core/test/run-mem_range_is_reserved.c @@ -17,12 +17,8 @@ #include #define BITS_PER_LONG (sizeof(long) * 8) -/* Don't include this, it's PPC-specific */ -#define __CPU_H -static unsigned int cpu_max_pir = 1; -struct cpu_thread { - unsigned int chip_id; -}; + +#include "dummy-cpu.h" #include diff --git a/core/test/run-mem_region.c b/core/test/run-mem_region.c index f2506d65f19a..1fd20937e12f 100644 --- a/core/test/run-mem_region.c +++ b/core/test/run-mem_region.c @@ -15,14 +15,12 @@ */ #include +#include +#include #define BITS_PER_LONG (sizeof(long) * 8) -/* Don't include this, it's PPC-specific */ -#define __CPU_H -static unsigned int cpu_max_pir = 1; -struct cpu_thread { - unsigned int chip_id; -}; + +#include "dummy-cpu.h" #include #include diff --git a/core/test/run-mem_region_init.c b/core/test/run-mem_region_init.c index f1028da32703..f70d70f85280 100644 --- a/core/test/run-mem_region_init.c +++ b/core/test/run-mem_region_init.c @@ -17,12 +17,8 @@ #include #define BITS_PER_LONG (sizeof(long) * 8) -/* Don't include this, it's PPC-specific */ -#define __CPU_H -static unsigned int cpu_max_pir = 1; -struct cpu_thread { - unsigned int chip_id; -}; + +#include "dummy-cpu.h" #include diff --git a/core/test/run-mem_region_next.c b/core/test/run-mem_region_next.c index 72d02a981a6e..fec5df8f7c13 100644 --- a/core/test/run-mem_region_next.c +++ b/core/test/run-mem_region_next.c @@ -17,12 +17,8 @@ #include #define BITS_PER_LONG (sizeof(long) * 8) -/* Don't include this, it's PPC-specific */ -#define __CPU_H -static unsigned int cpu_max_pir = 1; -struct cpu_thread { - unsigned int chip_id; -}; + +#include "dummy-cpu.h" #include #include diff --git a/core/test/run-mem_region_release_unused.c b/core/test/run-mem_region_release_unused.c index fdd273a7f55b..4fe62ca5dc39 100644 --- a/core/test/run-mem_region_release_unused.c +++ b/core/test/run-mem_region_release_unused.c @@ -17,12 +17,8 @@ #include #define BITS_PER_LONG (sizeof(long) * 8) -/* Don't include this, it's PPC-specific */ -#define __CPU_H -static unsigned int cpu_max_pir = 1; -struct cpu_thread { - unsigned int chip_id; -}; + +#include "dummy-cpu.h" #include diff --git a/core/test/run-mem_region_release_unused_noalloc.c b/core/test/run-mem_region_release_unused_noalloc.c index 6ae79591f08e..fe571350d957 100644 --- a/core/test/run-mem_region_release_unused_noalloc.c +++ b/core/test/run-mem_region_release_unused_noalloc.c @@ -17,12 +17,8 @@ #include #define BITS_PER_LONG (sizeof(long) * 8) -/* Don't include this, it's PPC-specific */ -#define __CPU_H -static unsigned int cpu_max_pir = 1; -struct cpu_thread { - unsigned int chip_id; -}; + +#include "dummy-cpu.h" #include diff --git a/core/test/run-mem_region_reservations.c b/core/test/run-mem_region_reservations.c index ae885829645f..b0e484740ff0 100644 --- a/core/test/run-mem_region_reservations.c +++ b/core/test/run-mem_region_reservations.c @@ -17,12 +17,8 @@ #include #define BITS_PER_LONG (sizeof(long) * 8) -/* Don't include this, it's PPC-specific */ -#define __CPU_H -static unsigned int cpu_max_pir = 1; -struct cpu_thread { - unsigned int chip_id; -}; + +#include "dummy-cpu.h" #include diff --git a/core/test/stubs.c b/core/test/stubs.c index 39ff18d8f103..939e3dc7950b 100644 --- a/core/test/stubs.c +++ b/core/test/stubs.c @@ -16,6 +16,7 @@ #include #include #include +#include #include "../../ccan/list/list.c" @@ -41,6 +42,49 @@ static void stub_function(void) abort(); } +struct cpu_thread; + +struct cpu_job *__cpu_queue_job(struct cpu_thread *cpu, + const char *name, + void (*func)(void *data), void *data, + bool no_return); +void cpu_wait_job(struct cpu_job *job, bool free_it); +void cpu_process_local_jobs(void); +struct cpu_job *cpu_queue_job_on_node(uint32_t chip_id, + const char *name, + void (*func)(void *data), void *data); + +struct cpu_job *cpu_queue_job_on_node(uint32_t chip_id, + const char *name, + void (*func)(void *data), void *data) +{ + (void)chip_id; + return __cpu_queue_job(NULL, name, func, data, false); +} + +struct cpu_job *__cpu_queue_job(struct cpu_thread *cpu, + const char *name, + void (*func)(void *data), void *data, + bool no_return) +{ + (void)cpu; + (void)name; + (func)(data); + (void)no_return; + return NULL; +} + +void cpu_wait_job(struct cpu_job *job, bool free_it) +{ + (void)job; + (void)free_it; + return; +} + +void cpu_process_local_jobs(void) +{ +} + #define STUB(fnname) \ void fnname(void) __attribute__((weak, alias ("stub_function"))) diff --git a/hdata/test/hdata_to_dt.c b/hdata/test/hdata_to_dt.c index 8c61b4f62a48..bd11fb0b40e7 100644 --- a/hdata/test/hdata_to_dt.c +++ b/hdata/test/hdata_to_dt.c @@ -83,6 +83,15 @@ struct cpu_thread { uint32_t pir; uint32_t chip_id; }; +struct cpu_job *__cpu_queue_job(struct cpu_thread *cpu, + const char *name, + void (*func)(void *data), void *data, + bool no_return); +void cpu_wait_job(struct cpu_job *job, bool free_it); +void cpu_process_local_jobs(void); +struct cpu_job *cpu_queue_job_on_node(uint32_t chip_id, + const char *name, + void (*func)(void *data), void *data); struct cpu_thread __boot_cpu, *boot_cpu = &__boot_cpu; static unsigned long fake_pvr = PVR_P7; diff --git a/hdata/test/stubs.c b/hdata/test/stubs.c index 592257051bd2..f7b1da105e0e 100644 --- a/hdata/test/stubs.c +++ b/hdata/test/stubs.c @@ -18,6 +18,7 @@ #include #include #include +#include #include @@ -84,6 +85,52 @@ void *__zalloc(size_t bytes, const char *location) return p; } +struct cpu_thread; + +struct cpu_job *__cpu_queue_job(struct cpu_thread *cpu, + const char *name, + void (*func)(void *data), void *data, + bool no_return); + +struct cpu_job *cpu_queue_job_on_node(uint32_t chip_id, + const char *name, + void (*func)(void *data), void *data); + +struct cpu_job *cpu_queue_job_on_node(uint32_t chip_id, + const char *name, + void (*func)(void *data), void *data) +{ + (void)chip_id; + return __cpu_queue_job(NULL, name, func, data, false); +} + +struct cpu_job *__cpu_queue_job(struct cpu_thread *cpu, + const char *name, + void (*func)(void *data), void *data, + bool no_return) +{ + (void)cpu; + (void)name; + (func)(data); + (void)no_return; + return NULL; +} + +void cpu_wait_job(struct cpu_job *job, bool free_it); + +void cpu_wait_job(struct cpu_job *job, bool free_it) +{ + (void)job; + (void)free_it; + return; +} + +void cpu_process_local_jobs(void); + +void cpu_process_local_jobs(void) +{ +} + /* Add any stub functions required for linking here. */ static void stub_function(void) { diff --git a/include/device.h b/include/device.h index fd66df11a1f2..a447dcd4b727 100644 --- a/include/device.h +++ b/include/device.h @@ -237,9 +237,12 @@ u32 dt_n_size_cells(const struct dt_node *node); u64 dt_get_number(const void *pdata, unsigned int cells); /* Find an ibm,chip-id property in this node; if not found, walk up the parent - * nodes. Returns -1 if no chip-id property exists. */ + * nodes. */ u32 dt_get_chip_id(const struct dt_node *node); +/* Same as dt_get_chip_id except Returns -1 if no chip-id property exists. */ +u32 __dt_get_chip_id(const struct dt_node *node); + /* Address accessors ("reg" properties parsing). No translation, * only support "simple" address forms (1 or 2 cells). Asserts * if address doesn't exist From patchwork Thu Jun 28 02:54:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stewart Smith X-Patchwork-Id: 935861 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41GPXr0yMRz9ry1 for ; Thu, 28 Jun 2018 12:55:40 +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 41GPXq6MLtzF1Kr for ; Thu, 28 Jun 2018 12:55:39 +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 41GPXj3qbZzF1JL for ; Thu, 28 Jun 2018 12:55:32 +1000 (AEST) Received: from pps.filterd (m0098399.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w5S2s7ns139546 for ; Wed, 27 Jun 2018 22:55:30 -0400 Received: from e34.co.us.ibm.com (e34.co.us.ibm.com [32.97.110.152]) by mx0a-001b2d01.pphosted.com with ESMTP id 2jvmsr52vc-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 27 Jun 2018 22:55:30 -0400 Received: from localhost by e34.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 27 Jun 2018 20:55:29 -0600 Received: from b03cxnp08026.gho.boulder.ibm.com (9.17.130.18) by e34.co.us.ibm.com (192.168.1.134) 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:27 -0600 Received: from b03ledav005.gho.boulder.ibm.com (b03ledav005.gho.boulder.ibm.com [9.17.130.236]) by b03cxnp08026.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w5S2tQKk11141612 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 27 Jun 2018 19:55:27 -0700 Received: from b03ledav005.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D9176BE04F; Wed, 27 Jun 2018 20:55:26 -0600 (MDT) Received: from b03ledav005.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 03742BE056; Wed, 27 Jun 2018 20:55:25 -0600 (MDT) Received: from birb.localdomain (unknown [9.102.42.25]) by b03ledav005.gho.boulder.ibm.com (Postfix) with SMTP; Wed, 27 Jun 2018 20:55:25 -0600 (MDT) Received: by birb.localdomain (Postfix, from userid 1000) id 9C1474EC6A1; Thu, 28 Jun 2018 12:55:21 +1000 (AEST) From: Stewart Smith To: Nicholas Piggin , Stewart Smith Date: Thu, 28 Jun 2018 12:54:58 +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-0016-0000-0000-0000090055F5 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:28 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18062802-0017-0000-0000-00003F6F645A Message-Id: <20180628025501.20676-4-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=2 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 3/6] Scan PCI and clear memory simultaneously 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" For many systems, scanning PCI takes about as much time as zeroing all of RAM, so we may as well do them at the same time and cut a few seconds off the total fast reboot time. Signed-off-by: Stewart Smith --- core/fast-reboot.c | 5 ++++- core/mem_region.c | 51 +++++++++++++++++++++++++++++--------------- include/mem_region.h | 3 ++- 3 files changed, 40 insertions(+), 19 deletions(-) diff --git a/core/fast-reboot.c b/core/fast-reboot.c index 8234799bb7a7..b7e518b1a492 100644 --- a/core/fast-reboot.c +++ b/core/fast-reboot.c @@ -371,6 +371,9 @@ void __noreturn fast_reboot_entry(void) /* Start preloading kernel and ramdisk */ start_preload_kernel(); + /* Start clearing memory */ + start_mem_region_clear_unused(); + /* Poke the consoles (see comments in the code there) */ fsp_console_reset(); @@ -396,7 +399,7 @@ void __noreturn fast_reboot_entry(void) ipmi_set_fw_progress_sensor(IPMI_FW_PCI_INIT); - mem_region_clear_unused(); + wait_mem_region_clear_unused(); /* Load and boot payload */ load_and_boot_kernel(true); diff --git a/core/mem_region.c b/core/mem_region.c index a8f18b01a17b..b8ed15fba74d 100644 --- a/core/mem_region.c +++ b/core/mem_region.c @@ -1224,31 +1224,38 @@ static void mem_region_clear_job(void *data) #define MEM_REGION_CLEAR_JOB_SIZE (16ULL*(1<<30)) -void mem_region_clear_unused(void) +static struct cpu_job **mem_clear_jobs; +static struct mem_region_clear_job_args *mem_clear_job_args; +static int mem_clear_njobs = 0; + +void start_mem_region_clear_unused(void) { - int njobs = 0; - struct cpu_job **jobs; struct mem_region *r; - struct mem_region_clear_job_args *job_args; uint64_t s,l; uint64_t total = 0; uint32_t chip_id; char *path; int i; + struct cpu_job **jobs; + struct mem_region_clear_job_args *job_args; lock(&mem_region_lock); assert(mem_regions_finalised); + mem_clear_njobs = 0; + list_for_each(®ions, r, list) { if (!(r->type == REGION_OS)) continue; - njobs++; + mem_clear_njobs++; /* One job per 16GB */ - njobs += r->len / MEM_REGION_CLEAR_JOB_SIZE; + mem_clear_njobs += r->len / MEM_REGION_CLEAR_JOB_SIZE; } - jobs = malloc(njobs * sizeof(struct cpu_job*)); - job_args = malloc(njobs * sizeof(struct mem_region_clear_job_args)); + jobs = malloc(mem_clear_njobs * sizeof(struct cpu_job*)); + job_args = malloc(mem_clear_njobs * sizeof(struct mem_region_clear_job_args)); + mem_clear_jobs = jobs; + mem_clear_job_args = job_args; prlog(PR_NOTICE, "Clearing unused memory:\n"); i = 0; @@ -1278,7 +1285,6 @@ void mem_region_clear_unused(void) (job_args[i].e - job_args[i].s), chip_id); free(path); - printf("job: %s\n", job_args[i].job_name); jobs[i] = cpu_queue_job_on_node(chip_id, job_args[i].job_name, mem_region_clear_job, @@ -1300,25 +1306,36 @@ void mem_region_clear_unused(void) (job_args[i].e - job_args[i].s), chip_id); free(path); - printf("job: %s\n", job_args[i].job_name); jobs[i] = cpu_queue_job_on_node(chip_id, job_args[i].job_name, mem_region_clear_job, &job_args[i]); i++; } + unlock(&mem_region_lock); cpu_process_local_jobs(); +} + +void wait_mem_region_clear_unused(void) +{ + uint64_t l; + uint64_t total = 0; + int i; + + for(i=0; i < mem_clear_njobs; i++) { + total += (mem_clear_job_args[i].e - mem_clear_job_args[i].s); + } + l = 0; - for(i=0; i < njobs; i++) { - cpu_wait_job(jobs[i], true); - l += (job_args[i].e - job_args[i].s); + for(i=0; i < mem_clear_njobs; i++) { + cpu_wait_job(mem_clear_jobs[i], true); + l += (mem_clear_job_args[i].e - mem_clear_job_args[i].s); printf("Clearing memory... %"PRIu64"/%"PRIu64"GB done\n", l>>30, total>>30); - free(job_args[i].job_name); + free(mem_clear_job_args[i].job_name); } - unlock(&mem_region_lock); - free(jobs); - free(job_args); + free(mem_clear_jobs); + free(mem_clear_job_args); } static void mem_region_add_dt_reserved_node(struct dt_node *parent, diff --git a/include/mem_region.h b/include/mem_region.h index 9e288dac45be..018dfa0e5eb0 100644 --- a/include/mem_region.h +++ b/include/mem_region.h @@ -65,7 +65,8 @@ size_t mem_allocated_size(const void *ptr); bool mem_check(const struct mem_region *region); bool mem_check_all(void); void mem_region_release_unused(void); -void mem_region_clear_unused(void); +void start_mem_region_clear_unused(void); +void wait_mem_region_clear_unused(void); int64_t mem_dump_free(void); void mem_dump_allocs(void); From patchwork Thu Jun 28 02:54:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stewart Smith X-Patchwork-Id: 935865 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 41GPZ76fS6z9ry1 for ; Thu, 28 Jun 2018 12:56:47 +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 41GPZ75Jh3zF1LP for ; Thu, 28 Jun 2018 12:56:47 +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.158.5; 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 (mx0b-001b2d01.pphosted.com [148.163.158.5]) (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 41GPXk2MLgzF1Kh for ; Thu, 28 Jun 2018 12:55:33 +1000 (AEST) Received: from pps.filterd (m0098421.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w5S2rwXX122849 for ; Wed, 27 Jun 2018 22:55:30 -0400 Received: from e14.ny.us.ibm.com (e14.ny.us.ibm.com [129.33.205.204]) by mx0a-001b2d01.pphosted.com with ESMTP id 2jvnf7bekt-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 27 Jun 2018 22:55:30 -0400 Received: from localhost by e14.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 27 Jun 2018 22:55:29 -0400 Received: from b01cxnp22034.gho.pok.ibm.com (9.57.198.24) by e14.ny.us.ibm.com (146.89.104.201) 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 22:55:28 -0400 Received: from b01ledav005.gho.pok.ibm.com (b01ledav005.gho.pok.ibm.com [9.57.199.110]) by b01cxnp22034.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w5S2tRlu6291850 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 28 Jun 2018 02:55:27 GMT Received: from b01ledav005.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5E452AE067; Wed, 27 Jun 2018 22:55:17 -0400 (EDT) Received: from b01ledav005.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7ACF6AE068; Wed, 27 Jun 2018 22:55:16 -0400 (EDT) Received: from birb.localdomain (unknown [9.102.42.25]) by b01ledav005.gho.pok.ibm.com (Postfix) with SMTP; Wed, 27 Jun 2018 22:55:16 -0400 (EDT) Received: by birb.localdomain (Postfix, from userid 1000) id A17BB4EC6A2; Thu, 28 Jun 2018 12:55:21 +1000 (AEST) From: Stewart Smith To: Nicholas Piggin , Stewart Smith Date: Thu, 28 Jun 2018 12:54:59 +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-0052-0000-0000-00000305327B 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:29 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18062802-0053-0000-0000-00005D2A40B8 Message-Id: <20180628025501.20676-5-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=893 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1806210000 definitions=main-1806280029 Subject: [Skiboot] [RFC v2 PATCH 4/6] mem_region: log region name on mem_alloc failure 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" This can help with debugging when trying to do node local allocations. Signed-off-by: Stewart Smith --- core/mem_region.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/mem_region.c b/core/mem_region.c index b8ed15fba74d..571ee52c929c 100644 --- a/core/mem_region.c +++ b/core/mem_region.c @@ -447,8 +447,8 @@ void *mem_alloc(struct mem_region *region, size_t size, size_t align, if (r) return r; - prerror("mem_alloc(0x%lx, 0x%lx, \"%s\") failed !\n", - size, align, location); + prerror("mem_alloc(0x%lx, 0x%lx, \"%s\", %s) failed !\n", + size, align, location, region->name); mem_dump_allocs(); return NULL; } From patchwork Thu Jun 28 02:55:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stewart Smith X-Patchwork-Id: 935866 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41GPZW07mDz9ry1 for ; Thu, 28 Jun 2018 12:57:07 +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 41GPZV5sF5zF1LQ for ; Thu, 28 Jun 2018 12:57:06 +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 41GPXl3WMFzF1JL for ; Thu, 28 Jun 2018 12:55:35 +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 w5S2ruJQ093591 for ; Wed, 27 Jun 2018 22:55:33 -0400 Received: from e36.co.us.ibm.com (e36.co.us.ibm.com [32.97.110.154]) by mx0a-001b2d01.pphosted.com with ESMTP id 2jvndhkukk-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 27 Jun 2018 22:55:32 -0400 Received: from localhost by e36.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 27 Jun 2018 20:55:32 -0600 Received: from b03cxnp08027.gho.boulder.ibm.com (9.17.130.19) by e36.co.us.ibm.com (192.168.1.136) 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 b03ledav003.gho.boulder.ibm.com (b03ledav003.gho.boulder.ibm.com [9.17.130.234]) by b03cxnp08027.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w5S2tUmN8389040 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 27 Jun 2018 19:55:30 -0700 Received: from b03ledav003.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5EF846A047; Wed, 27 Jun 2018 20:55:30 -0600 (MDT) Received: from b03ledav003.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 946996A04F; Wed, 27 Jun 2018 20:55:29 -0600 (MDT) Received: from birb.localdomain (unknown [9.102.42.25]) by b03ledav003.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 A729C4EC6A5; Thu, 28 Jun 2018 12:55:21 +1000 (AEST) From: Stewart Smith To: Nicholas Piggin , Stewart Smith Date: Thu, 28 Jun 2018 12:55:00 +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-0020-0000-0000-00000E369FF1 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-0021-0000-0000-000062173E0F Message-Id: <20180628025501.20676-6-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=2 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=963 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1806210000 definitions=main-1806280029 Subject: [Skiboot] [RFC v2 PATCH 5/6] mem_check(): Correct alignment assumptions 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" Back in the dim dark past, mem_check() was written to take the assumption that mem regions need to be sizeof(alloc_hdr) aligned. I can't see any real reason for this, so change it to sizeof(long) aligned as we count space by number of longs, so at least that kind of makes sense. We hit this assert in a future patch when preserving BOOTKERNEL across fast reboots. Signed-off-by: Stewart Smith --- core/mem_region.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/mem_region.c b/core/mem_region.c index 571ee52c929c..ce1280b64073 100644 --- a/core/mem_region.c +++ b/core/mem_region.c @@ -548,12 +548,12 @@ bool mem_check(const struct mem_region *region) struct free_hdr *f; /* Check it's sanely aligned. */ - if (region->start % sizeof(struct alloc_hdr)) { + if (region->start % sizeof(long)) { prerror("Region '%s' not sanely aligned (%llx)\n", region->name, (unsigned long long)region->start); return false; } - if ((long)region->len % sizeof(struct alloc_hdr)) { + if ((long)region->len % sizeof(long)) { prerror("Region '%s' not sane length (%llu)\n", region->name, (unsigned long long)region->len); return false; 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);