From patchwork Mon Mar 6 13:14:06 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Hocko X-Patchwork-Id: 735699 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3vcL1959GZz9sNS for ; Tue, 7 Mar 2017 00:17:17 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="XAhI6Z+U"; dkim-atps=neutral DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=GvHdYOkIpTcLB1lFadcLak1kp9zzB1xcBYPWBBVdcJA=; b=XAhI6Z+UE3qO1XaoovgbVEfPGv dtH24Fr6GWFGvIlZYdlzUBjxx+AqGCjvYr2uENzNi/v7SEOKS5lt/Z6YvmkUjVZgyoKq/XP+HVEud vev8btw//EnRMwnpg2qRIU4N2nkImTagrpPPmqjjSBjavcnllkKRNALWuzLDxuOjl4TrEEL4wbR10 KcGdmmD9DW2L2sGQh/YfbQ63v0eWKsfkGrczrVwrQVnVrbFiCXDxdGFe9Dnsxsf77t749NBVZXOZC prL9PnwKyqxE0jIIRoBAoVl84SxOdhuvxqLrDv9+ENAKYvGQfzsPWei4DKvhWDVtEUGDAPtIKCwIu 36YMbdag==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1cksVh-0001wM-5G; Mon, 06 Mar 2017 13:17:09 +0000 Received: from mail-wm0-f67.google.com ([74.125.82.67]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cksTL-0007or-Sl; Mon, 06 Mar 2017 13:14:46 +0000 Received: by mail-wm0-f67.google.com with SMTP id n11so13687820wma.0; Mon, 06 Mar 2017 05:14:26 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=dW9cVsTCUsZPEYwSqqpucAWcvTumyXJIjNhENGYBr8U=; b=DPk951RucICjtutpxVUMwEYC869mR1yBb3SefgRUR8P2VWITM0yg5XueBy3NuV0zHz /O0BOp1BI21sEqQIQK0aYP0snb6vdWPAdH7qO3RkOQPTIazSckKpViWHFN8vw8tiYJhH 8XQ58c4TXbiybUHRLh5jbSS719lCF6v0YIfJ8nzjkhHcWV7TzaYqiJS31PjhBJ1BzzYC 867P7OHmiBvtIoUBKlQwU6nufipsgK03f3d48vVWxVroGrl9FRFAAln+nMs1DgTBMx+F nGhGbOfXq2lMFdjd9KnS1PrlWzWVBfyIgB7YRxRl+m8Y0mG975sxAYL8qzuXI3AoY1gF ghAw== X-Gm-Message-State: AMke39lE4L42OOmCshhCx9GbQ49fpZCrowe7+s2wnaQybmdNCuIqKmnYysW7bfpKXb5xxA== X-Received: by 10.28.51.205 with SMTP id z196mr13852830wmz.22.1488806064882; Mon, 06 Mar 2017 05:14:24 -0800 (PST) Received: from tiehlicka.suse.cz (prg-ext-pat.suse.com. [213.151.95.130]) by smtp.gmail.com with ESMTPSA id d6sm14829593wmd.6.2017.03.06.05.14.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 06 Mar 2017 05:14:24 -0800 (PST) From: Michal Hocko To: Andrew Morton , Subject: [PATCH 5/7] xfs: use memalloc_nofs_{save, restore} instead of memalloc_noio* Date: Mon, 6 Mar 2017 14:14:06 +0100 Message-Id: <20170306131408.9828-6-mhocko@kernel.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170306131408.9828-1-mhocko@kernel.org> References: <20170306131408.9828-1-mhocko@kernel.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170306_051444_098983_BC18E24B X-CRM114-Status: GOOD ( 11.85 ) X-Spam-Score: -1.2 (-) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-1.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- 0.5 RCVD_IN_SORBS_SPAM RBL: SORBS: sender is a spam source [74.125.82.67 listed in dnsbl.sorbs.net] -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [74.125.82.67 listed in list.dnswl.org] -0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [74.125.82.67 listed in wl.mailspike.net] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (mstsxfx[at]gmail.com) -0.0 SPF_PASS SPF: sender matches SPF record 0.0 HEADER_FROM_DIFFERENT_DOMAINS From and EnvelopeFrom 2nd level mail domains are different -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.0 RCVD_IN_MSPIKE_WL Mailspike good senders 0.2 FREEMAIL_FORGED_FROMDOMAIN 2nd level domains in From and EnvelopeFrom freemail headers are different X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Michal Hocko , Jan Kara , djwong@kernel.org, Dave Chinner , David Sterba , Chris Mason , linux-mtd@lists.infradead.org, logfs@logfs.org, linux-afs@lists.infradead.org, "Darrick J. Wong" , cluster-devel@redhat.com, linux-ext4@vger.kernel.org, Brian Foster , reiserfs-devel@vger.kernel.org, ceph-devel@vger.kernel.org, Vlastimil Babka , linux-nfs@vger.kernel.org, Theodore Ts'o , linux-mm@kvack.org, linux-ntfs-dev@lists.sourceforge.net, LKML , linux-f2fs-devel@lists.sourceforge.net, linux-xfs@vger.kernel.org, linux-btrfs@vger.kernel.org MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org From: Michal Hocko kmem_zalloc_large and _xfs_buf_map_pages use memalloc_noio_{save,restore} API to prevent from reclaim recursion into the fs because vmalloc can invoke unconditional GFP_KERNEL allocations and these functions might be called from the NOFS contexts. The memalloc_noio_save will enforce GFP_NOIO context which is even weaker than GFP_NOFS and that seems to be unnecessary. Let's use memalloc_nofs_{save,restore} instead as it should provide exactly what we need here - implicit GFP_NOFS context. Changes since v1 - s@memalloc_noio_restore@memalloc_nofs_restore@ in _xfs_buf_map_pages as per Brian Foster Acked-by: Vlastimil Babka Reviewed-by: Brian Foster Reviewed-by: Darrick J. Wong Signed-off-by: Michal Hocko --- fs/xfs/kmem.c | 12 ++++++------ fs/xfs/xfs_buf.c | 8 ++++---- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/fs/xfs/kmem.c b/fs/xfs/kmem.c index e14da724a0b5..6b7b04468aa8 100644 --- a/fs/xfs/kmem.c +++ b/fs/xfs/kmem.c @@ -66,7 +66,7 @@ kmem_alloc(size_t size, xfs_km_flags_t flags) void * kmem_zalloc_large(size_t size, xfs_km_flags_t flags) { - unsigned noio_flag = 0; + unsigned nofs_flag = 0; void *ptr; gfp_t lflags; @@ -78,17 +78,17 @@ kmem_zalloc_large(size_t size, xfs_km_flags_t flags) * __vmalloc() will allocate data pages and auxillary structures (e.g. * pagetables) with GFP_KERNEL, yet we may be under GFP_NOFS context * here. Hence we need to tell memory reclaim that we are in such a - * context via PF_MEMALLOC_NOIO to prevent memory reclaim re-entering + * context via PF_MEMALLOC_NOFS to prevent memory reclaim re-entering * the filesystem here and potentially deadlocking. */ - if ((current->flags & PF_MEMALLOC_NOFS) || (flags & KM_NOFS)) - noio_flag = memalloc_noio_save(); + if (flags & KM_NOFS) + nofs_flag = memalloc_nofs_save(); lflags = kmem_flags_convert(flags); ptr = __vmalloc(size, lflags | __GFP_HIGHMEM | __GFP_ZERO, PAGE_KERNEL); - if ((current->flags & PF_MEMALLOC_NOFS) || (flags & KM_NOFS)) - memalloc_noio_restore(noio_flag); + if (flags & KM_NOFS) + memalloc_nofs_restore(nofs_flag); return ptr; } diff --git a/fs/xfs/xfs_buf.c b/fs/xfs/xfs_buf.c index b6208728ba39..ca09061369cb 100644 --- a/fs/xfs/xfs_buf.c +++ b/fs/xfs/xfs_buf.c @@ -443,17 +443,17 @@ _xfs_buf_map_pages( bp->b_addr = NULL; } else { int retried = 0; - unsigned noio_flag; + unsigned nofs_flag; /* * vm_map_ram() will allocate auxillary structures (e.g. * pagetables) with GFP_KERNEL, yet we are likely to be under * GFP_NOFS context here. Hence we need to tell memory reclaim - * that we are in such a context via PF_MEMALLOC_NOIO to prevent + * that we are in such a context via PF_MEMALLOC_NOFS to prevent * memory reclaim re-entering the filesystem here and * potentially deadlocking. */ - noio_flag = memalloc_noio_save(); + nofs_flag = memalloc_nofs_save(); do { bp->b_addr = vm_map_ram(bp->b_pages, bp->b_page_count, -1, PAGE_KERNEL); @@ -461,7 +461,7 @@ _xfs_buf_map_pages( break; vm_unmap_aliases(); } while (retried++ <= 1); - memalloc_noio_restore(noio_flag); + memalloc_nofs_restore(nofs_flag); if (!bp->b_addr) return -ENOMEM;