From patchwork Tue Jul 22 14:01:56 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 34093 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f197.google.com (mail-lb0-f197.google.com [209.85.217.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 10BD620540 for ; Tue, 22 Jul 2014 14:02:35 +0000 (UTC) Received: by mail-lb0-f197.google.com with SMTP id c11sf5329744lbj.4 for ; Tue, 22 Jul 2014 07:02:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=iNnCDYwlw5hUO6OQtCloarHt3SqPYpLRvxDMbxSizbw=; b=dvRvbVWh/Q3Vi50yOWz8DfbuOihghnpS6OejGFkHcoIgP2folr+hgDGv2jOMcD03a0 D6cyrFiqgdmuAf6ngqWXxjdDE5uJoV3e6H3CeFqY4A6p61yXVtRcgNPcAOVq3QR1D7aV GxUqT8cUq92R1+VtXCzqdwb6tro2HsGbvPtOl9dcXSzvT6jY8b9upgeLfJRoI+RvwGkn 2jNYcNl/RrKLLVVNKoF6UTi9gIBuR5trUFPTeH2oofP5Gcfaz8IR1kA/dnG15aprmaVl p/Khh3Hl793xy2aAnplWDtQOPOXmEuqjG1uOnvC80VvpJCbIce47zlmOGbniZE5JWT8N CkBA== X-Gm-Message-State: ALoCoQn6+r8tjw5z36cJC0n+taUes3E6vrdOfzpRHAjyt7ZiQDtTlIq3Cj2JqInv42E3jp5l2jxJ X-Received: by 10.194.21.98 with SMTP id u2mr2023020wje.1.1406037754621; Tue, 22 Jul 2014 07:02:34 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.92.120 with SMTP id a111ls2402897qge.15.gmail; Tue, 22 Jul 2014 07:02:34 -0700 (PDT) X-Received: by 10.53.13.200 with SMTP id fa8mr24040310vdd.57.1406037754428; Tue, 22 Jul 2014 07:02:34 -0700 (PDT) Received: from mail-vc0-f170.google.com (mail-vc0-f170.google.com [209.85.220.170]) by mx.google.com with ESMTPS id b17si859175vco.20.2014.07.22.07.02.28 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 22 Jul 2014 07:02:28 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.170 as permitted sender) client-ip=209.85.220.170; Received: by mail-vc0-f170.google.com with SMTP id lf12so14901588vcb.29 for ; Tue, 22 Jul 2014 07:02:28 -0700 (PDT) X-Received: by 10.221.47.9 with SMTP id uq9mr23050369vcb.48.1406037748186; Tue, 22 Jul 2014 07:02:28 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.221.37.5 with SMTP id tc5csp198726vcb; Tue, 22 Jul 2014 07:02:27 -0700 (PDT) X-Received: by 10.66.122.36 with SMTP id lp4mr33739511pab.82.1406037747212; Tue, 22 Jul 2014 07:02:27 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ez2si531567pbb.186.2014.07.22.07.02.26; Tue, 22 Jul 2014 07:02:26 -0700 (PDT) Received-SPF: none (google.com: linux-kernel-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754807AbaGVOCY (ORCPT + 14 others); Tue, 22 Jul 2014 10:02:24 -0400 Received: from mail-ie0-f179.google.com ([209.85.223.179]:41653 "EHLO mail-ie0-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751751AbaGVOBy (ORCPT ); Tue, 22 Jul 2014 10:01:54 -0400 Received: by mail-ie0-f179.google.com with SMTP id rl12so8118218iec.38 for ; Tue, 22 Jul 2014 07:01:54 -0700 (PDT) X-Received: by 10.50.147.99 with SMTP id tj3mr16731608igb.38.1406037714133; Tue, 22 Jul 2014 07:01:54 -0700 (PDT) Received: from localhost.localdomain (c-24-245-18-91.hsd1.mn.comcast.net. [24.245.18.91]) by mx.google.com with ESMTPSA id ga11sm2569229igd.8.2014.07.22.07.01.53 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 22 Jul 2014 07:01:53 -0700 (PDT) From: Alex Elder To: akpm@linux-foundation.org Cc: kay@vrfy.org, pmladek@suse.cz, bp@suse.de, john.stultz@linaro.org, jack@suse.cz, linux-kernel@vger.kernel.org Subject: [PATCH v2 1/2] printk: kill LOG_CONT Date: Tue, 22 Jul 2014 09:01:56 -0500 Message-Id: <1406037717-9670-2-git-send-email-elder@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1406037717-9670-1-git-send-email-elder@linaro.org> References: <1406037717-9670-1-git-send-email-elder@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: elder@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.170 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , The LOG_CONT and LOG_NEWLINE flags are mutually exclusive, i.e., the presence of LOG_NEWLINE implies the absense of LOG_CONT, and vice-versa. As a result, wherever LOG_CONT is used, we can equivalently substitute !LOG_NEWLINE; and we can use LOG_NEWLINE wherever !LOG_CONT is used. Switch to using LOG_NEWLINE only, and get rid of LOG_CONT. Make some refinements on a nearby block of comments. Signed-off-by: Alex Elder --- kernel/printk/printk.c | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c index 6848e7d..49c9238 100644 --- a/kernel/printk/printk.c +++ b/kernel/printk/printk.c @@ -211,7 +211,6 @@ enum log_flags { LOG_NOCONS = 1, /* already flushed, do not print to console */ LOG_NEWLINE = 2, /* text ended with a newline */ LOG_PREFIX = 4, /* text started with a prefix */ - LOG_CONT = 8, /* text is a fragment of a continuation line */ }; struct printk_log { @@ -613,22 +612,25 @@ static ssize_t devkmsg_read(struct file *file, char __user *buf, do_div(ts_usec, 1000); /* - * If we couldn't merge continuation line fragments during the print, - * export the stored flags to allow an optional external merge of the - * records. Merging the records isn't always necessarily correct, like - * when we hit a race during printing. In most cases though, it produces - * better readable output. 'c' in the record flags mark the first - * fragment of a line, '+' the following. + * Sometimes it's necessary to flush an incomplete record to the log. + * When this happens, consecutive records should be merged to produce + * a logically complete message. + * + * Indicate this to user space with a flag character. A 'c' indicates + * the first of a series of incomplete log records. A '+' indicates + * a record that should be merged with one or more earlier records. + * And a '-' indicates a "normal" self-contained single record. */ - if ((user->prev & LOG_CONT) && !(msg->flags & LOG_PREFIX)) + if (!(user->prev & LOG_NEWLINE) && !(msg->flags & LOG_PREFIX)) cont = '+'; - else if (msg->flags & LOG_CONT) + else if (!(msg->flags & LOG_NEWLINE)) cont = 'c'; else cont = '-'; /* Insert a newline if the previous line was not terminated properly */ - insert_newline = (user->prev & LOG_CONT) && (msg->flags & LOG_PREFIX); + insert_newline = !(user->prev & LOG_NEWLINE) && + (msg->flags & LOG_PREFIX); len = sprintf(user->buf, "%s%u,%llu,%llu,%c;", insert_newline ? "\n" : "", (msg->facility << 3) | msg->level, @@ -1007,13 +1009,13 @@ static size_t msg_print_text(const struct printk_log *msg, enum log_flags prev, bool newline = true; size_t len = 0; - if ((prev & LOG_CONT) && !(msg->flags & LOG_PREFIX)) + if (!(prev & LOG_NEWLINE) && !(msg->flags & LOG_PREFIX)) prefix = false; - if (msg->flags & LOG_CONT) + if (!(msg->flags & LOG_NEWLINE)) newline = false; - if ((prev & LOG_CONT) && (msg->flags & LOG_PREFIX) && len < size) { + if (!(prev & LOG_NEWLINE) && (msg->flags & LOG_PREFIX) && len < size) { if (buf) buf[len++] = '\n'; else @@ -1081,7 +1083,7 @@ static int syslog_print(char __user *buf, int size) */ syslog_seq = log_first_seq; syslog_idx = log_first_idx; - syslog_prev &= LOG_NEWLINE|LOG_CONT; + syslog_prev &= LOG_NEWLINE; syslog_partial = 0; } if (syslog_seq == log_next_seq) { @@ -1210,7 +1212,7 @@ static int syslog_print_all(char __user *buf, int size, bool clear) */ seq = log_first_seq; idx = log_first_idx; - prev &= LOG_NEWLINE|LOG_CONT; + prev &= LOG_NEWLINE; } } } @@ -1319,7 +1321,7 @@ int do_syslog(int type, char __user *buf, int len, bool from_file) */ syslog_seq = log_first_seq; syslog_idx = log_first_idx; - syslog_prev &= LOG_NEWLINE|LOG_CONT; + syslog_prev &= LOG_NEWLINE; syslog_partial = 0; } if (from_file) { @@ -1534,7 +1536,7 @@ static bool cont_add(int facility, int level, const char *text, size_t len) if (cont.len + len > sizeof(cont.buf)) { /* the line gets too long, split it up in separate records */ - cont_flush(LOG_CONT); + cont_flush(0); return false; } @@ -1552,7 +1554,7 @@ static bool cont_add(int facility, int level, const char *text, size_t len) cont.len += len; if (cont.len > (sizeof(cont.buf) * 80) / 100) - cont_flush(LOG_CONT); + cont_flush(0); return true; } @@ -1665,8 +1667,6 @@ asmlinkage int vprintk_emit(int facility, int level, if (text_len && text[text_len-1] == '\n') { text_len--; lflags = LOG_NEWLINE; - } else { - lflags = LOG_CONT; } /* strip kernel syslog prefix and extract log level or control flags */ @@ -2167,7 +2167,7 @@ again: if (console_seq < log_first_seq) { len = sprintf(text, "%s** %u printk messages dropped **\n", - (console_prev & LOG_CONT) ? "\n" : "", + (console_prev & LOG_NEWLINE) ? "" : "\n", (unsigned)(log_first_seq - console_seq)); /* Messages are gone, move to first one. */ console_seq = log_first_seq;