Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp50521img; Sun, 17 Mar 2019 20:03:49 -0700 (PDT) X-Google-Smtp-Source: APXvYqwpP0qFmx0QWiYX5AbOQK54VwPVDpDB101lPqY0nTYqLBhbezeq0nuK/by98dz0rbrYxiY/ X-Received: by 2002:a62:1144:: with SMTP id z65mr1812953pfi.187.1552878229159; Sun, 17 Mar 2019 20:03:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552878229; cv=none; d=google.com; s=arc-20160816; b=ViSeWir0F3m8GQNRNgkGJNRvKrPKMoPHZhxu59zG/p+qVF0q2z9O2E4JoXDX1pxlPk loWiQR1+K74uBj9xd6F0UTUnz/2bwQ2u5pfBcCPuK68mnVkG63pwUmBOqajBhBDF77G9 QilWnzFaNTVpesNU7fw1vfRoMWrrSoSZzhFBFv6eJHP32p2dnwoh2nVzNYUzhrFn3Up0 sq3wwwyhqWVm+X3ImNpB8DYkSzkNtLoYvhexLFAJLSIEDBAf5VpAILAVlZ7e/cr20Mdk qy2G4fgmX4TkbWc+8mETZLdARoVa1lugDuIR1plRcNvRn61zSHQTaEOAXL0X83KRZCyy 4rQw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=fZnDLc28KwM4M8LbQEF8uqIX16CVSEwDbjI+S4Ud2PA=; b=zu3/gCuBpuyoKrmhFFcSugVNJ/gO7mr8ppHLgvXiTbdFm2bAOdvvobpk0Exkj1XNsQ fapGl9Y2qel2oIApOvWeAE4az206j56f3XY/toFATR/mIctfCsF7DjIu1i4PWB1weEuB KRElPxkyjgyUi8vDRTeXApbQOXv1B1aScHD95Z7XXHWN7EgsUi6iZkb2LWTWp60dykh/ ncgcDQTUIrG9cBxHKJSaULFrDGQeJDT2so3sOM+tXN+54AvhCMtbQB3Qt3Ktf7pBYJS3 /1JYjLCXjQKBpv3UgMdA1ka5bplSuWrs9Fauq2pbgnfONuMyoM6GU38Bob089IBTKrIJ Gbag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=UUl8BYH4; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w14si1007091pga.584.2019.03.17.20.03.33; Sun, 17 Mar 2019 20:03:49 -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; dkim=pass header.i=@linaro.org header.s=google header.b=UUl8BYH4; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727738AbfCRDCn (ORCPT + 99 others); Sun, 17 Mar 2019 23:02:43 -0400 Received: from mail-wm1-f65.google.com ([209.85.128.65]:39249 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726828AbfCRDCm (ORCPT ); Sun, 17 Mar 2019 23:02:42 -0400 Received: by mail-wm1-f65.google.com with SMTP id t124so11098550wma.4 for ; Sun, 17 Mar 2019 20:02:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=fZnDLc28KwM4M8LbQEF8uqIX16CVSEwDbjI+S4Ud2PA=; b=UUl8BYH4blelcEBifxiXclFdhpoM8CBjGOsgR2N75p2EVcoU+0mJ0zG3wjLW2ydjVi nWwspEUJcqK18egd0+KsEdcIERt1tWk2VshIlxwuMq/pgYKtg5+oKCMEE3ZTNLhvDzxz m8XtBaZb/B8SnJ3Cwq+t/+X7CxbRMqxcS1xqRU71xnOeDaJ/LP9KDwRYLTkPPTJt4tk5 fL0KVw3cPibAybm8Va77pH3NPZGCm1wJNDqCR7/kCnB2WouzXK2+FtRlTPOO+OEMb531 kdAj+EL9ufY47G3lZ63W1Yf369OqqTwN6Hv2EmPnM4lBBKPgCjvdwA0d6k5RchhYUqKy yu1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=fZnDLc28KwM4M8LbQEF8uqIX16CVSEwDbjI+S4Ud2PA=; b=bb8uI5/881dlxCQKvV1Yge/MipnI73SzlcQxmpvWdZ4go7FIw1dP7BkYluhcesXINN uDHaZYFAgzgIsJUTfwEhHK6WVnNZDQTHpICgjxnlPi4I9CBCLX0rv0cPMiBk2uKw2/n9 l2UP5X3r5o/scD5T++Qt4iOKqXCziv7O0UKpHDo2l7Jp+XRE1uawgekMsgzMla3dSqYw 4imZLqlI8Q5hBPk+hfPcCpg0ab+Cee+OV7E1JokpYfzCn6S+PkZGwOF57c3/QX3B3FKA 7Hj9ljxhScuoaluyfm+OZYNmTfAqlQ7liLMPgYKEt+ncWpVgJY5iRUwEj5ZVsjZWzq/9 VyVw== X-Gm-Message-State: APjAAAW1g97cpaoM5ukWiyX9qGNcFQ8xuIOQUyn0euDHZK4Pnz2nii+Z TeXkdAy57mCojUCx39HqwFHvAQ== X-Received: by 2002:a7b:c34d:: with SMTP id l13mr9131538wmj.37.1552878161077; Sun, 17 Mar 2019 20:02:41 -0700 (PDT) Received: from oak.lan (cpc141214-aztw34-2-0-cust773.18-1.cable.virginm.net. [86.9.19.6]) by smtp.gmail.com with ESMTPSA id c10sm1380953wrt.65.2019.03.17.20.02.40 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 17 Mar 2019 20:02:40 -0700 (PDT) Date: Mon, 18 Mar 2019 03:02:38 +0000 From: Daniel Thompson To: Douglas Anderson Cc: Steven Rostedt , Ingo Molnar , Jason Wessel , kgdb-bugreport@lists.sourceforge.net, Brian Norris , linux-kernel@vger.kernel.org Subject: Re: [PATCH v4 3/3] tracing: kdb: Allow ftdump to skip all but the last few entries Message-ID: <20190318030238.GD27232@oak.lan> References: <20190315230906.250598-1-dianders@chromium.org> <20190315230906.250598-3-dianders@chromium.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190315230906.250598-3-dianders@chromium.org> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Mar 15, 2019 at 04:09:06PM -0700, Douglas Anderson wrote: > The 'ftdump' command in kdb is currently a bit of a last resort, at > least if you have lots of traces turned on. It's going to print a > whole boatload of data out your serial port which is probably running > at 115200. This could easily take many, many minutes. > > Usually you're most interested in what's at the _end_ of the ftrace > buffer, AKA what happened most recently. That means you've got to > wait the full time for the dump. The 'ftdump' command does attempt to > help you a little bit by allowing you to skip a fixed number of > entries. Unfortunately it provides no way for you to know how many > entries you should skip. > > Let's do similar to python and allow you to use a negative number to > indicate that you want to skip all entries except the last few. This > allows you to quickly see what you want. > > Note that we also change the printout in ftdump to print the > (positive) number of entries actually skipped since that could be > helpful to know when you've specified a negative skip count. > > Signed-off-by: Douglas Anderson There's a small nitpick below but otherwise: Acked-by: Daniel Thompson > --- > > Changes in v4: > - Now uses trace_total_entries() / trace_total_entries_cpu(). > - Based upon new patch that renames "lines" to "entries". > > Changes in v3: > - Optimize counting as per Steven Rostedt. > - Down to 1 patch since patch #1 from v2 landed. > > kernel/trace/trace_kdb.c | 17 +++++++++++++++-- > 1 file changed, 15 insertions(+), 2 deletions(-) > > diff --git a/kernel/trace/trace_kdb.c b/kernel/trace/trace_kdb.c > index 4b666643d69f..996e1e9cd9a6 100644 > --- a/kernel/trace/trace_kdb.c > +++ b/kernel/trace/trace_kdb.c > @@ -39,7 +39,8 @@ static void ftrace_dump_buf(int skip_entries, long cpu_file) > /* don't look at user memory in panic mode */ > tr->trace_flags &= ~TRACE_ITER_SYM_USEROBJ; > > - kdb_printf("Dumping ftrace buffer:\n"); > + kdb_printf("Dumping ftrace buffer (skipping %d entries):\n", > + skip_entries); If someone *doesn't* need to skip any entries I'm not a fan of telling them we are "skipping 0 entries"; it is more unnerving than helpful ("huh? what does it need to tell me that no entried were skipped? what makes the tracer skip entries?... Doh... I get it"). Daniel. > > /* reset all but tr, trace, and overruns */ > memset(&iter.seq, 0, > @@ -109,6 +110,7 @@ static int kdb_ftdump(int argc, const char **argv) > int skip_entries = 0; > long cpu_file; > char *cp; > + int cnt; > > if (argc > 2) > return KDB_ARGCOUNT; > @@ -129,6 +131,16 @@ static int kdb_ftdump(int argc, const char **argv) > } > > kdb_trap_printk++; > + > + /* A negative skip_entries means skip all but the last entries */ > + if (skip_entries < 0) { > + if (cpu_file == RING_BUFFER_ALL_CPUS) > + cnt = trace_total_entries(NULL); > + else > + cnt = trace_total_entries_cpu(NULL, cpu_file); > + skip_entries = max(cnt + skip_entries, 0); > + } > + > ftrace_dump_buf(skip_entries, cpu_file); > kdb_trap_printk--; > > @@ -138,7 +150,8 @@ static int kdb_ftdump(int argc, const char **argv) > static __init int kdb_ftrace_register(void) > { > kdb_register_flags("ftdump", kdb_ftdump, "[skip_#entries] [cpu]", > - "Dump ftrace log", 0, KDB_ENABLE_ALWAYS_SAFE); > + "Dump ftrace log; -skip dumps last #entries", 0, > + KDB_ENABLE_ALWAYS_SAFE); > return 0; > } > > -- > 2.21.0.360.g471c308f928-goog >