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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D7C55C433FE for ; Mon, 24 Oct 2022 01:57:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229491AbiJXB5G (ORCPT ); Sun, 23 Oct 2022 21:57:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47862 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229455AbiJXB5E (ORCPT ); Sun, 23 Oct 2022 21:57:04 -0400 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2ADDA6610E for ; Sun, 23 Oct 2022 18:57:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1666576624; x=1698112624; h=from:to:cc:subject:references:date:in-reply-to: message-id:mime-version; bh=gpg1bc4kGtPIDhO6eUFSZuZY+nqE2oI4ubjdCw5mQqw=; b=FKjukddk83baOAuaAQx/kOCL2PyjNFwfWjg3WYZdwGyKyWB9mOF4Qc5w P67/tSQ/UhQzOYHSJRR8YOYxNF7YZrAlhm7xY2PgltMbtLxdMXaqWE65j 0fhWVzPwi/gFvRd1HShjlze3kvlaE7B6PT6kutzfBmKzeIPtCoacqJLZh kd7E7d2ncPGutJb3Pu8hGMHjkwvotohMDiwvOGHlO++GIUjWq4ZMMM4pO 0shT9OB7yzbtIltZlIHQvb4huXSVGa1xhU2fI4pd2a70viGWc9wj1dOtv HWQp2zF1eG+5CfWyT8vQNhgGTzVYF0iQLB66kPc55ivHYOJ6zUe/X1VuC w==; X-IronPort-AV: E=McAfee;i="6500,9779,10509"; a="393633516" X-IronPort-AV: E=Sophos;i="5.95,207,1661842800"; d="scan'208";a="393633516" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Oct 2022 18:57:04 -0700 X-IronPort-AV: E=McAfee;i="6500,9779,10509"; a="876292155" X-IronPort-AV: E=Sophos;i="5.95,207,1661842800"; d="scan'208";a="876292155" Received: from yhuang6-desk2.sh.intel.com (HELO yhuang6-desk2.ccr.corp.intel.com) ([10.238.208.55]) by fmsmga006-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Oct 2022 18:57:01 -0700 From: "Huang, Ying" To: Yang Shi , Andrew Morton Cc: Baolin Wang , david@redhat.com, ziy@nvidia.com, apopple@nvidia.com, jingshan@linux.alibaba.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 1/2] mm: migrate: Fix return value if all subpages of THPs are migrated successfully References: <20221021114149.eadf6fafdd0b2c2409a46389@linux-foundation.org> Date: Mon, 24 Oct 2022 09:56:22 +0800 In-Reply-To: (Yang Shi's message of "Fri, 21 Oct 2022 13:55:07 -0700") Message-ID: <871qqym1bt.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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Yang Shi writes: > On Fri, Oct 21, 2022 at 11:41 AM Andrew Morton > wrote: >> >> On Fri, 21 Oct 2022 18:16:23 +0800 Baolin Wang wrote: >> >> > When THP migration, if THPs are split and all subpages are migrated successfully >> > , the migrate_pages() will still return the number of THP that were not migrated. >> > That will confuse the callers of migrate_pages(), for example, which will make >> > the longterm pinning failed though all pages are migrated successfully. >> > >> > Thus we should return 0 to indicate all pages are migrated in this case. >> > >> >> This had me puzzled for a while. I think this wording is clearer? >> >> : During THP migration, if THPs are not migrated but they are split and all >> : subpages are migrated successfully, migrate_pages() will still return the >> : number of THP pages that were not migrated. This will confuse the callers >> : of migrate_pages(). For example, the longterm pinning will failed though >> : all pages are migrated successfully. >> : >> : Thus we should return 0 to indicate that all pages are migrated in this >> : case. >> >> This is a fairly longstanding problem? No Fixes: we can identify? > > It doesn't seem like a long standing issue. It seems like commit > b5bade978e9b ("mm: migrate: fix the return value of migrate_pages()") > fixed one problem, but introduced this new one IIUC. > > Before this commit, the code did: > > nr_failed += retry + thp_retry; > rc = nr_failed; > > But retry and thp_retry were actually reset for each retry until the > last one. So as long as there is no permanent migration failure and > THP split failure, nr_failed should be 0 IIUC. TBH the code is a > little bit hard to follow, please correct me if I'm wrong. I think that you are correct. We can added Fixes: b5bade978e9b ("mm: migrate: fix the return value of migrate_pages()") >> Did you consider the desirability of a -stable backport? I think this can be backport to -stable. Best Regards, Huang, Ying