Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp1803094ybh; Fri, 17 Jul 2020 01:17:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwSPEvvBvwfFQQcuaHpGPS8HqbbZFO8d6isHC+4mTxuSAq5S7jI5qfpQbP/rCEM96o32KPD X-Received: by 2002:a17:906:57c6:: with SMTP id u6mr7430489ejr.194.1594973857555; Fri, 17 Jul 2020 01:17:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594973857; cv=none; d=google.com; s=arc-20160816; b=YiLhhSfuvCtF/VW4Cydd6vZqlq3cZmkylcRnt4bs56JzSZi1+UBiXQxBO/bBkKJTcI YQcJEShoqlLbp+W5Fc//gCjjzWN3jwGxCb0mCKjblSedEi35NEVSPVWmKrz7jPfeCdxw JZS6Yu40i/NhUpkXUBV77nz3/aT2DLPkNar3fTieUwWib5Yb/NDL1Hy1/Ep49DhTYZcW SQOLzdJ7KhfjIXrULiwS1Y8mvuS4I8fCaTYAa9vZg89fWT2zkKXsRVRhZwka6P6QFoby bvdkwLHw4kuIDtIu4zK2ZwTvcL00EBGBnF4TZG2MmDJ1BOM2NbHsDNTishvvYnR9V1gm 0w2w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:references:cc:to:from:subject; bh=go/w9l4mvT76/vm9EzI6E3d6adhrkvCDqg764G+1vMA=; b=uTG2jBJkCMTUPljQNcm2RRBWdNKFS1vOM8XlheH8YoUdAgKoLPCeWf3Mx22PwaEy4Q f6YT6hzQyzi8EfPdcfpLerTQGx/L7B0KFrGuVHPTaF+1S4IpxRdogpILTW96aEtRDCBd tnONEi6QMIywUYIG/G9Rnz0rHqDK8fx0ug1K0CttrrbW7oPJp2sWopYPLRJSHDpy/jQr nPEYXYMnhDd0Sh51OJUAdYxtltoy0e5au7kMBhS//0Mhrq9q6O1MWFojYuEIGS14MVku OR1pIgntCagYrYtNRswgdpFyffqte3+yfBPSpweo0wkXHjz/tKSRnvfmilnNIzHGu12d 4RnQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h7si4648309ejy.82.2020.07.17.01.17.14; Fri, 17 Jul 2020 01:17:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728262AbgGQIPG (ORCPT + 99 others); Fri, 17 Jul 2020 04:15:06 -0400 Received: from mx2.suse.de ([195.135.220.15]:54316 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726201AbgGQIPG (ORCPT ); Fri, 17 Jul 2020 04:15:06 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id A7952AFF7; Fri, 17 Jul 2020 08:15:08 +0000 (UTC) Subject: Re: [PATCH 1/4] mm/page_alloc: fix non cma alloc context From: Vlastimil Babka To: Joonsoo Kim Cc: Andrew Morton , Linux Memory Management List , LKML , kernel-team@lge.com, Christoph Hellwig , Roman Gushchin , Mike Kravetz , Naoya Horiguchi , Michal Hocko , "Aneesh Kumar K . V" , Joonsoo Kim , stable@vger.kernel.org References: <1594789529-6206-1-git-send-email-iamjoonsoo.kim@lge.com> <332d620b-bfe3-3b69-931b-77e3a74edbfd@suse.cz> <6f18d999-4518-31ce-4cea-9b5b89a577ad@suse.cz> <5a8b13d5-da40-7b1b-2968-e6701001cc0e@suse.cz> Message-ID: Date: Fri, 17 Jul 2020 10:15:03 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <5a8b13d5-da40-7b1b-2968-e6701001cc0e@suse.cz> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 7/17/20 10:10 AM, Vlastimil Babka wrote: > On 7/17/20 9:29 AM, Joonsoo Kim wrote: >> 2020년 7월 16일 (목) 오후 4:45, Vlastimil Babka 님이 작성: >>> >>> On 7/16/20 9:27 AM, Joonsoo Kim wrote: >>> > 2020년 7월 15일 (수) 오후 5:24, Vlastimil Babka 님이 작성: >>> >> > /* >>> >> > * get_page_from_freelist goes through the zonelist trying to allocate >>> >> > * a page. >>> >> > @@ -3706,6 +3714,8 @@ get_page_from_freelist(gfp_t gfp_mask, unsigned int order, int alloc_flags, >>> >> > struct pglist_data *last_pgdat_dirty_limit = NULL; >>> >> > bool no_fallback; >>> >> > >>> >> > + current_alloc_flags(gfp_mask, &alloc_flags); >>> >> >>> >> I don't see why to move the test here? It will still be executed in the >>> >> fastpath, if that's what you wanted to avoid. >>> > >>> > I want to execute it on the fastpath, too. Reason that I moved it here >>> > is that alloc_flags could be reset on slowpath. See the code where >>> > __gfp_pfmemalloc_flags() is on. This is the only place that I can apply >>> > this option to all the allocation paths at once. >>> >>> But get_page_from_freelist() might be called multiple times in the slowpath, and >>> also anyone looking for gfp and alloc flags setup will likely not examine this >>> function. I don't see a problem in having it in two places that already deal >>> with alloc_flags setup, as it is now. >> >> I agree that anyone looking alloc flags will miss that function easily. Okay. >> I will place it on its original place, although we now need to add one >> more place. >> *Three places* are gfp_to_alloc_flags(), prepare_alloc_pages() and >> __gfp_pfmemalloc_flags(). > > Hm the check below should also work for ALLOC_OOM|ALLOC_NOCMA then. > > /* Avoid allocations with no watermarks from looping endlessly */ > if (tsk_is_oom_victim(current) && > (alloc_flags == ALLOC_OOM || > (gfp_mask & __GFP_NOMEMALLOC))) > goto nopage; > > Maybe it's simpler to change get_page_from_freelist() then. But document well. But then we have e.g. should_reclaim_retry() which calls __zone_watermark_ok() where ALLOC_CMA plays a role too, so that means we should have alloc_mask set up correctly wrt ALLOC_CMA at the __alloc_pages_slowpath() level... >> Thanks. >> >