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 95169EE49A4 for ; Mon, 21 Aug 2023 02:22:21 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7D6178D0003; Sun, 20 Aug 2023 22:22:20 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 785E28D0001; Sun, 20 Aug 2023 22:22:20 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 64E208D0003; Sun, 20 Aug 2023 22:22:20 -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 52E588D0001 for ; Sun, 20 Aug 2023 22:22:20 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 0E885A017C for ; Mon, 21 Aug 2023 02:22:19 +0000 (UTC) X-FDA: 81146512398.22.1E8724B Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.126]) by imf28.hostedemail.com (Postfix) with ESMTP id 6BD02C0007 for ; Mon, 21 Aug 2023 02:22:15 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=ZGhrbFQn; spf=pass (imf28.hostedemail.com: domain of ying.huang@intel.com designates 134.134.136.126 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=1692584536; 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=Ue4vzyKUO9J46X9bkySEMU50B7LuTgPZ9BXMRdfrQpk=; b=5WKU5AlNwsOhGwshGkSFGGYCakgN/AhUbZcf7H2Qd8/V5EZz56cnm4RG3mgCoH/NfYEoHv TELzswNfZqp6Iaqi7km65T/FPGYvlD3NYzpPuF5LWJb3zuP/cMLMCFnEXId1l0XVjL+/FM zHTjh/HC3KlnxGiN38gh69aJwkEAEnY= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1692584536; a=rsa-sha256; cv=none; b=5apdZFyqM1Sw3W7RKJESrabpGf9sejORKQsxxj73rBo1t0G/KaSGlyuCn+tr2LHrOJ+Fag 3epg02HI/+pP/POe+Tul0I5d8aj5xG8W4lwaRzyGVt9lWnXg6adbyHcq3nvdUUTq7+NkmV 2goNgMhQZbR0b0pNyZ3q8skbl8vfZZw= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=ZGhrbFQn; spf=pass (imf28.hostedemail.com: domain of ying.huang@intel.com designates 134.134.136.126 as permitted sender) smtp.mailfrom=ying.huang@intel.com; dmarc=pass (policy=none) header.from=intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1692584535; x=1724120535; h=from:to:cc:subject:references:date:in-reply-to: message-id:mime-version; bh=RohFg+AyWwBklRGlOXwUffXNwQqkzustdxDW53emd7E=; b=ZGhrbFQnUCQim3bzVJQNlDkzVH5LZ9AdYplF3SBnYYj1XWhGw0/qWcDX b+dpuC9sKSxMCYBhgq4avk2fIb7MCJoEfz0IkR0S4e+EC62K74TECrMct ewYQit2VbKxDvlDZL6qVwFIbcr1Q6P+UriM9lG3h6mqkl7uA01NP2WI4L DseuE5v0qdNfMaPimXNONZoFJY2qv5ALWRwqzeRSw092lFbsGl6F/MbzC xIEGPdQgEk1TncnasFktGcQx7XNpPBVHXmk58EjB6fKLBFlk9BWgv2rIl mc5y5MwZS0Qy2LOxSp8J0HFDsUFOmSM2lHv9gsbA4YFqD2lOFXrUBZmgU A==; X-IronPort-AV: E=McAfee;i="6600,9927,10808"; a="358452574" X-IronPort-AV: E=Sophos;i="6.01,189,1684825200"; d="scan'208";a="358452574" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Aug 2023 19:22:13 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10808"; a="729240373" X-IronPort-AV: E=Sophos;i="6.01,189,1684825200"; d="scan'208";a="729240373" Received: from yhuang6-desk2.sh.intel.com (HELO yhuang6-desk2.ccr.corp.intel.com) ([10.238.208.55]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Aug 2023 19:22:10 -0700 From: "Huang, Ying" To: Baolin Wang Cc: , , , , , Subject: Re: [PATCH 1/4] mm: migrate: move migration validation into numa_migrate_prep() References: Date: Mon, 21 Aug 2023 10:20:01 +0800 In-Reply-To: (Baolin Wang's message of "Sat, 19 Aug 2023 18:52:34 +0800") Message-ID: <87h6otdtm6.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-Stat-Signature: bzodnit73e5dysrou4ighpia3e6h4byd X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 6BD02C0007 X-Rspam-User: X-HE-Tag: 1692584535-459385 X-HE-Meta: U2FsdGVkX1/9k/hZYjuweESYa0Hj7OTlQxV6K5lfUumCTUHMLHZ4CLQPpLJ0Mf5zjRiBOxeu8KMSkBT0b18rGzWrPeNVgFQaZDalcDDqZPHeupjUxQuTBP63o32F38U8HJdmGQegcA/wIwbhSXUtUpyVPD+gY62BnfjUVtg34Qcg4uxbVhvnbVq7p6/8TqdJCDLwk4K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precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Baolin Wang writes: > Now there are 3 places will validate if a page can mirate or not, and > some validations are performed later, which will waste some CPU to call > numa_migrate_prep(). > > Thus we can move all the migration validation into numa_migrate_prep(), > which is more maintainable as well as saving some CPU resources. Another > benefit is that it can serve as a preparation for supporting batch migration > in do_numa_page() in future. > > Signed-off-by: Baolin Wang > --- > mm/memory.c | 19 +++++++++++++++++++ > mm/migrate.c | 19 ------------------- > 2 files changed, 19 insertions(+), 19 deletions(-) > > diff --git a/mm/memory.c b/mm/memory.c > index d003076b218d..bee9b1e86ef0 100644 > --- a/mm/memory.c > +++ b/mm/memory.c > @@ -4747,6 +4747,25 @@ int numa_migrate_prep(struct page *page, struct vm_area_struct *vma, > *flags |= TNF_FAULT_LOCAL; > } > > + /* > + * Don't migrate file pages that are mapped in multiple processes > + * with execute permissions as they are probably shared libraries. > + */ > + if (page_mapcount(page) != 1 && page_is_file_lru(page) && > + (vma->vm_flags & VM_EXEC)) > + return NUMA_NO_NODE; > + > + /* > + * Also do not migrate dirty pages as not all filesystems can move > + * dirty pages in MIGRATE_ASYNC mode which is a waste of cycles. > + */ > + if (page_is_file_lru(page) && PageDirty(page)) > + return NUMA_NO_NODE; > + > + /* Do not migrate THP mapped by multiple processes */ > + if (PageTransHuge(page) && total_mapcount(page) > 1) > + return NUMA_NO_NODE; > + > return mpol_misplaced(page, vma, addr); In mpol_misplaced()->should_numa_migrate_memory(), accessing CPU and PID will be recorded. So the code change above will introduce some behavior change. How about move these checks into a separate function which is called between numa_migrate_prep() and migrate_misplaced_page() after unlocking PTL? -- Best Regards, Huang, Ying > } > > diff --git a/mm/migrate.c b/mm/migrate.c > index e21d5a7e7447..9cc98fb1d6ec 100644 > --- a/mm/migrate.c > +++ b/mm/migrate.c > @@ -2485,10 +2485,6 @@ static int numamigrate_isolate_page(pg_data_t *pgdat, struct page *page) > > VM_BUG_ON_PAGE(order && !PageTransHuge(page), page); > > - /* Do not migrate THP mapped by multiple processes */ > - if (PageTransHuge(page) && total_mapcount(page) > 1) > - return 0; > - > /* Avoid migrating to a node that is nearly full */ > if (!migrate_balanced_pgdat(pgdat, nr_pages)) { > int z; > @@ -2533,21 +2529,6 @@ int migrate_misplaced_page(struct page *page, struct vm_area_struct *vma, > LIST_HEAD(migratepages); > int nr_pages = thp_nr_pages(page); > > - /* > - * Don't migrate file pages that are mapped in multiple processes > - * with execute permissions as they are probably shared libraries. > - */ > - if (page_mapcount(page) != 1 && page_is_file_lru(page) && > - (vma->vm_flags & VM_EXEC)) > - goto out; > - > - /* > - * Also do not migrate dirty pages as not all filesystems can move > - * dirty pages in MIGRATE_ASYNC mode which is a waste of cycles. > - */ > - if (page_is_file_lru(page) && PageDirty(page)) > - goto out; > - > isolated = numamigrate_isolate_page(pgdat, page); > if (!isolated) > goto out;