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 7D6C9C4345F for ; Fri, 26 Apr 2024 14:48:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=nCI5pBcjfbwg2cealgtarJgLjrLStIYa2u7FyqEdH34=; b=BsfSvGZ6e3a963 iJdObWzvSU2QvbEqBmqEjfBkXwzaboJr8w7C0ur3TxYktA3hyq+1VLPKnFrgzrI1R2XVm6/4/8cFM bIr3SakpSWFfFoN1ByI0vFSwDIGwjryrK8zB1DN8dWAzapwZJlnEOaZfZ2KC3LGPt8YHGCH+htfUy S1/J7VpzIGEGbVbcL0TrDDo0BgDbeQ/5336eGoOFlT2rSYFHrhwHMVmCGD2EC5Pkhvc4LQzQytQAn BMhuyjATGRHlyqgCPaaja5O1FXvIMsiuyJ3U+HhHNrXGhEAcDeQ/t22c1wAZgcxfs3sEjlphJ/sP5 9ONTgpY0aiSu9rLYhO2g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s0MsD-0000000CtqZ-2ATF; Fri, 26 Apr 2024 14:48:25 +0000 Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1s0MsA-0000000Ctq5-0bIo for linux-arm-kernel@lists.infradead.org; Fri, 26 Apr 2024 14:48:23 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id CA9B462089; Fri, 26 Apr 2024 14:48:20 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 32607C113CD; Fri, 26 Apr 2024 14:48:18 +0000 (UTC) Date: Fri, 26 Apr 2024 15:48:15 +0100 From: Catalin Marinas To: Ryan Roberts Cc: David Hildenbrand , Will Deacon , Joey Gouly , Ard Biesheuvel , Mark Rutland , Anshuman Khandual , Peter Xu , Mike Rapoport , Shivansh Vij , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v1 1/2] arm64/mm: Move PTE_PROT_NONE and PMD_PRESENT_INVALID Message-ID: References: <20240424111017.3160195-1-ryan.roberts@arm.com> <20240424111017.3160195-2-ryan.roberts@arm.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240426_074822_318170_A6833C02 X-CRM114-Status: GOOD ( 19.39 ) 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: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Thu, Apr 25, 2024 at 11:37:42AM +0100, Ryan Roberts wrote: > Also, IMHO we shouldn't really need to reserve PMD_PRESENT_INVALID for swap > ptes; it would be cleaner to have one bit that defines "present" when valid is > clear (similar to PTE_PROT_NONE today) then another bit which is only defined > when "present && !valid" which tells us if this is PTE_PROT_NONE or > PMD_PRESENT_INVALID (I don't think you can ever have both at the same time?). I think this make sense, maybe rename the above to PTE_PRESENT_INVALID and use it for both ptes and pmds. > But there is a problem with this: __split_huge_pmd_locked() calls > pmdp_invalidate() for a pmd before it determines that it is pmd_present(). So > the PMD_PRESENT_INVALID can be set in a swap pte today. That feels wrong to me, > but was trying to avoid the whole thing unravelling so didn't persue. Maybe what's wrong is the arm64 implementation setting this bit on a swap/migration pmd (though we could handle this in the core code as well, it depends what the other architectures do). The only check for the PMD_PRESENT_INVALID bit is in the arm64 code and it can be absorbed into the pmd_present() check. I think it is currently broken as pmd_present() can return true for a swap pmd after pmd_mkinvalid(). So I don't think we lose anything if pmd_mkinvalid() skips any bit setting when !PTE_VALID. Maybe it even fixes some corner case we never hit yet (like pmd_present() on a swap/migration+invalid pmd). -- Catalin _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel