From patchwork Mon May 9 11:13:37 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nikunj A Dadhania X-Patchwork-Id: 619832 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 AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3r3KWj4rkfz9snl for ; Mon, 9 May 2016 21:13:53 +1000 (AEST) Received: from ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 3r3KWj42r1zDqBM for ; Mon, 9 May 2016 21:13:53 +1000 (AEST) X-Original-To: slof@lists.ozlabs.org Delivered-To: slof@lists.ozlabs.org Received: from e28smtp06.in.ibm.com (e28smtp06.in.ibm.com [125.16.236.6]) (using TLSv1.2 with cipher CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 3r3KWd3jMJzDq5m for ; Mon, 9 May 2016 21:13:48 +1000 (AEST) Received: from localhost by e28smtp06.in.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 9 May 2016 16:43:46 +0530 Received: from d28dlp02.in.ibm.com (9.184.220.127) by e28smtp06.in.ibm.com (192.168.1.136) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 9 May 2016 16:43:44 +0530 X-IBM-Helo: d28dlp02.in.ibm.com X-IBM-MailFrom: nikunj@linux.vnet.ibm.com X-IBM-RcptTo: slof@lists.ozlabs.org Received: from d28relay09.in.ibm.com (d28relay09.in.ibm.com [9.184.220.160]) by d28dlp02.in.ibm.com (Postfix) with ESMTP id 9400A3940060 for ; Mon, 9 May 2016 16:43:42 +0530 (IST) Received: from d28av02.in.ibm.com (d28av02.in.ibm.com [9.184.220.64]) by d28relay09.in.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id u49BDftu23855250 for ; Mon, 9 May 2016 16:43:41 +0530 Received: from d28av02.in.ibm.com (localhost [127.0.0.1]) by d28av02.in.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id u49BDerY005220 for ; Mon, 9 May 2016 16:43:41 +0530 Received: from abhimanyu.in.ibm.com ([9.79.208.189]) by d28av02.in.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id u49BDefA005199; Mon, 9 May 2016 16:43:40 +0530 From: Nikunj A Dadhania To: slof@lists.ozlabs.org Date: Mon, 9 May 2016 16:43:37 +0530 Message-Id: <1462792417-3232-1-git-send-email-nikunj@linux.vnet.ibm.com> X-Mailer: git-send-email 2.5.5 X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16050911-0021-0000-0000-00000C54B0C7 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused Subject: [SLOF] [PATCH v2] rtas-nvram: optimize erase X-BeenThere: slof@lists.ozlabs.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: "Patches for https://github.com/aik/SLOF" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: slof-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "SLOF" As this was done at byte granularity, erasing complete nvram(64K default) took a lot of time. To reduce the number of rtas call per byte write which is expensive, the erase is done at one shot using the nvram_buffer that is initiated during the nvram_init call for RTAS_NVRAM. After this patch there is ~450msec improvement during boot. Default qemu booting does not provide file backed nvram, so every boot there would be full erase of 64K. Before this patch: real 0m2.214s user 0m0.015s sys 0m0.006s real 0m2.222s user 0m0.014s sys 0m0.005s real 0m2.201s user 0m0.010s sys 0m0.005s After this patch: real 0m1.762s user 0m0.014s sys 0m0.006s real 0m1.773s user 0m0.011s sys 0m0.004s real 0m1.754s user 0m0.013s sys 0m0.005s Signed-off-by: Nikunj A Dadhania Reviewed-by: Thomas Huth --- lib/libnvram/nvram.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lib/libnvram/nvram.c b/lib/libnvram/nvram.c index 473814e..99deb2a 100644 --- a/lib/libnvram/nvram.c +++ b/lib/libnvram/nvram.c @@ -373,6 +373,17 @@ void erase_nvram(int offset, int len) { int i; +#ifdef RTAS_NVRAM + char *erase_buf = get_nvram_buffer(len); + if (erase_buf) { + /* Speed up by erasing all memory at once */ + memset(erase_buf, 0, len); + nvram_store(offset, erase_buf, len); + free_nvram_buffer(erase_buf); + return; + } + /* If get_nvram_buffer failed, fall through to default code */ +#endif for (i=offset; i