Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp149537ybz; Tue, 28 Apr 2020 20:28:54 -0700 (PDT) X-Google-Smtp-Source: APiQypIOqzz2UwosX/+JFPutu+cq7dDhNDLSB0aYr/roNwsDrxdmuoW43pci7pJlzHSKnEM9DNr4 X-Received: by 2002:a05:6402:1ad0:: with SMTP id ba16mr772973edb.11.1588130934632; Tue, 28 Apr 2020 20:28:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588130934; cv=none; d=google.com; s=arc-20160816; b=QqHhOIR7Rojlm0DwRmX/k7dDd8WpDRgfjtxyoWCJrD1JoJI78u5EHCqu2D0G9xRlR5 RYBM4xf2hQioTlwkqRVc8+57kr5tAEGiMibU6RGBLF8e3axuC7mMlNs6KKZFtu3UtT7Y 8C+uOXPUzjPMoW9CT4YGFGxN3yBhKZlYQFU2wd04zifaDSGXcW+rn4rntyuOcMIhNHuN xdaXVR6ysU0VGsZrWnPz+ByYPJ+2mOhXRGtkLRcZiDhGUnIbFYSYflma5DJp6VR7KTJk SjJyUn7YiqNC80m58O8kX9b/0NHtIXBam/ZE87K2l4KTG+d7AVbNqI7rja38rwXLSbd6 gAjw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=Unb6vzKYfZVHOut29YQ6Kvm+UYMfQLEK+TJmxHNNGJY=; b=LXCF0PwgzGnmv9cdCsjCoPV92ct8NwxkSL7f3WOBphGPbsvCmGgzRZ/Hwujvkw9Siu sT+3aCzaCmPT7FiFbuI9HR+e6Z9CCM41K+I84UCwtWC7GWouZwy/w+tbq8zpbiLWxcex oO9Y5yB8YsEqAa8KPWPa0nTMvncQ1/RWkFvc8KA81p2TVsmPGrHoOeOC/eHCC1CEvYBm Xt/D7Iyy5SHsfeNNO8LDS6ILaTVSHxqEW0qy7yRQAHIEsaue24ztscpVaXQNtuQ9u5l+ n7U7ilTkrIJK8vFnryZJFJjbRn8sVV0WWXU182VhGg3ejGOI7G52UO/CfVmpEJGBHCFl iy/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=bNtHgy3N; 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 j21si2762391edt.523.2020.04.28.20.28.31; Tue, 28 Apr 2020 20:28:54 -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=bNtHgy3N; 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 S1726634AbgD2D1G (ORCPT + 99 others); Tue, 28 Apr 2020 23:27:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42660 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726508AbgD2D1G (ORCPT ); Tue, 28 Apr 2020 23:27:06 -0400 Received: from mail-pl1-x643.google.com (mail-pl1-x643.google.com [IPv6:2607:f8b0:4864:20::643]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 26187C03C1AC for ; Tue, 28 Apr 2020 20:27:06 -0700 (PDT) Received: by mail-pl1-x643.google.com with SMTP id h11so319710plr.11 for ; Tue, 28 Apr 2020 20:27:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Unb6vzKYfZVHOut29YQ6Kvm+UYMfQLEK+TJmxHNNGJY=; b=bNtHgy3NUjLmwef1ZHhK57fe3JiO55VlxYKnn5RshIkUTMNjEQ8/R2+4Hox/hDl4Sw BlrWHCBt89hiCS7EtfeMIJiLpnazYudS4VtnG2Mqlac5rz0sN2koMm6vnH8ZahohhMiH IkZCYgsdeC593M0bWx+yBa3myqFB+cwngBfY4Na2par4h98l19BJA4+eOH+ZjIljPwAI 5YpcX6cyBHaFOTv//9m+ziunxBzEQPAY/VfUmaubLTeZZalHI/eNAoOF8DezNFMZstKq MT4r2GgN4BjWDpk/E8qYPoMa3rqYBxXBn+T8G1Gf07YQ9/eztqfXUOpBY7VeJKg47laa ozNw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Unb6vzKYfZVHOut29YQ6Kvm+UYMfQLEK+TJmxHNNGJY=; b=Ca75bC8QilI49/pYSdkPIbOPsHWRN1oDwxxfn/H4ZWs0T19qGVggmcdosWjNB559fy KIdlSmTFHreoyD+uyKNwDg6adl0rOcMEpnwO8HEloN1YRjvy8IzK+6BLy7pnuJe0Qwdf ox1gnhlXYF/UrpS7cAOdF08m4zBA94gtCWvyMYKk1/OqSGCoOzf0y4WKOS6uEqm6LPcu 5MfCcWdOqPmQqA8CWL7lDfrPv4clX3BLUd6Dcf4xP9DRizni3SS+xQ43BmpUMoMTC2o/ ok1bHVEI6U/8I8qAqanotSOv1J13JxaL7nT+8eFlzQHrNU8fFeRkF+aUsB0xzpbMw/Sq A8eA== X-Gm-Message-State: AGi0Pub1danwV6IMsozSwUdzd5qhTfqMH07eZ7FHWTmwgVA00bykwhRo vEyM1uerpUaXfDCAegPiACg= X-Received: by 2002:a17:902:d30a:: with SMTP id b10mr18608241plc.3.1588130825605; Tue, 28 Apr 2020 20:27:05 -0700 (PDT) Received: from localhost.localdomain ([114.206.198.176]) by smtp.gmail.com with ESMTPSA id q11sm9559796pfl.97.2020.04.28.20.27.01 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 28 Apr 2020 20:27:05 -0700 (PDT) From: js1304@gmail.com X-Google-Original-From: iamjoonsoo.kim@lge.com To: Andrew Morton Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, 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, Christoph Hellwig , Joonsoo Kim Subject: [PATCH v2 01/10] mm/page-flags: introduce PageHighMemZone() Date: Wed, 29 Apr 2020 12:26:34 +0900 Message-Id: <1588130803-20527-2-git-send-email-iamjoonsoo.kim@lge.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1588130803-20527-1-git-send-email-iamjoonsoo.kim@lge.com> References: <1588130803-20527-1-git-send-email-iamjoonsoo.kim@lge.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Joonsoo Kim PageHighMem() is used for two different cases. One is to check if there is a direct mapping for this page or not. The other is to check the zone of this page, that is, weather it is the highmem type zone or not. Until now, both the cases are the perfectly same thing. So, implementation of the PageHighMem() uses the one case that checks if the zone of the page is the highmem type zone or not. "#define PageHighMem(__p) is_highmem_idx(page_zonenum(__p))" ZONE_MOVABLE is special. It is considered as normal type zone on !CONFIG_HIGHMEM, but, it is considered as highmem type zone on CONFIG_HIGHMEM. Let's focus on later case. In later case, all pages on the ZONE_MOVABLE has no direct mapping until now. However, following patchset "mm/cma: manage the memory of the CMA area by using the ZONE_MOVABLE" , which is once merged and reverted, will be tried again and will break this assumption that all pages on the ZONE_MOVABLE has no direct mapping. Hence, the ZONE_MOVABLE which is considered as highmem type zone could have the both types of pages, direct mapped and not. Since the ZONE_MOVABLE could have both type of pages, __GFP_HIGHMEM is still required to allocate the memory from it. And, we conservatively need to consider the ZONE_MOVABLE as highmem type zone. Even in this situation, PageHighMem() for the pages on the ZONE_MOVABLE when it is called for checking the direct mapping should return correct result. Current implementation of PageHighMem() just returns TRUE if the zone of the page is on a highmem type zone. So, it could be wrong if the page on the MOVABLE_ZONE is actually direct mapped. To solve this potential problem, this patch introduces a new PageHighMemZone() macro. In following patches, two use cases of PageHighMem() are separated by calling proper macro, PageHighMem() and PageHighMemZone(). Then, implementation of PageHighMem() will be changed as just checking if the direct mapping exists or not, regardless of the zone of the page. 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 implementation is just copy of the previous PageHighMem() implementation and won't be changed. My final plan is to change the name, PageHighMem() to PageNoDirectMapped() or something else in order to represent proper meaning. Acked-by: Roman Gushchin Signed-off-by: Joonsoo Kim --- include/linux/page-flags.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h index 222f6f7..fca0cce 100644 --- a/include/linux/page-flags.h +++ b/include/linux/page-flags.h @@ -378,10 +378,16 @@ PAGEFLAG(Readahead, reclaim, PF_NO_COMPOUND) /* * Must use a macro here due to header dependency issues. page_zone() is not * available at this point. + * PageHighMem() is for checking if the direct mapping exists or not. + * PageHighMemZone() is for checking the zone, where the page is belong to, + * in order to predict previous gfp_flags or to count something for system + * memory management. */ #define PageHighMem(__p) is_highmem_idx(page_zonenum(__p)) +#define PageHighMemZone(__p) is_highmem_idx(page_zonenum(__p)) #else PAGEFLAG_FALSE(HighMem) +PAGEFLAG_FALSE(HighMemZone) #endif #ifdef CONFIG_SWAP -- 2.7.4