From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 15B0F32CF80; Wed, 10 Sep 2025 16:12:04 +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=1757520726; cv=none; b=pBigdv2zEZ3pkcXAfXKNSpMUgWTek+8x8VNoDOMzzc6WPziikVH7FkO6eostasv1xwOKPXa0nc83GOB2sSjjxKKezB+cs2htTOspLmfcxxSUXTdTQryzUQ9xqo8yvr/aWM3JP83r4aqTKXYkS/A+8m4BVDYDy2ReILxjzMgbpMM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757520726; c=relaxed/simple; bh=cdS8DQ91Fk2KRig7JcdWAE1Tb1sePXx/4ByqYYrByXY=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=O3CkWBJnjuAby8b4h0emDdVjvnxhbkNqQaGu91oaCKNTwS0UyQbUPk4ilWUEz3KDlRfRzeikFL30NR8uQcHqBHCkcV/eO83nNyAiDhOxDH7j2mifxlL5L8y70UZAZ0JBRrvoZL6CBTrvSmWwvmX3WQNLkDP1ulXDs+iDUnrEEUA= 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 B91C716F2; Wed, 10 Sep 2025 09:11:55 -0700 (PDT) Received: from [10.57.67.148] (unknown [10.57.67.148]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 8F3D43F63F; Wed, 10 Sep 2025 09:11:56 -0700 (PDT) Message-ID: <250835cd-f07a-4b8a-bc01-ace24b407efc@arm.com> Date: Wed, 10 Sep 2025 18:11:54 +0200 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2 2/7] mm: introduce local state for lazy_mmu sections To: Alexander Gordeev Cc: David Hildenbrand , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Andreas Larsson , Andrew Morton , Boris Ostrovsky , Borislav Petkov , Catalin Marinas , Christophe Leroy , Dave Hansen , "David S. Miller" , "H. Peter Anvin" , Ingo Molnar , Jann Horn , Juergen Gross , "Liam R. Howlett" , Lorenzo Stoakes , Madhavan Srinivasan , Michael Ellerman , Michal Hocko , Mike Rapoport , Nicholas Piggin , Peter Zijlstra , Ryan Roberts , Suren Baghdasaryan , Thomas Gleixner , Vlastimil Babka , Will Deacon , Yeoreum Yun , linux-arm-kernel@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, sparclinux@vger.kernel.org, xen-devel@lists.xenproject.org, Mark Rutland References: <20250908073931.4159362-1-kevin.brodsky@arm.com> <20250908073931.4159362-3-kevin.brodsky@arm.com> <2fecfae7-1140-4a23-a352-9fd339fcbae5-agordeev@linux.ibm.com> <47ee1df7-1602-4200-af94-475f84ca8d80@arm.com> Content-Language: en-GB From: Kevin Brodsky In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 09/09/2025 16:38, Alexander Gordeev wrote: >>>>> Would that integrate well with LAZY_MMU_DEFAULT etc? >>>> Hmm... I though the idea is to use LAZY_MMU_* by architectures that >>>> want to use it - at least that is how I read the description above. >>>> >>>> It is only kasan_populate|depopulate_vmalloc_pte() in generic code >>>> that do not follow this pattern, and it looks as a problem to me. >> This discussion also made me realise that this is problematic, as the >> LAZY_MMU_{DEFAULT,NESTED} macros were meant only for architectures' >> convenience, not for generic code (where lazy_mmu_state_t should ideally >> be an opaque type as mentioned above). It almost feels like the kasan >> case deserves a different API, because this is not how enter() and >> leave() are meant to be used. This would mean quite a bit of churn >> though, so maybe just introduce another arch-defined value to pass to >> leave() for such a situation - for instance, >> arch_leave_lazy_mmu_mode(LAZY_MMU_FLUSH)? > What about to adjust the semantics of apply_to_page_range() instead? > > It currently assumes any caller is fine with apply_to_pte_range() to > enter the lazy mode. By contrast, kasan_(de)populate_vmalloc_pte() are > not fine at all and must leave the lazy mode. That literally suggests > the original assumption is incorrect. > > We could change int apply_to_pte_range(..., bool create, ...) to e.g. > apply_to_pte_range(..., unsigned int flags, ...) and introduce a flag > that simply skips entering the lazy mmu mode. This is pretty much what Ryan proposed [1r] some time ago, although for a different purpose (avoiding nesting). There wasn't much appetite for it then, but I agree that this would be a more logical way to go about it. - Kevin [1r] https://lore.kernel.org/all/20250530140446.2387131-4-ryan.roberts@arm.com/