Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp2468069rdg; Mon, 16 Oct 2023 05:41:27 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFInBn1gchV627YIDaIBtxTqpSNCF6XGxCwS1GUuJbxzjhH5R6EXrOMLlGHFKVo2A8WitAJ X-Received: by 2002:a05:6a00:1691:b0:693:3cbc:3d8e with SMTP id k17-20020a056a00169100b006933cbc3d8emr39665530pfc.0.1697460087241; Mon, 16 Oct 2023 05:41:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697460087; cv=none; d=google.com; s=arc-20160816; b=K6+RmDRKkUf7uXf0TBzWd/atoSAFl0I6m0XfaOcYv2aLL+Kvrd6vfItQFoKP9piKN0 X2Zt1jQDSpG8Kg/WF8zhP0mCbpdXOiPTWmesudmDLYD0Vo6VC56hcQDe/n3E6Osx5EpZ VyD5GVSdC57K2HjJIT+E/1TQK8Fvrd4WhaThPUXmZbHKi6TYEkvsaFzxgn82FuhP+VX/ FsYdePLemJfpjZWTvoYglI2JOPD0x8VmX80zOvJTZ1hQPn+pi8bw9WTaM9cp7gZzyoIc W2X2EhXrgCjt+IELMMU0fJ0N2Vav1q1jM49tELq6XMIjtiQXzme88adCUFHGq/PXjX9D A8GQ== 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; bh=7A0wbU2zva4yUVI2ojIAha5iaTFNMMOR5zkRFB42juA=; fh=662FnxvaMUPpGpbpQaKOb5FYDcM6B26e8RC2ZBxI39o=; b=E+kqNPrljhpKc5FyqkKWqRLnT76uHqUN6cYYX3bgIBWNmIvlheVrVcaNFJJ9mU40uG H89njpTegBsOO9EdVP+DzshvtRzPaWGxICp3ydm31NSf+FSPuJ90P/v/SQaPcVKPE03p 855cL0WcdsBMrKFGndmxez2Z4ViyKL5JxWlg8wBFhvTcykpoyya6Bz+aYK3+EVl+EdE+ bDyPVjqCYOJGZ2dysaZexIBpesxKg/s/f8mkpZtt3e7jh1arIEv4EGzsufqhVflkYWox mR0IRMHy+rELBCw5cv1nKXLyWvl0Z5GlEgE4lQPEUomy4bG2OcZmwZJHSdRzBxMVNXK6 vsrA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id x25-20020a634859000000b0057851fc2b4asi10801996pgk.55.2023.10.16.05.41.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Oct 2023 05:41:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id B51908085F97; Mon, 16 Oct 2023 05:40:54 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233568AbjJPMkk (ORCPT + 99 others); Mon, 16 Oct 2023 08:40:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47784 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233477AbjJPMkW (ORCPT ); Mon, 16 Oct 2023 08:40:22 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 9DCED1A6; Mon, 16 Oct 2023 05:40:12 -0700 (PDT) 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 DD7541FB; Mon, 16 Oct 2023 05:40:51 -0700 (PDT) Received: from monolith (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id E092D3F5A1; Mon, 16 Oct 2023 05:40:05 -0700 (PDT) Date: Mon, 16 Oct 2023 13:40:39 +0100 From: Alexandru Elisei To: Hyesoo Yu 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, rppt@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, 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 04/37] mm: Add MIGRATE_METADATA allocation policy Message-ID: References: <20230823131350.114942-1-alexandru.elisei@arm.com> <20230823131350.114942-5-alexandru.elisei@arm.com> <20231012012824.GA2426387@tiffany> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231012012824.GA2426387@tiffany> X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.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 (howler.vger.email [0.0.0.0]); Mon, 16 Oct 2023 05:40:54 -0700 (PDT) Hello, On Thu, Oct 12, 2023 at 10:28:24AM +0900, Hyesoo Yu wrote: > On Wed, Aug 23, 2023 at 02:13:17PM +0100, Alexandru Elisei wrote: > > Some architectures implement hardware memory coloring to catch incorrect > > usage of memory allocation. One such architecture is arm64, which calls its > > hardware implementation Memory Tagging Extension. > > > > So far, the memory which stores the metadata has been configured by > > firmware and hidden from Linux. For arm64, it is impossible to to have the > > entire system RAM allocated with metadata because executable memory cannot > > be tagged. Furthermore, in practice, only a chunk of all the memory that > > can have tags is actually used as tagged. which leaves a portion of > > metadata memory unused. As such, it would be beneficial to use this memory, > > which so far has been unaccessible to Linux, to service allocation > > requests. To prepare for exposing this metadata memory a new migratetype is > > being added to the page allocator, called MIGRATE_METADATA. > > > > One important aspect is that for arm64 the memory that stores metadata > > cannot have metadata associated with it, it can only be used to store > > metadata for other pages. This means that the page allocator will *not* > > allocate from this migratetype if at least one of the following is true: > > > > - The allocation also needs metadata to be allocated. > > - The allocation isn't movable. A metadata page storing data must be > > able to be migrated at any given time so it can be repurposed to store > > metadata. > > > > Both cases are specific to arm64's implementation of memory metadata. > > > > For now, metadata storage pages management is disabled, and it will be > > enabled once the architecture-specific handling is added. > > > > Signed-off-by: Alexandru Elisei > > --- > > [..] > > @@ -2144,6 +2156,15 @@ __rmqueue(struct zone *zone, unsigned int order, int migratetype, > > if (alloc_flags & ALLOC_CMA) > > page = __rmqueue_cma_fallback(zone, order); > > > > + /* > > + * Allocate data pages from MIGRATE_METADATA only if the regular > > + * allocation path fails to increase the chance that the > > + * metadata page is available when the associated data page > > + * needs it. > > + */ > > + if (!page && (alloc_flags & ALLOC_FROM_METADATA)) > > + page = __rmqueue_metadata_fallback(zone, order); > > + > > Hi! > > I guess it would cause non-movable page starving issue as CMA. I don't understand what you mean by "non-movable page starving issue as CMA". Would you care to elaborate? > The metadata pages cannot be used for non-movable allocations. > Metadata pages are utilized poorly, non-movable allocations may end up > getting starved if all regular movable pages are allocated and the only > pages left are metadata. If the system has a lot of CMA pages, then > this problem would become more bad. I think it would be better to make > use of it in places where performance is not critical, including some > GFP_METADATA ? GFP_METADATA pages must be used only for movable allocations. The kernel must be able to migrate GFP_METADATA pages (if they have been allocated) when they are reserved to serve as tag storage for a newly allocated tagged page. If you are referring to the fact that GFP_METADATA pages are allocated only when there are no more free pages in the zone, then yes, I can understand that that might be an issue. However, it's worth keeping in mind that if a GFP_METADATA page is in use when it needs to be repurposed to serve as tag storage, its contents must be migrated first, and this is obviously slow. To put it another way, the more eager the page allocator is to allocate from GFP_METADATA, the slower it will be to allocate tagged pages because reserving the corresponding tag storage will be slow due to migration. Before making a decision, I think it would be very helpful to run performance tests with different allocation policies for GFP_METADATA. But I would say that it's a bit premature for that, and I think it would be best to wait until the series stabilizes. And thank you for the feedback! Alex > > Thanks, > Hyesoo Yu.