From patchwork Tue May 8 00:25:47 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 10384995 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 7EEA960353 for ; Tue, 8 May 2018 00:25:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 666B328B89 for ; Tue, 8 May 2018 00:25:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5B3D428BC9; Tue, 8 May 2018 00:25:56 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BA4D628B89 for ; Tue, 8 May 2018 00:25:55 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8F2AB6B000C; Mon, 7 May 2018 20:25:54 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 8A2986B000D; Mon, 7 May 2018 20:25:54 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 743476B0010; Mon, 7 May 2018 20:25:54 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf0-f200.google.com (mail-pf0-f200.google.com [209.85.192.200]) by kanga.kvack.org (Postfix) with ESMTP id 324156B000C for ; Mon, 7 May 2018 20:25:54 -0400 (EDT) Received: by mail-pf0-f200.google.com with SMTP id q15so3337606pff.17 for ; Mon, 07 May 2018 17:25:54 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:date:from:to:subject:message-id :references:mime-version:content-disposition:in-reply-to:user-agent; bh=Ng4WQa4iBMJXGDNkoei8Y95CN/7FgGJEm4kSYU28IQI=; b=pnZk66DSlxubGYe/2jLwguBPxaQBS7iZbQhGORwJq9pACvdwQvV2JGA/29yl5hVPdj 5ufQmPxES1RTuoIXnQJv4Hfc4uAv0R5iUCMKNCaI4w/4Vq6bD2D3GHxsYV0wiMndD0ZG AqHa/wXpMwWsjxJzIp5xHBc5Q0pKCKtf7apnBbZnb6U/9axdhpB1XRKd7FqW6jRtAyW/ MBQjNo3PtQO3Ve72Ao4zNt/xJzinnJvyhKEQcJgJskT5uLmCF5K6wLlAB5xcO2sYzN7u tUKIpud2i7gL24/XEIeZdv/4/h/u8OolOJs60xdj/TQq1HTTs1A1S592ruXoTm3eKwvG 4nCA== X-Gm-Message-State: ALQs6tAn/t2weVgnJmEdEjYXe8Yfb3Qx34K4JMm1ytZq5k9RcDyCWxdV IL4AHYu6nTa0iBifHbVr90CoyHPRr5RvC+tIEohdBVL1d/ozzrUK+Rc9nMykx6bgTN60REps9C7 7Dv1bDNCd2iIVaswzElY3ZYj89EdlZ/8RktG0ayYjZMEEYq01DimHITQ4ovu6Ip5nJw== X-Received: by 2002:a17:902:7283:: with SMTP id d3-v6mr16315267pll.192.1525739153780; Mon, 07 May 2018 17:25:53 -0700 (PDT) X-Google-Smtp-Source: AB8JxZoY60JQj04DhYNt4G0XdpHi6dt1mOqIzmb/HgPNO4mZsMSRaDdAG56Ufhni4FptLkK4aA2g X-Received: by 2002:a17:902:7283:: with SMTP id d3-v6mr16315239pll.192.1525739153176; Mon, 07 May 2018 17:25:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525739153; cv=none; d=google.com; s=arc-20160816; b=tSb++G50uwa3D01rEgSQVDN9GyPm07Lj3omUXfGB+3pD2zRFjHb8WmmbtR0wuHUWWE FCxlW2EWKlpVwvTiTstGfF1vbq96pQ2IN/rqltstgVlJmZS/MB5Wag8iphxckRPU2p1H vXZLMq0hTxEgcPdnXwQ/1Wlm66cg1SX+Da+ILttGf4VMwyu+6UvfZAUI2HSnRp3LX032 fzpQ4botGZCRzn7F0U1A69SNyGzUdCmb159lzraFzofFiRNlMWc3dvT1u0861H7WfK3P 9nbFW/hJaFTdrUY4aH+gZglEHtXJk4gw4W6tRGejAPi/I99+2wgjkFiFE9ORWm9BOdva mlZg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=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=m0Vl6sOFg2E1RHgT8i+hY8ywBHu2gx26OZ1tOS70LxVKehSIaVrPhqF/FBO4ocqYQT DCZbKrfG8k4GQzSA+QivcYadUyfewk0DOqbYyoGhJ8qNVwgru1mgPnsARd7eSsEJXLCb XxxIvZhzjU9Zkin07Fq89DD04dSkRzXDc/AF3E8j1dMxZkiKSNRBqo19DzMWmvmyMFTp JDYJ6zKDJ80DtbRAMWx2chgrEVWEwzWRC9OgPGSbinvj6afg0oh8jjv8oqplVqu1tM0h x+wOr8cBx3oa3+b9FSbbWxLKdwir9lvs3gJ2a5Mh7ZYFPBZLkJiOfAX9GAKpZ+HBxLDu uMtQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=euEFwKzf; spf=pass (google.com: best guess record for domain of willy@infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=willy@infradead.org Received: from bombadil.infradead.org (bombadil.infradead.org. [2607:7c80:54:e::133]) by mx.google.com with ESMTPS id c129si23596696pfa.99.2018.05.07.17.25.51 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 07 May 2018 17:25:51 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of willy@infradead.org designates 2607:7c80:54:e::133 as permitted sender) client-ip=2607:7c80:54:e::133; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=euEFwKzf; spf=pass (google.com: best guess record for domain of willy@infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=willy@infradead.org 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-Disposition: inline In-Reply-To: <20180507212500.bdphwfhk55w6vlbb@twin.jikos.cz> User-Agent: Mutt/1.9.2 (2017-12-15) X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP 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;