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 4071EC3A59D for ; Mon, 24 Oct 2022 01:57:07 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A0674940008; Sun, 23 Oct 2022 21:57:06 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9B6C1940007; Sun, 23 Oct 2022 21:57:06 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 87E11940008; Sun, 23 Oct 2022 21:57:06 -0400 (EDT) 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 75310940007 for ; Sun, 23 Oct 2022 21:57:06 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 32279409A4 for ; Mon, 24 Oct 2022 01:57:06 +0000 (UTC) X-FDA: 80054180052.03.659531F Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by imf08.hostedemail.com (Postfix) with ESMTP id 2A51516000D for ; Mon, 24 Oct 2022 01:57:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1666576625; x=1698112625; h=from:to:cc:subject:references:date:in-reply-to: message-id:mime-version; bh=gpg1bc4kGtPIDhO6eUFSZuZY+nqE2oI4ubjdCw5mQqw=; b=LN3dwl9n+0AbjVPNog6Pl45XJqfEjmPIzpG75jdKHQHzDxvd8eS8drHL HJ4XjDTVibeUq3QDumij/59IxBWgfiyu4j/CGhoOESFzjFWlis2/VOg/3 /jO2vrYJ+1XTLhtkU4DSGG/TJN0pjMdGm/vWCifwrv/oT3hHoWTSG2nb8 08hx0mro51kTZSfwdYhYl+U8oS6ivDv0Af4H2lJlwpW4aeKn4HmC/0vwA nKLK8dcrv1BeowmSLJQIhz9mLJYUoKSKHaWAmCCy7kUn1fbMwyTlKd+YB L8NrHuHUMLs41Pjfe21HLPO9CDkSw3RJkHA9mjKIX2uehj57yIPqJYcDI A==; X-IronPort-AV: E=McAfee;i="6500,9779,10509"; a="287717431" X-IronPort-AV: E=Sophos;i="5.95,207,1661842800"; d="scan'208";a="287717431" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga107.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 ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=none ("invalid DKIM record") header.d=intel.com header.s=Intel header.b=LN3dwl9n; spf=pass (imf08.hostedemail.com: domain of ying.huang@intel.com designates 192.55.52.151 as permitted sender) smtp.mailfrom=ying.huang@intel.com; dmarc=pass (policy=none) header.from=intel.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1666576625; a=rsa-sha256; cv=none; b=fB1HklNT4sHjILPpD0zav7rW7P88u0v3SpKeLfn/vZRsIKzzCL4A3oWtmsxU3HlMu6+OqQ PBHAqdb5KrKQ7WbGSRg/mQszzruBJaUiIsALrC4YNaDAkfMII6EAheaKR1RZXdYMdbPR3p jMwpWn0veMZ/sIQBiOv38OqJzIiMAVs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1666576625; 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-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=yu7nqyBhx9rLygIBKi22hg534qtd4MhUY7XkDHgXjOc=; b=w4dPj82UpJH8o7NqjuIEVdRmkj3eP7Kooi930jIHEhSZXjgdVfD3EPUt7kq3Er+CldYF08 KqCEwuSAieo/axm0F1weZUS0XcHDuDVL5NhhcQE4go8E4FB4/NCIP7JaIpI/IfMR8wHg0F g1HsYQXRP53IpLAH9xUSRbOl4S7lep0= Authentication-Results: imf08.hostedemail.com; dkim=none ("invalid DKIM record") header.d=intel.com header.s=Intel header.b=LN3dwl9n; spf=pass (imf08.hostedemail.com: domain of ying.huang@intel.com designates 192.55.52.151 as permitted sender) smtp.mailfrom=ying.huang@intel.com; dmarc=pass (policy=none) header.from=intel.com X-Stat-Signature: m1toz354ertdb9z19qonxn5s4fqnaxfh X-Rspamd-Queue-Id: 2A51516000D X-Rspamd-Server: rspam02 X-Rspam-User: X-HE-Tag: 1666576624-111258 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000003, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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