From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754316AbbFAXgn (ORCPT ); Mon, 1 Jun 2015 19:36:43 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:50609 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753714AbbFAXgQ (ORCPT ); Mon, 1 Jun 2015 19:36:16 -0400 Date: Mon, 1 Jun 2015 16:36:14 -0700 From: Andrew Morton To: Joe Perches Cc: LKML Subject: Re: [RFC patch] vsprintf: Add %pav extension for print_vma_addr Message-Id: <20150601163614.7913956304f68fa22bc0cb91@linux-foundation.org> In-Reply-To: <1433094677.2984.27.camel@perches.com> References: <1432681504.2846.116.camel@perches.com> <20150527140406.bcc33ecc79da09ad6782b971@linux-foundation.org> <1432760971.2846.180.camel@perches.com> <20150527141908.4cf02ef4456201ad7db78883@linux-foundation.org> <1433094677.2984.27.camel@perches.com> X-Mailer: Sylpheed 3.4.1 (GTK+ 2.24.23; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, 31 May 2015 10:51:17 -0700 Joe Perches wrote: > On Wed, 2015-05-27 at 14:19 -0700, Andrew Morton wrote: > > On Wed, 27 May 2015 14:09:31 -0700 Joe Perches 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.