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 20AB2C4167B for ; Mon, 27 Nov 2023 11:53:08 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AED3B6B02DA; Mon, 27 Nov 2023 06:53:07 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id A76CE6B02DB; Mon, 27 Nov 2023 06:53:07 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 919016B02DC; Mon, 27 Nov 2023 06:53:07 -0500 (EST) 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 7D4656B02DA for ; Mon, 27 Nov 2023 06:53:07 -0500 (EST) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 513D61CAD8D for ; Mon, 27 Nov 2023 11:53:07 +0000 (UTC) X-FDA: 81503573214.11.F37014C Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf25.hostedemail.com (Postfix) with ESMTP id 8CD03A001B for ; Mon, 27 Nov 2023 11:53:05 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=none; spf=pass (imf25.hostedemail.com: domain of alexandru.elisei@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=alexandru.elisei@arm.com; dmarc=pass (policy=none) header.from=arm.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1701085985; a=rsa-sha256; cv=none; b=f+xFPUsCN0r9ypuICAHJ3gLvabPPlFa/h3rIze4lYeY2mGTO6HAifjC2UpM6dxQG0Z0yYr QjF4JNOYq0fbWlLrHAo8twpIQWQULZyvYCp5/TrZsOajvF+MjOEaIYQpUnc2nl+I+HtkgX xaFm//D0ELYKspfJ6YVCJVRTKrOCQ1Y= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=none; spf=pass (imf25.hostedemail.com: domain of alexandru.elisei@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=alexandru.elisei@arm.com; dmarc=pass (policy=none) header.from=arm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1701085985; 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; bh=b61SQGJUkArgmCKGbOznYYFvvaOOeZBn2Ov90MH8d64=; b=U/M1A56th2aP3nzjxnX8xqNTzGh6TIrm7pQvXczv/c/dOyY3tYXCDmeC5/Jm8JRnIQLzYp 3vlwRBpSiCB9RFIwVhAbMRa1AfiUOvk/33ft4/kyzQeMCzCf1sDjLcnkRzpk8lMNId8kGw jtyJ+p0Wze4bH/puDxKzgW5JVbFz8TE= Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 054652F4; Mon, 27 Nov 2023 03:53:52 -0800 (PST) Received: from raptor (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 35DB03F73F; Mon, 27 Nov 2023 03:52:59 -0800 (PST) Date: Mon, 27 Nov 2023 11:52:56 +0000 From: Alexandru Elisei To: Mike Rapoport Cc: catalin.marinas@arm.com, will@kernel.org, oliver.upton@linux.dev, maz@kernel.org, james.morse@arm.com, suzuki.poulose@arm.com, yuzenghui@huawei.com, arnd@arndb.de, akpm@linux-foundation.org, mingo@redhat.com, peterz@infradead.org, juri.lelli@redhat.com, vincent.guittot@linaro.org, dietmar.eggemann@arm.com, rostedt@goodmis.org, bsegall@google.com, mgorman@suse.de, bristot@redhat.com, vschneid@redhat.com, mhiramat@kernel.org, hughd@google.com, pcc@google.com, steven.price@arm.com, anshuman.khandual@arm.com, vincenzo.frascino@arm.com, david@redhat.com, eugenis@google.com, kcc@google.com, hyesoo.yu@samsung.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, kvmarm@lists.linux.dev, linux-fsdevel@vger.kernel.org, linux-arch@vger.kernel.org, linux-mm@kvack.org, linux-trace-kernel@vger.kernel.org Subject: Re: [PATCH RFC v2 04/27] mm: migrate/mempolicy: Add hook to modify migration target gfp Message-ID: References: <20231119165721.9849-1-alexandru.elisei@arm.com> <20231119165721.9849-5-alexandru.elisei@arm.com> <20231125100322.GH636165@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231125100322.GH636165@kernel.org> X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 8CD03A001B X-Stat-Signature: 6nzr7cj4199y5axd9fqjsdt3pzzzuiz9 X-HE-Tag: 1701085985-313109 X-HE-Meta: U2FsdGVkX18vsx2KWom0kLofftGchxQIQKtPDOqmSNoNcUHpzAfp+9o3sTiypwRlsSQ1tc3+CR1nThOSjAlz2H3iZon3m7rKzys2ftz1DmbMytVr7yxmAx+inE7frBsvAJ0d1Id2/wVyX/cx2cEDhCOo/P95OpRyZFghuZCN+NSldJyYtxXQY6bR6dnD8WK2wS+fFqQi8412lsPEPKlyal9qVHiYzJwjN8P8wuGHI9eJo/YYuSlgRHglk11QNDmm2c89qDMRGNCe+MQNKKsf//FqeVpmmLq8N/VxmgH6UoR3Mg9XsDMCsTvtno3xRiuxXz9GSrVt/Tn7VfGaJUwdAO/DS0ylzLQNtOcZCNi5GHYkz8smtZVRj3dU7Hj42bzBwzanGOzmReuiYEnyH05mqr1L8YqyNi2vUVYf4FEZUr/+WGpVj7ZRhsM8gFR9ITzVIus8UuG8GHjSTQo++npzRFArx/TAXqjiVyVJyVCPUqYTJzI4y7AG8Dqn9KW1pEplm+C5v0hr9kMmJsx5kxOupONVq01StmWkUHaM2gVbgEwQfwyPa9ndexb6FrQi4Vo6+/HYs7+P1G7w8g8oZIKF4tWtrpEQsjW7TvlW34SYNxN113qRwov2XPNnoZv/7uGwhzavXzQbyezYc6lyGSeLNUr+cOAwU1i3+mCstbenm59lptgFAO1HNaWx8O0C6BDQCwNc9MhRKW3EuK3OrpVBnzD/2qGIJGnbLiDnxmTJ79/oOvNythNkb+ebXN4bqQo3NbFr3V0m1OlYwZNmr1uJjfd6q1rjxX08wJ9ztkY38azBG+5hWFes8glrtDufmRR+xt445XV2CBKwMZfi8G09+NXedXCcJATK3brvPYSaU4kzqqVuekp364TCA5X1nCh4Wz7P89zb7rFCvx/Btg4y/cWPpvipmPy8eZOyk8nAuQwTekeY38KtebeM1MT48CQO77ge1e6HpX5AHyeJJ04 dmKMNFiM 13mfLCSa43bwOhTKWEbcISREIMc+g/6HT667110aLBuuuyZQguVRRJe0vNwMuPtzAWQSDI4gIyEjHjSPspJ1uNuYH9HcRfoYSF+F/d83a3aWDdc1qKIPoG7FEK1sUYOyxNu9havtIYmYXXJKiXE16k5fvDd/zIuKmQ/Wi 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: List-Subscribe: List-Unsubscribe: Hi Mike, I really appreciate you having a look! On Sat, Nov 25, 2023 at 12:03:22PM +0200, Mike Rapoport wrote: > On Sun, Nov 19, 2023 at 04:56:58PM +0000, Alexandru Elisei wrote: > > It might be desirable for an architecture to modify the gfp flags used to > > allocate the destination page for migration based on the page that it is > > being replaced. For example, if an architectures has metadata associated > > with a page (like arm64, when the memory tagging extension is implemented), > > it can request that the destination page similarly has storage for tags > > already allocated. > > > > No functional change. > > > > Signed-off-by: Alexandru Elisei > > --- > > include/linux/migrate.h | 4 ++++ > > mm/mempolicy.c | 2 ++ > > mm/migrate.c | 3 +++ > > 3 files changed, 9 insertions(+) > > > > diff --git a/include/linux/migrate.h b/include/linux/migrate.h > > index 2ce13e8a309b..0acef592043c 100644 > > --- a/include/linux/migrate.h > > +++ b/include/linux/migrate.h > > @@ -60,6 +60,10 @@ struct movable_operations { > > /* Defined in mm/debug.c: */ > > extern const char *migrate_reason_names[MR_TYPES]; > > > > +#ifndef arch_migration_target_gfp > > +#define arch_migration_target_gfp(src, gfp) 0 > > +#endif > > + > > #ifdef CONFIG_MIGRATION > > > > void putback_movable_pages(struct list_head *l); > > diff --git a/mm/mempolicy.c b/mm/mempolicy.c > > index 10a590ee1c89..50bc43ab50d6 100644 > > --- a/mm/mempolicy.c > > +++ b/mm/mempolicy.c > > @@ -1182,6 +1182,7 @@ static struct folio *alloc_migration_target_by_mpol(struct folio *src, > > > > h = folio_hstate(src); > > gfp = htlb_alloc_mask(h); > > + gfp |= arch_migration_target_gfp(src, gfp); > > I think it'll be more robust to have arch_migration_target_gfp() to modify > the flags and return the new mask with added (or potentially removed) > flags. I did it this way so an arch won't be able to remove flags set by the MM code. There's a similar pattern in do_mmap() -> calc_vm_flag_bits() -> arch_calc_vm_flag_bits(). I'll change it to return the new mask if you think that's better. Thanks, Alex > > > nodemask = policy_nodemask(gfp, pol, ilx, &nid); > > return alloc_hugetlb_folio_nodemask(h, nid, nodemask, gfp); > > } > > @@ -1190,6 +1191,7 @@ static struct folio *alloc_migration_target_by_mpol(struct folio *src, > > gfp = GFP_TRANSHUGE; > > else > > gfp = GFP_HIGHUSER_MOVABLE | __GFP_RETRY_MAYFAIL | __GFP_COMP; > > + gfp |= arch_migration_target_gfp(src, gfp); > > > > page = alloc_pages_mpol(gfp, order, pol, ilx, nid); > > return page_rmappable_folio(page); > > -- > Sincerely yours, > Mike. >