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=-9.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,USER_AGENT_GIT 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 30E27C3815B for ; Mon, 20 Apr 2020 08:00:51 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id D324E21D79 for ; Mon, 20 Apr 2020 08:00:50 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="orTGtLKO" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D324E21D79 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 80AA78E000A; Mon, 20 Apr 2020 04:00:50 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7B9CB8E0003; Mon, 20 Apr 2020 04:00:50 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6A9C58E000A; Mon, 20 Apr 2020 04:00:50 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0217.hostedemail.com [216.40.44.217]) by kanga.kvack.org (Postfix) with ESMTP id 4FB0C8E0003 for ; Mon, 20 Apr 2020 04:00:50 -0400 (EDT) Received: from smtpin06.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id F2AED180AD83E for ; Mon, 20 Apr 2020 08:00:49 +0000 (UTC) X-FDA: 76727487018.06.pig81_5e8a0889f710c X-HE-Tag: pig81_5e8a0889f710c X-Filterd-Recvd-Size: 6814 Received: from mail-pj1-f65.google.com (mail-pj1-f65.google.com [209.85.216.65]) by imf22.hostedemail.com (Postfix) with ESMTP for ; Mon, 20 Apr 2020 08:00:49 +0000 (UTC) Received: by mail-pj1-f65.google.com with SMTP id a32so4217847pje.5 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=QFr+aZ0yj1bVSTJLEEnp/6CZyrit7ZFbhxxHhbPtv6bbU+gsK/RP19GLATO6EbVorT 5xeqUS1Vpr/IMqI9TcnnLx4vhlDyIsy8Gb2beLeEYYKlCwaDb5Yn4uoDpwgFn72xHjq9 zQ8DyJfcgabwBmi3bkWMTQD+rW0sI0WsUmAi73WmmFrTpPktqGoVmL3OLe1+qpi+RqrY +y0jNzpghJdA0LKJxwdVpbOKpcX3BVpjrlaZ0xrGHU4u+r1vWzmVebdoXdcWqW0spU2L mWOAvUHLbb+VCBibGZTVsBQVpa7V6DPeydGHJ59+llw1vO3b93Vdr1C9sWLa1CTkGq0f lkdg== X-Gm-Message-State: AGi0PuZG4dA52jrE6EU5gfMoXnijjoZ3Hm65H3LYtkkasHfwC7dLkxAz Oo1xj0i/D6Zav2laehGMjpA= X-Google-Smtp-Source: APiQypKKbyPIRbMq1vcNKZR0DJGfCfwbyZGhnv1+btoqsxzPHzT9AeM+BFO1DpUTeokUXQL0O0yLug== 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> 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: 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