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 36B01EB64D9 for ; Mon, 19 Jun 2023 04:29:08 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 76CE48D0002; Mon, 19 Jun 2023 00:29:07 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6F68F8D0001; Mon, 19 Jun 2023 00:29:07 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 597568D0002; Mon, 19 Jun 2023 00:29:07 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 473F98D0001 for ; Mon, 19 Jun 2023 00:29:07 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 138D714031D for ; Mon, 19 Jun 2023 04:29:07 +0000 (UTC) X-FDA: 80918217534.05.DF98756 Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by imf03.hostedemail.com (Postfix) with ESMTP id 549F720007 for ; Mon, 19 Jun 2023 04:29:04 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=Sxq5BXw0; spf=pass (imf03.hostedemail.com: domain of ying.huang@intel.com designates 134.134.136.100 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=1687148945; a=rsa-sha256; cv=none; b=ofq0ks+HhQ72fr9hHytLNZntSn5n1AmSxqOtxC+Lnl25luvM5poU3DbFlR+w4sYzvy2L7r EcF6jNwVeMpjJ2D9jK/WLTGfKrpfklWucbmi4wlqYK1Ocmxkh0j0Ksnz+xXGoO69QCbnkC b8XcOgpxswyHEJkOtoBRUOdvjrF0GbQ= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=Sxq5BXw0; spf=pass (imf03.hostedemail.com: domain of ying.huang@intel.com designates 134.134.136.100 as permitted sender) smtp.mailfrom=ying.huang@intel.com; dmarc=pass (policy=none) header.from=intel.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1687148945; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=vKBRbgzJW7vzMBHGLH8ohXl75AZt2cXAn7t18TQRU9s=; b=VTRsvnPCG5XxmeHAiCvP8fcOzOtxa1zhVPZnNtVJme8W9S0WmQN9mLegOeNnymW9HJ10gw dsK9rqIU5/PG9452jLNE1jwCHb1iOijOxl+LTUaIXKTEg6+T4gFcHJnxXhcbfs7EL1rrOq C/YFnFwayOFDcFIDdasvhqYPNdxOx/c= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1687148944; x=1718684944; h=from:to:cc:subject:references:date:in-reply-to: message-id:mime-version:content-transfer-encoding; bh=Nm2PU+XrA/C9g13+5/DoFJAy+VRzHa5O8+Yy7/+ZiL0=; b=Sxq5BXw05TDvxDdR/qWU5WJcLShMjnYGdPR6QIP5/ZBiA1CTnedqHER0 sYYLD31MiTom5wsEb51hg0TMsW9WtOft3/mWdsQisBOCkHXV6AhIgNbYf GfUQzoSYpM6+ow7xlS4iUPb9TLRSasb/oOd/tZv/JOeJKrn31GSttoMdl Qj9ewVDjCsz2GzbEvZr6rQMLbefaYNePcMJL/sj0jm2NqK7II6M+DLzQL 0qlrB0X9IRDjKzYOtYmTadieTvVFeN9fH8zzIiY/+J4jVnrjUOgt7Z/SW tHs2Es1N7xXC/RmOWrkNBQnhTRvXh9yQbE6AbgpUh/9obgty3GbFKKS+M Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10745"; a="425491646" X-IronPort-AV: E=Sophos;i="6.00,253,1681196400"; d="scan'208";a="425491646" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Jun 2023 21:29:01 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10745"; a="743295957" X-IronPort-AV: E=Sophos;i="6.00,253,1681196400"; d="scan'208";a="743295957" Received: from yhuang6-desk2.sh.intel.com (HELO yhuang6-desk2.ccr.corp.intel.com) ([10.238.208.55]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Jun 2023 21:28:56 -0700 From: "Huang, Ying" To: Yosry Ahmed Cc: Andrew Morton , Yu Zhao , "Jan Alexander Steffens (heftig)" , Steven Barrett , Brian Geffon , "T.J. Alumbaugh" , Gaosheng Cui , Suren Baghdasaryan , "Matthew Wilcox (Oracle)" , "Liam R. Howlett" , David Hildenbrand , Jason Gunthorpe , Mathieu Desnoyers , David Howells , Hugh Dickins , Greg Thelen , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [RFC PATCH 5/5] Revert "mm/migrate: __unmap_and_move() push good newpage to LRU" References: <20230618065824.1365750-1-yosryahmed@google.com> <87ilbk8b89.fsf@yhuang6-desk2.ccr.corp.intel.com> Date: Mon, 19 Jun 2023 12:27:22 +0800 In-Reply-To: (Yosry Ahmed's message of "Sun, 18 Jun 2023 20:59:52 -0700") Message-ID: <87a5ww84b9.fsf@yhuang6-desk2.ccr.corp.intel.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 549F720007 X-Stat-Signature: m9herwz34sybjj96e4efkr6x55pkp7zk X-Rspam-User: X-HE-Tag: 1687148944-205182 X-HE-Meta: U2FsdGVkX1/p8Ws36XddKkGxvLgVlGKB3CBDZKZyilyXpv4D3gQ+icwhCC14lakew21FvrZiSc6KSwQGbn0+gGoikZZ7u0Hp6mTXKuAuHiidgqmJH8wwbuG6bt0Pc3rJAh1L7FJ9ZQ3EI3vC04tdKOZY2h7GHBoOZCeGyWFsFAWidkaBjQzvEd3nExKbySO6VKJfojPU50iyVDx/8rG4bQG7I2xjX8lGadEZfCdU2ILdU95l7//9UQuROV3hUCHCw6d9d1Y3ggpilLPXx/Au+VtQUDNIUdDvXoU6XdFJqW9tGZKNllsFvg2fH4PRpyaHXV+UyhdFgAhgT5XUN1vDGPZDIvUPw6flILbdBu4QRD8XEecZLopOtTEYWqgT92Q/NgLItxwhBeBgOxiaceuE5L/dV0f92U6GG6kcpxEE+F8qtyHA3/rQxryHr6er6JarQCdNOqXvEMsqr5hSdTfG04kAPpwSfuBFAcPsPAu4/FPyAp4hzyxVr4V4haxQ0oI0PMnGsAgfXeks16v1/muwODCk5fP2mrRUokNPEuKrLV+LygGHBmmlAJ/tE+lm3T+q1inCvFx0mC1c0BkOX2pLQ1P1x4XOglKJUD0Vp1FXqWJAKMiOFJLwWUoj5haQAGJPEW9wTpZQTOs2Fvo+CHDVBBiZq29BfbH998D5Gvuuqcf+xYTeP+Jd21tpRuaThj1JNhI/WbO5h1FKzOO+CqvFuSWvt0R1Ju7RsfNW8Gp4JI1hTj3KrmGrNGGmhI0JWU6Ay19h3N+LZtXwyMQwVgElu/q1ffKlAQxCQf/QC+c9bafvyOc8TkAcZ1qYkch60ktAr6DbeLcU9hEFUsQYKW+CLw91J0sT2h+vTF72IohiDK5UC2jSOxTOGFP5TnszLPdml8dRQfyvNDJd5CH3PnZCtj0OuxG2Xzx5LVJM0nNeINsg5YmnMCV87PsqSWRx8+ZoHMnBw/tlmGX98jSH9h7 YwyG4ThD 2tPSMgbqgmsIc76s2kdAsJKtB4BhKJ1NvK3HBdjobkd/3RDvG1fPjH83RssULmj350+Poeb5RzMzG6CV1X9byB1uq7zPd1CM/4i72jrpGnoCOjV8pJwf9jITUmOlQhMbogIYeSuN32FbZPVXVjB6qu7Gr8Ayi6kWXad8z4Y4kPSDwm4UIz7+PP1HJtQjALIa0t8MqOUoVdx7n8VU2/VCiQHUG6wrg6FDIapRxiKM21lzEFT+7kRtnpHibdA== 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: Yosry Ahmed writes: > On Sun, Jun 18, 2023 at 7:00=E2=80=AFPM Huang, Ying wrote: >> >> Hi, Yosry, >> >> Yosry Ahmed writes: >> >> > This reverts commit c3096e6782b733158bf34f6bbb4567808d4e0740. >> > >> > That commit made sure we immediately add the new page to the LRU before >> > remove_migration_ptes() is called in migrate_move_folio() (used to be >> > __unmap_and_move() back then), such that the rmap walk will rebuild the >> > correct mlock_count for the page again. This was needed because the >> > mlock_count was lost when the page is isolated. This is no longer the >> > case since mlock_count no longer overlays page->lru. >> > >> > Revert the commit (the code was foliated afterward the commit, so the >> > revert is updated as such). >> > >> > Signed-off-by: Yosry Ahmed >> > --- >> > mm/migrate.c | 24 +++++++++--------------- >> > 1 file changed, 9 insertions(+), 15 deletions(-) >> > >> > diff --git a/mm/migrate.c b/mm/migrate.c >> > index 01cac26a3127..68f693731865 100644 >> > --- a/mm/migrate.c >> > +++ b/mm/migrate.c >> > @@ -1279,19 +1279,6 @@ static int migrate_folio_move(free_page_t put_n= ew_page, unsigned long private, >> > if (unlikely(!is_lru)) >> > goto out_unlock_both; >> >> The patch itself looks good to me! Thanks! >> >> Reviewed-by: "Huang, Ying" > > Thanks for taking a look! > >> >> And, it seems that we can remove the above 2 lines and "out_unlock_both" >> label now. That can make the code simpler a little. Right? > > I am not familiar with this code. If we remove the above condition > then pages that have is_lru =3D=3D 0 (i.e __PageMovable(src) is true) and > page_was_mapped =3D=3D 1 will call remove_migration_ptes(). This wouldn't > happen without removing the above 2 lines. If this combination is > impossible (is_lru =3D=3D 0 && page_was_mapped =3D=3D 1), then yeah we can > remove the above condition. > > It looks like __SetPageMovable() is only called by zsmalloc, z3fold, > and balloon_page_insert(). The former 2 will never have those pages > mapped into userspace. I am not familiar with balloon_page_insert(), > but my gut feeling is that those are pages used by the driver and are > also not mapped into userspace. You can take a look at migrate_folio_unmap(), where "page_was_mapped" will not be set to 1 if !is_lru. Best Regards, Huang, Ying > So I guess we can just remove the condition, but a confirmation for > the above would be reassuring :) > >> >> Best Regards, >> Huang, Ying >> >> > - /* >> > - * When successful, push dst to LRU immediately: so that if it >> > - * turns out to be an mlocked page, remove_migration_ptes() will >> > - * automatically build up the correct dst->mlock_count for it. >> > - * >> > - * We would like to do something similar for the old page, when >> > - * unsuccessful, and other cases when a page has been temporarily >> > - * isolated from the unevictable LRU: but this case is the easie= st. >> > - */ >> > - folio_add_lru(dst); >> > - if (page_was_mapped) >> > - lru_add_drain(); >> > - >> > if (page_was_mapped) >> > remove_migration_ptes(src, dst, false); >> > >> > @@ -1301,9 +1288,16 @@ static int migrate_folio_move(free_page_t put_n= ew_page, unsigned long private, >> > /* >> > * If migration is successful, decrease refcount of dst, >> > * which will not free the page because new page owner increased >> > - * refcounter. >> > + * refcounter. As well, if it is LRU folio, add the folio to LRU >> > + * list in here. Use the old state of the isolated source folio = to >> > + * determine if we migrated a LRU folio. dst was already unlocked >> > + * and possibly modified by its owner - don't rely on the folio >> > + * state. >> > */ >> > - folio_put(dst); >> > + if (unlikely(!is_lru)) >> > + folio_put(dst); >> > + else >> > + folio_putback_lru(dst); >> > >> > /* >> > * A folio that has been migrated has all references removed >>