From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 681C5CD4F54 for ; Wed, 20 May 2026 08:41:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: Content-Type:In-Reply-To:From:References:Cc:To:Subject:MIME-Version:Date: Message-ID:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=mwkmkiBD9C6AzEumXzl36+9Ya4pNjd8VrP4O4E2jgTk=; b=v59/R30MuZyGZKFSKoy3Vhg1Au XER2tbk58Jc5ZMraGpS3qAPfDYltAg5iwanbe6ECBLi4N8ktj+tnMOm4+cxTtQFgN+42jJVzRdiRL Qom0kJqavrrWCiIlwN60REagxOiACzyqBOkG5HTevBNJTRlHHDUKMRa39Bff42UXm88luGdFoPHuT M/coZarNGEwIDbaoVoPF3S2FsheOlI++1cntVJ0oQ4famZDgHd/ecn0Kvk0Dxg9J7oZ34AOp/alEi G6Wvezno9V5PcbrPeQ/g1NywkUOmDkQAIez+BkO9IMFFzg7IaUnR08oeEJ2IbVYwqbBwABpyIfhms VRLZf67g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.99.1 #2 (Red Hat Linux)) id 1wPcUa-00000003zGV-1k3e; Wed, 20 May 2026 08:41:28 +0000 Received: from sea.source.kernel.org ([172.234.252.31]) by bombadil.infradead.org with esmtps (Exim 4.99.1 #2 (Red Hat Linux)) id 1wPcUY-00000003zFo-28IQ for linux-arm-kernel@lists.infradead.org; Wed, 20 May 2026 08:41:27 +0000 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by sea.source.kernel.org (Postfix) with ESMTP id BD4AC439DF; Wed, 20 May 2026 08:41:25 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6C9B61F000E9; Wed, 20 May 2026 08:41:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1779266485; bh=mwkmkiBD9C6AzEumXzl36+9Ya4pNjd8VrP4O4E2jgTk=; h=Date:Subject:To:Cc:References:From:In-Reply-To; b=kBH6DuUG4C6QpVo6IiVACT2i/nABs96Pm8EXIE6G5MoFBJNZBOvGKp/Oyu0Amgxpm AQZtxq8C8ev68/W96+ygmw+2NDWB6NV9S6FV1uhN+HTSDW161E+4qVogmxpHzTKSRO HunFITy+sQ4iu+TxSc86dzLqFmxjKGjICt/Pk0DfFWHyOxoHRGtTrKUfu4YEMUbgOa mpUaH5il65pXDbUqBpzkNREI7z5e4dbX9HyRRk/Wt+c8N55wOzfUHiWP0hlERF3ti9 m+T/rb5IILdceVqvDTmErOeSitmqtJw+UdpA5GiLt/I7CpujzjBUxY8ADuObrsSRN+ pmxZvHMr2boZQ== Message-ID: Date: Wed, 20 May 2026 10:41:15 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 1/8] mm: Add ptep_try_install() for lockless empty-slot installs To: Alexei Starovoitov , Tejun Heo Cc: David Vernet , Andrea Righi , Changwoo Min , Alexei Starovoitov , Andrii Nakryiko , Daniel Borkmann , Martin KaFai Lau , Kumar Kartikeya Dwivedi , Catalin Marinas , Will Deacon , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , Andrew Morton , Mike Rapoport , Emil Tsalapatis , sched-ext@lists.linux.dev, bpf , X86 ML , linux-arm-kernel , linux-mm , LKML References: <20260517211232.1670594-1-tj@kernel.org> <20260517211232.1670594-2-tj@kernel.org> <9ba50fd2-077e-4291-9276-9adb18186873@kernel.org> <2f02d90d-cdc9-48ef-abe3-99e00f22595f@kernel.org> <297658c4ae2d6e7103f5968efc936224@kernel.org> <04b03066-86d3-4c0b-b077-307fd0f3bc9c@kernel.org> <5590fd3d-dae1-4070-b52f-bc40982ac678@kernel.org> From: "David Hildenbrand (Arm)" Content-Language: en-US Autocrypt: addr=david@kernel.org; keydata= xsFNBFXLn5EBEAC+zYvAFJxCBY9Tr1xZgcESmxVNI/0ffzE/ZQOiHJl6mGkmA1R7/uUpiCjJ dBrn+lhhOYjjNefFQou6478faXE6o2AhmebqT4KiQoUQFV4R7y1KMEKoSyy8hQaK1umALTdL QZLQMzNE74ap+GDK0wnacPQFpcG1AE9RMq3aeErY5tujekBS32jfC/7AnH7I0v1v1TbbK3Gp XNeiN4QroO+5qaSr0ID2sz5jtBLRb15RMre27E1ImpaIv2Jw8NJgW0k/D1RyKCwaTsgRdwuK Kx/Y91XuSBdz0uOyU/S8kM1+ag0wvsGlpBVxRR/xw/E8M7TEwuCZQArqqTCmkG6HGcXFT0V9 PXFNNgV5jXMQRwU0O/ztJIQqsE5LsUomE//bLwzj9IVsaQpKDqW6TAPjcdBDPLHvriq7kGjt WhVhdl0qEYB8lkBEU7V2Yb+SYhmhpDrti9Fq1EsmhiHSkxJcGREoMK/63r9WLZYI3+4W2rAc UucZa4OT27U5ZISjNg3Ev0rxU5UH2/pT4wJCfxwocmqaRr6UYmrtZmND89X0KigoFD/XSeVv jwBRNjPAubK9/k5NoRrYqztM9W6sJqrH8+UWZ1Idd/DdmogJh0gNC0+N42Za9yBRURfIdKSb B3JfpUqcWwE7vUaYrHG1nw54pLUoPG6sAA7Mehl3nd4pZUALHwARAQABzS5EYXZpZCBIaWxk ZW5icmFuZCAoQ3VycmVudCkgPGRhdmlkQGtlcm5lbC5vcmc+wsGQBBMBCAA6AhsDBQkmWAik AgsJBBUKCQ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oqE2Dzh3FvYHVeX4Us+bRL/oqareJ CIFqgYMyvHj7Q06kTKmauOe4Nf0l0qEkIuIzfoLJ3qr5UyXc2hLtWyT9Ir+lYlX9efqh7mOY qIws/H2t In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20260520_014126_595193_F8D4E9CA X-CRM114-Status: GOOD ( 21.56 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 5/19/26 21:04, Alexei Starovoitov wrote: > On Tue, May 19, 2026 at 10:11 AM Tejun Heo wrote: >> >> On Tue, May 19, 2026 at 11:40:48AM +0200, David Hildenbrand (Arm) wrote: >> ... >> >> Wouldn't it still be either or with both cases being okay? >> >>> >>> ... or can we run into similar problems with kprobes? (I am obviously no bpf >>> expert ...) >> >> Yeah, I mean, that was just the first TP I found scanning the code. Any >> kprobes or other TPs in the path would behave the same. >> >> When this fault triggers, the BPF program has already malfunctioned, so it's >> not going to be a high frequency path and performance isn't a primary >> consideration. So, anything that can ensure that the kernel doesn't crash or >> lock up would be fine. Any better ideas? > > As you guys already figured out the trylock is not an option. And that should be carefully documented. > The fault handler has to install _some_ page and let kernel continue. > Scratch page or arena page doesn't matter. Potentially different CPUs > will see different page. It's not a concern at all. > bpf prog is buggy, but the kernel will continue to work without a glitch. > bpf runtime will disable and unload misbehaving prog. Having one page table walker overwrite a scratch page on race is just rather ... questionable locking design, that just screams for problems long-term, really. At least in apply_range_clear_cb() one could similarly switch to ptep_try_install() to at least have both these paths handle races in a reasonable way. (having to handle when ptep_try_install() is not really implemented) Anyhow, the documentation of ptep_try_install() must clearly spell out that this must be used very carefully, and only in special kernel page tables, never user page tables. There are likely other scenarios we should document (caller must prevent concurrent page table teardown somehow, and must be prepared to handle races if other code is not using atomics). To highlight that, we should likely consider adding a "kernel" in the name, like "ptep_try_install_kernel()". I am also not sure if "install" is the right terminology and whether it should instead be "ptep_try_set()". (set_pte_at is the non-atomic interface right now) Further note that last time I talked to Linus about arch helpers, he preferred #define ptep_try_install ptep_try_install over __HAVE_ARCH_PTEP_TRY_INSTALL -- Cheers, David