Received: by 10.213.65.68 with SMTP id h4csp40039imn; Mon, 19 Mar 2018 18:51:48 -0700 (PDT) X-Google-Smtp-Source: AG47ELvY1DNUYUI3j/jm7Srsr4rcBO6bW05gFgLb85YflCGB3V0bSJYXmoPXqC8/PQFu9S/k+Bck X-Received: by 10.99.151.74 with SMTP id d10mr10892058pgo.219.1521510708491; Mon, 19 Mar 2018 18:51:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521510708; cv=none; d=google.com; s=arc-20160816; b=FQBdzPiUiCOElJlAViIOyvnGxiUpOil+X2/5J7NL3r6NHI03yynSHjmFyVJS2X3N2r r1uIbgZ3+siKIwEgaBIZmZvpYqn49aESSN2iY3YmupMNTTP/Rwd19lxR9QUO7jGoKall EbcY9DUg+lYV29ibUz+QuaiwQA3O2VJlIXbjs5IcKRzw9bM5IEKzN5dhofUjvBjMnq8b aGiDUWdclJHv8PVfxeFheZvrE6Y1WewM96T2rDterxbdBP+UCzKcysDFjBMJg5PEb7b0 7QbR+Vx4PS9Bp2TdVxlvGKXFdpnAZPStAinzvOjUQQFX87MsBUvFbaA2GtpXlJSDT1pC QJ3w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:organization:from:references:cc:to:subject :arc-authentication-results; bh=Kw/YvBpMMyAY0BeDAaYKukO2XoQDCCq4r7BBe/qrO9c=; b=gXzcCqFFjUeyqUtPj59aTDqjRkjkcJp5h9srinQcoxwJhJef1ZDsAkPyGdhJG5/8wR KWuML1LaSnIxyhiIyjjq2wVrDl97YvpR+zYim24peH/AozejHmLnRkprIobE4Ub2+UdE rqiZITsISA/DTc4EhNCiAKRzsszezSQuMXZBNskfmIrtGtTENSRBDL69Tzo5R2EjUHFz a2ZYyBA/VmZXztLj8WgFehnBZaYc7GfIrB555jQEbK0GLcxKO4+L8/horI/fqReHbGvz scYqH+P95o4qKnFLXmRnT6qw688PyuYOnBB36aiWx77a1ltkBvhx/zLxmFqSf/uPdx4C dnHA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h67si399057pgc.353.2018.03.19.18.51.34; Mon, 19 Mar 2018 18:51:48 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S971459AbeCSUne (ORCPT + 99 others); Mon, 19 Mar 2018 16:43:34 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:35566 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S971364AbeCSUn3 (ORCPT ); Mon, 19 Mar 2018 16:43:29 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id DED4F8D77A; Mon, 19 Mar 2018 20:43:28 +0000 (UTC) Received: from jlaw-desktop.bos.csb (dhcp-17-208.bos.redhat.com [10.18.17.208]) by smtp.corp.redhat.com (Postfix) with ESMTP id C2DBC2166BB2; Mon, 19 Mar 2018 20:43:28 +0000 (UTC) Subject: Re: [PATCH 1/2] sched/debug: fix per-task line continuation for console To: Peter Zijlstra Cc: linux-kernel@vger.kernel.org, Ingo Molnar References: <1521484555-8620-1-git-send-email-joe.lawrence@redhat.com> <1521484555-8620-2-git-send-email-joe.lawrence@redhat.com> <20180319201723.GK4043@hirez.programming.kicks-ass.net> From: Joe Lawrence Organization: Red Hat Message-ID: <6b826ab1-c6a4-244e-ace6-d735b415a268@redhat.com> Date: Mon, 19 Mar 2018 16:43:28 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.0 MIME-Version: 1.0 In-Reply-To: <20180319201723.GK4043@hirez.programming.kicks-ass.net> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Mon, 19 Mar 2018 20:43:28 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Mon, 19 Mar 2018 20:43:28 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'joe.lawrence@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 03/19/2018 04:17 PM, Peter Zijlstra wrote: > On Mon, Mar 19, 2018 at 02:35:54PM -0400, Joe Lawrence wrote: >> When the SEQ_printf() macro prints to the console, it runs a simple >> printk() without KERN_CONT "continued" line printing. The result of >> this is oddly wrapped task info, for example: >> >> % echo t > /proc/sysrq-trigger >> % dmesg >> ... >> runnable tasks: >> ... >> [ 29.608611] I >> [ 29.608613] rcu_sched 8 3252.013846 4087 120 >> [ 29.608614] 0.000000 29.090111 0.000000 >> [ 29.608615] 0 0 >> [ 29.608616] / >> >> Modify SEQ_printf to use pr_cont() for expected one-line results: >> >> % echo t > /proc/sysrq-trigger >> % dmesg >> ... >> runnable tasks: >> ... >> [ 106.716329] S cpuhp/5 37 2006.315026 14 120 0.000000 0.496893 0.000000 0 0 / >> >> Signed-off-by: Joe Lawrence >> --- >> kernel/sched/debug.c | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/kernel/sched/debug.c b/kernel/sched/debug.c >> index 1ca0130ed4f9..50026aa2d81e 100644 >> --- a/kernel/sched/debug.c >> +++ b/kernel/sched/debug.c >> @@ -32,7 +32,7 @@ >> if (m) \ >> seq_printf(m, x); \ >> else \ >> - printk(x); \ >> + pr_cont(x); \ > > That used to work I think.. I think someone changed how printk() behaves > somewhere along the lines. > Hi Peter, This code: printk("printk one"); printk("printk two\n"); pr_cont("\n"); pr_cont("pr_cont one"); pr_cont("pr_cont two\n"); pr_cont("pr_cont first line\n"); pr_cont("\n"); pr_cont("\n"); pr_cont("pr_cont next line"); Creates this output: % uname -r 4.16.0-rc5+ % dmesg [ 575.221280] printk one [ 575.221281] printk two [ 575.221282] pr_cont onepr_cont two [ 575.221283] pr_cont first line I don't have the commit offhand that changed the printk behavior, but from observation: 1 - printk implies a trailing newline: https://lwn.net/Articles/732420/ 2 - pr_cont seems to eat redundant newlines > Does pr_cont("\n") DTRT? it seems like something weird. > Yeah, pr_cont() is kind of a hack. It will terminate a line if that's the first newline, but as demonstrated above, I don't think it likes extra newline chars. A better fix would be to marshal the text into temp buffer then dump it out. Dunno if you prefer that kind of churn for these stats. -- Joe