From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9590FC433E7 for ; Fri, 17 Jul 2020 09:12:58 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 522EC20684 for ; Fri, 17 Jul 2020 09:12:58 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="pN+iEkbK" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 522EC20684 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id E72838D0009; Fri, 17 Jul 2020 05:12:57 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E22816B0062; Fri, 17 Jul 2020 05:12:57 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D11558D0009; Fri, 17 Jul 2020 05:12:57 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0151.hostedemail.com [216.40.44.151]) by kanga.kvack.org (Postfix) with ESMTP id B99486B0055 for ; Fri, 17 Jul 2020 05:12:57 -0400 (EDT) Received: from smtpin23.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 75BF21847717B for ; Fri, 17 Jul 2020 09:12:57 +0000 (UTC) X-FDA: 77047003194.23.iron28_3d09aa926f09 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin23.hostedemail.com (Postfix) with ESMTP id C031BA542 for ; Fri, 17 Jul 2020 09:12:27 +0000 (UTC) X-HE-Tag: iron28_3d09aa926f09 X-Filterd-Recvd-Size: 6374 Received: from mail-qk1-f195.google.com (mail-qk1-f195.google.com [209.85.222.195]) by imf02.hostedemail.com (Postfix) with ESMTP for ; Fri, 17 Jul 2020 09:12:27 +0000 (UTC) Received: by mail-qk1-f195.google.com with SMTP id b4so8111332qkn.11 for ; 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=IUZIE9dWBeo31FmcU9W6AUTdBlhDhDv7dQDy4K1f53a26+Z3fPHDiJs4YLvUQWzfTW ha9rpzFRadQLouHbkUlO/PJkq2sEvAE34jio7bONu/v1aAPbj87hrIsCYGGygEBqNY0P nBqK8sXyZkh19zDJyGES6f4b7DE35bAr/9m9bgTX6n3IvT9K3hOTolSpOPcr93ayauhk 5NwDLPmEOgIhP8nepKZfntElW0ir2Z1dyOowrfKRUQyZrygMi6DZIoJjohimKFihpc4z /r9AOGdk2N3kIMXLbZb3tqho5G4pblCEB5PkrQuJoCklCw0pU2D8GkeGfULQD5qyLajg WPVg== X-Gm-Message-State: AOAM532wk+XGRBGAiKyEYcSV4/UdjeLJ9JGiVGEjf6PgGtBHbgmidnO6 ujz86g+wx8c7o+zlL4923OZQWz4u8S69HxLaDPo= X-Google-Smtp-Source: ABdhPJwmbE7fIST0ir+FIiy8ZXFYqX5dhV/83uc8D0YuefqFKwDvOAb6dqbKFeID4IrE+dQsoSmmK/rQBrf4jDDZsyM= 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 X-Rspamd-Queue-Id: C031BA542 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam05 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000005, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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.