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 02C40EB64D8 for ; Mon, 19 Jun 2023 02:00:26 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 498788D0002; Sun, 18 Jun 2023 22:00:26 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4484D8D0001; Sun, 18 Jun 2023 22:00:26 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 310508D0002; Sun, 18 Jun 2023 22:00:26 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 212818D0001 for ; Sun, 18 Jun 2023 22:00:26 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id E3222A03BE for ; Mon, 19 Jun 2023 02:00:25 +0000 (UTC) X-FDA: 80917842810.15.CFC32BF Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by imf21.hostedemail.com (Postfix) with ESMTP id 28F3F1C0006 for ; Mon, 19 Jun 2023 02:00:22 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b="VT64Wdo/"; dmarc=pass (policy=none) header.from=intel.com; spf=pass (imf21.hostedemail.com: domain of ying.huang@intel.com designates 192.55.52.115 as permitted sender) smtp.mailfrom=ying.huang@intel.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1687140024; 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=aniASOrFb9X0AX+UMkuF+OZdyDhgVVY82dtmSlecjAg=; b=HrOMOW8RgpiixbgCHgvU5gA0cInYKHCHk+y/0uqhfEtmiEeCh42LfhPTHlAGqI+R/pt4Sc jpVrK9TWcdXWjoIS4o6lPCVIBKC3wPIDzFSRTl35lAInoACpMPyPokDGOrMZjvTttbECNe oCxKE/ZbP8h7iBXtcPWWfcSjHKaWAWw= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b="VT64Wdo/"; dmarc=pass (policy=none) header.from=intel.com; spf=pass (imf21.hostedemail.com: domain of ying.huang@intel.com designates 192.55.52.115 as permitted sender) smtp.mailfrom=ying.huang@intel.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1687140024; a=rsa-sha256; cv=none; b=bR7Njv5K4SU6iiHhmAJUfWOjKury+YmMMoVjDhuHhxrIhh+oRg+chH13tZwAg/bmtq03F7 THaAfyoVM0Wo0L1ipncpFYhvjL5f8wUx92lMQ2JeIN1USmLpficE4MvAE2dWWxcGw/2F1z U+r7kjqq3CZ58YZ7sOlQpLXOadOcNjw= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1687140023; x=1718676023; h=from:to:cc:subject:references:date:in-reply-to: message-id:mime-version; bh=oR4P0GMr2zpplJmRIjn6et1iR6kpZud+0pyoFilsgp4=; b=VT64Wdo/OYnaN7r9CgCvgaMU6PE4KRlK1YknlZrnfmvZllmzyRlojjAZ XIZoW93hghdbO1kTyfsNm0YNYnCEyq4hXwnbIPrzfQXdwa4D04JPoVAs6 JBlelLkM+FwRYpNI3kF9baEK5uJm3uUONItejxzVCttdtFdHRdVdGVXyr aWJYyY3uxZ+6Zlxz32C2WKj93Oun3MurDwSkn9ziGrtfa9vDgYyvkrVvD 02y3CtrQtIZxwVSq4DcLxuJ8vgQ/5TNwflNcW4SErbzrEZMW/0X5eiZfO dTg5kC4YYksmYmeBNOGK9aFeb20HodoCMcyfCFRavkn8K7wuBxBzumGlF w==; X-IronPort-AV: E=McAfee;i="6600,9927,10745"; a="359534607" X-IronPort-AV: E=Sophos;i="6.00,253,1681196400"; d="scan'208";a="359534607" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Jun 2023 18:59:42 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10745"; a="663812323" X-IronPort-AV: E=Sophos;i="6.00,253,1681196400"; d="scan'208";a="663812323" Received: from yhuang6-desk2.sh.intel.com (HELO yhuang6-desk2.ccr.corp.intel.com) ([10.238.208.55]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Jun 2023 18:59:38 -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> Date: Mon, 19 Jun 2023 09:57:58 +0800 In-Reply-To: <20230618065824.1365750-1-yosryahmed@google.com> (Yosry Ahmed's message of "Sun, 18 Jun 2023 06:58:24 +0000") Message-ID: <87ilbk8b89.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=ascii X-Rspamd-Queue-Id: 28F3F1C0006 X-Rspam-User: X-Rspamd-Server: rspam04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hM2gvaZ1LvLH2X/0rZcXMfRx77Gv68udkXu85V3V9MGhP5TcrOFMn2Wzed5uDTgpc7KKsJ7XsANCHOzcBqchgLu+xS0Q74hcxZVZ8AFxnPkNs5jX7eC8n+ApV9IP2YqLjKc6MM4nJ4Uuzx9AwVB+i48+lDvlq76hYcdo69RCjYo7kBHmBAGTYYNRyhagLe/kS/Oj/ye4hKpI51MtCt8Fkdo5/LXQYsERdfeS5fz6sz7CLpQx+Fw/MA== 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: 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_new_page, unsigned long private, > if (unlikely(!is_lru)) > goto out_unlock_both; The patch itself looks good to me! Thanks! Reviewed-by: "Huang, Ying" 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? 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 easiest. > - */ > - 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_new_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