Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2782035rwd; Fri, 19 May 2023 10:05:16 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4Wqa0BwR80zydEfrvQjUbIjT2/wJt+l9x6FNnyKXu7ga/yssK2PgiR/FByTZkScv59L+3V X-Received: by 2002:a17:90a:3e03:b0:253:6e6f:f5c5 with SMTP id j3-20020a17090a3e0300b002536e6ff5c5mr5725678pjc.7.1684515916335; Fri, 19 May 2023 10:05:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684515916; cv=none; d=google.com; s=arc-20160816; b=CVhDHm+VNGUnDoloGUY68/ngWu27ji7KfZyGN1PGOxoXv2zrmmnJfPcnmpT5UfUW+G bCY+vvNK7s8yKYR9x2SrCAEqwo+fhCp6kmLeKS8vSTpUmed+sK8fN3OSjtjTiGwjrasX Z+wCKH01u6WF8UTJed0uq/wFxle6ku26dBut1YuDVVPuN8pAtFl/QXKA+J6AhEOGamvx LzwIP/1yuCszTDVR98QAxcLtyxRkg8HwmgOVKfyu8MZ1R4Hkk6tI4RjGgejfGAopE0L7 69oHbruS6LU+jutnV/CR4vAArTmeg7HCHmJRMkhFCiTPfRUUArzNA9/nXOhBQHsvgsVA ruPA== 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=xjWr6uAP2eX48tFLD5mVkLGnd5r/LJjSY8IVA9YiNK4=; b=Ilky/itoseXHqDVtZY7qiA6SC30wzPYDWCOzwnih7VBPZ8FUGo/CylPAb63RdSKU4l VukxUiFl2ms2TkYoKnDjSD6a1KT76MrODLTYvkTD1wzahoKN1nypq0MWNhfYE/3Q/HXP aEJ0ZI//h4MEbbkFt6lb7Yml8W869yco7bzkEBHzvaqnn1hbo1D46LM5G6l6Z/QrwQ// LGtTRI6PBaSvKklwlX5WiF1b4zFcbY4N+lROlWbqbJD6q8cRu3shehQyEA1TaTrI0It2 W6Ocx4N8nn7M7g/jSUE/9L3r0ZYNNre1rHsCsSzD587iSfFhB9EOh3nU7OPgT66LPkGB NWtQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x64-20020a638643000000b005004b2acf6dsi2588440pgd.810.2023.05.19.10.04.32; Fri, 19 May 2023 10:05:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231475AbjESQyR (ORCPT + 99 others); Fri, 19 May 2023 12:54:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41702 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231448AbjESQyQ (ORCPT ); Fri, 19 May 2023 12:54:16 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BCDB5114 for ; Fri, 19 May 2023 09:54:15 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 4C6D765961 for ; Fri, 19 May 2023 16:54:15 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DFFBFC433EF; Fri, 19 May 2023 16:54:11 +0000 (UTC) Date: Fri, 19 May 2023 17:54:09 +0100 From: Catalin Marinas To: Peter Collingbourne Cc: Qun-wei Lin =?utf-8?B?KOael+e+pOW0tCk=?= , linux-arm-kernel@lists.infradead.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, "surenb@google.com" , "david@redhat.com" , Chinwen Chang =?utf-8?B?KOW8temMpuaWhyk=?= , "kasan-dev@googlegroups.com" , Kuan-Ying Lee =?utf-8?B?KOadjuWGoOepjik=?= , Casper Li =?utf-8?B?KOadjuS4reamrik=?= , "gregkh@linuxfoundation.org" , vincenzo.frascino@arm.com, Alexandru Elisei , will@kernel.org, eugenis@google.com, Steven Price Subject: Re: [PATCH v3 3/3] arm64: mte: Simplify swap tag restoration logic Message-ID: References: <20230517022115.3033604-1-pcc@google.com> <20230517022115.3033604-4-pcc@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230517022115.3033604-4-pcc@google.com> X-Spam-Status: No, score=-4.0 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, May 16, 2023 at 07:21:13PM -0700, Peter Collingbourne wrote: > As a result of the previous two patches, there are no circumstances > in which a swapped-in page is installed in a page table without first > having arch_swap_restore() called on it. Therefore, we no longer need > the logic in set_pte_at() that restores the tags, so remove it. > > Because we can now rely on the page being locked, we no longer need to > handle the case where a page is having its tags restored by multiple tasks > concurrently, so we can slightly simplify the logic in mte_restore_tags(). [...] > diff --git a/arch/arm64/mm/mteswap.c b/arch/arm64/mm/mteswap.c > index cd508ba80ab1..3a78bf1b1364 100644 > --- a/arch/arm64/mm/mteswap.c > +++ b/arch/arm64/mm/mteswap.c > @@ -53,10 +53,9 @@ void mte_restore_tags(swp_entry_t entry, struct page *page) > if (!tags) > return; > > - if (try_page_mte_tagging(page)) { > - mte_restore_page_tags(page_address(page), tags); > - set_page_mte_tagged(page); > - } > + WARN_ON_ONCE(!try_page_mte_tagging(page)); > + mte_restore_page_tags(page_address(page), tags); > + set_page_mte_tagged(page); > } Can we have a situation where two processes share the same swap pte (CoW) and they both enter the do_swap_page() or the unuse_pte() paths triggering this warning? Other than that, the looks nice, it simplifies the logic and probably saves a few cycles as well on the set_pte_at() path. Reviewed-by: Catalin Marinas