Re: [RFC patch] vsprintf: Add %pav extension for print_vma_addr

From: Joe Perches
Date: Wed May 27 2015 - 17:09:39 EST


On Wed, 2015-05-27 at 14:04 -0700, Andrew Morton wrote:
> On Tue, 26 May 2015 16:05:04 -0700 Joe Perches <joe@xxxxxxxxxxx> wrote:
> > print_vma_addr is another function to emit useful
> > data similar to print_symbol. The print_symbol
> > functionality has been added via %p[fFsS] vsprintf
> > extensions.
> >
> > Perhaps it's appropriate to add vma_addr address
> > decoding to vsprintf too.
[]
> > static noinline_for_stack
> > +char *vma_addr(char *buf, char *end, const void *addr,
> > + struct printf_spec spec, const char *fmt)
> > +{
> > + struct mm_struct *mm = current->mm;
> > + struct vm_area_struct *vma;
> > + unsigned long ip = *(unsigned long *)addr;
> > + char *rtn;
> > +
> > + /* if we are in atomic contexts (in exception stacks, etc.) */
> > + if (preempt_count())
> > + return string(buf, end, "(atomic context)", spec);
>
> 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?


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/