From patchwork Tue Feb 14 03:18:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baolin Wang X-Patchwork-Id: 13139323 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 2A0DBC636D4 for ; Tue, 14 Feb 2023 03:18:38 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 69188280003; Mon, 13 Feb 2023 22:18:36 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 61B2B6B0075; Mon, 13 Feb 2023 22:18:36 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 46B10280003; Mon, 13 Feb 2023 22:18:36 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 2D5FE6B0074 for ; Mon, 13 Feb 2023 22:18:36 -0500 (EST) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id EBF0EC05B4 for ; Tue, 14 Feb 2023 03:18:35 +0000 (UTC) X-FDA: 80464439790.03.0AE9194 Received: from out30-119.freemail.mail.aliyun.com (out30-119.freemail.mail.aliyun.com [115.124.30.119]) by imf12.hostedemail.com (Postfix) with ESMTP id 6D56B40003 for ; Tue, 14 Feb 2023 03:18:33 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=alibaba.com; spf=pass (imf12.hostedemail.com: domain of baolin.wang@linux.alibaba.com designates 115.124.30.119 as permitted sender) smtp.mailfrom=baolin.wang@linux.alibaba.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1676344713; 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=+roXL7HgZQYWOI/UHpiNDGpxvt04oLVwFQx9KgkpYVo=; b=rixgPu6gZA+aVmjb7S9GcT9+C45HU/ZVhe0UEsTKyAAX2XPC/8NnO3mekpBLOVp9bWWR+8 /CvNRELdSRCnbvp93oro7ef90uhpVGienoJKZJcbrFmvo1BlaSRT8yd7kAiRAO4Q51A+6s C4hP8ot8fEytqcm/RJa2Gb3w1ybKiiw= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=alibaba.com; spf=pass (imf12.hostedemail.com: domain of baolin.wang@linux.alibaba.com designates 115.124.30.119 as permitted sender) smtp.mailfrom=baolin.wang@linux.alibaba.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1676344713; a=rsa-sha256; cv=none; b=SRrz1QgpY37TDEROlu60MfB+e7zNYY4Bl1EI4zEN3JgYZAY38Nkto4TO5s2MQcqwQ+j+o2 /i2f5bosSNgLimbRFhQ0wTaFnGJCwk3WklutVHIXwksd3Kx/JzHBq61ZJmNs2VUk/No63M KsqvjdYO3q1Elmpq6Y+QBVqOMHbYpqA= X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R851e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018046059;MF=baolin.wang@linux.alibaba.com;NM=1;PH=DS;RN=13;SR=0;TI=SMTPD_---0VbdtbCV_1676344707; Received: from localhost(mailfrom:baolin.wang@linux.alibaba.com fp:SMTPD_---0VbdtbCV_1676344707) by smtp.aliyun-inc.com; Tue, 14 Feb 2023 11:18:27 +0800 From: Baolin Wang To: akpm@linux-foundation.org Cc: torvalds@linux-foundation.org, sj@kernel.org, hannes@cmpxchg.org, mhocko@kernel.org, roman.gushchin@linux.dev, shakeelb@google.com, muchun.song@linux.dev, baolin.wang@linux.alibaba.com, damon@lists.linux.dev, cgroups@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/3] mm: check negative error of isolate_lru_page() when failed to isolate a page Date: Tue, 14 Feb 2023 11:18:07 +0800 Message-Id: X-Mailer: git-send-email 2.27.0 In-Reply-To: References: MIME-Version: 1.0 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 6D56B40003 X-Rspam-User: X-Stat-Signature: q7bf6b9n8egrhuwhc49czbzqqdkmabug X-HE-Tag: 1676344713-187025 X-HE-Meta: U2FsdGVkX1/KW4AEkmcx8sGXlCWQOqU5Socs9yqlnyuSwPeFwZRfrgqLocl8Q3GudGo2q/HVntb4/2z7Z2Jaaui0b0Aza1ghDGBaSjj15yy1vAtpazp8mLuBOHQmHXMh/caFVmgAS5fgSvePJGs21xnvc2anbIkY9eomUeYbBv/nWQsMGV1teBLAmjdz20ur7JjZx62CPvd3a+stK8CMlBAOwxEDvI17ee7GvwXXDM78Uk2LL0hKAeLis/WR0FwXEGq9sK1rPHg2pR9H+w8soh/Qh1vBzQrQ/2govkpw1Zw7ZRiUNekfUstW7B4EnXUZZDuPwwXcIwHFSyBug/MS5099nv+MHcH+l25sXyijJAMLQBaTjYketMsSvw0FY4ls5/q+1FEMqTi8MQE+TQbehpLy6k//S14GHQhl5nzcXdlgdwx7EgpFKn4wrBaochqg1lHNYtV7fAlBhRLSEXxAtjATQgAEynx8qR63QFQM3uQWXzn+gx8PRDFSm9pHJI3BXDJV4v+teXXWgn+4ohZ0Srt3VH2sJsHb2vv8H0zgP40/eutcwUGRpKr2uid01mdZ6akin/VjE2ApbdKRxWvFwshuKmhHH08J5oz7/DCSabeKoFeC7oR6COnhkChiaFNqjuzzgatny4L0dMyWXlRe1n+UMYxVCrjIj9JZgmEj9UCBvUhIItcXHTqyB+SEp3YINbKjrSlhi43H4tR1CFjft6GaS6+P4EAs5n5l1BQb5fUHpW0TknLz6XC+PF4KUUOUZ/EmP9+dtEijwoQgcLRkn1/Gd1h67DPvm2rw0PF0w9wkF67boZc7mRLPjwVoKb3AU9xIzsh8pMg1TavF1xw5K4kVO4rGj+silgvfO99HwBSxAysF8XcjMEJG9co4KH+IS9HMbAVRZJ9vht6ehVZytmIY0DSsmn3jyeoPDvvgs9TVo2WOm6leFkCuoGzR+k9KVSyQO7gkYdzNoK2QcJ1 aRxY+ZEI kcXWcZa52ueSW6GgxeYCl4CUxJSAqpC4LNajZO/FrfVV7IluBiWv6+kpXgT6plZlhg7ECXvW/jJkbZg8oZTxYRdwIYcxNmRYceCGX5bP0NmLJ0LUBfys4wunjWfklG7hiPs0ZzLGeznZwmQlw4EDzb5NOFxWYlJAs5JwO 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: Better to check the negative error of isolate_lru_page() when failed to isolate a page from its LRU, which makes the code more clear. No functional changes. Signed-off-by: Baolin Wang --- mm/khugepaged.c | 2 +- mm/memcontrol.c | 2 +- mm/migrate.c | 4 ++-- mm/migrate_device.c | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/mm/khugepaged.c b/mm/khugepaged.c index 463dfca4b841..99a2d993b51c 100644 --- a/mm/khugepaged.c +++ b/mm/khugepaged.c @@ -659,7 +659,7 @@ static int __collapse_huge_page_isolate(struct vm_area_struct *vma, * Isolate the page to avoid collapsing an hugepage * currently in use by the VM. */ - if (isolate_lru_page(page)) { + if (isolate_lru_page(page) < 0) { unlock_page(page); result = SCAN_DEL_PAGE_LRU; goto out; diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 17335459d8dc..33cad66a4132 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -6226,7 +6226,7 @@ static int mem_cgroup_move_charge_pte_range(pmd_t *pmd, */ if (PageTransCompound(page)) goto put; - if (!device && isolate_lru_page(page)) + if (!device && isolate_lru_page(page) < 0) goto put; if (!mem_cgroup_move_account(page, false, mc.from, mc.to)) { diff --git a/mm/migrate.c b/mm/migrate.c index ef68a1aff35c..eaae39564f86 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -2135,7 +2135,7 @@ static int add_page_for_migration(struct mm_struct *mm, unsigned long addr, head = compound_head(page); err = isolate_lru_page(head); - if (err) + if (err < 0) goto out_putpage; err = 1; @@ -2541,7 +2541,7 @@ static int numamigrate_isolate_page(pg_data_t *pgdat, struct page *page) return 0; } - if (isolate_lru_page(page)) + if (isolate_lru_page(page) < 0) return 0; mod_node_page_state(page_pgdat(page), NR_ISOLATED_ANON + page_is_file_lru(page), diff --git a/mm/migrate_device.c b/mm/migrate_device.c index 6c3740318a98..1ab56b5b7914 100644 --- a/mm/migrate_device.c +++ b/mm/migrate_device.c @@ -388,7 +388,7 @@ static unsigned long migrate_device_unmap(unsigned long *src_pfns, allow_drain = false; } - if (isolate_lru_page(page)) { + if (isolate_lru_page(page) < 0) { src_pfns[i] &= ~MIGRATE_PFN_MIGRATE; restore++; continue;