Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp2986050rdh; Mon, 27 Nov 2023 04:10:33 -0800 (PST) X-Google-Smtp-Source: AGHT+IEteuXsPG3kq1dG6NisvzW5cNTP30qVxfDmkuy8lTS88tIMNtNNC+hQ4ioD9tRmHdk+X8oW X-Received: by 2002:a17:90b:224b:b0:27d:880d:8645 with SMTP id hk11-20020a17090b224b00b0027d880d8645mr11635748pjb.49.1701087033257; Mon, 27 Nov 2023 04:10:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701087033; cv=none; d=google.com; s=arc-20160816; b=OsM5v0YKIzXQBcDcPWqyGurlY/rym5XV73PUCBzOHYIuJnckE+f0DyjDWp+YsdnPRz 6MV21n17XR8NRHxEKwYas1ayPV2B0PBGo+WaFcZgzjFM6F9QnGDdaBZTlETC26yg2W9N 6nAOFqiFZSmGbxZGQAV1MQZM6/FVAtaARJQPiiyR2oyBp3QNddGXyK1Gb9D7xr7BkhC2 YU9fYUkl/EWxGOAoXG8RcJJ0k9+zLLz1+5csi8hJKJspXlYnMSK3iUkOQ8ZZk4fWZduP B2OsgOrgNcUg27kh14Ey3JjLhxRhpvJbgJA+quZH7pn4+vwMp5N5KOy8uDtaBGpjRuNu s8pQ== 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=uMJfzns+BF9eVaeItcjIQhGqCjfByysMspdawX7auak=; fh=oVyZPWtm6mpH3d4qDAoXsAeagaN2dloHFHPyagpC8cc=; b=WBNykSXqITovQUU/UrMawe1TEqVS+DXjkCm7nAy2cHMj1m5ARHYzTEXADEQ0ZVQoCo paFR28c6SzrM9/yzsHjS284sjtAFDJqz8MwrMnerPFpuP6o+T2l48b2lW5D/Dzy5H3ih Ryua7AzFm4plgs+ywkOZb07B7TeADskxIsO/4GfFS8u3xRW4iQXkch5hmeckX08V3nwZ QgFkS93KWIOP+f4zdBp8ov2GqTP4/Q1dTv+2Ri2caB4Y63N6FHeGP8Acy3psfF8dqe4Q bq2lboTrNw3ItZ1DDOKgkE/8dHlhhn9EQRZjIxvVu1R6c+vlEqxaGl8X2FU7kQtpwONg JgKA== 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 w18-20020a17090aea1200b0027769032e57si10144174pjy.52.2023.11.27.04.10.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Nov 2023 04:10:33 -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 B58CE8023197; Mon, 27 Nov 2023 04:10:30 -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 S233155AbjK0MKE (ORCPT + 99 others); Mon, 27 Nov 2023 07:10:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47044 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233109AbjK0MKB (ORCPT ); Mon, 27 Nov 2023 07:10:01 -0500 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 7AF2BEA; Mon, 27 Nov 2023 04:10:07 -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 BA2DA2F4; Mon, 27 Nov 2023 04:10:54 -0800 (PST) Received: from raptor (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 39E373F73F; Mon, 27 Nov 2023 04:10:02 -0800 (PST) Date: Mon, 27 Nov 2023 12:09:59 +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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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]); Mon, 27 Nov 2023 04:10:30 -0800 (PST) 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? Thanks, Alex > > -- > Cheers, > > David / dhildenb >