Received: by 10.192.165.148 with SMTP id m20csp4896488imm; Tue, 24 Apr 2018 10:08:01 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/RdutMLfcbuI2WGD38BEsGZmdxJh+KyHi1xcF+c9DSw7i3NbGGWUg4gxLetx0NvUaxLGFl X-Received: by 2002:a17:902:8481:: with SMTP id c1-v6mr25366872plo.310.1524589681302; Tue, 24 Apr 2018 10:08:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524589681; cv=none; d=google.com; s=arc-20160816; b=yo9CpgBcz3yCc68XySBy5sY74Uofb3uWq3/sOWHLuJTs8owLNb6rkKVur8MZaHeqp4 aQYpK5vdmCp7NvuRkMP3nrtCrfyibUhXohc2+CzDHdlI2YpNn0/IGbyRQJvSuIJE5z7T NyziKheg1SEWGDc8vwigmr+M+NpzV9XuRoCC7vLcqJBGwDOHqMinpakrvnKQ7TPSKp9s /Iayb5esgBPFQY3zZeLAOBKsjY8Fv499/a7JE+0uRsTUFXG1Y58xKZ8GbRfS7FftguST NCmLwd0WVfqyRmGoVjbdTm0w30MNoAbY+Os1XMyoEbdoqfVTd33eGur9yjNOU9UDYZl6 x4+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date :arc-authentication-results; bh=/N+33tziXYQpivJvpog8QEsMhkc+kAYbgbIxpraMYUQ=; b=D/fgmmHec0YfK2907X5yr311Grp85+hsgotwTtzHz71djeR7u1W+4y1yktoFcQq1AN RGU9VY1cP071M03OSEyYv72GYkUcvBgaU8ms/cpBOoLpW4dSWXgDD29qn6kwLIJfhn1L ukZzo6KtGGcMAt7/UuZrdbzXJu53JolCo9dbAuMvJBNZAkCjM45uAIVfwHmCWvay6nS7 j/pWhSjasW2j5kDMjtcl/QqDstGq1sbY98x4PkvmUDmiYGrCzz9cvduRpIlcDtT/t/1E lInGIb5F9UewpYAsUSlIs0XaSgOHDbFCN3z+cde8e6XJWrauDDKrByR+62HzxMIOPS9m eYNg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r12si11064114pgf.217.2018.04.24.10.07.46; Tue, 24 Apr 2018 10:08:01 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751535AbeDXRFa (ORCPT + 99 others); Tue, 24 Apr 2018 13:05:30 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:55482 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750735AbeDXRF1 (ORCPT ); Tue, 24 Apr 2018 13:05:27 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C7F07410FBB4; Tue, 24 Apr 2018 17:05:26 +0000 (UTC) Received: from file01.intranet.prod.int.rdu2.redhat.com (file01.intranet.prod.int.rdu2.redhat.com [10.11.5.7]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 79564202342E; Tue, 24 Apr 2018 17:05:26 +0000 (UTC) Received: from file01.intranet.prod.int.rdu2.redhat.com (localhost [127.0.0.1]) by file01.intranet.prod.int.rdu2.redhat.com (8.14.4/8.14.4) with ESMTP id w3OH5QtO031895; Tue, 24 Apr 2018 13:05:26 -0400 Received: from localhost (mpatocka@localhost) by file01.intranet.prod.int.rdu2.redhat.com (8.14.4/8.14.4/Submit) with ESMTP id w3OH5P8J031891; Tue, 24 Apr 2018 13:05:25 -0400 X-Authentication-Warning: file01.intranet.prod.int.rdu2.redhat.com: mpatocka owned process doing -bs Date: Tue, 24 Apr 2018 13:05:25 -0400 (EDT) From: Mikulas Patocka X-X-Sender: mpatocka@file01.intranet.prod.int.rdu2.redhat.com To: Michal Hocko cc: LKML , Artem Bityutskiy , Richard Weinberger , David Woodhouse , Brian Norris , Boris Brezillon , Marek Vasut , Cyrille Pitchen , "Theodore Ts'o" , Andreas Dilger , Steven Whitehouse , Bob Peterson , Trond Myklebust , Anna Schumaker , Adrian Hunter , Philippe Ombredanne , Kate Stewart , linux-mtd@lists.infradead.org, linux-ext4@vger.kernel.org, cluster-devel@redhat.com, linux-nfs@vger.kernel.org, linux-mm@kvack.org Subject: Re: vmalloc with GFP_NOFS In-Reply-To: <20180424165532.GO17484@dhcp22.suse.cz> Message-ID: References: <20180424162712.GL17484@dhcp22.suse.cz> <20180424165532.GO17484@dhcp22.suse.cz> User-Agent: Alpine 2.02 (LRH 1266 2009-07-14) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Tue, 24 Apr 2018 17:05:26 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Tue, 24 Apr 2018 17:05:26 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'mpatocka@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 24 Apr 2018, Michal Hocko wrote: > On Tue 24-04-18 12:46:55, Mikulas Patocka wrote: > > > > > > On Tue, 24 Apr 2018, Michal Hocko wrote: > > > > > Hi, > > > it seems that we still have few vmalloc users who perform GFP_NOFS > > > allocation: > > > drivers/mtd/ubi/io.c > > > fs/ext4/xattr.c > > > fs/gfs2/dir.c > > > fs/gfs2/quota.c > > > fs/nfs/blocklayout/extent_tree.c > > > fs/ubifs/debug.c > > > fs/ubifs/lprops.c > > > fs/ubifs/lpt_commit.c > > > fs/ubifs/orphan.c > > > > > > Unfortunatelly vmalloc doesn't suppoer GFP_NOFS semantinc properly > > > because we do have hardocded GFP_KERNEL allocations deep inside the > > > vmalloc layers. That means that if GFP_NOFS really protects from > > > recursion into the fs deadlocks then the vmalloc call is broken. > > > > > > What to do about this? Well, there are two things. Firstly, it would be > > > really great to double check whether the GFP_NOFS is really needed. I > > > cannot judge that because I am not familiar with the code. It would be > > > great if the respective maintainers (hopefully get_maintainer.sh pointed > > > me to all relevant ones). If there is not reclaim recursion issue then > > > simply use the standard vmalloc (aka GFP_KERNEL request). > > > > > > If the use is really valid then we have a way to do the vmalloc > > > allocation properly. We have memalloc_nofs_{save,restore} scope api. How > > > does that work? You simply call memalloc_nofs_save when the reclaim > > > recursion critical section starts (e.g. when you take a lock which is > > > then used in the reclaim path - e.g. shrinker) and memalloc_nofs_restore > > > when the critical section ends. _All_ allocations within that scope > > > will get GFP_NOFS semantic automagically. If you are not sure about the > > > scope itself then the easiest workaround is to wrap the vmalloc itself > > > with a big fat comment that this should be revisited. > > > > > > Does that sound like something that can be done in a reasonable time? > > > I have tried to bring this up in the past but our speed is glacial and > > > there are attempts to do hacks like checking for abusers inside the > > > vmalloc which is just too ugly to live. > > > > > > Please do not hesitate to get back to me if something is not clear. > > > > > > Thanks! > > > -- > > > Michal Hocko > > > SUSE Labs > > > > I made a patch that adds memalloc_noio/fs_save around these calls a year > > ago: http://lkml.iu.edu/hypermail/linux/kernel/1707.0/01376.html > > Yeah, and that is the wrong approach. It is crude, but it fixes the deadlock possibility. Then, the maintainers will have a lot of time to refactor the code and move these memalloc_noio_save calls to the proper scope. > Let's try to fix this properly > this time. As the above outlines, the worst case we can end up mid-term > would be to wrap vmalloc calls with the scope api with a TODO. But I am > pretty sure the respective maintainers can come up with a better > solution. I am definitely willing to help here. > -- > Michal Hocko > SUSE Labs Mikulas