Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp3364851ybz; Mon, 20 Apr 2020 01:02:03 -0700 (PDT) X-Google-Smtp-Source: APiQypILmry41JFFw0HSHNxhteV+OXm41cVYcgGrot1oBQlFgd8+vlybh3nk0BNhBFxccLjUxxWQ X-Received: by 2002:a17:906:14c:: with SMTP id 12mr15082029ejh.125.1587369723138; Mon, 20 Apr 2020 01:02:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587369723; cv=none; d=google.com; s=arc-20160816; b=CeWxJrWpTKiTWo+lzMbZ+zopyZTnq6xSQ78yTiFPOkgyUG2mLo9LBhd7k4xKJQQsOk tG75tnxFvLzMi7MGVrGq4lDYZvwN//o9A1c1q3RiWH1hmE496EzzEdM1nDkkNTNh8O+U /NfsVTMk7BVYD5YLvmlopN3LUdbd4xxY3vsRgQYG0Jb7kRp7fyGjJK7G9h0oqMcT6QVl 1R2mWDdANTzRRgtdAn7ugNPy7GgjnICXo2SS6sAEa7sUMnXExZoU9beR4gKoWohUrhAt 7SGhSn0RVXQtB+bYIc5+iWgi8poacXZ+lcWQ4Zu5K39x3jZvptFNYIF/Ef+8qBqK6Pn7 WB1w== 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=MEpV3hn90v/RuIN3YFDQo8euDWQ92aPlcVxL9l6luZc=; b=HK4rbmD7zXHEreLVJLzwNayOX3L2SuAin6m/8crStQbgeVYyUZbNQcAloCHDxbXmjz x4z4Zb/XuIdoHqZJA6IDhIOriGTxczJteYyF+iXgeUxbD9PaYozUTB/Up9SI0lfyna2n ovItOvx1QnEmy9f0xm6FUH30EKoaif5WubKEROmKp9GguKwlV0moXqWfb0np3TwdD8r5 /8ooO1Ij6DasYJetxZpd75mtZ2b9XRZCFZKMP3Ow90G9lrwUv6lBpQFfhY8nDzrbt7ld o98O7Il/Igy4IdbP4RUTkwZa9kQ8l50AuCSFsg9AObXfo0fMPbcoX2cTg0ntEVk7ey42 BmEA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="ItF3/sZ2"; 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 o5si84577eja.207.2020.04.20.01.01.40; Mon, 20 Apr 2020 01:02:03 -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="ItF3/sZ2"; 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 S1726240AbgDTIAd (ORCPT + 99 others); Mon, 20 Apr 2020 04:00:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45672 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725815AbgDTIAb (ORCPT ); Mon, 20 Apr 2020 04:00:31 -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 B088FC061A0C for ; Mon, 20 Apr 2020 01:00:31 -0700 (PDT) Received: by mail-pl1-x643.google.com with SMTP id y22so3665033pll.4 for ; Mon, 20 Apr 2020 01:00:31 -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=MEpV3hn90v/RuIN3YFDQo8euDWQ92aPlcVxL9l6luZc=; b=ItF3/sZ2EanrjBm2LMdHTVjFNOiCabn95CkywyoZB1iGsyLxMr6ftCI02m1MHLUjRs iC6a2bcD4Ik5496j6dODC1mg2gZICwfcWKbw6i49RgeJr3YcxIuxNDN9s7mbW3evoi7h WpsP/IhNbXg16uGjeoe5AQ8YbYSBKK5XDUhysWkIyso1o/+02mcrpiNJhd/6Nk8ztTPN xdYBJ866yeVULptcz9G340mEVWY1veIegHlirZ93tmTL8OQ3Eo2dgXhviySnyEBgdCms Zm1xicNj/yls67BHQA5vUiv/1ICX2/VRKDmDAQkrGvUZDsjVZhuEAMaVAsSptDHri8jX Ahtg== 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=MEpV3hn90v/RuIN3YFDQo8euDWQ92aPlcVxL9l6luZc=; b=qc3pAr0gyNoVbtUEiVjhVvFtYqXsVmcDUm60Amofn8RvY0mZ2aFI9W6VQww4IlcjHO 98VW5L9ci/22U0HkDmdvr8jWkix5AzoGGQQCAyhEeGNJGtZOYDVkBKDkrk78zle/L/Wi J6pKogZ4RFN1Y7ndzgpof5j4V10BnpwQ5U0IiaYKKCj8vZRgiaZyU4UHHmOatJqjViVr DZjjVg3Upvqu0uPZs31E+rQ/Fuyvxyyg+VnmLAQZXVTCyxlc7yegFV4URH6Kj9tD3dJ/ fpxuGQmLxtYr9tWRZrcoA155dZhEhHitbdzPrqrw8rRyyMUBv9wTqDUbv8QJFIWqgDmH jmGg== X-Gm-Message-State: AGi0Puay75RhHm1sgf4DPEvCWi5wi2X0fpx+3tnxNWynpXxqYVh1IzwN 23J8xQwqU/tO0gLiJtLh+ak= X-Received: by 2002:a17:90a:1910:: with SMTP id 16mr20345971pjg.119.1587369631174; Mon, 20 Apr 2020 01:00:31 -0700 (PDT) Received: from localhost.localdomain ([114.206.198.176]) by smtp.gmail.com with ESMTPSA id n9sm314947pjt.29.2020.04.20.01.00.27 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 20 Apr 2020 01:00:30 -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 , Joonsoo Kim Subject: [PATCH 01/10] mm/page-flags: introduce PageHighMemZone() Date: Mon, 20 Apr 2020 16:59:33 +0900 Message-Id: <1587369582-3882-2-git-send-email-iamjoonsoo.kim@lge.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1587369582-3882-1-git-send-email-iamjoonsoo.kim@lge.com> References: <1587369582-3882-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. 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