Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp2051366imm; Mon, 16 Jul 2018 00:58:29 -0700 (PDT) X-Google-Smtp-Source: AAOMgpc5k9LvWRgvvkw/6+Y0DRuPdZjfkMF9N8/p1w/XqhEfHofSznPonIKJSkrvAC+hsv0/J8z5 X-Received: by 2002:a63:2803:: with SMTP id o3-v6mr14716348pgo.158.1531727909918; Mon, 16 Jul 2018 00:58:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531727909; cv=none; d=google.com; s=arc-20160816; b=G190XqlgXoWkDV9kApUG6Sjzx0lis3MGKq4WO5/nj2Xw91jARotqgksR5En2WIq53W C6DMFrkGoXAPAA0zCgWGNCjQlt/NOcCGQTl8U4qKSWDFPjT3DnNKKKOxCS8p9vGvhFz3 0lqnz66odm/2ncp5sFlkqNgdmNXfovJ+ybItrCc6ZjbPEApOAQ6KA7TzDTaEXN9pj++q AZJjhEGn3eSNoYHo2QJfAG7DYlTlWIX1gJF6OiWbLLeCXp6RjEF8jWUDbea60kbWqMx3 lb0knJbytP38tHcH7648WxnWd3BelKOiVeyXqtWZSMvvGJIaIo8ReMgDK0c4hopinA63 iHPw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=XvV6yXZMAAqrYA4rab034joKijdJ6vVk/nDiq5mhKlY=; b=ghha7UhEpmj0qVBwSYhWITYCUfKAC09oSKekqLQkCvBglJ3uxUrDKrDIxG1Sl9MREK odeyPr8h4PkvkIUvEKAszIEe0e+WCh3hBGPOAhXqSElBuwOr23HbqRPK8Ns6FQJ91meE ZsJF6AnxFjf5hp0Ja93qbvzJCd8WL7iLh2UD2yNLMQqjdAsXLVPptcOx6si7FR7Pej37 Z/tZnGg8uv+ivbyHgrR7iZFtl9tPi2BSLeI4C6fUYJNt6dBd3DPUH5UUraLyFb5YBdFg AlssPYOKmRvMbTSXkIdO2ZEpIatInNpynw9oDoYbRCAlqUFQpCgQNCtKkkXeSM6BoxNX fnGQ== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n22-v6si30181006pff.370.2018.07.16.00.58.14; Mon, 16 Jul 2018 00:58:29 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732071AbeGPIEB (ORCPT + 99 others); Mon, 16 Jul 2018 04:04:01 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:46826 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728460AbeGPIEB (ORCPT ); Mon, 16 Jul 2018 04:04:01 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 91308CA0; Mon, 16 Jul 2018 07:37:59 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, jreck@google.com, tkjos@google.com, "Joel Fernandes (Google)" , "Steven Rostedt (VMware)" Subject: [PATCH 4.17 40/67] tracing: Reorder display of TGID to be after PID Date: Mon, 16 Jul 2018 09:35:09 +0200 Message-Id: <20180716073449.486391288@linuxfoundation.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180716073443.294323458@linuxfoundation.org> References: <20180716073443.294323458@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.17-stable review patch. If anyone has any objections, please let me know. ------------------ From: Joel Fernandes (Google) commit f8494fa3dd10b52eab47a9666a8bc34719a129aa upstream. Currently ftrace displays data in trace output like so: _-----=> irqs-off / _----=> need-resched | / _---=> hardirq/softirq || / _--=> preempt-depth ||| / delay TASK-PID CPU TGID |||| TIMESTAMP FUNCTION | | | | |||| | | bash-1091 [000] ( 1091) d..2 28.313544: sched_switch: However Android's trace visualization tools expect a slightly different format due to an out-of-tree patch patch that was been carried for a decade, notice that the TGID and CPU fields are reversed: _-----=> irqs-off / _----=> need-resched | / _---=> hardirq/softirq || / _--=> preempt-depth ||| / delay TASK-PID TGID CPU |||| TIMESTAMP FUNCTION | | | | |||| | | bash-1091 ( 1091) [002] d..2 64.965177: sched_switch: >From kernel v4.13 onwards, during which TGID was introduced, tracing with systrace on all Android kernels will break (most Android kernels have been on 4.9 with Android patches, so this issues hasn't been seen yet). From v4.13 onwards things will break. The chrome browser's tracing tools also embed the systrace viewer which uses the legacy TGID format and updates to that are known to be difficult to make. Considering this, I suggest we make this change to the upstream kernel and backport it to all Android kernels. I believe this feature is merged recently enough into the upstream kernel that it shouldn't be a problem. Also logically, IMO it makes more sense to group the TGID with the TASK-PID and the CPU after these. Link: http://lkml.kernel.org/r/20180626000822.113931-1-joel@joelfernandes.org Cc: jreck@google.com Cc: tkjos@google.com Cc: stable@vger.kernel.org Fixes: 441dae8f2f29 ("tracing: Add support for display of tgid in trace output") Signed-off-by: Joel Fernandes (Google) Signed-off-by: Steven Rostedt (VMware) Signed-off-by: Greg Kroah-Hartman --- kernel/trace/trace.c | 8 ++++---- kernel/trace/trace_output.c | 5 +++-- 2 files changed, 7 insertions(+), 6 deletions(-) --- a/kernel/trace/trace.c +++ b/kernel/trace/trace.c @@ -3363,8 +3363,8 @@ static void print_func_help_header(struc print_event_info(buf, m); - seq_printf(m, "# TASK-PID CPU# %s TIMESTAMP FUNCTION\n", tgid ? "TGID " : ""); - seq_printf(m, "# | | | %s | |\n", tgid ? " | " : ""); + seq_printf(m, "# TASK-PID %s CPU# TIMESTAMP FUNCTION\n", tgid ? "TGID " : ""); + seq_printf(m, "# | | %s | | |\n", tgid ? " | " : ""); } static void print_func_help_header_irq(struct trace_buffer *buf, struct seq_file *m, @@ -3384,9 +3384,9 @@ static void print_func_help_header_irq(s tgid ? tgid_space : space); seq_printf(m, "# %s||| / delay\n", tgid ? tgid_space : space); - seq_printf(m, "# TASK-PID CPU#%s|||| TIMESTAMP FUNCTION\n", + seq_printf(m, "# TASK-PID %sCPU# |||| TIMESTAMP FUNCTION\n", tgid ? " TGID " : space); - seq_printf(m, "# | | | %s|||| | |\n", + seq_printf(m, "# | | %s | |||| | |\n", tgid ? " | " : space); } --- a/kernel/trace/trace_output.c +++ b/kernel/trace/trace_output.c @@ -594,8 +594,7 @@ int trace_print_context(struct trace_ite trace_find_cmdline(entry->pid, comm); - trace_seq_printf(s, "%16s-%-5d [%03d] ", - comm, entry->pid, iter->cpu); + trace_seq_printf(s, "%16s-%-5d ", comm, entry->pid); if (tr->trace_flags & TRACE_ITER_RECORD_TGID) { unsigned int tgid = trace_find_tgid(entry->pid); @@ -606,6 +605,8 @@ int trace_print_context(struct trace_ite trace_seq_printf(s, "(%5d) ", tgid); } + trace_seq_printf(s, "[%03d] ", iter->cpu); + if (tr->trace_flags & TRACE_ITER_IRQ_INFO) trace_print_lat_fmt(s, entry);