From mboxrd@z Thu Jan 1 00:00:00 1970 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 1EDBBC433EF for ; Mon, 7 Mar 2022 05:02:41 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6E2468D0003; Mon, 7 Mar 2022 00:02:40 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 691BB8D0001; Mon, 7 Mar 2022 00:02:40 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 559B08D0003; Mon, 7 Mar 2022 00:02:40 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0131.hostedemail.com [216.40.44.131]) by kanga.kvack.org (Postfix) with ESMTP id 4614D8D0001 for ; Mon, 7 Mar 2022 00:02:40 -0500 (EST) Received: from smtpin29.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id EC8691822BC5A for ; Mon, 7 Mar 2022 05:02:39 +0000 (UTC) X-FDA: 79216394838.29.61C6B9D Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by imf24.hostedemail.com (Postfix) with ESMTP id 2F2B5180005 for ; Mon, 7 Mar 2022 05:02:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1646629359; x=1678165359; h=from:to:cc:subject:references:date:in-reply-to: message-id:mime-version; bh=fSzZifNYct0Has80OHs9poHqh4YGD9Xak8s4xLdqB7U=; b=JE44ImUFnk+s8OWrmRuxI9M+TxIxqO6O7vT6N1wVt3jcuhOxdDBpG/0w UiwVySjlX3C8kEaXc5McDm5EQexaLniBEjUpZ87Ct3tlZfnDKlIKOauqj hCWqs5U1fLxw0V7HtV0X2RCc687ieuYIKdJ6AsZu/x05VXHqkzyVMmNKD fC5/juOkfB0EKJk520feq75X9LamqSGZGqefM9LW+vqVCH851AjRYUVmF ZX/3k6EDAkhN7Mvo1unTzXmqelslGS8X3S731ZRRUV8bhMwHDGmwlQqHi PwcSfLHfDEHKY9SAAPxFyIavGFJROyF333lL+vcTunmW0gPy5T8rYOJUg w==; X-IronPort-AV: E=McAfee;i="6200,9189,10278"; a="241730675" X-IronPort-AV: E=Sophos;i="5.90,160,1643702400"; d="scan'208";a="241730675" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Mar 2022 21:02:38 -0800 X-IronPort-AV: E=Sophos;i="5.90,160,1643702400"; d="scan'208";a="512535412" Received: from yhuang6-desk2.sh.intel.com (HELO yhuang6-desk2.ccr.corp.intel.com) ([10.239.13.94]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Mar 2022 21:02:33 -0800 From: "Huang, Ying" To: Baolin Wang Cc: Miaohe Lin , , , , , , , , , , , , , , , , , , Subject: Re: [PATCH 12/16] mm/migration: fix potential page refcounts leak in migrate_pages References: <20220304093409.25829-1-linmiaohe@huawei.com> <20220304093409.25829-13-linmiaohe@huawei.com> <20f47ec9-3b5b-5326-b1c3-4b1a0c38ef46@linux.alibaba.com> Date: Mon, 07 Mar 2022 13:02:27 +0800 In-Reply-To: <20f47ec9-3b5b-5326-b1c3-4b1a0c38ef46@linux.alibaba.com> (Baolin Wang's message of "Mon, 7 Mar 2022 09:57:30 +0800") Message-ID: <87mti25p98.fsf@yhuang6-desk2.ccr.corp.intel.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=ascii X-Rspam-User: X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 2F2B5180005 X-Stat-Signature: f9cwjhm1u37uohigr48p811gchcuwsna Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=JE44ImUF; dmarc=pass (policy=none) header.from=intel.com; spf=none (imf24.hostedemail.com: domain of ying.huang@intel.com has no SPF policy when checking 134.134.136.20) smtp.mailfrom=ying.huang@intel.com X-HE-Tag: 1646629358-29994 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: Baolin Wang writes: > Hi Miaohe, > > On 3/4/2022 5:34 PM, Miaohe Lin wrote: >> In -ENOMEM case, there might be some subpages of fail-to-migrate THPs >> left in thp_split_pages list. We should move them back to migration >> list so that they could be put back to the right list by the caller >> otherwise the page refcnt will be leaked here. Also adjust nr_failed >> and nr_thp_failed accordingly to make vm events account more accurate. >> Fixes: b5bade978e9b ("mm: migrate: fix the return value of >> migrate_pages()") >> Signed-off-by: Miaohe Lin >> --- >> mm/migrate.c | 9 +++++++++ >> 1 file changed, 9 insertions(+) >> diff --git a/mm/migrate.c b/mm/migrate.c >> index e0db06927f02..6c2dfed2ddb8 100644 >> --- a/mm/migrate.c >> +++ b/mm/migrate.c >> @@ -1422,6 +1422,15 @@ int migrate_pages(struct list_head *from, new_page_t get_new_page, >> } >> nr_failed_pages += nr_subpages; >> + /* >> + * There might be some subpages of fail-to-migrate THPs >> + * left in thp_split_pages list. Move them back to migration >> + * list so that they could be put back to the right list by >> + * the caller otherwise the page refcnt will be leaked. >> + */ >> + list_splice_init(&thp_split_pages, from); >> + nr_failed += retry; >> + nr_thp_failed += thp_retry; > > Yes, I think we missed this case before, and your patch looks > right. But we should also update the 'rc' to return the correct number > of pages that were not migrated, right? Per my understanding, -ENOMEM should be returned to indicate an fatal error. Best Regards, Huang, Ying