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: 56649 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2735983wrn; Mon, 13 Feb 2023 19:32:02 -0800 (PST) X-Google-Smtp-Source: AK7set/M1iA9HIFld6c6oCEKO4M9Lg6Y2y00FyWx17NjTdSnq7oOI1qwogNBBr/jhzGYaDrqwj+x X-Received: by 2002:a17:906:e2d1:b0:879:ab3:93d1 with SMTP id gr17-20020a170906e2d100b008790ab393d1mr1559554ejb.4.1676345521857; Mon, 13 Feb 2023 19:32:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676345521; cv=none; d=google.com; s=arc-20160816; b=ZTenQprjrKZBc4TifWJOi8cs6S9OH7BBi1GYnApf4lymLHwlY9X9FBeGcQmARsXnki /PJVShxszHoFo2eb5oB4cLkbDEEa7acG0xPzS74lTlSj298/kcXCZk1uAU8O1s5NXPT1 gzHObiiMK1e8ztanB6p6fEAwjuvUFB/IO9iokB3MN6ZhNPfuFyCr3kx2xasxBNIjRF8c pvApABkjLvLzqSRZRIanrmDqiNgi/wafq8B9VNVvlsfOcfJqsPAyXVKoFsWiOaJh4SFa 6kS62kTdYI5OYQhVBN/Yv9lgTo/Ix3ywszCacFMH0sbsS43L7B4insT3tKvEPSwPXN7r X7Ww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=+roXL7HgZQYWOI/UHpiNDGpxvt04oLVwFQx9KgkpYVo=; b=vj6fLQmsgoRMARqU5DjiieJFzAr2nfH4cbj7Ifybx9ntsSiE3RrMNZ+2eRZQV4Nr2B 3A4zwA2egalOpgRJ1tkZit4XdODp/qOAyiHcOk32eenOz16MyjTjgEFFpbVCg5hx9ImP wQxbJp49uBB0N1I86MTu/ODQOv6oAuFHm77AZ7GrSgNa4amWfjtVnliDPbY6R4goVzKf OVp0w5il9yHGCvUFbSxlGzUd6ZqkHnQJhAsE8tmixy63m/sPK5zIL69glHIjErXmnEOv 4vRV2QZOi1zwUTji4NOxo0rptgJnx6IW+mo3BPYLGrKsXj3QYniF/D/VW7/3PASNO5/E CBvg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v18-20020a17090610d200b008af42fad70bsi15207139ejv.75.2023.02.13.19.31.38; Mon, 13 Feb 2023 19:32:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231464AbjBNDSk (ORCPT + 99 others); Mon, 13 Feb 2023 22:18:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52996 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231398AbjBNDSd (ORCPT ); Mon, 13 Feb 2023 22:18:33 -0500 Received: from out30-97.freemail.mail.aliyun.com (out30-97.freemail.mail.aliyun.com [115.124.30.97]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A4EEE12587; Mon, 13 Feb 2023 19:18:32 -0800 (PST) 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-Spam-Status: No, score=-9.9 required=5.0 tests=BAYES_00, ENV_AND_HDR_SPF_MATCH,SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY, USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1757775682030892057?= X-GMAIL-MSGID: =?utf-8?q?1757775682030892057?= 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;