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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 23850C433EF for ; Thu, 5 May 2022 06:47:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245222AbiEEGuh (ORCPT ); Thu, 5 May 2022 02:50:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59048 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233151AbiEEGuf (ORCPT ); Thu, 5 May 2022 02:50:35 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E37951FA7C for ; Wed, 4 May 2022 23:46:55 -0700 (PDT) Received: from kwepemi500012.china.huawei.com (unknown [172.30.72.57]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4Kv4310yQ8zfbF5; Thu, 5 May 2022 14:45:49 +0800 (CST) Received: from kwepemm600017.china.huawei.com (7.193.23.234) by kwepemi500012.china.huawei.com (7.221.188.12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Thu, 5 May 2022 14:46:53 +0800 Received: from [10.174.179.234] (10.174.179.234) by kwepemm600017.china.huawei.com (7.193.23.234) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Thu, 5 May 2022 14:46:52 +0800 Message-ID: <3f0439c7-9c25-b83a-58dd-9c3d638b9236@huawei.com> Date: Thu, 5 May 2022 14:46:51 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.8.0 Subject: Re: [PATCH -next v6 5/6] arm64/mm: Enable ARCH_SUPPORTS_PAGE_TABLE_CHECK To: Catalin Marinas CC: Anshuman Khandual , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , , "H. Peter Anvin" , Pasha Tatashin , Andrew Morton , Will Deacon , Paul Walmsley , Palmer Dabbelt , Albert Ou , , , , , Kefeng Wang , Guohanjun References: <20220426081036.1374452-1-tongtiangen@huawei.com> <20220426081036.1374452-6-tongtiangen@huawei.com> <80f6c347-db5d-8836-bc79-60c7b2a6eed8@huawei.com> From: Tong Tiangen In-Reply-To: Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 8bit X-Originating-IP: [10.174.179.234] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To kwepemm600017.china.huawei.com (7.193.23.234) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 在 2022/5/5 1:26, Catalin Marinas 写道: > 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)); > OK, This implementation is good and avoids redundant conversion, will fix it next version. Thanks, Tong.