Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp3192990ybz; Sun, 3 May 2020 20:05:51 -0700 (PDT) X-Google-Smtp-Source: APiQypKVyxJu8OSQVpoONzAr/u7Xz1clSY+R/KIjJXMQBy0keIRm5dq4XYSxaMFV/8un0j7vPyAg X-Received: by 2002:a05:6402:1d15:: with SMTP id dg21mr13249778edb.13.1588561551271; Sun, 03 May 2020 20:05:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588561551; cv=none; d=google.com; s=arc-20160816; b=y24/a4ILpfGJZd8C5DscvQ1D19gJqKlqqQvpsOQqreih4Vqq+b6Hee3FECjJP86HnN JxxrlydAcssb6yaSvhoxBWK4s1kkWtzIjXhYhkuElpxy77IaML4wTGA5VkwNKaLwdOP8 zRSuoTQ3SygDysW6Pz+uJT3qvZA3plU4/CeuxuW3kmwKtdv74d8feswD1Ac0jvbOaC5w mkk6qOiJpnQM6g1FIFQpERt1cFeR1jxpQ3H8FeUpna/c/YRziSxyxDcLowULm3+jKVbv 6hZA5CPyVavF8npEQoPpl943GP7HN2cTBBlxqzNJbD3F2Ep1EGFdI+3dXZpfjpEUPNDv ODAg== 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=6VKmRZQoAi2XKZ9R9IxXdPd+IOCcT2HWgI8X3qTMjEk=; b=MoLcNGPsd259fdoP6jGhXPhCYCOaFvQV5z1EpMLvOEFjNKeVPW6P6QRt5k3AN560h3 lixqAPuPVftRHO8vkrUtkEsPShiClTLPab9mHv1h3iwZ5/zlVVryWS8D7MfK4eOizdIk JxHzXMnUuEtl2S9xCFMUjIyUX2vlRb8VKzgLCuBmLkbcUuRWi6usm4irZu/NQoAp+7QX dmzRjQzGdyOlqyzgm/Hf4T/m5dfkw91n/cd9hsov3Js8T8hssKJowqZ3JXrKtHjqBAx9 C7wOErPG0AuLgD8mMA7lpeYilGEw9+QeMdJRdsP0rl1oXiQ7BaSCDkcRBk8xjyy8Ydh+ tpYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=WDG+Nkkc; 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 p16si6404372ejx.212.2020.05.03.20.05.28; Sun, 03 May 2020 20:05:51 -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=WDG+Nkkc; 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 S1727102AbgEDDDE (ORCPT + 99 others); Sun, 3 May 2020 23:03:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58434 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726927AbgEDDDE (ORCPT ); Sun, 3 May 2020 23:03:04 -0400 Received: from mail-qk1-x743.google.com (mail-qk1-x743.google.com [IPv6:2607:f8b0:4864:20::743]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6762DC061A0E for ; Sun, 3 May 2020 20:03:04 -0700 (PDT) Received: by mail-qk1-x743.google.com with SMTP id q7so15319393qkf.3 for ; Sun, 03 May 2020 20:03:04 -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=XjXs1WcO6nj5g6LH9GWqTE2+pwZbU5RDbkl6A8GzOhr9GfnlpxQRqiCbDTDpCfrZlA 84Gv6m8bGWXC/aGuzy6dZ5uwsoA1I1cL4yQCBNmhIzltD6/uXllQ6WyUjOIAuVMAAXfm zG30Qf+NoFblHB09W70cbBEojFVWzZDELnH+GGHTQzrUAP7gPde1H2A9bAv18MWlZ6hi Tm53Pla0+Ci3dZxSA9/4BW8Rtlu9jVT10wxAOI6trvNvjYQe4pFh+FdwnhP/mKFXgTfw nGkwCNXftfgYoaTNXM4BtXFNmi7alkM2GvGAeiVvxoQhZ9X1Fq96t/pQTDsbLlv7YyIr qHHQ== X-Gm-Message-State: AGi0PubFAAdU+qVqfaOomAxGehAQaOoZL+Ai0rN+MLFb3EjUOV43ES97 95pUi558bYyUPyEaenhJvM5ZjPlseHj1mTkdvuk= 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 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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.