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 05D20EB64DD for ; Thu, 13 Jul 2023 12:17:46 +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-Type: Content-Transfer-Encoding:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id: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=eJ7Y/z0jx+M8ZZcfxYvadVtdYcNt/WHbWibOSqpm1n4=; b=iCbAQNIX5GDzaL xZRtRXZfrMwSMrDZKYGttru+kHgFXi37N/mM9Fj5dRBUhHxDBl5ulNOntP70jBYZryg/2zNU3Q5UB r6kjKqwGsXLeVC6gvV6ZWF9WD8aGHt58LP4muYsp4oJCKF4HczEAOTADdij7gLmCGqhOR3vffwmL0 FsKaT8baXstiTq4cBYv4f2dN9w8o2P8KtXMIR5pW+5SMgn1duAir6S++Ykqz3iI82NzGZfZkuIpzz Q1RR+nQ5JRwtBJswBhi7ekoRMmCM4nhL1C8RgmkRImVLol4Vp2HMIBt7c1gym//ieeWhhBWOy/sBw m7ZKGnpCOBxgksiUOt2w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qJvFy-003CxQ-1a; Thu, 13 Jul 2023 12:17:14 +0000 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qJvFw-003Cwt-0O for linux-arm-kernel@lists.infradead.org; Thu, 13 Jul 2023 12:17:13 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1689250630; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=O/8LqiC6QlUvXSN10idrMxAvpQIqE3LX2fGViAlsLns=; b=Mky+qUpiCatOwXPoTxJTV+vpWXSprlcer5EJvbwjptkw3tyd4V45Opt84YLNLIxHGUut8Y DKYCtBv5H5qTwkJbYuCX5ddoW09rL6gADro08PTrzL1f+oCpOsZIfs0VELeelaKqLTY+UE 0R7UujGyTGn375pS4itqPqA+A38pQZU= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-266-ynnxu0PTOcOdnbtOML6S7g-1; Thu, 13 Jul 2023 08:17:09 -0400 X-MC-Unique: ynnxu0PTOcOdnbtOML6S7g-1 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-3fbe356b8deso3553995e9.0 for ; Thu, 13 Jul 2023 05:17:09 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689250628; x=1691842628; h=content-transfer-encoding:in-reply-to:organization:from:references :cc:to:content-language:subject:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=O/8LqiC6QlUvXSN10idrMxAvpQIqE3LX2fGViAlsLns=; b=ZEgQ3kP/hk77QQntOhN4uFKy1LbWHyvV8rOubBxM+2HWl3R2c0TyrD9CPxJ6upxC6c Hd+OP0L1Nt0pZ7x1MWktQqQAA1IrqKNAKZDHGunkNq+8lo9tnjMqgAac2ULgQE2c4wm6 Vv8pAeb6uXroLkZOMa1WmqOoFB1AhvW88PXXP8mtZKG/PzTGUy9lHxitcYJnCmb96l60 5qNBkj6F85w/KKELySpn/HSlLH4vOdhjBohiWB6HWRzpiybkH7lpOLB5qhlm4hjaLO4k QpEwXGjLa4PkiSaXCkPfYcy7BnCaaHhMZMZvr54Lhqj5BkeUWlfYJgRxdiBA0qXVUf03 xr2g== X-Gm-Message-State: ABy/qLZk8aAYVnmwbKBesLJj/LmZKSiC8CP0Pv9b0Wx/qMCNZwCNOTR6 dEi/hIe0VVnkmbclypVEo/8CIKoHI4YDmxKZQFEdLv57EvZHNQW+NZZennEcrirqsIwByF7ipIs oPDnz0AzYvQHeVqQ2SNToBlA5mSMiJD0Ssn8= X-Received: by 2002:a1c:7414:0:b0:3fb:ba04:6d5d with SMTP id p20-20020a1c7414000000b003fbba046d5dmr1255204wmc.12.1689250628190; Thu, 13 Jul 2023 05:17:08 -0700 (PDT) X-Google-Smtp-Source: APBJJlEpx3LU8EUsWQF1DZWtF+CPMES9CCsA5X6eHyVTsaP8JeTZuKPHy0iS78dQFv5unRikPNa1Ug== X-Received: by 2002:a1c:7414:0:b0:3fb:ba04:6d5d with SMTP id p20-20020a1c7414000000b003fbba046d5dmr1255182wmc.12.1689250627780; Thu, 13 Jul 2023 05:17:07 -0700 (PDT) Received: from ?IPV6:2003:cb:c717:6100:2da7:427e:49a5:e07? (p200300cbc71761002da7427e49a50e07.dip0.t-ipconnect.de. [2003:cb:c717:6100:2da7:427e:49a5:e07]) by smtp.gmail.com with ESMTPSA id l4-20020a1ced04000000b003fbe561f6a3sm18254150wmh.37.2023.07.13.05.17.06 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 13 Jul 2023 05:17:07 -0700 (PDT) Message-ID: <24920ffd-1afa-e791-f8ae-c2eb801afd34@redhat.com> Date: Thu, 13 Jul 2023 14:17:06 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.12.0 Subject: Re: [PATCH] arm64/mm: Set only the PTE_DIRTY bit while preserving the HW dirty state To: Anshuman Khandual , linux-arm-kernel@lists.infradead.org Cc: Catalin Marinas , Will Deacon , Mark Rutland , linux-kernel@vger.kernel.org References: <20230713071518.628440-1-anshuman.khandual@arm.com> From: David Hildenbrand Organization: Red Hat In-Reply-To: <20230713071518.628440-1-anshuman.khandual@arm.com> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230713_051712_230440_AC619A53 X-CRM114-Status: GOOD ( 19.35 ) 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-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 13.07.23 09:15, Anshuman Khandual wrote: > pte_mkdirty() creates dirty states both in SW and HW bits, which is really > not required, either in pte_wrprotect() or pte_modify() for preserving the > HW dirty state. Because pte_mkdirty() sets PTE_DIRTY and clears PTE_RDONLY > as pte_write() always evaluates to be true - otherwise pte_hw_dirty() will > not test out in the first place. Clearing PTE_RDONLY again is not required > here because the pte is already in pte_hw_dirty() but might soon loose its > dirty state thus requiring preservation in SW dirty bit i.e PTE_DIRTY. > > Cc: Catalin Marinas > Cc: Will Deacon > Cc: Mark Rutland > Cc: linux-arm-kernel@lists.infradead.org > Cc: linux-kernel@vger.kernel.org > Signed-off-by: Anshuman Khandual > --- > This applies on v6.5-rc1 > > arch/arm64/include/asm/pgtable.h | 5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) > > diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h > index 0bd18de9fd97..171d6d7f8087 100644 > --- a/arch/arm64/include/asm/pgtable.h > +++ b/arch/arm64/include/asm/pgtable.h > @@ -212,7 +212,7 @@ static inline pte_t pte_wrprotect(pte_t pte) > * clear), set the PTE_DIRTY bit. > */ > if (pte_hw_dirty(pte)) > - pte = pte_mkdirty(pte); > + pte = set_pte_bit(pte, __pgprot(PTE_DIRTY)); > > pte = clear_pte_bit(pte, __pgprot(PTE_WRITE)); > pte = set_pte_bit(pte, __pgprot(PTE_RDONLY)); > @@ -823,7 +823,8 @@ static inline pte_t pte_modify(pte_t pte, pgprot_t newprot) > PTE_ATTRINDX_MASK; > /* preserve the hardware dirty information */ > if (pte_hw_dirty(pte)) > - pte = pte_mkdirty(pte); > + pte = set_pte_bit(pte, __pgprot(PTE_DIRTY)); > + > pte_val(pte) = (pte_val(pte) & ~mask) | (pgprot_val(newprot) & mask); > return pte; > } Reviewed-by: David Hildenbrand -- Cheers, David / dhildenb _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel