Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp1828856ybh; Fri, 17 Jul 2020 02:13:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwGYJ5uWQqnwF4lTWppzGrDjFk1UjGs+F1uQD4j6aShFhoc8GnsXVGg8tCRg0j71cq81Lix X-Received: by 2002:a17:906:f91a:: with SMTP id lc26mr7366221ejb.372.1594977194192; Fri, 17 Jul 2020 02:13:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594977194; cv=none; d=google.com; s=arc-20160816; b=zWUlRJ1hxnQP3uAF2XgV6JSojltgofJEUeitnujHwTVVI6YqiU8qCDVkEgFtDMPqph jn6WueZ1Xco746kHkjne9eCTtCtz5dKGGeuirXMbE9JpvUTVSWnfnb4PDsWgbNaTR/DQ 0wo5ncIQ4PbItbB4B8B4rE4e8OwiVIqx2UTklWfbzdKL9Imbb4Mg41KGOLcoqmxsodXQ fYf/57mOL4MxS8db6lZDlTnN8vou+3fX6SkZk6NWDgS+HSvtYPI3aCb5htH3GkO48FHc Zx1RJaZ1rAVRE4Cvvv9QKgD6p5WUTkGvQ5w0SeFfyBCcBXUoaYSawZqz2JfLCSyE/q/I Cqyw== 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:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=GnonKWI30rguXS7h1YA4tqQthfNBF8/h7qxKFP7NCi8=; b=Nlji9ZIptJcY1UGcYbqQED/D+mBn9AGW0OB3Zkc8izT3FvEp2W/HiR9kT4Ie7IpXUz B41asCG4svEjexPfxacvlGIB1kz9oUjIZ40eCqdrJm7k+TOIdg0FMCvDp/6Vacssl00v u3jHVLBmmzzFwFLxsiYAhKvSlfFID6L21fo6bxY9/jIy+bvDoyDwfL49ouKakpm7me8k TiS9KavSuxk4xhT7THIXvHQ/a3al01PDRG2ksNEUqNMmedEviDwyVhN3b4ZhsdQRclUB DYb7TKnT19ABB8n/3XjbVL5BbkWqcESn2XZ5o7dwxebCV7ZBpPzlsISNy4mAIR9EB/lF hxEA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=pN+iEkbK; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y97si4865403ede.234.2020.07.17.02.12.51; Fri, 17 Jul 2020 02:13:14 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=pN+iEkbK; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726070AbgGQJM2 (ORCPT + 99 others); Fri, 17 Jul 2020 05:12:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51564 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725864AbgGQJM1 (ORCPT ); Fri, 17 Jul 2020 05:12:27 -0400 Received: from mail-qk1-x744.google.com (mail-qk1-x744.google.com [IPv6:2607:f8b0:4864:20::744]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8BFC6C061755; Fri, 17 Jul 2020 02:12:27 -0700 (PDT) Received: by mail-qk1-x744.google.com with SMTP id l23so310459qkk.0; Fri, 17 Jul 2020 02:12:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=GnonKWI30rguXS7h1YA4tqQthfNBF8/h7qxKFP7NCi8=; b=pN+iEkbKtmtWOS1dFVEJxVYGvO6Nv3DJxZ2rcKhy2el36Lo2M2637mw/46dCxCHNIW TPhRPgJUaJND4/d2lfuHCgJawl1BZnE2N/Hczsun4G2e0Skaqa/mO7JtCZBwC3X+Bkwc ivPyM6GgChG/9O464ICajuDpJjM65TvQrjnJygIgXnXmwAWV1rSx8OppUb7pDLkpJKNv kY735v+9f105rpSvNnA/BFNLcwHKI7AVTTQwuAVJB1n5uK1DSGYvwp5W3+oz35VybHDy 1eLFZkjaKl4xULjNOzpLVLnpEWaqqQ046yVXcLrJ7pN2O2tkK9gL7jmiGoSs/m65+Y8E es+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=GnonKWI30rguXS7h1YA4tqQthfNBF8/h7qxKFP7NCi8=; b=q6m0tJ/r+nZHZVqMJ3fTA53wmUfX6H4iGsvyGHfpECLyTj9o4OZYuvvM+MNU3atZVm HwB3UDxwmxqrBcXnE5I/Eeltxnpx/Pxh3rSTVF9iVtHEhdFj5gkSPd0lwBr6DSugtDP+ ApTW7hfIvwxUURYsp2GQJXYb05Y3zo6LE/cotf9o6HplllOpF0JBCLnL2ylYrq/kHuOX KBEQHfOYO6beRxbo/Z+3xp0K+0Ta3uSCZ5H5MJHgtEytdr2zvaMtRpwmFlvWzb/Vjcqn Iu+ZXDXaxJN2VE9PvgfZLXIQFB5H9i7z0mi/U7HG5aqO4TfC8sr1zRi0EOlUAMYTIcJ+ 9a/w== X-Gm-Message-State: AOAM530ghUKdat4AhpPYrZ9oxMrtCmjqBdqxj/vqefOIB4Fz5SYIi8eG Hcy+kWUT2q9KImCniFeRXEa6YjrX5Vt5nSfFVfk= X-Received: by 2002:a37:a785:: with SMTP id q127mr8092807qke.452.1594977146715; Fri, 17 Jul 2020 02:12:26 -0700 (PDT) MIME-Version: 1.0 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> In-Reply-To: From: Joonsoo Kim Date: Fri, 17 Jul 2020 18:12:15 +0900 Message-ID: Subject: Re: [PATCH 1/4] mm/page_alloc: fix non cma alloc context To: Vlastimil Babka 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 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 2020=EB=85=84 7=EC=9B=94 17=EC=9D=BC (=EA=B8=88) =EC=98=A4=ED=9B=84 5:15, V= lastimil Babka =EB=8B=98=EC=9D=B4 =EC=9E=91=EC=84=B1: > > On 7/17/20 10:10 AM, Vlastimil Babka wrote: > > On 7/17/20 9:29 AM, Joonsoo Kim wrote: > >> 2020=EB=85=84 7=EC=9B=94 16=EC=9D=BC (=EB=AA=A9) =EC=98=A4=ED=9B=84 4:= 45, Vlastimil Babka =EB=8B=98=EC=9D=B4 =EC=9E=91=EC=84=B1: > >>> > >>> On 7/16/20 9:27 AM, Joonsoo Kim wrote: > >>> > 2020=EB=85=84 7=EC=9B=94 15=EC=9D=BC (=EC=88=98) =EC=98=A4=ED=9B=84= 5:24, Vlastimil Babka =EB=8B=98=EC=9D=B4 =EC=9E=91=EC=84= =B1: > >>> >> > /* > >>> >> > * get_page_from_freelist goes through the zonelist trying to a= llocate > >>> >> > * a page. > >>> >> > @@ -3706,6 +3714,8 @@ get_page_from_freelist(gfp_t gfp_mask, uns= igned int order, int alloc_flags, > >>> >> > struct pglist_data *last_pgdat_dirty_limit =3D 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 i= n the > >>> >> fastpath, if that's what you wanted to avoid. > >>> > > >>> > I want to execute it on the fastpath, too. Reason that I moved it h= ere > >>> > 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 a= pply > >>> > this option to all the allocation paths at once. > >>> > >>> But get_page_from_freelist() might be called multiple times in the sl= owpath, and > >>> also anyone looking for gfp and alloc flags setup will likely not exa= mine this > >>> function. I don't see a problem in having it in two places that alrea= dy 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 =3D=3D ALLOC_OOM || > > (gfp_mask & __GFP_NOMEMALLOC))) > > goto nopage; > > > > Maybe it's simpler to change get_page_from_freelist() then. But documen= t 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... Good catch! Hmm... Okay. It would be necessarily handled in three places. I will fix it on the next version. Anyway, we need some clean-up about alloc_flags handling since it looks not good for maintenance. Thanks.