linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Stephen Boyd <sboyd@kernel.org>
To: Anton Vorontsov <anton@enomsg.org>, Arnd Bergmann <arnd@arndb.de>,
	Catalin Marinas <catalin.marinas@arm.com>,
	Colin Cross <ccross@android.com>, Ingo Molnar <mingo@redhat.com>,
	Jason Baron <jbaron@akamai.com>,
	Jim Cromie <jim.cromie@gmail.com>, Joe Perches <joe@perches.com>,
	Joel Fernandes <joel@joelfernandes.org>,
	Kees Cook <keescook@chromium.org>,
	Laura Abbott <labbott@redhat.com>,
	Masami Hiramatsu <mhiramat@kernel.org>,
	Rob Herring <robh+dt@kernel.org>,
	Sai Prakash Ranjan <saiprakash.ranjan@codeaurora.org>,
	Steven Rostedt <rostedt@goodmis.org>,
	Tony Luck <tony.luck@intel.com>,
	Will Deacon <will.deacon@arm.com>,
	devicetree@vger.kernel.org
Cc: Rajendra Nayak <rnayak@codeaurora.org>,
	Vivek Gautam <vivek.gautam@codeaurora.org>,
	Sibi Sankar <sibis@codeaurora.org>,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Ingo Molnar <mingo@kernel.org>,
	Tom Zanussi <tom.zanussi@linux.intel.com>,
	Prasad Sodagudi <psodagud@codeaurora.org>,
	tsoni@codeaurora.org, Bryan Huntsman <bryanh@codeaurora.org>,
	Tingwei Zhang <tingwei@codeaurora.org>
Subject: Re: [PATCH 2/6] pstore: Add event tracing support
Date: Mon, 17 Sep 2018 10:38:20 -0700	[thread overview]
Message-ID: <153720590027.119890.15984895820368075914@swboyd.mtv.corp.google.com> (raw)
In-Reply-To: <444d7b13-2653-ba0e-e9e6-a448fded2a77@codeaurora.org>

Quoting Sai Prakash Ranjan (2018-09-11 03:46:01)
> On 9/9/2018 1:57 AM, Sai Prakash Ranjan wrote:
> > +void notrace pstore_event_call(struct trace_event_buffer *fbuffer)
> > +{
> > +     struct trace_iterator *iter;
> > +     struct trace_seq *s;
> > +     struct trace_event_call *event_call;
> > +     struct pstore_record record;
> > +     struct trace_event *event;
> > +     struct seq_buf *seq;
> > +     unsigned long flags;
> > +
> > +     if (!psinfo)
> > +             return;
> > +
> > +     if (unlikely(oops_in_progress))
> > +             return;
> > +
> > +     pstore_record_init(&record, psinfo);
> > +     record.type = PSTORE_TYPE_EVENT;
> > +
> > +     iter = kmalloc(sizeof(*iter), GFP_KERNEL);
> > +     if (!iter)
> > +             return;
> > +
> > +     event_call = fbuffer->trace_file->event_call;
> > +     if (!event_call || !event_call->event.funcs ||
> > +         !event_call->event.funcs->trace)
> > +             goto fail_event;
> > +
> > +     event = &fbuffer->trace_file->event_call->event;
> > +
> > +     spin_lock_irqsave(&psinfo->buf_lock, flags);
> > +
> > +     trace_seq_init(&iter->seq);
> > +     iter->ent = fbuffer->entry;
> > +     event_call->event.funcs->trace(iter, 0, event);
> > +     trace_seq_putc(&iter->seq, 0);
> > +
> > +     if (seq->size > psinfo->bufsize)
> > +             seq->size = psinfo->bufsize;
> > +
> > +     s = &iter->seq;
> > +     seq = &s->seq;
> > +
> > +     record.buf = (char *)(seq->buffer);
> > +     record.size = seq->len;
> > +     psinfo->write(&record);
> > +
> > +     spin_unlock_irqrestore(&psinfo->buf_lock, flags);
> > +
> > +fail_event:
> > +     kfree(iter);
> > +}
> > +
> > 
> 
> When tracing sched events on sdm845 mtp, I hit below bug repeatedly.
> Seems like pstore_event_call can be called in atomic context.
> I will respin the below fix in next version of the patch.
> Reviews on other parts would be appreciated, thanks.
> 
> diff --git a/fs/pstore/ftrace.c b/fs/pstore/ftrace.c
> index d47dc93ac098..a497cf782ee8 100644
> --- a/fs/pstore/ftrace.c
> +++ b/fs/pstore/ftrace.c
> @@ -73,6 +73,7 @@ void notrace pstore_event_call(struct 
> trace_event_buffer *fbuffer)
>          struct trace_event *event;
>          struct seq_buf *seq;
>          unsigned long flags;
> +       gfp_t gfpflags;
> 
>          if (!psinfo)
>                  return;
> @@ -83,7 +84,9 @@ void notrace pstore_event_call(struct 
> trace_event_buffer *fbuffer)
>          pstore_record_init(&record, psinfo);
>          record.type = PSTORE_TYPE_EVENT;
> 
> -       iter = kmalloc(sizeof(*iter), GFP_KERNEL);
> +       gfpflags = (in_atomic() || irqs_disabled()) ? GFP_ATOMIC : 
> GFP_KERNEL;
> +

Do you need to allocate at all? Can you throw the iter on the stack?

Using in_atomic() and irqs_disabled() to figure out if an atomic or a
non-atomic allocation should be used is not a good solution.


  reply	other threads:[~2018-09-17 17:38 UTC|newest]

Thread overview: 50+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-08 20:27 [PATCH 0/6] Tracing register accesses with pstore and dynamic debug Sai Prakash Ranjan
2018-09-08 20:27 ` [PATCH 1/6] dt-bindings: ramoops: Add event-size property Sai Prakash Ranjan
     [not found]   ` <5b9f3f67.1c69fb81.3125b.c205@mx.google.com>
2018-09-17 17:15     ` Sai Prakash Ranjan
2018-09-08 20:27 ` [PATCH 2/6] pstore: Add event tracing support Sai Prakash Ranjan
2018-09-11 10:46   ` Sai Prakash Ranjan
2018-09-17 17:38     ` Stephen Boyd [this message]
2018-09-17 19:43       ` Sai Prakash Ranjan
2018-09-16  7:07   ` Sai Prakash Ranjan
     [not found]     ` <CAEXW_YSPNqVgoYWjVAMvGg_WoRV4SC2xDH1wQWTdQfBUOMQbbQ@mail.gmail.com>
2018-09-17 14:54       ` Kees Cook
2018-09-17 17:17         ` Sai Prakash Ranjan
2018-09-17 17:13       ` Sai Prakash Ranjan
2018-09-17 23:04     ` Steven Rostedt
2018-09-18  6:24       ` Sai Prakash Ranjan
2018-09-17 23:34   ` Steven Rostedt
2018-09-18 17:52     ` Sai Prakash Ranjan
2018-09-18 20:44       ` Steven Rostedt
2018-09-18 21:13         ` Sai Prakash Ranjan
2018-09-22  6:48           ` Sai Prakash Ranjan
2018-09-22  9:05   ` Joel Fernandes
2018-09-22 16:37     ` Sai Prakash Ranjan
2018-09-22 17:32       ` Sai Prakash Ranjan
2018-09-22 17:45       ` Sai Prakash Ranjan
2018-09-23 15:33       ` Sai Prakash Ranjan
2018-09-25 20:37         ` Joel Fernandes
2018-09-25 20:39           ` Joel Fernandes
2018-09-25 20:40             ` Joel Fernandes
2018-09-26  9:52               ` Sai Prakash Ranjan
2018-09-08 20:27 ` [PATCH 3/6] tracing: Add tp_pstore cmdline to have tracepoints go to pstore Sai Prakash Ranjan
2018-09-25 21:25   ` Joel Fernandes
2018-09-26  9:46     ` Sai Prakash Ranjan
2018-10-08 14:16       ` Sai Prakash Ranjan
2018-10-08 14:36         ` Steven Rostedt
2018-10-08 22:40           ` Joel Fernandes
2018-10-09 18:22             ` Sai Prakash Ranjan
2018-10-10 19:37               ` Steven Rostedt
2018-09-08 20:27 ` [PATCH 4/6] arm64/io: Add tracepoint for register accesses Sai Prakash Ranjan
2018-09-08 20:27 ` [PATCH 5/6] arm64/io: Add header for instrumentation of io operations Sai Prakash Ranjan
2018-09-17 23:39   ` Steven Rostedt
2018-09-18  7:10     ` Sai Prakash Ranjan
2018-09-18 11:47       ` Will Deacon
2018-09-18 12:43         ` Sai Prakash Ranjan
2018-09-08 20:27 ` [PATCH 6/6] dynamic_debug: Add flag for dynamic event tracing Sai Prakash Ranjan
2018-09-11 15:11 ` [PATCH 0/6] Tracing register accesses with pstore and dynamic debug Will Deacon
2018-09-11 16:11   ` Sai Prakash Ranjan
2018-10-20  5:25 ` Joel Fernandes
2018-10-20  6:32   ` Sai Prakash Ranjan
2018-10-20 16:27     ` Joel Fernandes
2018-10-21  3:46       ` Sai Prakash Ranjan
2018-10-21  4:59         ` Sai Prakash Ranjan
2018-10-21  5:09         ` Joel Fernandes

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=153720590027.119890.15984895820368075914@swboyd.mtv.corp.google.com \
    --to=sboyd@kernel.org \
    --cc=anton@enomsg.org \
    --cc=arnd@arndb.de \
    --cc=bryanh@codeaurora.org \
    --cc=catalin.marinas@arm.com \
    --cc=ccross@android.com \
    --cc=devicetree@vger.kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=jbaron@akamai.com \
    --cc=jim.cromie@gmail.com \
    --cc=joe@perches.com \
    --cc=joel@joelfernandes.org \
    --cc=keescook@chromium.org \
    --cc=labbott@redhat.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mhiramat@kernel.org \
    --cc=mingo@kernel.org \
    --cc=mingo@redhat.com \
    --cc=psodagud@codeaurora.org \
    --cc=rnayak@codeaurora.org \
    --cc=robh+dt@kernel.org \
    --cc=rostedt@goodmis.org \
    --cc=saiprakash.ranjan@codeaurora.org \
    --cc=sibis@codeaurora.org \
    --cc=tingwei@codeaurora.org \
    --cc=tom.zanussi@linux.intel.com \
    --cc=tony.luck@intel.com \
    --cc=tsoni@codeaurora.org \
    --cc=vivek.gautam@codeaurora.org \
    --cc=will.deacon@arm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).