Skip to contentSkip to conversation

Drivers: hv: vmbus: make bus ids in sysfs persistent

PATCH Superseded Vitaly Kuznetsov 2 participants 8 messages Aug 9, 2016 – Aug 17, 2016 Hyper-V/Azure core and drivers

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover Drivers: hv: vmbus: make bus ids in sysfs persistent

Bus ids for VMBus devices in /sys/bus/vmbus/devices/ are not guaranteed to be persistent across reboot or kernel restart and this causes problems for some tools. E.g. kexec tools use these ids to identify NIC on kdump. Fix the issue by using relid from channel offer as the unique id instead of an auto incremented counter.

Vitaly Kuznetsov (2):
Drivers: hv: make VMBus bus ids persistent
Drivers: hv: get rid of id in struct vmbus_channel

 drivers/hv/channel_mgmt.c | 2 --
 drivers/hv/vmbus_drv.c    | 2 +-
 include/linux/hyperv.h    | 3 ---
 3 files changed, 1 insertion(+), 6 deletions(-)
Signature · 1 line
2.7.4
#1 lore raw

PATCH 1/2 Drivers: hv: make VMBus bus ids persistent

Some tools use bus ids to identify devices and they count on the fact that these ids are persistent across reboot. This may be not true for VMBus as we use auto incremented counter from alloc_channel() as such id. Switch to using child_relid from channel offer, this id is supposed to be persistent.

---
 drivers/hv/vmbus_drv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hv/vmbus_drv.c +1 -1
index e82f7e1..ef42909 100644
@@ -962,7 +962,7 @@ int vmbus_device_register(struct hv_device *child_device_obj)
 	int ret = 0;
 
 	dev_set_name(&child_device_obj->device, "vmbus_%d",
-		     child_device_obj->channel->id);
+		     child_device_obj->channel->offermsg.child_relid);
 
 	child_device_obj->device.bus = &hv_bus;
 	child_device_obj->device.parent = &hv_acpi_dev->dev;
Signature · 1 line
2.7.4
#2 lore raw

PATCH 2/2 Drivers: hv: get rid of id in struct vmbus_channel

In reply to Vitaly Kuznetsov

The auto incremented counter is not being used anymore, get rid of it.

---
 drivers/hv/channel_mgmt.c | 2 --
 include/linux/hyperv.h    | 3 ---
 2 files changed, 5 deletions(-)
drivers/hv/channel_mgmt.c +0 -2
index b6c1211..4b4a41d 100644
@@ -251,14 +251,12 @@ EXPORT_SYMBOL_GPL(vmbus_prep_negotiate_resp);
  */
 static struct vmbus_channel *alloc_channel(void)
 {
-	static atomic_t chan_num = ATOMIC_INIT(0);
 	struct vmbus_channel *channel;
 
 	channel = kzalloc(sizeof(*channel), GFP_ATOMIC);
 	if (!channel)
 		return NULL;
 
-	channel->id = atomic_inc_return(&chan_num);
 	channel->acquire_ring_lock = true;
 	spin_lock_init(&channel->inbound_lock);
 	spin_lock_init(&channel->lock);
include/linux/hyperv.h +0 -3
index b10954a..d9371a7 100644
@@ -701,9 +701,6 @@ struct vmbus_device {
 };
 
 struct vmbus_channel {
-	/* Unique channel id */
-	int id;
-
 	struct list_head listentry;
 
 	struct hv_device *device_obj;
Signature · 1 line
2.7.4
#3 lore raw
In reply to Vitaly Kuznetsov
Quoted 10 lines

-----Original Message-----
From: Vitaly Kuznetsov [mailto:[email protected]]
Sent: Tuesday, August 9, 2016 1:46 AM
To: [email protected]
Cc: [email protected]; Haiyang Zhang <[email protected]>; KY Srinivasan <[email protected]>
Subject: [PATCH 0/2] Drivers: hv: vmbus: make bus ids in sysfs persistent

Quoted 5 lines

Bus ids for VMBus devices in /sys/bus/vmbus/devices/ are not guaranteed to be persistent across reboot or kernel restart and this causes problems for some tools. E.g. kexec tools use these ids to identify NIC on kdump. Fix the issue by using relid from channel offer as the unique id instead of an auto incremented counter.

Relids are not persistent. It is only valid between a channel offer message and a relid released message (or an unload or initiate contact message, which invalidates all channels). This is an opaque number that the root generates and uses to track channels. There is no guarantee that the same type of channel (networking, storage, etc) will get the same relid on each reboot.

Regards,

K. Y

Quoted 12 lines

Vitaly Kuznetsov (2):
Drivers: hv: make VMBus bus ids persistent
Drivers: hv: get rid of id in struct vmbus_channel

 drivers/hv/channel_mgmt.c | 2 --
 drivers/hv/vmbus_drv.c    | 2 +-
 include/linux/hyperv.h    | 3 ---
 3 files changed, 1 insertion(+), 6 deletions(-)

--
2.7.4

#4 lore raw
Quoted 14 lines · KY Srinivasan
Quoted 8 lines

-----Original Message-----
From: Vitaly Kuznetsov [mailto:[email protected]]
Sent: Tuesday, August 9, 2016 1:46 AM
To: [email protected]
Cc: [email protected]; Haiyang Zhang <[email protected]>; KY Srinivasan <[email protected]>
Subject: [PATCH 0/2] Drivers: hv: vmbus: make bus ids in sysfs persistent

Quoted 5 lines

Bus ids for VMBus devices in /sys/bus/vmbus/devices/ are not guaranteed to be persistent across reboot or kernel restart and this causes problems for some tools. E.g. kexec tools use these ids to identify NIC on kdump. Fix the issue by using relid from channel offer as the unique id instead of an auto incremented counter.

Quoted 7 lines

Relids are not persistent. It is only valid between a channel offer message and a relid released message (or an unload or initiate contact message, which invalidates all channels). This is an opaque number that the root generates and uses to track channels. There is no guarantee that the same type of channel (networking, storage, etc) will get the same relid on each reboot.

Thanks for the info,

can we use device_id (offermsg.offer.if_instance.b) instead?

Signature · 1 line
  Vitaly
#5 lore raw
Quoted 36 lines

-----Original Message-----
From: Vitaly Kuznetsov [mailto:[email protected]]
Sent: Thursday, August 11, 2016 2:17 AM
To: KY Srinivasan <[email protected]>
Cc: [email protected]; [email protected]; Haiyang Zhang <[email protected]>
Subject: Re: [PATCH 0/2] Drivers: hv: vmbus: make bus ids in sysfs persistent

Quoted 9 lines · KY Srinivasan
Quoted 9 lines

-----Original Message-----
From: Vitaly Kuznetsov [mailto:[email protected]]
Sent: Tuesday, August 9, 2016 1:46 AM
To: [email protected]
Cc: [email protected]; Haiyang Zhang <[email protected]>; KY Srinivasan <[email protected]>
Subject: [PATCH 0/2] Drivers: hv: vmbus: make bus ids in sysfs persistent

Quoted 3 lines
Quoted 3 lines

Bus ids for VMBus devices in /sys/bus/vmbus/devices/ are not guaranteed to be persistent across reboot or kernel restart and this causes problems for some tools. E.g. kexec tools use these ids to identify

NIC on kdump.

Quoted 10 lines
Quoted 2 lines

Fix the issue by using relid from channel offer as the unique id instead of an auto incremented counter.

Relids are not persistent. It is only valid between a channel offer message and a relid released message (or an unload or initiate contact message, which invalidates all channels). This is an opaque number that the root generates and uses to track channels. There is no guarantee that the same type of channel (networking, storage, etc) will get the same relid on each reboot.

Quoted 3 lines

Thanks for the info,

can we use device_id (offermsg.offer.if_instance.b) instead?

I think you could; I am going to verify and get back to you on this. Sometime back I removed all the non-determinism in the vmbus device ID generation. Now, the current scheme of generating the device IDs does result in persistent IDs across boot (as long as the host presents the devices to the guest in the same order across boots). Do you have this fix?

Regards,

K. Y

Quoted 3 lines

--
Vitaly

#6 lore raw
Quoted 34 lines · KY Srinivasan
Quoted 34 lines

-----Original Message-----
From: Vitaly Kuznetsov [mailto:[email protected]]
Sent: Thursday, August 11, 2016 2:17 AM
To: KY Srinivasan <[email protected]>
Cc: [email protected]; [email protected]; Haiyang Zhang <[email protected]>
Subject: Re: [PATCH 0/2] Drivers: hv: vmbus: make bus ids in sysfs persistent

Quoted 9 lines · KY Srinivasan
Quoted 9 lines

-----Original Message-----
From: Vitaly Kuznetsov [mailto:[email protected]]
Sent: Tuesday, August 9, 2016 1:46 AM
To: [email protected]
Cc: [email protected]; Haiyang Zhang <[email protected]>; KY Srinivasan <[email protected]>
Subject: [PATCH 0/2] Drivers: hv: vmbus: make bus ids in sysfs persistent

Quoted 3 lines
Quoted 3 lines

Bus ids for VMBus devices in /sys/bus/vmbus/devices/ are not guaranteed to be persistent across reboot or kernel restart and this causes problems for some tools. E.g. kexec tools use these ids to identify

NIC on kdump.

Quoted 10 lines
Quoted 2 lines

Fix the issue by using relid from channel offer as the unique id instead of an auto incremented counter.

Relids are not persistent. It is only valid between a channel offer message and a relid released message (or an unload or initiate contact message, which invalidates all channels). This is an opaque number that the root generates and uses to track channels. There is no guarantee that the same type of channel (networking, storage, etc) will get the same relid on each reboot.

Quoted 5 lines
Quoted 3 lines

Thanks for the info,

can we use device_id (offermsg.offer.if_instance.b) instead?

I think you could; I am going to verify and get back to you on this.

Thanks!

Quoted 4 lines

Sometime back I removed all the non-determinism in the vmbus device ID generation. Now, the current scheme of generating the device IDs does result in persistent IDs across boot (as long as the host presents the devices to the guest in the same order across boots). Do you have this fix?

Yes, I think I do. The issue I'm trying to address happens rearly on kdump when we get devices present to us in a different order.

Signature · 1 line
  Vitaly
#7 lore raw
Quoted 47 lines

-----Original Message-----
From: Vitaly Kuznetsov [mailto:[email protected]]
Sent: Monday, August 15, 2016 9:11 AM
To: KY Srinivasan <[email protected]>
Cc: [email protected]; [email protected]; Haiyang Zhang <[email protected]>
Subject: Re: [PATCH 0/2] Drivers: hv: vmbus: make bus ids in sysfs persistent

Quoted 5 lines · KY Srinivasan
Quoted 5 lines

-----Original Message-----
From: Vitaly Kuznetsov [mailto:[email protected]]
Sent: Thursday, August 11, 2016 2:17 AM
To: KY Srinivasan <[email protected]>
Cc: [email protected]; [email protected]; Haiyang

Zhang

Quoted 29 lines
Quoted 29 lines

<[email protected]>
Subject: Re: [PATCH 0/2] Drivers: hv: vmbus: make bus ids in sysfs persistent

Quoted 9 lines · KY Srinivasan
Quoted 9 lines

-----Original Message-----
From: Vitaly Kuznetsov [mailto:[email protected]]
Sent: Tuesday, August 9, 2016 1:46 AM
To: [email protected]
Cc: [email protected]; Haiyang Zhang <[email protected]>; KY Srinivasan <[email protected]>
Subject: [PATCH 0/2] Drivers: hv: vmbus: make bus ids in sysfs persistent

Quoted 3 lines
Quoted 3 lines

Bus ids for VMBus devices in /sys/bus/vmbus/devices/ are not guaranteed to be persistent across reboot or kernel restart and this causes problems for some tools. E.g. kexec tools use these ids to identify

NIC on kdump.

Quoted 10 lines
Quoted 2 lines

Fix the issue by using relid from channel offer as the unique id instead of an auto incremented counter.

Relids are not persistent. It is only valid between a channel offer message and a relid released message (or an unload or initiate contact message, which invalidates all channels). This is an opaque number that the root generates and uses to track channels. There is no guarantee that the same type of channel (networking, storage, etc) will get the same relid on each reboot.

Quoted 7 lines
Quoted 5 lines
Quoted 3 lines

Thanks for the info,

can we use device_id (offermsg.offer.if_instance.b) instead?

I think you could; I am going to verify and get back to you on this.

Thanks!

The instance GUID is guaranteed to be persistent between boots and also across live migration.

K. Y