From patchwork Wed Apr 29 03:26:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joonsoo Kim X-Patchwork-Id: 11515951 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id F38D292A for ; Wed, 29 Apr 2020 03:27:22 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id B5EB82068E for ; Wed, 29 Apr 2020 03:27:22 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="rs9+Ni8w" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B5EB82068E 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 EA9608E0009; Tue, 28 Apr 2020 23:27:21 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id E814A8E0001; Tue, 28 Apr 2020 23:27:21 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D96F28E0009; Tue, 28 Apr 2020 23:27:21 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0189.hostedemail.com [216.40.44.189]) by kanga.kvack.org (Postfix) with ESMTP id C38598E0001 for ; Tue, 28 Apr 2020 23:27:21 -0400 (EDT) Received: from smtpin01.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 8F75549960B for ; Wed, 29 Apr 2020 03:27:21 +0000 (UTC) X-FDA: 76759457082.01.toad32_7a6ba95460b0c X-Spam-Summary: 2,0,0,59b4448324025aed,d41d8cd98f00b204,js1304@gmail.com,,RULES_HIT:41:355:379:541:800:960:966:973:988:989:1260:1345:1359:1437:1535:1543:1711:1730:1747:1777:1792:2194:2196:2199:2200:2393:2559:2562:2898:3138:3139:3140:3141:3142:3355:3865:3866:3867:3868:3871:3872:3874:4117:4321:4385:5007:6119:6261:6653:6742:7576:7903:8957:9413:10004:11026:11232:11473:11638:11658:11914:12043:12296:12297:12438:12517:12519:12555:12679:12895:13053:13161:13180:13229:13548:14096:14181:14394:14721:14819:21080:21325:21444:21451:21627:21666:21740:21990:30054:30064:30070:30079,0,RBL:209.85.215.195:@gmail.com:.lbl8.mailshell.net-62.18.0.100 66.100.201.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:24,LUA_SUMMARY:none X-HE-Tag: toad32_7a6ba95460b0c X-Filterd-Recvd-Size: 6924 Received: from mail-pg1-f195.google.com (mail-pg1-f195.google.com [209.85.215.195]) by imf16.hostedemail.com (Postfix) with ESMTP for ; Wed, 29 Apr 2020 03:27:21 +0000 (UTC) Received: by mail-pg1-f195.google.com with SMTP id d3so367672pgj.6 for ; Tue, 28 Apr 2020 20:27:21 -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=h4/eFw0vWwBVRaZ/3UIgJHxLSvTZ3eLOl09I88FAedw=; b=rs9+Ni8w22sXa2fxOCse9k1u5KKvpq45u6RYgFD5LUjVWiQJ/O9bc0lxa7v4eq5hdI BQkya5ZqzYtX0fd2dUOt1QRWJ8FKBKayS+ow0GjDI3u1P3KeSjyI2bKCSdaw6WoqiBQH 7XzJVvu50l15zTz2KqNrRT5/qP7o8y7pg4JJdSsImjSy/siN+6EtIsJdR+yuYcXAi+X3 IPiynHNv2JbUeYZs1TPRpS39c8KtFWo/Rx3nyBOx/cJMqhN7qk9VZNhS2EKYjsXGk4+o ExeY4tLlYL4ulNjzKW3B4jqIAGVt3fw9K1pB/zr5HbjfDi7vZK3rNZJuq/mbF8U8Mw6N 0gDA== 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=h4/eFw0vWwBVRaZ/3UIgJHxLSvTZ3eLOl09I88FAedw=; b=dt9rcYL4bDQrMyDfOTnDXUzRLQfdbtzNXkkYi+HHzuzEetgxNcGUkC7lichBWtYkkU k0r160HFUb2PJpqD+IXoG/cWRqn4+FoQHY8HOy5GiF0Dzq3AEQPCfjc1eCso2U03M2V5 S3cug61efTY+LxjMCuyYedANJGBgX5wqOa2MoCWHfDOKNbqqH0IyhRch2Os56vdZ7grX 26wapqoB61H7FmGgFMGmnlFfJKAoi3al4qNbuYH5fkDEdrTojNumPZOkoEobzlEcVvKp 9Avprb+xemRMWMzWHZAk3ZQ7kPrAX6XOCz2iS94IC7MKcmRsoJTxL7BPyKLe21YLVeM1 LVVQ== X-Gm-Message-State: AGi0PuZbyzFVpO/ZUz77SFU3FgeV/J/JzAUD89zhs3sl/oqY7vKA5R3x TS2TE9RTfYFXEQ0aQOxWfYc= X-Google-Smtp-Source: APiQypKEbzHnKMzCKX/ncGYbZgq1pAvZNsSE1f4dlTDfmYezOsLJMtfjO4PiP2/R4GsGUKyg6wWRyw== X-Received: by 2002:a62:6807:: with SMTP id d7mr33624182pfc.296.1588130840165; Tue, 28 Apr 2020 20:27:20 -0700 (PDT) Received: from localhost.localdomain ([114.206.198.176]) by smtp.gmail.com with ESMTPSA id q11sm9559796pfl.97.2020.04.28.20.27.15 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 28 Apr 2020 20:27:19 -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 04/10] power: separate PageHighMem() and PageHighMemZone() use case Date: Wed, 29 Apr 2020 12:26:37 +0900 Message-Id: <1588130803-20527-5-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> 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. Acked-by: Roman Gushchin 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))