Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp3366903ybz; Mon, 20 Apr 2020 01:04:45 -0700 (PDT) X-Google-Smtp-Source: APiQypLJNSiW5CWISQUWNqVozcK7WoRUmtouxyJgmpmTtYsJq7Adv1F3eckiO1fkGAgNi7yS2/f2 X-Received: by 2002:a05:6402:30ad:: with SMTP id df13mr12753750edb.339.1587369885236; Mon, 20 Apr 2020 01:04:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587369885; cv=none; d=google.com; s=arc-20160816; b=R+p4P88/aTPAKmq1J82Dlnd9DFqIxJ7drxM0/OW4rLnd9PTMhhitwb545S2F7tfNNm LFllYz+C5nZnMzNw0sQ+21pQojx1uWCUUKO16y4mJHwKKEVWuv7DRE6eqeiWv9HaJWf2 YdxUNfhNRxt2Z1rBw397VS/+SVpqUi1/RJR8cmv9pUhw2xvsRGALwFjLh45IrFoWhc9l kLTbQrh+Az6RP+pGzFvXRUk5Kp0ATLvtbbZvE08tDKVVApylLkGRH8PcuslsbZ8YsjXf 7e+C53O/Yoxk6OsxaP0WTzUUsB6Bj3kaI7xyjJzjKyxqYJPC2vah7Y0dYN+U9YQ1BChg QV6g== 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=sBX6qWohHq9VKZ0U2mSr5aRQHj4zccdByOlpRqoMWwY=; b=UTHTuUHBRbItOHYPbAy9yPuAtVZxcwpAIl/qtFaXYS+sHvk3BTq5rMYBihZxabtjSZ kyLyu3W0kC1gJRCIXsN9JhUPJ7706F8UFbbI3jEpGldjv6uaXw1Y6rU5LbY0UZB+5+Vp mybGFXKaAlnlRvaCdvAZ2zera1Vn6s8KKUl9DgZwSHOvSAn46YV8GStMIQyLUjbzsy2/ N/Mvkb4swma22Hx+xr/HZQSkc/Brr/YUkAmAa41fCKeQlJn/iLx/cXNxOX9k8f0PYJn8 pf2m2VmMoiDlr3hn86zy8BFrlpc9pHsxkbCXgLfDfJ0788auynFvGScavPNCB6Sp9X1X W3Ug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=orTGtLKO; 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 g12si70467ejw.314.2020.04.20.01.04.22; Mon, 20 Apr 2020 01:04:45 -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=orTGtLKO; 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 S1726392AbgDTIAt (ORCPT + 99 others); Mon, 20 Apr 2020 04:00:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45726 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725815AbgDTIAt (ORCPT ); Mon, 20 Apr 2020 04:00:49 -0400 Received: from mail-pl1-x641.google.com (mail-pl1-x641.google.com [IPv6:2607:f8b0:4864:20::641]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 10100C061A0C for ; Mon, 20 Apr 2020 01:00:49 -0700 (PDT) Received: by mail-pl1-x641.google.com with SMTP id v2so3653642plp.9 for ; Mon, 20 Apr 2020 01:00:49 -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=sBX6qWohHq9VKZ0U2mSr5aRQHj4zccdByOlpRqoMWwY=; b=orTGtLKOeO92VzedvwhPGpw+IJTJ77Ml1eZ8mqw74O+Jee5x6bfAEvyptoPctixtsg vstlIqY6+Po0HjsIaniK9lMNl4iAmo4P6x0PZGr4/IfrL5Umg5ikWaa2K1M5LO5n1XT6 FAn5xLXWdfzKZjbfbexpTDWdpjXx4cQptExRCZb5DbLNDl/IOP3inQxmL9NtZyo+wX6J QO5fkWlk0qqIdnPMVTUnkesY/2QmJRKQXPQRydWW6p4qftXq11Dz+Dc8RmvIDB2YtEa8 zhqlJNUIfrwQxcI3BB6ZpAbj6i5pKcAE1xC/NgG2FsNUY539eMZWSOOk17o8jcqO+44p Abkw== 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=sBX6qWohHq9VKZ0U2mSr5aRQHj4zccdByOlpRqoMWwY=; b=BmMSzxAEN6KiyfXHxASRu1KdLeFjaYUo9T2Sdd6axeaKKv99YssP33xoUkxzQJEH0q WKmvbgoTasG8lxj1MR5p+Z2OidGeJ7j2da6CVwqwOHx+brsVnP3xukjYPX1M7fENgFxC bmRavsf1eMCMspmS8ZGnDFDq3QTY28RAdhMdodSiaB2uUqiwWpxtc4Z5gxnuE4vQfcVQ yRHUMyH7A7EzGhgLTLiRxeLv55NxSt1EVvsZinoxZmpw9qjcfS/lmVSp3CaikLIBwrcG 0QmMz7BuIl59qs3Y5R/K2KVPuSlDFOHgvVWjvD7sbvhJiNGu/YBhWcDkvXXkLGDL2DQX scmg== X-Gm-Message-State: AGi0PuZzRLCkCjisn7rwJ1XEXzmtzHIo7HZy/uIDNg+V3UAnhpbtJClP aOUa9QNjeS9JYy4ej3DXiu8= X-Received: by 2002:a17:90b:3851:: with SMTP id nl17mr1446291pjb.45.1587369648598; Mon, 20 Apr 2020 01:00:48 -0700 (PDT) Received: from localhost.localdomain ([114.206.198.176]) by smtp.gmail.com with ESMTPSA id n9sm314947pjt.29.2020.04.20.01.00.44 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 20 Apr 2020 01:00:47 -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 05/10] power: separate PageHighMem() and PageHighMemZone() use case Date: Mon, 20 Apr 2020 16:59:37 +0900 Message-Id: <1587369582-3882-6-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 Until now, 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. Now, we have separate functions, PageHighMem() and PageHighMemZone() for 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 implementation is just copy of the previous PageHighMem() implementation and won't be changed. I apply the rule #3 for this patch. Signed-off-by: Joonsoo Kim --- kernel/power/snapshot.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/kernel/power/snapshot.c b/kernel/power/snapshot.c index 6598001..be759a6 100644 --- a/kernel/power/snapshot.c +++ b/kernel/power/snapshot.c @@ -1227,7 +1227,7 @@ static struct page *saveable_highmem_page(struct zone *zone, unsigned long pfn) if (!page || page_zone(page) != zone) return NULL; - BUG_ON(!PageHighMem(page)); + BUG_ON(!PageHighMemZone(page)); if (swsusp_page_is_forbidden(page) || swsusp_page_is_free(page)) return NULL; @@ -1291,7 +1291,7 @@ static struct page *saveable_page(struct zone *zone, unsigned long pfn) if (!page || page_zone(page) != zone) return NULL; - BUG_ON(PageHighMem(page)); + BUG_ON(PageHighMemZone(page)); if (swsusp_page_is_forbidden(page) || swsusp_page_is_free(page)) return NULL; @@ -1529,7 +1529,7 @@ static unsigned long preallocate_image_pages(unsigned long nr_pages, gfp_t mask) if (!page) break; memory_bm_set_bit(©_bm, page_to_pfn(page)); - if (PageHighMem(page)) + if (PageHighMemZone(page)) alloc_highmem++; else alloc_normal++; @@ -1625,7 +1625,7 @@ static unsigned long free_unnecessary_pages(void) unsigned long pfn = memory_bm_next_pfn(©_bm); struct page *page = pfn_to_page(pfn); - if (PageHighMem(page)) { + if (PageHighMemZone(page)) { if (!to_free_highmem) continue; to_free_highmem--; @@ -2264,7 +2264,7 @@ static unsigned int count_highmem_image_pages(struct memory_bitmap *bm) memory_bm_position_reset(bm); pfn = memory_bm_next_pfn(bm); while (pfn != BM_END_OF_MAP) { - if (PageHighMem(pfn_to_page(pfn))) + if (PageHighMemZone(pfn_to_page(pfn))) cnt++; pfn = memory_bm_next_pfn(bm); @@ -2541,7 +2541,7 @@ static void *get_buffer(struct memory_bitmap *bm, struct chain_allocator *ca) return ERR_PTR(-EFAULT); page = pfn_to_page(pfn); - if (PageHighMem(page)) + if (PageHighMemZone(page)) return get_highmem_page_buffer(page, ca); if (swsusp_page_is_forbidden(page) && swsusp_page_is_free(page)) -- 2.7.4