From: Andrew Morton <akpm@linux-foundation.org>
To: Joe Perches <joe@perches.com>
Cc: LKML <linux-kernel@vger.kernel.org>
Subject: Re: [RFC patch] vsprintf: Add %pav extension for print_vma_addr
Date: Mon, 1 Jun 2015 16:36:14 -0700 [thread overview]
Message-ID: <20150601163614.7913956304f68fa22bc0cb91@linux-foundation.org> (raw)
In-Reply-To: <1433094677.2984.27.camel@perches.com>
On Sun, 31 May 2015 10:51:17 -0700 Joe Perches <joe@perches.com> wrote:
> On Wed, 2015-05-27 at 14:19 -0700, Andrew Morton wrote:
> > On Wed, 27 May 2015 14:09:31 -0700 Joe Perches <joe@perches.com> wrote:
> >
> > > > Problems when CONFIG_PREEMPT=n.
> > > >
> > > > > + down_read(&mm->mmap_sem);
> > > > > + vma = find_vma(mm, ip);
> > > > > + if (vma && vma->vm_file) {
> > > > > + struct file *f = vma->vm_file;
> > > > > + char *gfp_buf = (char *)__get_free_page(GFP_KERNEL);
> > > >
> > > > We shouldn't assume we can use GFP_KERNEL here. Even if the
> > > > preempt_count() worked, we might be in a context which requires
> > > > GFP_NOFS or GFP_NOIO.
> > >
> > > This code is basically a copy of the existing print_vma_addr()
> > > so is that true for all the existing uses too?
> >
> > Yeah, the current code is pretty junky. But normally print_vma_addr()
> > should never be called so nobody noticed...
> >
> > In e8bff74a Ingo did a fiddle to preempt_conditional_sti() which looks
> > like it will address the CONFIG_PREEMPT=n issue, but only on x86.
>
> Maybe this? (using GFP_ATOMIC and __GFP_NOWARN)
(tries to remember what this is about)
Please do include the (updated) changelog each time.
This is intended to replace open-coded calls to print_vma_addr(), yes?
We shouldn't really need the memory allocation at all - we could poke
these characters one at a time into the log buffer. That would require
quite some hackery with d_path which would be rather pointless. Maybe
for this purpose it's sufficient to just grab
vma->vm_file->f_path->dentry->d_name. It's not as if this is terribly
important code.
But we still have the down_read(mmap_sem) in there. I don't
immediately see any deadlocks in the current callsites but it isn't
obvious.
I dunno, I just don't think it's a nice idea to be allocating memory
and taking mmap_sem and doing rcu_read_lock (in d_path) all within core
vsprintf/printk. printk() is supposed to be callable from virtually
any context, not "any context as long as you don't use features X Y and
Z".
If we can make print_vma_addr() robust then OK. Perhaps we just don't
try to print the vma's filename. People can look up the hex address in
/proc/pid/maps if it's really needed.
prev parent reply other threads:[~2015-06-01 23:36 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-26 23:05 Joe Perches
2015-05-27 21:04 ` Andrew Morton
2015-05-27 21:09 ` Joe Perches
2015-05-27 21:19 ` Andrew Morton
2015-05-31 17:51 ` Joe Perches
2015-06-01 23:36 ` Andrew Morton [this message]
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=20150601163614.7913956304f68fa22bc0cb91@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=joe@perches.com \
--cc=linux-kernel@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
all inboxes | Powered by JetHome®