Received: by 10.192.165.148 with SMTP id m20csp3688490imm; Mon, 7 May 2018 17:26:29 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpvMaDhSatGNrcIGObatlSJAP6dBEwNq3WdhZNqcE6hCUTHk4yVedUAQmd6guJxBEAaGwrV X-Received: by 2002:a17:902:6b03:: with SMTP id o3-v6mr38612131plk.213.1525739189880; Mon, 07 May 2018 17:26:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525739189; cv=none; d=google.com; s=arc-20160816; b=rsN01Pp0iuI5o+ZJrDu3gHu7zr9iZWmFwKfvsbU3B44MApiY0Mu8z1zsWKjlPsjK7S zY+Gy3BkSPNOBXlTchI+w7Z0lWTZc98zR2dT7GmHVrwO+49G0b3+GDx6VSkka3sLn+q/ HwoVbqNKLuGulkRtHfCk0XIsAUI9/optPyVhHsq+dmGT1h1WatOw58EtdKM0PjFImQAs 7gbH05KF7eN9HVmvbyraD5muLn+8pYL5sa3eh8K0/kqUe4lC0dsgvT3HDGNn4DZZZWsX TsDPUWFe37+RnzQ6y6IljR/KBj0zPSbJbmCo75YgqzYZcju/Lc3zzNeK1WS57M+B/ghl qKqw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:to :from:date:dkim-signature:arc-authentication-results; bh=Ng4WQa4iBMJXGDNkoei8Y95CN/7FgGJEm4kSYU28IQI=; b=mBv/weIuCPLKEwEoSyNNFX36pk1y5bpK1Q32S3fn80oZpcsbDs8Qgu+YiE6jj/lEPC znl5xP8wHXZ6S6bM4gMqTSkhDb3+Bn2U/2ynMQg9uzjTKiHe3T5XOGtEeBcw1RdgJdel gP7W863TxIpDv+FI3n65/xlvYKef6WE+qLksj86Qp/XaBgj5+FccbGECCIGFlVO+NWFI Hpq+iKrgUBcakfyHU6yr1EwcUjQNVhLX2Hds+iMvba1gHpe7yzsCReksH+RZkGGLcgpn FJfkEHZ8rqjbnRZJXC+9MRsUTj7ysGL3QknHJ/rVd7rUMRl79d/GhnXP+gwWWtHkHFDQ X+iw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=euEFwKzf; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s4-v6si676515pgn.403.2018.05.07.17.26.15; Mon, 07 May 2018 17:26:29 -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; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=euEFwKzf; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753698AbeEHA0B (ORCPT + 99 others); Mon, 7 May 2018 20:26:01 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:49966 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753615AbeEHA0A (ORCPT ); Mon, 7 May 2018 20:26:00 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:To:From:Date:Sender:Reply-To:Cc: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=Ng4WQa4iBMJXGDNkoei8Y95CN/7FgGJEm4kSYU28IQI=; b=euEFwKzfD2ibM7XoDjVIXoKUC Td+TSRBYMGGi631qzqFgUn8zlHKZUEf1WdytUg4LN9BLTe4LBDaINoZqr6FLvdI551XZ/UKzo/qdO yfYz6UfwrGGC7prQx4i8RvaZU2dwJH8aW+JQkTTDaKTN7OrKKKXujD3hWx8ovLfueuvGdrdND3PE+ 1r7pmRCv3TCUAlympoE5MKAh9q3OQguCjkC0JES+/AaqU7hYwg6x63OXFG0cxsbQAa1I/dBIoMRU/ GJl6G1LUwYhUL+5dDwgvlxRc9P+2r32GO/FAVk5Z9lNL+b9eS2vNKFJO+K7rAXdN7QtHeYEmPF3OQ QB+1ntG5A==; Received: from willy by bombadil.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1fFqRv-0008Mz-SD; Tue, 08 May 2018 00:25:47 +0000 Date: Mon, 7 May 2018 17:25:47 -0700 From: Matthew Wilcox To: dsterba@suse.cz, Huaisheng HS1 Ye , Michal Hocko , "akpm@linux-foundation.org" , "linux-mm@kvack.org" , "vbabka@suse.cz" , "mgorman@techsingularity.net" , "pasha.tatashin@oracle.com" , "alexander.levin@verizon.com" , "hannes@cmpxchg.org" , "penguin-kernel@I-love.SAKURA.ne.jp" , "colyli@suse.de" , NingTing Cheng , "linux-kernel@vger.kernel.org" Subject: Re: [External] Re: [PATCH 2/3] include/linux/gfp.h: use unsigned int in gfp_zone Message-ID: <20180508002547.GA16338@bombadil.infradead.org> References: <1525416729-108201-3-git-send-email-yehs1@lenovo.com> <20180504133533.GR4535@dhcp22.suse.cz> <20180504154004.GB29829@bombadil.infradead.org> <20180506134814.GB7362@bombadil.infradead.org> <20180506185532.GA13604@bombadil.infradead.org> <20180507184410.GA12361@bombadil.infradead.org> <20180507212500.bdphwfhk55w6vlbb@twin.jikos.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180507212500.bdphwfhk55w6vlbb@twin.jikos.cz> User-Agent: Mutt/1.9.2 (2017-12-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, May 07, 2018 at 11:25:01PM +0200, David Sterba wrote: > On Mon, May 07, 2018 at 11:44:10AM -0700, Matthew Wilcox wrote: > > But something like btrfs should almost certainly be using ~GFP_ZONEMASK. > > Agreed, the direct use of __GFP_DMA32 was added in 3ba7ab220e8918176c6f > to substitute GFP_NOFS, so the allocation flags are less restrictive but > still acceptable for allocation from slab. > > The requirement from btrfs is to avoid highmem, the 'must be acceptable > for slab' requirement is more MM internal and should have been hidden > under some opaque flag mask. There was no strong need for that at the > time. The GFP flags encode a multiple of different requirements. There's "What can the allocator do to free memory" and "what area of memory can the allocation come from". btrfs doesn't actually want to allocate memory from ZONE_MOVABLE or ZONE_DMA either. It's probably never been called with those particular flags set, but in the spirit of future-proofing btrfs, perhaps a patch like this is in order? ---- >8 ---- Subject: btrfs: Allocate extents from ZONE_NORMAL From: Matthew Wilcox If anyone ever passes a GFP_DMA or GFP_MOVABLE allocation flag to allocate_extent_state, it will try to allocate memory from the wrong zone. We just want to allocate memory from ZONE_NORMAL, so use GFP_RECLAIM_MASK to get what we want. Signed-off-by: Matthew Wilcox diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c index e99b329002cf..4e4a67b7b29d 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -216,12 +216,7 @@ static struct extent_state *alloc_extent_state(gfp_t mask) { struct extent_state *state; - /* - * The given mask might be not appropriate for the slab allocator, - * drop the unsupported bits - */ - mask &= ~(__GFP_DMA32|__GFP_HIGHMEM); - state = kmem_cache_alloc(extent_state_cache, mask); + state = kmem_cache_alloc(extent_state_cache, mask & GFP_RECLAIM_MASK); if (!state) return state; state->state = 0;