From patchwork Sat Feb 19 02:47:09 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Travis X-Patchwork-Id: 574281 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p1J2lTOo024641 for ; Sat, 19 Feb 2011 02:47:42 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754091Ab1BSCrL (ORCPT ); Fri, 18 Feb 2011 21:47:11 -0500 Received: from relay3.sgi.com ([192.48.152.1]:42525 "EHLO relay.sgi.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752924Ab1BSCrL (ORCPT ); Fri, 18 Feb 2011 21:47:11 -0500 Received: from gulag1.americas.sgi.com (gulag1.americas.sgi.com [128.162.236.41]) by relay3.corp.sgi.com (Postfix) with ESMTP id 74253AC00F; Fri, 18 Feb 2011 18:47:06 -0800 (PST) Received: by gulag1.americas.sgi.com (Postfix, from userid 5508) id 1B4651037A63E; Fri, 18 Feb 2011 20:47:06 -0600 (CST) Message-Id: <20110219024705.979810372@gulag1.americas.sgi.com> References: <20110219024705.308511527@gulag1.americas.sgi.com> User-Agent: quilt/0.46-1 Date: Fri, 18 Feb 2011 20:47:09 -0600 From: Mike Travis To: Ingo Molnar Cc: Jack Steiner , Robin Holt , Len Brown , Thomas Gleixner , "H. Peter Anvin" , Andrew Morton , Yinghai Lu , linux-acpi@vger.kernel.org, x86@kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 4/6] printk: Break out printk_time Content-Disposition: inline; filename=break-out-printk_time Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Sat, 19 Feb 2011 02:47:43 +0000 (UTC) --- linux.orig/kernel/printk.c +++ linux/kernel/printk.c @@ -726,6 +726,24 @@ static inline void printk_delay(void) } } +/* Follow the token with the time */ +static inline int printk_emit_time(void) +{ + char tbuf[50], *tp; + unsigned tlen; + unsigned long long t; + unsigned long microsec_rem; + + t = cpu_clock(printk_cpu); + microsec_rem = do_div(t, 1000000000) / 1000; + tlen = sprintf(tbuf, "[%5lu.%06lu] ", (unsigned long)t, microsec_rem); + + for (tp = tbuf; tp < tbuf + tlen; tp++) + emit_log_char(*tp); + + return tlen; +} + asmlinkage int vprintk(const char *fmt, va_list args) { int printed_len = 0; @@ -810,23 +828,9 @@ asmlinkage int vprintk(const char *fmt, printed_len += 3; new_text_line = 0; - if (printk_time) { - /* Follow the token with the time */ - char tbuf[50], *tp; - unsigned tlen; - unsigned long long t; - unsigned long nanosec_rem; - - t = cpu_clock(printk_cpu); - nanosec_rem = do_div(t, 1000000000); - tlen = sprintf(tbuf, "[%5lu.%06lu] ", - (unsigned long) t, - nanosec_rem / 1000); - - for (tp = tbuf; tp < tbuf + tlen; tp++) - emit_log_char(*tp); - printed_len += tlen; - } + /* add time if requested */ + if (printk_time) + printed_len += printk_emit_time(); if (!*p) break;