From patchwork Mon Aug 24 06:58:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Xinhai X-Patchwork-Id: 11732259 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 0ABC71510 for ; Mon, 24 Aug 2020 06:58:23 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id AF35A20767 for ; Mon, 24 Aug 2020 06:58:22 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="AuZ1B0Vy" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AF35A20767 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 B377D6B0002; Mon, 24 Aug 2020 02:58:21 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id AE6DF6B0005; Mon, 24 Aug 2020 02:58: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 9D5DF6B0006; Mon, 24 Aug 2020 02:58:21 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0236.hostedemail.com [216.40.44.236]) by kanga.kvack.org (Postfix) with ESMTP id 85FC86B0002 for ; Mon, 24 Aug 2020 02:58:21 -0400 (EDT) Received: from smtpin16.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 431BD824934B for ; Mon, 24 Aug 2020 06:58:21 +0000 (UTC) X-FDA: 77184558402.16.fact18_420d0f727051 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin16.hostedemail.com (Postfix) with ESMTP id 07E15100E690B for ; Mon, 24 Aug 2020 06:58:21 +0000 (UTC) X-Spam-Summary: 1,0,0,06a2c988fbc00c0c,d41d8cd98f00b204,lixinhai.lxh@gmail.com,,RULES_HIT:41:355:379:541:800:960:973:988:989:1260:1345:1437:1534:1541:1711:1730:1747:1777:1792:2393:2559:2562:2898:3138:3139:3140:3141:3142:3352:3865:3866:3868:3870:3871:3874:4321:5007:6119:6261:6653:7514:7875:7903:8660:9413:10004:11026:11658:11914:12297:12438:12517:12519:12555:12895:13069:13148:13161:13229:13230:13311:13357:14096:14181:14384:14394:14687:14721:21080:21444:21451:21627:21666:21939:21990:30012:30054:30070,0,RBL:209.85.218.66:@gmail.com:.lbl8.mailshell.net-62.50.0.100 66.100.201.100;04y8s6ezfhhapnns7un8ahdrga6rsypfrco6ryd9c5hjokiynd4jydzuk5dg7jc.7o7eadijxgrit5rmocdztt4pdkyrrjxmfy9prjop4jpx891cycaxu4j3uabyaj6.4-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:neutral,Custom_rules:0:0:0,LFtime:24,LUA_SUMMARY:none X-HE-Tag: fact18_420d0f727051 X-Filterd-Recvd-Size: 3909 Received: from mail-ej1-f66.google.com (mail-ej1-f66.google.com [209.85.218.66]) by imf16.hostedemail.com (Postfix) with ESMTP for ; Mon, 24 Aug 2020 06:58:20 +0000 (UTC) Received: by mail-ej1-f66.google.com with SMTP id dp2so5174399ejc.4 for ; Sun, 23 Aug 2020 23:58:20 -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; bh=NDqPM9t0ZaYktFcdL3ox/tJzqkvjq8QI8owlfuycvaE=; b=AuZ1B0VyrWD5VMFUArzJE1Vlfh380DeDzh9oxSiaGB40GVbKZAW84vbIaXa2QNSk+Y RKS7h2iwnBAqx55/bncfgy7A9AzKgTSUqly5FauFnSFYtOlEVVDAfzxIJ9MMB2G3DhOn kdpyH/lopwFLAepBccuIQBaWRHtlvLCyICCE+EOz+7ZfDbDx09bCxRBx3mtrbl5gqQeC BwfKqFxz/4lNlp1bWxcIixWFPkYkiYi+mH9T+iIoN3PzZpeklv9/G9sTBTRhVVPosR+0 2fXuCosoCszsnikE/UWjDCuIXBun0LVQp4IoH1QJPK3H0V2p61zTMJlYwB3a6DpcpLOG KJ/g== 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; bh=NDqPM9t0ZaYktFcdL3ox/tJzqkvjq8QI8owlfuycvaE=; b=KUVaFWUfZqe2ahP04ezbwdzF+h4PcbWg12COSj3qniXHfC1ayY3lnMZVerZABvdPsN +dGfwnBgr+/W7mdH8HugF+m1VeJ/pOPDrpbPI3In/dd1Z60AoFb8zIhii5iZcwzr7QBJ r0h6oxzgqds7EgpB/B+ob+l8iP/MmoncnLq17QO7coTAiwf5pM0EgpUZJP08V9i75wah 8acc8gDa3GZbDaYGoWLJnQzo+FYFTdRk/p0+H/lfY8990VY09z9wT3hhIJq+9+P1hmYp isFC980gwg+0zI4muUiiinRDvaJ7jWas5393Zi3nwlLUtzo/D+rarjsv2T/I/71fj/3z urHQ== X-Gm-Message-State: AOAM533DIL9oKvRfxOvJ2hssWdYdriPfb7oDhylWaLsQISw5f9UfqRHZ qLL+eqaHBfdWuOJZGvsR1Ijy7s8C0H4= X-Google-Smtp-Source: ABdhPJzP3MdjYbFSBsyLdx3umCHYtxFWHqIIfbVgNM7m5wHkf21iRklA+DbufGfZ9aU7rlEKa/C8rw== X-Received: by 2002:a17:906:7752:: with SMTP id o18mr4128374ejn.150.1598252299254; Sun, 23 Aug 2020 23:58:19 -0700 (PDT) Received: from localhost.localdomain ([131.228.2.20]) by smtp.gmail.com with ESMTPSA id a20sm4623925ejx.33.2020.08.23.23.58.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Aug 2020 23:58:18 -0700 (PDT) From: Li Xinhai To: linux-mm@kvack.org Cc: akpm@linux-foundation.org, mhocko@suse.com, david@redhat.com Subject: [PATCH] mm, isolation: avoid checking unmovable pages across pageblock boundary Date: Mon, 24 Aug 2020 14:58:11 +0800 Message-Id: <20200824065811.383266-1-lixinhai.lxh@gmail.com> X-Mailer: git-send-email 2.18.4 X-Rspamd-Queue-Id: 07E15100E690B X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam04 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000012, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: In has_unmovable_pages(), the page parameter would not always be the first page within a pageblock (see how the page pointer is passed in from start_isolate_page_range() after call __first_valid_page()), so that would cause checking unmovable pages span two pageblocks. After this patch, the checking is enforced within one pageblock no matter the page is first one or not, and obey the semantics of this function. This issue is found by code inspection. Signed-off-by: Li Xinhai Reviewed-by: Oscar Salvador Acked-by: Michal Hocko --- mm/page_alloc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 0e2bab486fea..c2c5b565f1f3 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -8213,6 +8213,7 @@ struct page *has_unmovable_pages(struct zone *zone, struct page *page, { unsigned long iter = 0; unsigned long pfn = page_to_pfn(page); + unsigned long offset = pfn % pageblock_nr_pages; /* * TODO we could make this much more efficient by not checking every @@ -8234,7 +8235,7 @@ struct page *has_unmovable_pages(struct zone *zone, struct page *page, return page; } - for (; iter < pageblock_nr_pages; iter++) { + for (; iter < pageblock_nr_pages - offset; iter++) { if (!pfn_valid_within(pfn + iter)) continue;