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=-6.6 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS autolearn=ham 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 67569C28CBC for ; Mon, 4 May 2020 03:03:05 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 19BDD206E6 for ; Mon, 4 May 2020 03:03:05 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="WDG+Nkkc" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 19BDD206E6 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 ABD9C8E0005; Sun, 3 May 2020 23:03:04 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A6C248E0001; Sun, 3 May 2020 23:03:04 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 95BE08E0005; Sun, 3 May 2020 23:03:04 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0086.hostedemail.com [216.40.44.86]) by kanga.kvack.org (Postfix) with ESMTP id 79FCC8E0001 for ; Sun, 3 May 2020 23:03:04 -0400 (EDT) Received: from smtpin13.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 4DBBE16E1A for ; Mon, 4 May 2020 03:03:04 +0000 (UTC) X-FDA: 76777539888.13.birth62_37e0edac08640 X-HE-Tag: birth62_37e0edac08640 X-Filterd-Recvd-Size: 6803 Received: from mail-qk1-f196.google.com (mail-qk1-f196.google.com [209.85.222.196]) by imf45.hostedemail.com (Postfix) with ESMTP for ; Mon, 4 May 2020 03:03:03 +0000 (UTC) Received: by mail-qk1-f196.google.com with SMTP id k81so12584585qke.5 for ; Sun, 03 May 2020 20:03:03 -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=6VKmRZQoAi2XKZ9R9IxXdPd+IOCcT2HWgI8X3qTMjEk=; b=WDG+NkkcTqZQueDWsJd72lp06lGDOnKch7ZI9bj0ZpmR/z1dyQjpCQvH8gJgb5oCUQ JFkTAfLlILFElrDYcpzuSQckxBQdwb36P5NoVys6Tgf/8kCVM4qLljZ3KeHde5zxgzK8 P1S+Hxxjgelta8sFQkPIthS44Nof2yQcr2WC0Af4UB9wAhy3N85KUhSoftuhkHtqBNKa UeTlb1Cc3L0MZu/wcow3956MteAvwo3ClyGdjteqO4kTE7ZrK3AxB+uOXtMPaUpKV4fr Q1uVCXXtaU/CnEeYkpXGu5xTuaOXJGbfVO8WfJDvJqFJaP8XhAhU788X1U09QjKwSjC9 ZC8Q== 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=6VKmRZQoAi2XKZ9R9IxXdPd+IOCcT2HWgI8X3qTMjEk=; b=LvsmIJ4XEzn/HNcA8GSi0Nl0Y/s0kM2jvKeEfQW1Zw05riqt2t6P1MRzVd5s0ijFQT 3d0U3+mnmtbFJaPncER9JB95T5sY64wE6YoAyl+lwaxbaYEVRTjnaLgFKckAawnuby2l ot3Gpi/tLITolZZs0LFWWsFsv7hgf0E235O+Hx1vn4hKHdWv010YixAfrTsB68yq1nMs Eu+hVbJIt8UJt4D/sgRD9fhA6mzMpjUbRffGQ6rxPtGMOKSl1qpa93UD+qFrpor/amkB uYoSO9ziXwZXQT0JNUet/nEms2fznjlha3XzXN75T641DAg3eOE2tFNf/ak73tAAJOaf cj0w== X-Gm-Message-State: AGi0PubNRh9Ea75cTT9tA6qkWEyCixX6ozccZ4TByAZqnJqI9WvF2k29 un4asXWz4vRX8x/TrHi8tH7ljZynlABIekni/Rc= X-Google-Smtp-Source: APiQypIwV4l/gvU4QExXYfhUKUXlzf7D5RROpYiLehTEpXv/GWWOMLHjatqzIkIMiXJZVN0IbizscDuu2LUFHJBXTGI= X-Received: by 2002:ae9:ea0a:: with SMTP id f10mr8876257qkg.272.1588561383180; Sun, 03 May 2020 20:03:03 -0700 (PDT) MIME-Version: 1.0 References: <1588130803-20527-1-git-send-email-iamjoonsoo.kim@lge.com> <1588130803-20527-6-git-send-email-iamjoonsoo.kim@lge.com> <20200501122427.GB21897@infradead.org> In-Reply-To: <20200501122427.GB21897@infradead.org> From: Joonsoo Kim Date: Mon, 4 May 2020 12:02:52 +0900 Message-ID: Subject: Re: [PATCH v2 05/10] mm/gup: separate PageHighMem() and PageHighMemZone() use case To: Christoph Hellwig Cc: Andrew Morton , Linux Memory Management List , LKML , Vlastimil Babka , Laura Abbott , "Aneesh Kumar K . V" , Mel Gorman , Michal Hocko , Johannes Weiner , Roman Gushchin , Minchan Kim , Rik van Riel , Christian Koenig , Huang Rui , Eric Biederman , "Rafael J . Wysocki" , Pavel Machek , kernel-team@lge.com, Joonsoo Kim Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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: 2020=EB=85=84 5=EC=9B=94 1=EC=9D=BC (=EA=B8=88) =EC=98=A4=ED=9B=84 9:24, Ch= ristoph Hellwig =EB=8B=98=EC=9D=B4 =EC=9E=91=EC=84=B1: > > On Wed, Apr 29, 2020 at 12:26:38PM +0900, js1304@gmail.com wrote: > > From: Joonsoo Kim > > > > Until now, PageHighMem() is used for two different cases. One is to che= ck > > if there is a direct mapping for this page or not. The other is to chec= k > > the zone of this page, that is, weather it is the highmem type zone or = not. > > > > Now, we have separate functions, PageHighMem() and PageHighMemZone() fo= r > > each cases. Use appropriate one. > > > > Note that there are some rules to determine the proper macro. > > > > 1. If PageHighMem() is called for checking if the direct mapping exists > > or not, use PageHighMem(). > > 2. If PageHighMem() is used to predict the previous gfp_flags for > > this page, use PageHighMemZone(). The zone of the page is related to > > the gfp_flags. > > 3. If purpose of calling PageHighMem() is to count highmem page and > > to interact with the system by using this count, use PageHighMemZone(). > > This counter is usually used to calculate the available memory for an > > kernel allocation and pages on the highmem zone cannot be available > > for an kernel allocation. > > 4. Otherwise, use PageHighMemZone(). It's safe since it's implementatio= n > > is just copy of the previous PageHighMem() implementation and won't > > be changed. > > > > I apply the rule #2 for this patch. > > > > Acked-by: Roman Gushchin > > Signed-off-by: Joonsoo Kim > > --- > > mm/gup.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/mm/gup.c b/mm/gup.c > > index 11fda53..9652eed 100644 > > --- a/mm/gup.c > > +++ b/mm/gup.c > > @@ -1608,7 +1608,7 @@ static struct page *new_non_cma_page(struct page = *page, unsigned long private) > > */ > > gfp_t gfp_mask =3D GFP_USER | __GFP_NOWARN; > > > > - if (PageHighMem(page)) > > + if (PageHighMemZone(page)) > > gfp_mask |=3D __GFP_HIGHMEM; > > I think this wants to stay PageHighMem. This migrates CMA pages to > other places before doing a long term pin. Anything that didn't have > a direct mapping before won't need one for the new page, which could > also include non-highmem zones without a highmem mapping. What we want to do here is to guess allocation gfp flags of original page in order to allocate a new page with most relaxed gfp flag. It is depend on the zone where the page belong to rather than existence of direct mapping. Until now, existence of direct mapping implies the type of zone so there is no problem. After my future CMA patchset, direct mapped CMA page will be on the ZONE_MOVABLE. And, a page on ZONE_MOVABLE should be allocated with __GFP_HIGHMEM | __GFP_MOVABLE. So, most relaxed gfp flag for this CMA page would include __GFP_HIGHMEM. If PageHighMem() is used here, __GFP_HIGHMEM would be lost since this CMA page has a direct mapping. Therefore, PageHighMemZone() is right one here. Anyway, I saw Eric's comment in other e-mail that abstraction is needed to guess gfp flags of original page and I agree with it. This site can also get benefit of such a change. Thanks.