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 75C1BC433EF for ; Mon, 7 Mar 2022 05:01:41 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9F1DA8D0002; Mon, 7 Mar 2022 00:01:40 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 979CF8D0001; Mon, 7 Mar 2022 00:01:40 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8197D8D0002; Mon, 7 Mar 2022 00:01:40 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.a.hostedemail.com [64.99.140.24]) by kanga.kvack.org (Postfix) with ESMTP id 6E3748D0001 for ; Mon, 7 Mar 2022 00:01:40 -0500 (EST) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 3883623927 for ; Mon, 7 Mar 2022 05:01:40 +0000 (UTC) X-FDA: 79216392360.01.B6E98C7 Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by imf01.hostedemail.com (Postfix) with ESMTP id 1980040005 for ; Mon, 7 Mar 2022 05:01: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=1646629299; x=1678165299; h=from:to:cc:subject:references:date:in-reply-to: message-id:mime-version; bh=NFKgQZkdrQx8p8nN/Isk9HvHRlX5csN9smzrhWRrW1E=; b=gUzluM6Vg6OEGvvtVrZNyctNiFb9OEmfINzJz1HdJ5sLT3qopzlf24SK nJ9+OT54v6z+VwhpuvA+ZKA1JJ7xGNdY/zSe+ft++zddNpO1vuN1/4BYo eAwV4gRK1N3FrLsM5PFHpvdu4ZKMFw7pQNZ9NE9HfmUejoAOfWCbCFjsu FQQhki1QUQlWPGODSpLb/J1CM9vf8fKnV5Y9di6ztOCuXIo+gFeaWgn/6 2oPIcbM98MCTbaSw2Yt+2zMarPXU1SLFiq8S5SJIyt7SDE24Zgc1eKK48 leCl2m3rHF+GjHbgls9NVjeYsO9hiE3rImheDsJ2k4pIdaSg0jhHm69Vp w==; X-IronPort-AV: E=McAfee;i="6200,9189,10278"; a="241730424" X-IronPort-AV: E=Sophos;i="5.90,160,1643702400"; d="scan'208";a="241730424" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Mar 2022 21:01:37 -0800 X-IronPort-AV: E=Sophos;i="5.90,160,1643702400"; d="scan'208";a="552994919" Received: from yhuang6-desk2.sh.intel.com (HELO yhuang6-desk2.ccr.corp.intel.com) ([10.239.13.94]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Mar 2022 21:01:32 -0800 From: "Huang, Ying" To: Miaohe Lin Cc: , , , , , , , , , , , , , , , , , 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> Date: Mon, 07 Mar 2022 13:01:30 +0800 In-Reply-To: <20220304093409.25829-13-linmiaohe@huawei.com> (Miaohe Lin's message of "Fri, 4 Mar 2022 17:34:05 +0800") Message-ID: <87r17e5pat.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-Rspamd-Queue-Id: 1980040005 X-Stat-Signature: d7nf3i4qx5891fqk5aqm3u6bq1ejnfz8 X-Rspam-User: Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=gUzluM6V; spf=none (imf01.hostedemail.com: domain of ying.huang@intel.com has no SPF policy when checking 134.134.136.20) smtp.mailfrom=ying.huang@intel.com; dmarc=pass (policy=none) header.from=intel.com X-Rspamd-Server: rspam07 X-HE-Tag: 1646629298-793923 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: Miaohe Lin writes: > 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; It appears that we don't need to change nr_failed, because we don't use it for this situation. Otherwise looks good to me. Reviewed-by: "Huang, Ying" Best Regards, Huang, Ying > + nr_thp_failed += thp_retry; > goto out; > case -EAGAIN: > if (is_thp)