From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933918AbdDELmx (ORCPT ); Wed, 5 Apr 2017 07:42:53 -0400 Received: from mx2.suse.de ([195.135.220.15]:52002 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933125AbdDELmW (ORCPT ); Wed, 5 Apr 2017 07:42:22 -0400 Subject: Re: [PATCH 1/4] mm/vmalloc: allow to call vfree() in atomic context To: Andrey Ryabinin , Thomas Hellstrom , akpm@linux-foundation.org References: <20170330102719.13119-1-aryabinin@virtuozzo.com> <2cfc601e-3093-143e-b93d-402f330a748a@vmware.com> Cc: penguin-kernel@I-love.SAKURA.ne.jp, linux-kernel@vger.kernel.org, mhocko@kernel.org, linux-mm@kvack.org, hpa@zytor.com, chris@chris-wilson.co.uk, hch@lst.de, mingo@elte.hu, jszhang@marvell.com, joelaf@google.com, joaodias@google.com, willy@infradead.org, tglx@linutronix.de, stable@vger.kernel.org From: Vlastimil Babka Message-ID: <8d313f6c-9ea8-7be0-38cd-15370e5a1d6c@suse.cz> Date: Wed, 5 Apr 2017 13:42:19 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 03/30/2017 04:48 PM, Andrey Ryabinin wrote: > On 03/30/2017 03:00 PM, Thomas Hellstrom wrote: > >>> >>> if (unlikely(nr_lazy > lazy_max_pages())) >>> - try_purge_vmap_area_lazy(); >> >> Perhaps a slight optimization would be to schedule work iff >> !mutex_locked(&vmap_purge_lock) below? >> > > Makes sense, we don't need to spawn workers if we already purging. > > > > From: Andrey Ryabinin > Subject: mm/vmalloc: allow to call vfree() in atomic context fix > > Don't spawn worker if we already purging. > > Signed-off-by: Andrey Ryabinin > --- > mm/vmalloc.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/mm/vmalloc.c b/mm/vmalloc.c > index ea1b4ab..88168b8 100644 > --- a/mm/vmalloc.c > +++ b/mm/vmalloc.c > @@ -737,7 +737,8 @@ static void free_vmap_area_noflush(struct vmap_area *va) > /* After this point, we may free va at any time */ > llist_add(&va->purge_list, &vmap_purge_list); > > - if (unlikely(nr_lazy > lazy_max_pages())) > + if (unlikely(nr_lazy > lazy_max_pages()) && > + !mutex_is_locked(&vmap_purge_lock)) So, isn't this racy? (and do we care?) Vlastimil > schedule_work(&purge_vmap_work); > } > > From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Subject: Re: [PATCH 1/4] mm/vmalloc: allow to call vfree() in atomic context To: Andrey Ryabinin , Thomas Hellstrom , akpm@linux-foundation.org References: <20170330102719.13119-1-aryabinin@virtuozzo.com> <2cfc601e-3093-143e-b93d-402f330a748a@vmware.com> Cc: penguin-kernel@I-love.SAKURA.ne.jp, linux-kernel@vger.kernel.org, mhocko@kernel.org, linux-mm@kvack.org, hpa@zytor.com, chris@chris-wilson.co.uk, hch@lst.de, mingo@elte.hu, jszhang@marvell.com, joelaf@google.com, joaodias@google.com, willy@infradead.org, tglx@linutronix.de, stable@vger.kernel.org From: Vlastimil Babka Message-ID: <8d313f6c-9ea8-7be0-38cd-15370e5a1d6c@suse.cz> Date: Wed, 5 Apr 2017 13:42:19 +0200 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Sender: owner-linux-mm@kvack.org List-ID: On 03/30/2017 04:48 PM, Andrey Ryabinin wrote: > On 03/30/2017 03:00 PM, Thomas Hellstrom wrote: > >>> >>> if (unlikely(nr_lazy > lazy_max_pages())) >>> - try_purge_vmap_area_lazy(); >> >> Perhaps a slight optimization would be to schedule work iff >> !mutex_locked(&vmap_purge_lock) below? >> > > Makes sense, we don't need to spawn workers if we already purging. > > > > From: Andrey Ryabinin > Subject: mm/vmalloc: allow to call vfree() in atomic context fix > > Don't spawn worker if we already purging. > > Signed-off-by: Andrey Ryabinin > --- > mm/vmalloc.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/mm/vmalloc.c b/mm/vmalloc.c > index ea1b4ab..88168b8 100644 > --- a/mm/vmalloc.c > +++ b/mm/vmalloc.c > @@ -737,7 +737,8 @@ static void free_vmap_area_noflush(struct vmap_area *va) > /* After this point, we may free va at any time */ > llist_add(&va->purge_list, &vmap_purge_list); > > - if (unlikely(nr_lazy > lazy_max_pages())) > + if (unlikely(nr_lazy > lazy_max_pages()) && > + !mutex_is_locked(&vmap_purge_lock)) So, isn't this racy? (and do we care?) Vlastimil > schedule_work(&purge_vmap_work); > } > > -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org