Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp4206324rwi; Mon, 17 Oct 2022 03:06:43 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6Ilu/fptKqRGDbb7JHHwFpnj6l+avhvrbF7GXYc+qqO++9avku4tvqhtqDdn89/TEA6o09 X-Received: by 2002:a17:90b:4b8e:b0:20a:f240:9b23 with SMTP id lr14-20020a17090b4b8e00b0020af2409b23mr12944531pjb.19.1666001203458; Mon, 17 Oct 2022 03:06:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666001203; cv=none; d=google.com; s=arc-20160816; b=lNOKPhLl5N2GGTbf0CvNZF3Ixf8mHRwdZ6bFxcul6vkU3HJqwCF/rGPXdMepi4P1XC ToofccX3fYp8BQzL8nalw6W6YP1O5r7P4JJIl2ENbvO9rdGBf7yP/ICCwHtDfJt//BgN iCOctbypGJZ5mUXFYlHJi0DnfiIC+VmWl06wy7XTG9JOAqz4GbsGTixwAHnAzROh1KHA BRJEJkg8Eles9ngGokKy7wQ1eDofotze1bEHOWM730xM0FYqdN7tiS7QVtuOpTIOJ4r8 BGtFNRFGobm/eR6duk88QY7X3zrsP6fhjNCt6egi2yWZc6sijJuh97YG96PKS+YTJQyu o7Cw== 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 :mime-version:user-agent:date:message-id:from:references:cc:to :subject; bh=1zCYrVj6wyCdIj7RcAvvDOPbhP2NpFwXvz99wx0k+zI=; b=Q8KifV8cqbIRcshaSyvp8VRVq2IeTslf4Ecb7Tx8mfRaD+v8Zm8G5cs6PElfnAdGp5 5wQ37SWWVRYLf2ctzrZAVAqv6dYoecSz8nJKro/+8WrgzHI5qrr94Tdljo4Zqp7hesdr Vk0ryEeg0HmRmGyupMuqL/D7h4zLicJRaTLywMnOEiE77Nl7fuAxvPg5GP6AqeiAFL9D UTGz/uZz/4rEE3F/3/n8QehBk3a+/cT5DMANyro039znVcToLza8j4TS6hZUbblledeh cZvRbCDmaozY7uGpLRhq4NRzX2x+PYlCtKyOgFMV9Zo6XV9adyFN5lokQRIDxjLGWJuM xA+A== 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 z12-20020a1709028f8c00b00178a33faa42si10166948plo.66.2022.10.17.03.06.30; Mon, 17 Oct 2022 03:06:43 -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 S231293AbiJQJVg (ORCPT + 99 others); Mon, 17 Oct 2022 05:21:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34068 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231217AbiJQJVO (ORCPT ); Mon, 17 Oct 2022 05:21:14 -0400 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 17F40252B8 for ; Mon, 17 Oct 2022 02:20:50 -0700 (PDT) Received: from dggemv711-chm.china.huawei.com (unknown [172.30.72.57]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4MrWZ23v40z1P7Vh; Mon, 17 Oct 2022 17:15:54 +0800 (CST) Received: from kwepemm600005.china.huawei.com (7.193.23.191) by dggemv711-chm.china.huawei.com (10.1.198.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Mon, 17 Oct 2022 17:20:35 +0800 Received: from [10.67.103.158] (10.67.103.158) by kwepemm600005.china.huawei.com (7.193.23.191) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Mon, 17 Oct 2022 17:20:34 +0800 Subject: Re: [Linuxarm] [PATCH 1/2] hisi_acc_vfio_pci: Add debugfs to migration driver To: John Garry , , , CC: , , References: <20221014025757.39415-1-liulongfang@huawei.com> <20221014025757.39415-2-liulongfang@huawei.com> <42d12308-4777-47a7-a1ae-50dfada050cf@huawei.com> From: liulongfang Message-ID: <7c041671-71bf-d558-d47a-70296fe5c30e@huawei.com> Date: Mon, 17 Oct 2022 17:20:34 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: <42d12308-4777-47a7-a1ae-50dfada050cf@huawei.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-Originating-IP: [10.67.103.158] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To kwepemm600005.china.huawei.com (7.193.23.191) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS 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 2022/10/14 17:20, John Garry wrote: > On 14/10/2022 03:57, Longfang Liu wrote: >> +static void hisi_acc_vf_debugfs_init(struct hisi_acc_vf_core_device *hisi_acc_vdev) >> +{ >> +    struct pci_dev *vf_pdev = hisi_acc_vdev->vf_dev; >> +    struct device *dev = &vf_pdev->dev; >> +    int ret; >> + >> +    if (!atomic_read(&hisi_acc_root_ref)) >> +        hisi_acc_debugfs_root = debugfs_create_dir("hisi_vfio_acc", NULL); >> +    atomic_inc(&hisi_acc_root_ref); >> + > > This looks totally racy, such that I wonder why even bother using an atomic for hisi_acc_root_ref. When enabling VF, it is possible for multiple VMs to enable VF at the same time. The atomic variable is used to ensure that only one "hisi_vfio_acc" is created. When other VFs are enabled, it will not be created again, but will be used directly. Indeed, why is hisi_acc_debugfs_root not created in the driver module init? > Because the normal function of VF is to perform encryption and decryption services, the live migration function is an auxiliary function, which no need to be used in scenarios where only encryption and decryption services are performed. During module init, it can register ops(hisi_acc_vfio_pci_ops) that only perform encryption and decryption services, and can also register with live migration function ops(hisi_acc_vfio_pci_migrn_ops), and this debugfs only needs to register it when the the ops is hisi_acc_vfio_pci_migrn_ops. > Thanks, > John > . >