Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753243AbcKEDnU (ORCPT ); Fri, 4 Nov 2016 23:43:20 -0400 Received: from mail-vk0-f54.google.com ([209.85.213.54]:36483 "EHLO mail-vk0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750970AbcKEDnS (ORCPT ); Fri, 4 Nov 2016 23:43:18 -0400 MIME-Version: 1.0 In-Reply-To: <25c117ae-6d06-9846-6a88-ae6221ad6bfe@virtuozzo.com> References: <1477149440-12478-1-git-send-email-hch@lst.de> <1477149440-12478-5-git-send-email-hch@lst.de> <25c117ae-6d06-9846-6a88-ae6221ad6bfe@virtuozzo.com> From: Joel Fernandes Date: Fri, 4 Nov 2016 20:43:16 -0700 Message-ID: Subject: Re: [PATCH 4/7] mm: defer vmalloc from atomic context To: Andrey Ryabinin Cc: Christoph Hellwig , Andrew Morton , Jisheng Zhang , Chris Wilson , John Dias , "open list:MEMORY MANAGEMENT" , linux-rt-users@vger.kernel.org, LKML Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1212 Lines: 42 On Mon, Oct 24, 2016 at 8:44 AM, Andrey Ryabinin wrote: > > > On 10/22/2016 06:17 PM, Christoph Hellwig wrote: >> We want to be able to use a sleeping lock for freeing vmap to keep >> latency down. For this we need to use the deferred vfree mechanisms >> no only from interrupt, but from any atomic context. >> >> Signed-off-by: Christoph Hellwig >> --- >> mm/vmalloc.c | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/mm/vmalloc.c b/mm/vmalloc.c >> index a4e2cec..bcc1a64 100644 >> --- a/mm/vmalloc.c >> +++ b/mm/vmalloc.c >> @@ -1509,7 +1509,7 @@ void vfree(const void *addr) >> >> if (!addr) >> return; >> - if (unlikely(in_interrupt())) { >> + if (unlikely(in_atomic())) { > > in_atomic() cannot always detect atomic context, thus it shouldn't be used here. > You can add something like vfree_in_atomic() and use it in atomic call sites. > So because in_atomic doesn't work for !CONFIG_PREEMPT kernels, can we always defer the work in these cases? So for non-preemptible kernels, we always defer: if (!IS_ENABLED(CONFIG_PREEMPT) || in_atomic()) { // defer } Is this fine? Or any other ideas? Thanks, Joel