Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp2331465iob; Thu, 5 May 2022 23:33:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyPH7l/LuvBzbI3D0JkAJfnNxQfaCeiTKlXj/7SR9t7P74r0AYgkqElxfutA4LgFL2t+GB5 X-Received: by 2002:a05:6a00:26c3:b0:50d:d619:e4c6 with SMTP id p3-20020a056a0026c300b0050dd619e4c6mr2086626pfw.13.1651818822029; Thu, 05 May 2022 23:33:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651818822; cv=none; d=google.com; s=arc-20160816; b=DkKFyKT6Urf2g6kj265SJ19YPWQRP7c/wgBc9ErCLUU4mgZUf0/2y1Zk3f1C7NjTWr ejKpBWjgoco2vHv/B6g7f2wOzz3nRM1/pRiLnF8MMdPmNvSPTugKgNrE+kP4Rn7zVaGM W6prE6EihT+CHcKTnKg4hdKZ2n55qtzMYIKFcgglZCJ1l/3NLFa9NtGcPbfrWSaTphEQ 6zfHN7UPXmAS/Jms2hHpXiNkNYeSXmN5Qt7XsZmYp552LJlOZ0YOuHV3KbGixhryHgeI STRnOIxjWhtmE1v+AByPYfRNJqH7IU1iR/rX83X83vz1hwm+G8lO1xuIb7cO3I5qWGuT AdMw== 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-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=RHy2eOf0QrhJ6PESl7vrhO8ZIjox6Rkt2iMYBqTL0QE=; b=M3Pn6vcJAQaiiyrNrI4j9YDopGBMTZ9ErpwxURuEiBnXyf1sQKhe8A9GUqAwMCxeMs JQXHXURROL9x3ennF+K6F+JpTBZ1p4Gbd724jQfOZ5EP0qCk3bEPI+j2iZqJL/MG+4u0 Bf7COqEiLrPn2uaURpIhkHR+rALar4EtOxW9BNIkSuViBvhkbGv3H9CKPQpwLPSF7izG Ufhkklj0F0+Ss95KXSIQn7RU8vn+xBq9SXqm41oup7XIDO5h51gywoEn3i29iKNP6Evv OvrlVAtC1rfo+DuJjd+wFB7EpwPyy1wxn1ZR6LQivOxxKx67XJVHj7Uy67TLRE67O34s nKYQ== 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 h36-20020a63f924000000b003c5f33a6708si3861046pgi.661.2022.05.05.23.33.28; Thu, 05 May 2022 23:33:42 -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 S1376556AbiEDSKd (ORCPT + 99 others); Wed, 4 May 2022 14:10:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55704 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1359530AbiEDSKH (ORCPT ); Wed, 4 May 2022 14:10:07 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AD9AE5A143 for ; Wed, 4 May 2022 10:26:51 -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 4776560A27 for ; Wed, 4 May 2022 17:26:51 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 13756C385A4; Wed, 4 May 2022 17:26:46 +0000 (UTC) Date: Wed, 4 May 2022 18:26:43 +0100 From: Catalin Marinas To: Tong Tiangen Cc: Anshuman Khandual , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Pasha Tatashin , Andrew Morton , Will Deacon , Paul Walmsley , Palmer Dabbelt , Albert Ou , linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-arm-kernel@lists.infradead.org, linux-riscv@lists.infradead.org, Kefeng Wang , Guohanjun Subject: Re: [PATCH -next v6 5/6] arm64/mm: Enable ARCH_SUPPORTS_PAGE_TABLE_CHECK Message-ID: References: <20220426081036.1374452-1-tongtiangen@huawei.com> <20220426081036.1374452-6-tongtiangen@huawei.com> <80f6c347-db5d-8836-bc79-60c7b2a6eed8@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <80f6c347-db5d-8836-bc79-60c7b2a6eed8@huawei.com> X-Spam-Status: No, score=-6.7 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_HI,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 03, 2022 at 09:13:20AM +0800, Tong Tiangen wrote: > 在 2022/4/29 14:18, Anshuman Khandual 写道: > > On 4/26/22 13:40, Tong Tiangen wrote: > > > @@ -884,7 +928,11 @@ static inline pte_t ptep_get_and_clear(struct mm_struct *mm, > > > static inline pmd_t pmdp_huge_get_and_clear(struct mm_struct *mm, > > > unsigned long address, pmd_t *pmdp) > > > { > > > - return pte_pmd(ptep_get_and_clear(mm, address, (pte_t *)pmdp)); > > > + pmd_t pmd = pte_pmd(__pte(xchg_relaxed(&pte_val(*(pte_t *)pmdp), 0))); > > > > Why there is any change here ? Why not just the following instead, like what you did > > in ptep_get_and_clear() above. The page table entry return value here just needs to > > be preserved for subsequent page table check helpers. > > > > pmd_t pmd = pte_pmd(ptep_get_and_clear(mm, address, (pte_t *)pmdp)); > > The purpose of what I do here is to avoid doing page_table_check_pte_clear() > in ptep_get_and_clear(). there is no functional change here. I'm fine with using xchg here but I'd go for pmd_val directly, no need for conversion to pte_t: pmd_t pmd = __pmd(xchg_relaxed(&pmd_val(*pmdp), 0)); -- Catalin