stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg KH <gregkh@linuxfoundation.org>
To: Henrik Austad <henrik@austad.us>
Cc: linux-kernel@vger.kernel.org, Henrik Austad <haustad@cisco.com>,
	Ingo Molnar <mingo@kernel.org>,
	Peter Zijlstra <peterz@infradead.org>,
	Steven Rostedt <rostedt@goodmis.org>,
	stable@vger.kernel.org
Subject: Re: [PATCH] tracing: (backport) Replace kmap with copy_from_user() in trace_marker
Date: Fri, 9 Dec 2016 08:22:05 +0100	[thread overview]
Message-ID: <20161209072205.GC29639@kroah.com> (raw)
In-Reply-To: <1481265244-13986-1-git-send-email-haustad@cisco.com>

On Fri, Dec 09, 2016 at 07:34:04AM +0100, Henrik Austad wrote:
> Instead of using get_user_pages_fast() and kmap_atomic() when writing
> to the trace_marker file, just allocate enough space on the ring buffer
> directly, and write into it via copy_from_user().
> 
> Writing into the trace_marker file use to allocate a temporary buffer
> to perform the copy_from_user(), as we didn't want to write into the
> ring buffer if the copy failed. But as a trace_marker write is suppose
> to be extremely fast, and allocating memory causes other tracepoints to
> trigger, Peter Zijlstra suggested using get_user_pages_fast() and
> kmap_atomic() to keep the user space pages in memory and reading it
> directly.
> 
> Instead, just allocate the space in the ring buffer and use
> copy_from_user() directly. If it faults, return -EFAULT and write
> "<faulted>" into the ring buffer.
> 
> On architectures without a arch-specific get_user_pages_fast(), this
> will end up in the generic get_user_pages_fast() and this grabs
> mm->mmap_sem. Once you do this, then suddenly writing to the
> trace_marker can cause priority-inversions.
> 
> This is a backport of Steven Rostedts patch [1] and applied to 3.10.x so the
> signed-off-chain by is somewhat uncertain at this stage.
> 
> The patch compiles, boots and does not immediately explode on impact. By
> definition [2] it must therefore be perfect
> 
> 2) https://www.spinics.net/lists/kernel/msg2400769.html
> 2) http://lkml.iu.edu/hypermail/linux/kernel/9804.1/0149.html
> 
> Cc: Ingo Molnar <mingo@kernel.org>
> Cc: Henrik Austad <henrik@austad.us>
> Cc: Peter Zijlstra <peterz@infradead.org>
> Cc: Steven Rostedt <rostedt@goodmis.org>
> Cc: stable@vger.kernel.org
> 
> Suggested-by: Thomas Gleixner <tglx@linutronix.de>
> Used-to-be-signed-off-by: Steven Rostedt <rostedt@goodmis.org>
> Backported-by: Henrik Austad <haustad@cisco.com>
> Tested-by: Henrik Austad <haustad@cisco.com>
> Signed-off-by: Henrik Austad <haustad@cisco.com>
> ---
>  kernel/trace/trace.c | 78 +++++++++++++++-------------------------------------
>  1 file changed, 22 insertions(+), 56 deletions(-)

What is the git commit id of this patch in Linus's tree?  And what
stable trees do you feel it should be applied to?

thanks,

greg k-h

  reply	other threads:[~2016-12-09  7:21 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20161208134422.1ca7455a@gandalf.local.home>
2016-12-09  6:34 ` [PATCH] tracing: (backport) Replace kmap with copy_from_user() in trace_marker Henrik Austad
2016-12-09  7:22   ` Greg KH [this message]
2016-12-09  8:05     ` Henrik Austad
2016-12-09  8:26       ` Greg KH
2016-12-09 13:56       ` Steven Rostedt

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=20161209072205.GC29639@kroah.com \
    --to=gregkh@linuxfoundation.org \
    --cc=haustad@cisco.com \
    --cc=henrik@austad.us \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    --cc=stable@vger.kernel.org \
    /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).