From patchwork Sat Jun 27 17:17:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: DaeRo Lee X-Patchwork-Id: 11629799 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 E40381392 for ; Sat, 27 Jun 2020 17:17:30 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id A681920787 for ; Sat, 27 Jun 2020 17:17:30 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="FbffFxHU" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A681920787 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 9DA0D6B000C; Sat, 27 Jun 2020 13:17:29 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 992246B000D; Sat, 27 Jun 2020 13:17:29 -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 877596B000E; Sat, 27 Jun 2020 13:17:29 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0212.hostedemail.com [216.40.44.212]) by kanga.kvack.org (Postfix) with ESMTP id 6B99C6B000C for ; Sat, 27 Jun 2020 13:17:29 -0400 (EDT) Received: from smtpin17.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id C631A1EE6 for ; Sat, 27 Jun 2020 17:17:28 +0000 (UTC) X-FDA: 76975648176.17.neck40_440b58f26e5f Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin17.hostedemail.com (Postfix) with ESMTP id 8FC7F180D0186 for ; Sat, 27 Jun 2020 17:17:28 +0000 (UTC) X-Spam-Summary: 1,0,0,62ba2ebb135683b4,d41d8cd98f00b204,skseofh@gmail.com,,RULES_HIT:41:355:379:960:966:988:989:1260:1277:1312:1313:1314:1345:1437:1516:1518:1519:1534:1541:1593:1594:1595:1596:1711:1730:1747:1777:1792:2196:2199:2393:2559:2562:2898:3138:3139:3140:3141:3142:3352:3865:3867:3870:4362:4385:5007:6119:6120:6261:6653:7901:7903:8531:8957:9413:10004:10400:11026:11658:11914:12043:12295:12296:12297:12438:12517:12519:12555:12895:13069:13071:13311:13357:13439:13895:14096:14097:14180:14394:14687:14721:21060:21080:21444:21554:21627:21666:21990:30054:30070,0,RBL:209.85.216.68:@gmail.com:.lbl8.mailshell.net-62.18.0.100 66.100.201.100;04y8goz7891ce5afdc4uyx3hpbsdoop9xmjaaquy6pw39u8myyzhb4ipahoigs4.8s1a3e8e48wbmesmqrhzq5hjsj6ypw9egh1dhzeycc4ckwacnfb8a7krx83igj5.a-lbl8.mailshell.net-223.238.255.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:22,LUA_SUMMARY:none X-HE-Tag: neck40_440b58f26e5f X-Filterd-Recvd-Size: 4119 Received: from mail-pj1-f68.google.com (mail-pj1-f68.google.com [209.85.216.68]) by imf04.hostedemail.com (Postfix) with ESMTP for ; Sat, 27 Jun 2020 17:17:28 +0000 (UTC) Received: by mail-pj1-f68.google.com with SMTP id i4so6248947pjd.0 for ; Sat, 27 Jun 2020 10:17:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:date:to:cc:subject:message-id:mime-version:content-disposition :user-agent; bh=EYRKFWHdTmjhfMPSdNac/h2mrtHeqp36/cK7qNSyyVI=; b=FbffFxHUvZCcA0kcLBZ1GmRRKta3w0ldI7KKQ3PJDZs++tdH7aRmhX2NCkqhCB3Ax/ xM+4QJC5V5ds/guxAaIJcBYxP+xJnfYG2kQpN/X7Fz1Hfrrxkn6rdXjs1FXFonjLznjR D/DDrzakts7oPXE/tISwhbHS5OqiWBueJW6r9dthdd2P8rFuQHxWJFCl2Z7Iu8tM3GhH DtUwsnxPAeUggvek1Vmof1UHB0r/uH/84G4a1OsO8b8V9BuRA94FMbBSVo+fyLAXTlnW QsDbQBnlO66h9zj/u0VuEOOojJDnP6j65AveUTAjEXF2N6pHCPSyl2Vf/mvJg3mUfu5S 5LUQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:date:to:cc:subject:message-id:mime-version :content-disposition:user-agent; bh=EYRKFWHdTmjhfMPSdNac/h2mrtHeqp36/cK7qNSyyVI=; b=MZdTrEdMpH86KokbARvg2/balt3CR1sY1VaMvFe5DFGDWL7W1+pyGHcIBctXydWPkQ V/Hfffh+khEZHy5lj1cQyq10ga9lGF/yeaQRikeP3qtldNTpL3OY58XWq26saEv0Bu1F 3+VuJ8EIMS1O8E/REG2mkdDfZPP0Xn37AXi6sKTFfHXLcdHfac4ZKbTuT5FvkVkxJ1Ka +niUKVyQSH5K6VxulP54+0wGSI4uUy6NsI1A93X2cpCkRgYEMTmwCZ9n2VUkZ1bgPRvV lYaM0U5K2j+7xTEmqBiZvrWKFMAyY1UQIQe81S9cNk1Qdmv99E0q19df+B22PoacraTr YJgA== X-Gm-Message-State: AOAM532FEOU7wN3WIs6UphClbD8dK0kofc+4Z6coxRhstrlQ/cb0T0tq lwMlqtgSML1aJm+8Ehu96Lc= X-Google-Smtp-Source: ABdhPJx0akn7GhZRrYMYxBYOqRZU0AJFl5ZOtwIE6eNPoVBjYDCh19XvPok9pJrvZcTxuhgIdV4qmA== X-Received: by 2002:a17:90a:ee95:: with SMTP id i21mr9652104pjz.77.1593278247113; Sat, 27 Jun 2020 10:17:27 -0700 (PDT) Received: from roro-Lenovo-Y520-15IKBN ([175.113.143.57]) by smtp.gmail.com with ESMTPSA id i191sm29842320pfe.99.2020.06.27.10.17.25 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sat, 27 Jun 2020 10:17:26 -0700 (PDT) From: skseofh X-Google-Original-From: skseofh Date: Sun, 28 Jun 2020 02:17:22 +0900 To: akpm@linux-foundation.org Cc: linux-mm@kvack.org Subject: [PATCH] mm/page_alloc:Check pfn valid once in every page blocks Message-ID: <20200627171722.GA16398@roro-Lenovo-Y520-15IKBN> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.9.4 (2018-02-28) X-Rspamd-Queue-Id: 8FC7F180D0186 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam03 X-Bogosity: Ham, tests=bogofilter, spamicity=0.095486, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Hi, all Please check the patch below. Thanks:) No need to check validity for every pfn in [spfn, epfn). --- mm/page_alloc.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 174c849ba9f2..212460c9fe0f 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -6936,11 +6936,19 @@ void __init free_area_init_memoryless_node(int nid) */ static u64 __init init_unavailable_range(unsigned long spfn, unsigned long epfn) { - unsigned long pfn; + unsigned long pfn, block_pfn; u64 pgcnt = 0; + bool in_block = 0; + + block_pfn = ALIGN_DOWN(spfn, pageblock_nr_pages); for (pfn = spfn; pfn < epfn; pfn++) { - if (!pfn_valid(ALIGN_DOWN(pfn, pageblock_nr_pages))) { + if (block_pfn != ALIGN_DOWN(pfn, pageblock_nr_pages)) { + block_pfn = ALIGN_DOWN(pfn, pageblock_nr_pages); + in_block = 0; + } + + if (!in_block && !pfn_valid(ALIGN_DOWN(pfn, pageblock_nr_pages))) { pfn = ALIGN_DOWN(pfn, pageblock_nr_pages) + pageblock_nr_pages - 1; continue; @@ -6953,6 +6961,7 @@ static u64 __init init_unavailable_range(unsigned long spfn, unsigned long epfn) __init_single_page(pfn_to_page(pfn), pfn, 0, 0); __SetPageReserved(pfn_to_page(pfn)); pgcnt++; + in_block = 1; } return pgcnt;