Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp2968039iob; Fri, 6 May 2022 14:41:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz1k8NzM8Yo+VfFyzbI/ia45fZRXW/sHRopNHJvZLL4fZmQdeWY4K2c/C2DYOO5QVqlMNCu X-Received: by 2002:a17:902:7009:b0:158:3bcf:b774 with SMTP id y9-20020a170902700900b001583bcfb774mr5612293plk.103.1651873300319; Fri, 06 May 2022 14:41:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651873300; cv=none; d=google.com; s=arc-20160816; b=Y+q9PqbO2Np5/tgWDAdDt89Fpwzt07pEHQfcRhlUI4CclGb/PxtpAe7WDLI4DnpSiT TgZbcx8lmSYBAX3bRJA+vqBcVTjqD0mb1f/uIAumBrL/kAN40KYgrOGGlQI1MN99lm5V 0TYO0zHFySrptM9phdZYnZBN8dy3yvz+kUsV2Tbgt3/eR4J18WdbroiFACYSQVYfI3A1 gnl4w21fFAZzsVDbnW+POPogf9VqlZkdCTKrkxoBLY8atyZnJN7YM3n/EJCBwbcWeKVr zDFvTMwxx+3s1z55B1l8Cp/kDjfYBKEdgi5BUPTBVgU573MMdduBKO1iPfJnXnCnqncd /Fwg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:subject:user-agent:mime-version:date:message-id; bh=Rl0W7wZQWVgMdWTaJt14f6g1GCb8vXpYWYn7tz+Tigg=; b=PAq6Swrp+TNZZouuhFvHsaY9dNQi1eDwi/+MiGh+ef4PM2saYjafVeHfxS9PSZ0UYM qxIUaZ/jFkYF9Pdwvv3tTX28uD526gdCllU5ThWnpbIuJDBhq+3sElcPowMtSiKpt0kt nuwGgLyTJSEYK+IY0aw/LIAW71UY+RTYJo56ihWH6+rR0PPxGJnhH+NZzGKSrmTwMTYH m7RvslfVQhvn9mhoSJG+xgGiqHvKYJsS4GBId4uCLBAjhuxYA89cuy/a9at/4oxJKmc+ wJBMTrx/KTLc//2F8AqOtYZ30w2+1nStz2BOMDHjcL/8Pih5nXKYCZVPg/GKEJzyrsoY L5Aw== 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t20-20020a170902b21400b00153ce7c9244si3385027plr.97.2022.05.06.14.41.24; Fri, 06 May 2022 14:41:40 -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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245216AbiEEGuh (ORCPT + 99 others); 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 X-Spam-Status: No, score=-6.7 required=5.0 tests=BAYES_00,NICE_REPLY_A, 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 在 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.