From: Jean Sacren <sakiwit@gmail.com>
To: hpa@linux.intel.com
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: [PATCH 1/1] boot: Enhance performance by eliminating unnecessary calls to printf()
Date: Sun, 5 Jun 2011 18:40:38 -0600 [thread overview]
Message-ID: <20110606004038.GA28970@mail.gmail.com> (raw)
Hi,
Repeated calling to printf() for 13 times is a dire waste of CPU cycles.
For performance, combine all those calls into one while source code
formatting is preserved for readability.
Compile tested only.
Signed-off-by: Jean Sacren <sakiwit@gmail.com>
---
arch/x86/boot/compressed/mkpiggy.c | 30 ++++++++++++++++--------------
1 files changed, 16 insertions(+), 14 deletions(-)
diff --git a/arch/x86/boot/compressed/mkpiggy.c b/arch/x86/boot/compressed/mkpiggy.c
index 46a8238..0b6d82c 100644
--- a/arch/x86/boot/compressed/mkpiggy.c
+++ b/arch/x86/boot/compressed/mkpiggy.c
@@ -44,6 +44,7 @@ int main(int argc, char *argv[])
long ilen;
unsigned long offs;
FILE *f;
+ char *msg;
if (argc < 2) {
fprintf(stderr, "Usage: %s compressed_file\n", argv[0]);
@@ -82,21 +83,22 @@ int main(int argc, char *argv[])
offs += 64*1024 + 128; /* Add 64K + 128 bytes slack */
offs = (offs+4095) & ~4095; /* Round to a 4K boundary */
- printf(".section \".rodata..compressed\",\"a\",@progbits\n");
- printf(".globl z_input_len\n");
- printf("z_input_len = %lu\n", ilen);
- printf(".globl z_output_len\n");
- printf("z_output_len = %lu\n", (unsigned long)olen);
- printf(".globl z_extract_offset\n");
- printf("z_extract_offset = 0x%lx\n", offs);
/* z_extract_offset_negative allows simplification of head_32.S */
- printf(".globl z_extract_offset_negative\n");
- printf("z_extract_offset_negative = -0x%lx\n", offs);
-
- printf(".globl input_data, input_data_end\n");
- printf("input_data:\n");
- printf(".incbin \"%s\"\n", argv[1]);
- printf("input_data_end:\n");
+ msg = ".section \".rodata..compressed\",\"a\",@progbits\n"
+ ".globl z_input_len\n"
+ "z_input_len = %lu\n"
+ ".globl z_output_len\n"
+ "z_output_len = %lu\n"
+ ".globl z_extract_offset\n"
+ "z_extract_offset = 0x%lx\n"
+ ".globl z_extract_offset_negative\n"
+ "z_extract_offset_negative = -0x%lx\n"
+ ".globl input_data, input_data_end\n"
+ "input_data:\n"
+ ".incbin \"%s\"\n"
+ "input_data_end:\n";
+
+ printf(msg, ilen, (unsigned long)olen, offs, offs, argv[1]);
return 0;
}
--
1.7.2.2
--
Jean Sacren
next reply other threads:[~2011-06-06 0:40 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-06-06 0:40 Jean Sacren [this message]
2011-06-06 17:08 ` [PATCH 1/1] boot: Enhance performance by eliminating unnecessary calls to printf() H. Peter Anvin
2011-06-12 18:36 ` Jean Sacren
2011-06-14 18:23 ` Valdis.Kletnieks
2011-06-14 18:58 ` Bryan Donlan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20110606004038.GA28970@mail.gmail.com \
--to=sakiwit@gmail.com \
--cc=hpa@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox