From patchwork Thu Jul 17 14:09:09 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 33783 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ie0-f199.google.com (mail-ie0-f199.google.com [209.85.223.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 87EB520CA0 for ; Thu, 17 Jul 2014 14:10:02 +0000 (UTC) Received: by mail-ie0-f199.google.com with SMTP id tr6sf21308819ieb.6 for ; Thu, 17 Jul 2014 07:10:02 -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=O5h3p37ahJ1wl9EpODYIXHmDXdfggv/yQ73Lio27Sqc=; b=mtuJRlxf0duQEotwyduTOLNKPHZAPRvzgRmCwlWgC2QNNCCaU2st6god4vH7xYEuNm uiyxQMq8qbKHEyHqZaYUDr8j7PUHBgs2EjKhC8zWpyU5f7npbqHk6yQx3f6gWC/0LiVg mmb9zRaeM1vgAkgl5VkqFB1gdInWq73eezYvUTKg9NkjlCC1t/9ZSHcDsxki6A5UZh3b WzPhs03gWHDKM7HyqfOv+dkjB7VwRVwZOtlaEY/NXY3zLwtZwTkIemOJMRUZay8JakCf 3r8j0XmQxIkzoH0T8Lzyrz6PyrLPg3+sLFr8NsbksHwDBt75Dv1XIRmgCJHszi6sCw6z HVug== X-Gm-Message-State: ALoCoQmIVr+CmvgUeibfu9f3ARRAQE9d2yllqGn7AaOpk0HzNiVdoqLktvm3YAgQ1s6X87beacoa X-Received: by 10.42.62.73 with SMTP id x9mr1178454ich.15.1405606202047; Thu, 17 Jul 2014 07:10:02 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.94.236 with SMTP id g99ls699351qge.17.gmail; Thu, 17 Jul 2014 07:10:01 -0700 (PDT) X-Received: by 10.236.37.231 with SMTP id y67mr5235875yha.146.1405606201954; Thu, 17 Jul 2014 07:10:01 -0700 (PDT) Received: from mail-vc0-f171.google.com (mail-vc0-f171.google.com [209.85.220.171]) by mx.google.com with ESMTPS id s9si6985045yhh.39.2014.07.17.07.10.01 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 17 Jul 2014 07:10:01 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.171 as permitted sender) client-ip=209.85.220.171; Received: by mail-vc0-f171.google.com with SMTP id hq11so3112003vcb.2 for ; Thu, 17 Jul 2014 07:10:01 -0700 (PDT) X-Received: by 10.220.15.8 with SMTP id i8mr18428229vca.45.1405606201360; Thu, 17 Jul 2014 07:10:01 -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 tc5csp39435vcb; Thu, 17 Jul 2014 07:10:00 -0700 (PDT) X-Received: by 10.68.111.2 with SMTP id ie2mr37415194pbb.97.1405606200298; Thu, 17 Jul 2014 07:10:00 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id xs3si2483615pbb.247.2014.07.17.07.09.54; Thu, 17 Jul 2014 07:09:54 -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 S933319AbaGQOJT (ORCPT + 23 others); Thu, 17 Jul 2014 10:09:19 -0400 Received: from mail-ie0-f179.google.com ([209.85.223.179]:39819 "EHLO mail-ie0-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933174AbaGQOJQ (ORCPT ); Thu, 17 Jul 2014 10:09:16 -0400 Received: by mail-ie0-f179.google.com with SMTP id rl12so2880339iec.24 for ; Thu, 17 Jul 2014 07:09:15 -0700 (PDT) X-Received: by 10.50.114.162 with SMTP id jh2mr28339430igb.0.1405606155836; Thu, 17 Jul 2014 07:09:15 -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 hu10sm55538179igb.22.2014.07.17.07.09.14 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 17 Jul 2014 07:09:15 -0700 (PDT) From: Alex Elder To: akpm@linux-foundation.org Cc: pmladek@suse.cz, bp@suse.de, john.stultz@linaro.org, jack@suse.cz, linux-kernel@vger.kernel.org Subject: [PATCH v2 4/6] printk: honor LOG_PREFIX in msg_print_text() Date: Thu, 17 Jul 2014 09:09:09 -0500 Message-Id: <1405606151-19875-5-git-send-email-elder@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1405606151-19875-1-git-send-email-elder@linaro.org> References: <1405606151-19875-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.171 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: , This patch fixes a problem similar to what was addressed in the previous patch. All paths that read and format log records (for consoles, and for reading via syslog and /dev/kmsg) go through msg_print_text(). That function starts with some logic to determine whether the given log record when formatted should begin with a "prefix" string, and whether it should end with a newline. That logic has a bug. The LOG_PREFIX flag in a log record indicates that when it's formatted, a log record should include a prefix. This is used to force a record to begin a new line--even if its preceding log record contained LOG_CONT (indicating its content should be combined with the next record). Like the previous patch, the problem occurs when these flags are all set: prev & LOG_CONT msg->flags & LOG_PREFIX msg->flags & LOG_CONT In that case, "prefix" should be true but it is not. The fix involves checking LOG_PREFIX when a message has its LOG_CONT flag set, and in that case allowing "prefix" to become false only if LOG_PREFIX is not set. I.e., the logic for "prefix" would become: if (prev & LOG_CONT && !(msg->flags & LOG_PREFIX)) prefix = false; if (msg->flags & LOG_CONT) if (prev & LOG_CONT && !(msg->flags & LOG_PREFIX)) prefix = false; However, note that this makes the (msg->flags & LOG_CONT) block redunant--it's handled by the test just above it. The result becomes quite a bit simpler than before. The following table concisely defines the problem: prev | msg | msg || CONT |PREFIX| CONT ||prefix ------+------+------++------ clear| clear| clear|| true clear| clear| set || true clear| set | clear|| true clear| set | set || true set | clear| clear|| false set | clear| set || false set | set | clear|| true set | set | set || false <-- should be true Signed-off-by: Alex Elder Reviewed-by: Petr Mladek --- kernel/printk/printk.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c index 5d719bf..e5ee1cb 100644 --- a/kernel/printk/printk.c +++ b/kernel/printk/printk.c @@ -1006,11 +1006,8 @@ static size_t msg_print_text(const struct printk_log *msg, enum log_flags prev, if ((prev & LOG_CONT) && !(msg->flags & LOG_PREFIX)) prefix = false; - if (msg->flags & LOG_CONT) { - if (prev & LOG_CONT) - prefix = false; + if (msg->flags & LOG_CONT) newline = false; - } do { const char *next = memchr(text, '\n', text_size);