From: Reinette Chatre <reinette.chatre@intel.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Shuo A Liu <shuo.a.liu@intel.com>
Cc: linux-kernel@vger.kernel.org, x86@kernel.org,
"H . Peter Anvin" <hpa@zytor.com>,
Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
Sean Christopherson <sean.j.christopherson@intel.com>,
Yu Wang <yu1.wang@intel.com>, Zhi Wang <zhi.a.wang@intel.com>,
Zhenyu Wang <zhenyuw@linux.intel.com>
Subject: Re: [PATCH v3 06/17] virt: acrn: Introduce VM management interfaces
Date: Thu, 10 Sep 2020 11:33:30 -0700 [thread overview]
Message-ID: <df5adcb4-152b-f7fc-fae8-8c93eb2b818b@intel.com> (raw)
In-Reply-To: <20200910162810.GB1265411@kroah.com>
Hi Shuo and Greg,
On 9/10/2020 9:28 AM, Greg Kroah-Hartman wrote:
> On Thu, Sep 10, 2020 at 02:19:00PM +0800, Shuo A Liu wrote:
>> On Wed 9.Sep'20 at 11:45:16 +0200, Greg Kroah-Hartman wrote:
>>> On Wed, Sep 09, 2020 at 05:08:25PM +0800, shuo.a.liu@intel.com wrote:
...
>>>> /**
>>>> * struct acrn_vm - Properties of ACRN User VM.
>>>> + * @dev: The struct device this VM belongs to
>>>> + * @list: Entry within global list of all VMs
>>>> * @vmid: User VM ID
>>>> + * @vcpu_num: Number of virtual CPUs in the VM
>>>> + * @flags: Flags (ACRN_VM_FLAG_*) of the VM. This is VM flag management
>>>> + * in HSM which is different from the &acrn_vm_creation.vm_flag.
>>>> */
>>>> struct acrn_vm {
>>>> - u16 vmid;
>>>> + struct device *dev;
>>>> + struct list_head list;
>>>> + u16 vmid;
>>>> + int vcpu_num;
>>>> + unsigned long flags;
>>>> };
>>>>
>>>> +struct acrn_vm *acrn_vm_create(struct acrn_vm *vm,
>>>> + struct acrn_vm_creation *vm_param);
>>>> +int acrn_vm_destroy(struct acrn_vm *vm);
>>>> +
>>>> #endif /* __ACRN_HSM_DRV_H */
>>>> diff --git a/drivers/virt/acrn/hsm.c b/drivers/virt/acrn/hsm.c
>>>> index 28a3052ffa55..bc85a3c14f87 100644
>>>> --- a/drivers/virt/acrn/hsm.c
>>>> +++ b/drivers/virt/acrn/hsm.c
>>>> @@ -19,6 +19,8 @@
>>>>
>>>> #include "acrn_drv.h"
>>>>
>>>> +static struct miscdevice acrn_dev;
>>>> +
>>>> /*
>>>> * When /dev/acrn_hsm is opened, a 'struct acrn_vm' object is created to
>>>> * represent a VM instance and continues to be associated with the opened file
>>>> @@ -34,14 +36,77 @@ static int acrn_dev_open(struct inode *inode, struct file *filp)
>>>> return -ENOMEM;
>>>>
>>>> vm->vmid = ACRN_INVALID_VMID;
>>>> + vm->dev = get_device(acrn_dev.this_device);
>>>
>>> You are grabbing a reference on a static structure?
>>
>> acrn_dev is static, but acrn_dev.this_device is not.
>
> But you don't control that device, the misc device core does.
>
>>>
>>> Ugh, who reviewed this code before it was sent out???
>>
>> This part was just newly added according to your suggestion.. Please
>> refer to
>> https://lore.kernel.org/lkml/1946bf48-fda7-20e0-246d-93414a1a67f5@intel.com/
>
> What you were doing there was wrong, and what you are doing here is just
> odd.
>
> Step back please, and describe exactly what you are trying to do. And
> then explain how grabbing a reference to the device reference count for
> the misc device is going to help solve that issue.
>
From what I understand this current path was entered after Greg's
original suggestion from
https://lore.kernel.org/lkml/20200828102704.GB1470435@kroah.com
to replace the pr_xxx() calls with the more informative dev_xxx() ones.
Perhaps all that is needed to follow the original suggestion is to
replace the pr_xxx() calls with dev_xxx(acrn_dev.this_device, ...) ?
(An example of this is drivers/input/serio/userio.c and some others)
The device (acrn_dev.this_device) can be trusted to exist for the
lifetime of the driver since it is removed on module unload where the
misc device is unregistered.
Reinette
next prev parent reply other threads:[~2020-09-10 18:35 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-09 9:08 [PATCH v3 00/17] HSM driver for ACRN hypervisor shuo.a.liu
2020-09-09 9:08 ` [PATCH v3 01/17] docs: acrn: Introduce ACRN shuo.a.liu
2020-09-09 9:08 ` [PATCH v3 03/17] x86/acrn: Introduce an API to check if a VM is privileged shuo.a.liu
2020-09-09 9:08 ` [PATCH v3 04/17] x86/acrn: Introduce hypercall interfaces shuo.a.liu
2020-09-09 9:08 ` [PATCH v3 06/17] virt: acrn: Introduce VM management interfaces shuo.a.liu
2020-09-09 9:45 ` Greg Kroah-Hartman
2020-09-10 6:19 ` Shuo A Liu
2020-09-10 16:28 ` Greg Kroah-Hartman
2020-09-10 18:33 ` Reinette Chatre [this message]
2020-09-11 2:47 ` Liu, Shuo A
2020-09-09 9:08 ` [PATCH v3 07/17] virt: acrn: Introduce an ioctl to set vCPU registers state shuo.a.liu
2020-09-09 9:08 ` [PATCH v3 09/17] virt: acrn: Introduce I/O request management shuo.a.liu
2020-09-09 9:08 ` [PATCH v3 10/17] virt: acrn: Introduce PCI configuration space PIO accesses combiner shuo.a.liu
2020-09-09 9:08 ` [PATCH v3 12/17] virt: acrn: Introduce interrupt injection interfaces shuo.a.liu
2020-09-09 9:08 ` [PATCH v3 13/17] virt: acrn: Introduce interfaces to query C-states and P-states allowed by hypervisor shuo.a.liu
2020-09-09 9:08 ` [PATCH v3 14/17] virt: acrn: Introduce I/O ranges operation interfaces shuo.a.liu
2020-09-09 9:08 ` [PATCH v3 15/17] virt: acrn: Introduce ioeventfd shuo.a.liu
2020-09-09 9:08 ` [PATCH v3 17/17] virt: acrn: Introduce an interface for Service VM to control vCPU shuo.a.liu
[not found] ` <20200909090836.46762-3-shuo.a.liu@intel.com>
2020-09-09 9:36 ` [PATCH v3 02/17] x86/acrn: Introduce acrn_{setup, remove}_intr_handler() Greg Kroah-Hartman
2020-09-10 6:30 ` Shuo A Liu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=df5adcb4-152b-f7fc-fae8-8c93eb2b818b@intel.com \
--to=reinette.chatre@intel.com \
--cc=bp@alien8.de \
--cc=gregkh@linuxfoundation.org \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=sean.j.christopherson@intel.com \
--cc=shuo.a.liu@intel.com \
--cc=tglx@linutronix.de \
--cc=x86@kernel.org \
--cc=yu1.wang@intel.com \
--cc=zhenyuw@linux.intel.com \
--cc=zhi.a.wang@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®