From patchwork Wed Aug 2 09:37:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kemeng Shi X-Patchwork-Id: 13337509 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8D373C04E69 for ; Wed, 2 Aug 2023 01:37:38 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A2B79280115; Tue, 1 Aug 2023 21:37:35 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8EE2C280114; Tue, 1 Aug 2023 21:37:35 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 677FB280110; Tue, 1 Aug 2023 21:37:35 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 5344C2800C8 for ; Tue, 1 Aug 2023 21:37:35 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 2B842C0426 for ; Wed, 2 Aug 2023 01:37:35 +0000 (UTC) X-FDA: 81077452470.14.7706B6F Received: from dggsgout11.his.huawei.com (unknown [45.249.212.51]) by imf05.hostedemail.com (Postfix) with ESMTP id EFFB710000F for ; Wed, 2 Aug 2023 01:37:31 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=none; dmarc=none; spf=none (imf05.hostedemail.com: domain of shikemeng@huaweicloud.com has no SPF policy when checking 45.249.212.51) smtp.mailfrom=shikemeng@huaweicloud.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1690940252; a=rsa-sha256; cv=none; b=7RohjTXFwdU787tPQ3Xy2MIvwXXn9CCuL5NObuwwD50/timUvbb6YHrktB+um/66qz/Lk3 lYi0aP548ie/59EZxX9tS0u/XeXH60kuuOaDeNc7w7eHCfZ15eEqBXpRopUW3v2Q3Wh8aX BduomIWKD3i3W0v6/jQEFiv1Od4qAcw= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=none; dmarc=none; spf=none (imf05.hostedemail.com: domain of shikemeng@huaweicloud.com has no SPF policy when checking 45.249.212.51) smtp.mailfrom=shikemeng@huaweicloud.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1690940252; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=pdRei9fGJiN18feezXtlCPg8SZ6q5avN8dZRCRdO4gs=; b=3souoTyvQQjo9j43E4OX9yog36g2MwHWhtcAWjjS6Vv3GswIN560prHqC6P9drIEzHKwFT X7xDQdZvp19j76uZKQTWwLpTN+MdBQuR4QVnDAGuIJyUhPQF9+rFty1uondTkMlFBePh4q 4Orwg8IcP7ABPxAJInEpBV++SWz0vcE= Received: from mail02.huawei.com (unknown [172.30.67.143]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4RFvjf5kgxz4f3pBm for ; Wed, 2 Aug 2023 09:37:26 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.124.27]) by APP4 (Coremail) with SMTP id gCh0CgAXzrFTs8lkvrtvPQ--.56352S4; Wed, 02 Aug 2023 09:37:27 +0800 (CST) From: Kemeng Shi To: linux-mm@kvack.org, linux-kernel@vger.kernel.org, akpm@linux-foundation.org, baolin.wang@linux.alibaba.com, mgorman@techsingularity.net, david@redhat.com Cc: shikemeng@huaweicloud.com Subject: [PATCH v2 2/8] mm/compaction: correct last_migrated_pfn update in compact_zone Date: Wed, 2 Aug 2023 17:37:35 +0800 Message-Id: <20230802093741.2333325-3-shikemeng@huaweicloud.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20230802093741.2333325-1-shikemeng@huaweicloud.com> References: <20230802093741.2333325-1-shikemeng@huaweicloud.com> MIME-Version: 1.0 X-CM-TRANSID: gCh0CgAXzrFTs8lkvrtvPQ--.56352S4 X-Coremail-Antispam: 1UD129KBjvJXoW7CFyfAw1fGrWDCFWrZry7Wrg_yoW8CF48pa 4rC3Z7Kr4DWayUZF1Yq34kZw1Ykws3KF43JrZ8Jw18Ars5Ka4Iyw17K3WjvrW5XrnIy3sY vF4qgay7AanrZa7anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUPSb4IE77IF4wAFF20E14v26ryj6rWUM7CY07I20VC2zVCF04k2 6cxKx2IYs7xG6rWj6s0DM7CIcVAFz4kK6r1j6r18M280x2IEY4vEnII2IxkI6r1a6r45M2 8IrcIa0xkI8VA2jI8067AKxVWUXwA2048vs2IY020Ec7CjxVAFwI0_Gr0_Xr1l8cAvFVAK 0II2c7xJM28CjxkF64kEwVA0rcxSw2x7M28EF7xvwVC0I7IYx2IY67AKxVW7JVWDJwA2z4 x0Y4vE2Ix0cI8IcVCY1x0267AKxVW8Jr0_Cr1UM28EF7xvwVC2z280aVAFwI0_GcCE3s1l 84ACjcxK6I8E87Iv6xkF7I0E14v26rxl6s0DM2AIxVAIcxkEcVAq07x20xvEncxIr21l5I 8CrVACY4xI64kE6c02F40Ex7xfMcIj6xIIjxv20xvE14v26r1j6r18McIj6I8E87Iv67AK xVWUJVW8JwAm72CE4IkC6x0Yz7v_Jr0_Gr1lF7xvr2IYc2Ij64vIr41lF7I21c0EjII2zV CS5cI20VAGYxC7MxAIw28IcxkI7VAKI48JMxC20s026xCaFVCjc4AY6r1j6r4UMI8I3I0E 5I8CrVAFwI0_Jr0_Jr4lx2IqxVCjr7xvwVAFwI0_JrI_JrWlx4CE17CEb7AF67AKxVWUAV WUtwCIc40Y0x0EwIxGrwCI42IY6xIIjxv20xvE14v26r1j6r1xMIIF0xvE2Ix0cI8IcVCY 1x0267AKxVW8JVWxJwCI42IY6xAIw20EY4v20xvaj40_Jr0_JF4lIxAIcVC2z280aVAFwI 0_Jr0_Gr1lIxAIcVC2z280aVCY1x0267AKxVW8JVW8JrUvcSsGvfC2KfnxnUUI43ZEXa7s RNVbyUUUUUU== X-CM-SenderInfo: 5vklyvpphqwq5kxd4v5lfo033gof0z/ X-CFilter-Loop: Reflected X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: EFFB710000F X-Stat-Signature: sh4mh94bpfxnzsennr1fgy8behsz8h95 X-Rspam-User: X-HE-Tag: 1690940251-175978 X-HE-Meta: U2FsdGVkX19CkIlQk5/cJoOcK6A8SovPpoGQHG8uN0BjpAlQJI2XSbl12INLu/mwcoQXHBksLX32RUBH3MbXxvrZrSE3dXnejplWmyK1Hrnef1kMK2JhHke/xExmhHe/acVCYX8xcnev83LhRshkqX1D+hz/dehlXQd+erEIPMxZyup7ByAiRbzaDFRT8DvTfUhYYzPmjzhOYbXWz9Kx+Em2NznF8/kZH6r9ZIAodrwvtUltsj+yh0cbtadLDDtOkZSar3v/YljeqgJEd1OXBx16ugBpDgJbXa6WBbFxMkcZrpajEcJ5yf15lrM/Iy2/P0LCC9DKMuTL9GGBO7WqWqlH6uB7DwUZfcpzsWNmo+HH8hR2tO1fKa8XZCDICffnfQfWCzaHkbzGgZXBnmwnDDPT5uE2jjkt7A5dSx1opBzbCe3UkfJ9I9ClfMX+NQiCPhc6GOxLIYMQq6IZPzi63YUmpeX07jC1TDvJS/BCi/yueiQpKLKtvLCLLbC/SV/I5iREWweZyjoVGt1Qm1pIpkzuGIHSAj3i7Ealj/tS+zcQzuJpRHjEUItQ6QEpFw6e6N9FiXWs790H01Iif7EiDcTfNDkcy4rtLXP229Fr5ni3D5YuDVUbh+CTiwJdr2D07dJZqToQW4mWNHszFRorQUWaRTKRJVZjf2JTHO65k1FvBmbywGFwc7nVkpg7vjGYgWWv5YQdZ7qftKM6mZc56GE4NxDVV6wySdU2/u5GF5JFp8Qldf4nlBlOTCpWM/pXoECT1WVcl08ilXeFi328K1yVgduZ5wyXIWog3nVqDfwDY3KGkaqeqO3X0XTTlWlPv4sPk12J4XICQtaWrlPiJTOJApC74y8SS9uuAh1/F5iRHa75h9w9uEIPtpbFfqV/qLSoDo0AtQrYH5kDyCTQID3cDJcLM/AggyHD4Kza9p3WprEV5J70SdeYGhHlp9vz88lVOb9cSZ5GKTQNtyq 5GSMcVDq d0JVqkUoAKiaZyXl5V1tDJroWKugrmCDxJHpNVeeFZTO1wqF3NSJTue7VrNRWDWZK7s5ASpFAO+Y7mRDe2ZbaNr2dkX87nnOS7vLKKoG5qvQraLXvQVgcOw68qCLrhINXdxnoxWG/r6kzuDUAtk5PYb7/5ac3xeeUenaq/J7AjBclCvX5336bRCOTJO2FP73cic7HSjaF/9tQEFNRONnO36g0Jmi4nZC9X6ZbK91wC5OsKbKJ65kP2kviTu8Sga04gd3f5xS3UZdiaRSH0DCBxkoa+1JKyArXp4TsOfwJPNt4yA7JwuYFdP16xPs8tSII0q4W 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: We record start pfn of last isolated page block with last_migrated_pfn. And then: 1. We check if we mark the page block skip for exclusive access in isolate_migratepages_block by test if next migrate pfn is still in last isolated page block. If so, we will set finish_pageblock to do the rescan. 2. We check if a full cc->order block is scanned by test if last scan range passes the cc->order block boundary. If so, we flush the pages were freed. We treat cc->migrate_pfn before isolate_migratepages as the start pfn of last isolated page range. However, we always align migrate_pfn to page block or move to another page block in fast_find_migrateblock or in linearly scan forward in isolate_migratepages before do page isolation in isolate_migratepages_block. Update last_migrated_pfn with pageblock_start_pfn(cc->migrate_pfn - 1) after scan to correctly set start pfn of last isolated page range. To avoid that: 1. Miss a rescan with finish_pageblock set as last_migrate_pfn does not point to right pageblock and the migrate will not be in pageblock of last_migrate_pfn as it should be. 2. Wrongly issue flush by test cc->order block boundary with wrong last_migrate_pfn. Signed-off-by: Kemeng Shi Reviewed-by: Baolin Wang --- mm/compaction.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mm/compaction.c b/mm/compaction.c index a8cea916df9d..ec3a96b7afce 100644 --- a/mm/compaction.c +++ b/mm/compaction.c @@ -2487,7 +2487,8 @@ compact_zone(struct compact_control *cc, struct capture_control *capc) goto check_drain; case ISOLATE_SUCCESS: update_cached = false; - last_migrated_pfn = iteration_start_pfn; + last_migrated_pfn = max(cc->zone->zone_start_pfn, + pageblock_start_pfn(cc->migrate_pfn - 1)); } err = migrate_pages(&cc->migratepages, compaction_alloc,