Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp4007959rdh; Tue, 28 Nov 2023 09:17:44 -0800 (PST) X-Google-Smtp-Source: AGHT+IGcDUNAt+u52cXlEu4s3/cjOa7p+HDwSeakywv8q/suKI/zLSgoz4Z5NJIJu4WCiIMhDBJv X-Received: by 2002:a05:6a20:258f:b0:18c:64e0:4474 with SMTP id k15-20020a056a20258f00b0018c64e04474mr10433351pzd.1.1701191864227; Tue, 28 Nov 2023 09:17:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701191864; cv=none; d=google.com; s=arc-20160816; b=wf6thR17JAWnozOKZaCZNSc/+sqI3eySjZ54C6aFhgLNUVNvkUBVbTwk4CkEUd4VR/ YU2zo/UdzIOefFnuqQZGyIByuRJ4S93YruML+0Kev7odeXPCBtomlH0G21rpYXACIrNT GxToctcLwwTe9K5jGxxltZMSckmPbpoesmfbGKZbejeX/mDhtcsvWawPHuCz7q6EENwj SdVCI6HV1AFwhcJ9hXQqTgS46b7er+XoaOB1jFwDl1uNwbbehVxduvdozYQB5O2fu9GD hKF+hOA5fsr6OaTZusFYxj7F1BRxFuaewImO/bOgHH9wJ2z2MQe56nrvK/OXcn/Y4Hvr 0Vjg== 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=BDp4qsyVqR2xMh/m4hIcHNoVew/4DfGfZNkEPyCM7Bo=; fh=oVyZPWtm6mpH3d4qDAoXsAeagaN2dloHFHPyagpC8cc=; b=uhIB32r6WscA7YLAXzNN9vqWVHdZSZNi9K3u711I8IJY/dghLJwD2znBgato2OcBX2 LDNOJasxZF+pnNB12p1lEnWZSTl5vS3wbnb4Ajc98s3KkTb6mXKRJH7MiQ4W/HEaaELN KCrdmh4yA2FpsTdjXzWN3i0dW/qz+pVqf/L8+tdL+jSMV+TvT8MyDqo7SAsqULk8NPGr H0LMqJEUx5VJexWoPc+cZK1EQoA878gaovCqn1upsm2fsUsYO5wTabJL/19kjc9Xn7dH UzSj1FqTrFP1wxlkp884yb6F2lwcMIupjf8rxUjLpRGc5h5v9Ex30JG3UCzdRN73Nrvi hdvA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 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 morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id o1-20020a056a0015c100b006cc05bcf542si8189936pfu.319.2023.11.28.09.17.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Nov 2023 09:17:44 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 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 morse.vger.email (Postfix) with ESMTP id B5AF48066764; Tue, 28 Nov 2023 09:17:41 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344566AbjK1RR2 (ORCPT + 99 others); Tue, 28 Nov 2023 12:17:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33572 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229519AbjK1RR1 (ORCPT ); Tue, 28 Nov 2023 12:17:27 -0500 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 88FF610EC; Tue, 28 Nov 2023 09:17:33 -0800 (PST) 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 99F93C15; Tue, 28 Nov 2023 09:18:20 -0800 (PST) Received: from raptor (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 3F3773F6C4; Tue, 28 Nov 2023 09:17:28 -0800 (PST) Date: Tue, 28 Nov 2023 17:17:25 +0000 From: Alexandru Elisei To: David Hildenbrand 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, 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 05/27] mm: page_alloc: Add an arch hook to allow prep_new_page() to fail Message-ID: References: <20231119165721.9849-1-alexandru.elisei@arm.com> <20231119165721.9849-6-alexandru.elisei@arm.com> <0a0f9345-3138-4e89-80cd-c7edaf2ff62d@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <0a0f9345-3138-4e89-80cd-c7edaf2ff62d@redhat.com> X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, 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 morse.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 (morse.vger.email [0.0.0.0]); Tue, 28 Nov 2023 09:17:41 -0800 (PST) Hi, On Tue, Nov 28, 2023 at 05:57:31PM +0100, David Hildenbrand wrote: > On 27.11.23 13:09, Alexandru Elisei wrote: > > Hi, > > > > Thank you so much for your comments, there are genuinely useful. > > > > On Fri, Nov 24, 2023 at 08:35:47PM +0100, David Hildenbrand wrote: > > > On 19.11.23 17:56, Alexandru Elisei wrote: > > > > Introduce arch_prep_new_page(), which will be used by arm64 to reserve tag > > > > storage for an allocated page. Reserving tag storage can fail, for example, > > > > if the tag storage page has a short pin on it, so allow prep_new_page() -> > > > > arch_prep_new_page() to similarly fail. > > > > > > But what are the side-effects of this? How does the calling code recover? > > > > > > E.g., what if we need to populate a page into user space, but that > > > particular page we allocated fails to be prepared? So we inject a signal > > > into that poor process? > > > > When the page fails to be prepared, it is put back to the tail of the > > freelist with __free_one_page(.., FPI_TO_TAIL). If all the allocation paths > > are exhausted and no page has been found for which tag storage has been > > reserved, then that's treated like an OOM situation. > > > > I have been thinking about this, and I think I can simplify the code by > > making tag reservation a best effort approach. The page can be allocated > > even if reserving tag storage fails, but the page is marked as invalid in > > set_pte_at() (PAGE_NONE + an extra bit to tell arm64 that it needs tag > > storage) and next time it is accessed, arm64 will reserve tag storage in > > the fault handling code (the mechanism for that is implemented in patch #19 > > of the series, "mm: mprotect: Introduce PAGE_FAULT_ON_ACCESS for > > mprotect(PROT_MTE)"). > > > > With this new approach, prep_new_page() stays the way it is, and no further > > changes are required for the page allocator, as there are already arch > > callbacks that can be used for that, for example tag_clear_highpage() and > > arch_alloc_page(). The downside is extra page faults, which might impact > > performance. > > > > What do you think? > > That sounds a lot more robust, compared to intermittent failures to allocate > pages. Great, thank you for the feedback, I will use this approach for the next iteration of the series. Thanks, Alex > > -- > Cheers, > > David / dhildenb >