Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp3648061rdh; Mon, 27 Nov 2023 22:50:25 -0800 (PST) X-Google-Smtp-Source: AGHT+IESqT417EBYfM4dDp4Ih44PSWZxp3GtUw/afumIN1CbmBmMOOvqEgYkwHTM41GZiPAkPgzr X-Received: by 2002:a05:6808:1908:b0:3b8:37c1:417c with SMTP id bf8-20020a056808190800b003b837c1417cmr20884831oib.1.1701154225435; Mon, 27 Nov 2023 22:50:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701154225; cv=none; d=google.com; s=arc-20160816; b=HI65ESmlttjlh8+hN5DvP354zN1VQHa98+/Do3WK9GzemacDDAKmyXMLkWihaWZxxo tjpTmW31yQTDj8PuaozqrDWO85T+DbCaLFqo9NxPCKmMg6byh+PNXzjADCCVjU+6TeMO JO29cI8AHPon2hjBwLvNoKDDQukwH0HDAPB5wh9YcA4RzeodFKVe5tRObfrieegtao9z Zqf+NI5gtD+j6vq3cywMilofiJtJxNwl2R64NA7DCjxONCcM1ihnPH6SgWUISr96Lt6j QwkOftS7aNHMtvCFePvsQi1bbUFLvLc1MhRvXZkNef6fTJlTPb0wXz8OXFUqhxuS5y8m NbaA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=INn2t3m9W8b2w+j0OQX2a5Pi5mkrqP4M5X7d+HtEGIY=; fh=1QNTnXWELpAa0l3eKdRIQV+6e8FhoSoNhAGwB8AiE1o=; b=gISttfezK++XrGFQVz9GQLOrzjb1dnCFY3zgkvr0BNbJ1OyNL8mf0ya53fislsjYxl LtPDWzYRFQd0/O0ZGwnyUUPf39gDtZQ2lz92tUaQ2QhiZ9Eaz0DgEKQJ1dzquEyzcT7v yTJdmSO9WUpMLxs4Yq8WGDIlH9sIZ2IdJcFMxCZLGU1uty/zfdcdI1WM7o4ITbQBK3Kv n3vVOmtD0FQg7+H8UCJgx3PgRfEWL+XNSwsKeXlRXtiqw1I5MSAkP28mRqC7Xk//L0Uq ZwYqgiCrSsxzHMrbGZne2FNulumtuo1CXnBLClnFsJ7dm3Etpn07cPe7aafxNei1X6TS ryag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=if9fM89P; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id l3-20020a63ba43000000b005bd366fd5a1si11383580pgu.449.2023.11.27.22.50.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Nov 2023 22:50:25 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=if9fM89P; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id D4A93806115E; Mon, 27 Nov 2023 22:50:22 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343633AbjK1GuJ (ORCPT + 99 others); Tue, 28 Nov 2023 01:50:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36842 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231540AbjK1GuI (ORCPT ); Tue, 28 Nov 2023 01:50:08 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 464D2E1 for ; Mon, 27 Nov 2023 22:50:15 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A3030C433C7; Tue, 28 Nov 2023 06:50:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1701154214; bh=BijUODoSlZIznO9rdGnXggiSdi32BpO3PHuXhYrN1B8=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=if9fM89P+gYlCDnvkkF1Yr+BLEwcjrzHNVmL7eGBgP+mcsTCAA44Zo/jA2dVG0hka h/LUzMc86Pns899eb+eBzUHUyopA70K0VId+L6bo9UvWEtksLRnYfQgsCIcyFXTmsA StTDz/fcXiBOKdqidbSxUBOYr9dC1xwA/C8VFRnyTj6XuPag4Tu8h7UGU8HWcwBG9+ 1fH3R1gOS/OEy8/WIfOf04Wk3ofHB909dr1lvVQRSa/GLjFVYWIitbmdb/iG2c0hqj gI9GkHgvnjBOAPs5NT6aeOVlwPQnvsC/4BEjUwfK4dSUKeT8i6bctj0fIX1Dbg8u2L G9GIlEM7e/Y1Q== Date: Tue, 28 Nov 2023 08:49:57 +0200 From: Mike Rapoport To: Alexandru Elisei 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: <20231128064957.GI636165@kernel.org> 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: X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Mon, 27 Nov 2023 22:50:23 -0800 (PST) On Mon, Nov 27, 2023 at 11:52:56AM +0000, Alexandru Elisei wrote: > 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(). Ok, just add a sentence about it to the commit message. > 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. > > -- Sincerely yours, Mike.