Received: by 2002:a05:7412:d1aa:b0:fc:a2b0:25d7 with SMTP id ba42csp1619492rdb; Wed, 31 Jan 2024 04:24:47 -0800 (PST) X-Google-Smtp-Source: AGHT+IFtXGBE9Q5afhdQjttfqqPzknaSUkNWs6Lql1fT6UGkjin8dk63tLTFTAcUEuIYk3nHsAo3 X-Received: by 2002:a17:902:a50c:b0:1d8:f016:f697 with SMTP id s12-20020a170902a50c00b001d8f016f697mr1251592plq.59.1706703887413; Wed, 31 Jan 2024 04:24:47 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706703887; cv=pass; d=google.com; s=arc-20160816; b=qqpzcbCRlGUyGRuRALIE8SkXM2RAx/siNc+YX4kMLpajUbi3VeCy3suF3J2FNZ5V8Y BVloI8TLHGkNK24Drzb2O9aazx4Xlz+NpkQpkQ+3V14TfOrUaL+n486awHOfwCXy6Sfb vPF+B4JYIOvqsQPvdtziRvrp+nQ7iss93OeK+I/7fl/CP2XbNL+Gwh9jSuzaOicf6E6b MO6cacI2kC0kDbO6GwhlFyJov/YBR7oHpYw8vdX5GYyGPBPltTCO7JpxQ+dDQprneQ8B jVOFZNe4iN1t0wHfF+1txj34CSHvbveuU1oDtFYEWY8iiTSR+s6g42GkSqVkaOU3RryB L6sw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date; bh=ABFox6rRPIYyAXFl6faANmT7b+rplgUzQeKZ3q0wfLs=; fh=1yOmBSrcRfNv+qNnjlPjg+qxGgmYNhDmB3Np9OT1+Bs=; b=r2Y+C74SjwaJV4L8Afm3Am2Kzmq6uibdpq9N+MA6RmI9cQ5b8wtVloFLR9f2BmWqnu 0kLHMcm+fUc5b32cDvEiGSogggOUgwkhyiNsX8J8rW8woylKRgmjeLotfHQltc6XDZSb CBZF2X7V0KFlnug+fT0p39OU1EKGbVqp0nLNv/7CLnY38cqSU5TMxN0xIqKrBq5SDAzS SfQ+Gj675RyQwhGAi/u3HwALe9c3Tt3VexHk0KvUN1BPxubrF0mSBq0MF5ARZFsVn38e nByUvgk0rK+FY1R9NrvsC+x+O9qY/UzzkG30gct8XGSWXb457P0TwWUnAXQgzsgiVSmM 60vA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-46412-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-46412-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com X-Forwarded-Encrypted: i=1; AJvYcCVzzHy6pYQK6XBu7yVj9hy09myqUW3ZviN0apT6RppGIFyKqhfKRC71YFaEwLwu/+R8rFzAQK6J3VBr72BapESzy5+fEFf6s6I+cml8Cw== Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id bd10-20020a170902830a00b001d7758b8502si9420384plb.190.2024.01.31.04.24.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jan 2024 04:24:47 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-46412-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-46412-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-46412-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id B594B286615 for ; Wed, 31 Jan 2024 12:22:34 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1E39E78B6D; Wed, 31 Jan 2024 12:22:25 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 87CD678686; Wed, 31 Jan 2024 12:22:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706703744; cv=none; b=Bj4uyxqxKRMEpWS94DtLAhP6lAN5PdUO3mkU1zypPfem0p4aKFbZmnTuvttAKIQT/5p7QrnDaio2bNM7y3ISbnN8pvqne4Un+pFRFlxyyiS9hE/ziIuDHdvSPe+wKASo8KI6QL1+U6CWOMZP+RPovyaEevRHdQHCbSrKG7NGHWA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706703744; c=relaxed/simple; bh=JjRzeMvW2Ua9zjpVLjV5iutNqduF5tpcfH8Ei36DH8g=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Y6hFUTjjONujxHEaxSv7vPXb1flm5NRJ9JHJgTHk++2iHqu5elkOm40HFpRBR7fCKpJW0A1RsSTm0cvd7d8GjtGs9b71lJHk33cAzMnvuED3KfiCM6MOw7yWvSxEWYA92dQfUmt3uchNuuK+1C9tjvi/qzyo/mQVwMyOqKd/NtY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com 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 53ACFDA7; Wed, 31 Jan 2024 04:23:05 -0800 (PST) Received: from raptor (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 4D3293F738; Wed, 31 Jan 2024 04:22:16 -0800 (PST) Date: Wed, 31 Jan 2024 12:22:05 +0000 From: Alexandru Elisei To: Anshuman Khandual 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, 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 v3 11/35] mm: Allow an arch to hook into folio allocation when VMA is known Message-ID: References: <20240125164256.4147-1-alexandru.elisei@arm.com> <20240125164256.4147-12-alexandru.elisei@arm.com> <1e03aec4-705a-41b6-b258-0b8944d9dc0c@arm.com> <7612b843-cd31-4917-87c0-c26802c5bef2@arm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <7612b843-cd31-4917-87c0-c26802c5bef2@arm.com> Hi, On Wed, Jan 31, 2024 at 12:23:51PM +0530, Anshuman Khandual wrote: > > > On 1/30/24 17:04, Alexandru Elisei wrote: > > Hi, > > > > On Tue, Jan 30, 2024 at 03:25:20PM +0530, Anshuman Khandual wrote: > >> > >> On 1/25/24 22:12, Alexandru Elisei wrote: > >>> arm64 uses VM_HIGH_ARCH_0 and VM_HIGH_ARCH_1 for enabling MTE for a VMA. > >>> When VM_HIGH_ARCH_0, which arm64 renames to VM_MTE, is set for a VMA, and > >>> the gfp flag __GFP_ZERO is present, the __GFP_ZEROTAGS gfp flag also gets > >>> set in vma_alloc_zeroed_movable_folio(). > >>> > >>> Expand this to be more generic by adding an arch hook that modifes the gfp > >>> flags for an allocation when the VMA is known. > >>> > >>> Note that __GFP_ZEROTAGS is ignored by the page allocator unless __GFP_ZERO > >>> is also set; from that point of view, the current behaviour is unchanged, > >>> even though the arm64 flag is set in more places. When arm64 will have > >>> support to reuse the tag storage for data allocation, the uses of the > >>> __GFP_ZEROTAGS flag will be expanded to instruct the page allocator to try > >>> to reserve the corresponding tag storage for the pages being allocated. > >> Right but how will pushing __GFP_ZEROTAGS addition into gfp_t flags further > >> down via a new arch call back i.e arch_calc_vma_gfp() while still maintaining > >> (vma->vm_flags & VM_MTE) conditionality improve the current scenario. Because > > I'm afraid I don't follow you. > > I was just asking whether the overall scope of __GFP_ZEROTAGS flag is being > increased to cover more core MM paths through this patch. I think you have > already answered that below. > > > > >> the page allocator could have still analyzed alloc flags for __GFP_ZEROTAGS > >> for any additional stuff. > >> > >> OR this just adds some new core MM paths to get __GFP_ZEROTAGS which was not > >> the case earlier via this call back. > > Before this patch: vma_alloc_zeroed_movable_folio() sets __GFP_ZEROTAGS. > > After this patch: vma_alloc_folio() sets __GFP_ZEROTAGS. > > Understood. > > > > > This patch is about adding __GFP_ZEROTAGS for more callers. > > Right, I guess that is the real motivation for this patch. But just wondering > does this cover all possible anon fault paths for converting given vma_flag's > VM_MTE flag into page alloc flag __GFP_ZEROTAGS ? Aren't there any other file > besides (mm/shmem.c) which needs to be changed to include arch_calc_vma_gfp() ? My thoughts exactly. I went through most of the fault handling code, and from the code I read, all the allocation were executed with vma_alloc_folio() or by shmem. That's not to say there's no scope for improvment, there definitely is, but since having __GFP_ZEROTAGS isn't necessary for correctness (but it's very useful for performance, since it can avoid a page fault and a page migration) and this series is an RFC I settled on changing only the above, since KVM support for dynamic tag storage also benefits from this change. The series is very big already, I wanted to settle on an approach that is acceptable for upstreaming before thinking too much about performance. Thanks, Alex