Skip to contentSkip to conversation

xen: cleanup detection of non-essential pv devices

PATCH Applied Juergen Gross 6 participants 16 messages Oct 22, 2021 – Nov 25, 2021

Subsystems (11)
DRM drivers Sound DRM misc HID +7 more subsystems
lore
Share & tools
lore

Juergen Gross

author maintainer
#0 lore raw

cover xen: cleanup detection of non-essential pv devices

Today the non-essential pv devices are hard coded in the xenbus driver and this list is lacking multiple entries.

This series reworks the detection logic of non-essential devices by adding a flag for that purpose to struct xenbus_driver.

Juergen Gross (5):
xen: add "not_essential" flag to struct xenbus_driver
xen: flag xen_drm_front to be not essential for system boot
xen: flag hvc_xen to be not essential for system boot
xen: flag pvcalls-front to be not essential for system boot
xen: flag xen_snd_front to be not essential for system boot

 drivers/gpu/drm/xen/xen_drm_front.c        |  1 +
 drivers/input/misc/xen-kbdfront.c          |  1 +
 drivers/tty/hvc/hvc_xen.c                  |  1 +
 drivers/video/fbdev/xen-fbfront.c          |  1 +
 drivers/xen/pvcalls-front.c                |  1 +
 drivers/xen/xenbus/xenbus_probe_frontend.c | 14 +++-----------
 include/xen/xenbus.h                       |  1 +
 sound/xen/xen_snd_front.c                  |  1 +
 8 files changed, 10 insertions(+), 11 deletions(-)
Signature · 1 line
2.26.2
author maintainer
#1 lore raw

PATCH 1/5 xen: add "not_essential" flag to struct xenbus_driver

When booting the xenbus driver will wait for PV devices to have connected to their backends before continuing. The timeout is different between essential and non-essential devices.

Non-essential devices are identified by their nodenames directly in the xenbus driver, which requires to update this list in case a new device type being non-essential is added (this was missed for several types in the past).

In order to avoid this problem, add a "not_essential" flag to struct xenbus_driver which can be set to "true" by the respective frontend.

Set this flag for the frontends currently regarded to be not essential (vkbs and vfb) and use it for testing in the xenbus driver.

---
 drivers/input/misc/xen-kbdfront.c          |  1 +
 drivers/video/fbdev/xen-fbfront.c          |  1 +
 drivers/xen/xenbus/xenbus_probe_frontend.c | 14 +++-----------
 include/xen/xenbus.h                       |  1 +
 4 files changed, 6 insertions(+), 11 deletions(-)
drivers/input/misc/xen-kbdfront.c +1 -0
index 4ff5cd2a6d8d..3d17a0b3fe51 100644
@@ -542,6 +542,7 @@ static struct xenbus_driver xenkbd_driver = {
 	.remove = xenkbd_remove,
 	.resume = xenkbd_resume,
 	.otherend_changed = xenkbd_backend_changed,
+	.not_essential = true,
 };
 
 static int __init xenkbd_init(void)
drivers/video/fbdev/xen-fbfront.c +1 -0
index 5ec51445bee8..6826f986da43 100644
@@ -695,6 +695,7 @@ static struct xenbus_driver xenfb_driver = {
 	.remove = xenfb_remove,
 	.resume = xenfb_resume,
 	.otherend_changed = xenfb_backend_changed,
+	.not_essential = true,
 };
 
 static int __init xenfb_init(void)
drivers/xen/xenbus/xenbus_probe_frontend.c +3 -11
index 480944606a3c..07b010a68fcf 100644
@@ -211,19 +211,11 @@ static int is_device_connecting(struct device *dev, void *data, bool ignore_none
 	if (drv && (dev->driver != drv))
 		return 0;
 
-	if (ignore_nonessential) {
-		/* With older QEMU, for PVonHVM guests the guest config files
-		 * could contain: vfb = [ 'vnc=1, vnclisten=0.0.0.0']
-		 * which is nonsensical as there is no PV FB (there can be
-		 * a PVKB) running as HVM guest. */
+	xendrv = to_xenbus_driver(dev->driver);
 
-		if ((strncmp(xendev->nodename, "device/vkbd", 11) == 0))
-			return 0;
+	if (ignore_nonessential && xendrv->not_essential)
+		return 0;
 
-		if ((strncmp(xendev->nodename, "device/vfb", 10) == 0))
-			return 0;
-	}
-	xendrv = to_xenbus_driver(dev->driver);
 	return (xendev->state < XenbusStateConnected ||
 		(xendev->state == XenbusStateConnected &&
 		 xendrv->is_ready && !xendrv->is_ready(xendev)));
include/xen/xenbus.h +1 -0
index b94074c82772..b13eb86395e0 100644
@@ -112,6 +112,7 @@ struct xenbus_driver {
 	const char *name;       /* defaults to ids[0].devicetype */
 	const struct xenbus_device_id *ids;
 	bool allow_rebind; /* avoid setting xenstore closed during remove */
+	bool not_essential;     /* is not mandatory for boot progress */
 	int (*probe)(struct xenbus_device *dev,
 		     const struct xenbus_device_id *id);
 	void (*otherend_changed)(struct xenbus_device *dev,
Signature · 1 line
2.26.2
#2 lore raw

Re: [PATCH 1/5] xen: add "not_essential" flag to struct xenbus_driver

Quoted 9 lines · Juergen Gross

When booting the xenbus driver will wait for PV devices to have connected to their backends before continuing. The timeout is different between essential and non-essential devices.

Non-essential devices are identified by their nodenames directly in the xenbus driver, which requires to update this list in case a new device type being non-essential is added (this was missed for several types in the past).

Quoted 7 lines

In order to avoid this problem, add a "not_essential" flag to struct xenbus_driver which can be set to "true" by the respective frontend.

Set this flag for the frontends currently regarded to be not essential (vkbs and vfb) and use it for testing in the xenbus driver.

Wouldn't it be better to annotate essential?  That way, when new misc drivers come along, they don't by default block boot.

~Andrew

author maintainer
#3 lore raw

Re: [PATCH 1/5] xen: add "not_essential" flag to struct xenbus_driver

Quoted 13 lines · Andrew Cooper
Quoted 12 lines · Juergen Gross

When booting the xenbus driver will wait for PV devices to have connected to their backends before continuing. The timeout is different between essential and non-essential devices.

Non-essential devices are identified by their nodenames directly in the xenbus driver, which requires to update this list in case a new device type being non-essential is added (this was missed for several types in the past).

In order to avoid this problem, add a "not_essential" flag to struct xenbus_driver which can be set to "true" by the respective frontend.

Quoted 7 lines
Quoted 4 lines

Set this flag for the frontends currently regarded to be not essential (vkbs and vfb) and use it for testing in the xenbus driver.

Wouldn't it be better to annotate essential?  That way, when new misc drivers come along, they don't by default block boot.

It isn't as if new drivers would "block boot". Normally the short timeout for all drivers of 30 seconds is more than enough for all of them.

I'm a little bit hesitant to have a kind of "white listing" essential drivers, as there might be different views which drivers should have that flag. Doing this the other way round is easier: in case of disagreement such a patch just wouldn't go in, not breaking anything in that case.

Additionally there might be out-of-tree PV drivers, which could be hit by not being flagged to be essential. With the not_essential flag the situation wouldn't change for such a driver.

Juergen

author maintainer
#4 lore raw

PATCH 2/5 xen: flag xen_drm_front to be not essential for system boot

In reply to Juergen Gross

Similar to the virtual frame buffer (vfb) the pv display driver is not essential for booting the system. Set the respective flag.

---
 drivers/gpu/drm/xen/xen_drm_front.c | 1 +
 1 file changed, 1 insertion(+)
drivers/gpu/drm/xen/xen_drm_front.c +1 -0
index 9f14d99c763c..bc7605324db3 100644
@@ -773,6 +773,7 @@ static struct xenbus_driver xen_driver = {
 	.probe = xen_drv_probe,
 	.remove = xen_drv_remove,
 	.otherend_changed = displback_changed,
+	.not_essential = true,
 };
 
 static int __init xen_drv_init(void)
Signature · 1 line
2.26.2
maintainer Reviewed-by on v1 2/5
#5 lore raw

Re: [PATCH 2/5] xen: flag xen_drm_front to be not essential for system boot

Hi, Juergen!

Quoted 4 lines · Juergen Gross

Similar to the virtual frame buffer (vfb) the pv display driver is not essential for booting the system. Set the respective flag.

Quoted 16 lines
---
  drivers/gpu/drm/xen/xen_drm_front.c | 1 +
  1 file changed, 1 insertion(+)
drivers/gpu/drm/xen/xen_drm_front.c +1 -0
index 9f14d99c763c..bc7605324db3 100644
@@ -773,6 +773,7 @@ static struct xenbus_driver xen_driver = {
  	.probe = xen_drv_probe,
  	.remove = xen_drv_remove,
  	.otherend_changed = displback_changed,
+	.not_essential = true,
  };
 
  static int __init xen_drv_init(void)
author maintainer
#6 lore raw

PATCH 3/5 xen: flag hvc_xen to be not essential for system boot

In reply to Juergen Gross

The Xen pv console driver is not essential for boot. Set the respective flag.

---
 drivers/tty/hvc/hvc_xen.c | 1 +
 1 file changed, 1 insertion(+)
drivers/tty/hvc/hvc_xen.c +1 -0
index f0bf01ea069a..71e0dd2c0ce5 100644
@@ -522,6 +522,7 @@ static struct xenbus_driver xencons_driver = {
 	.remove = xencons_remove,
 	.resume = xencons_resume,
 	.otherend_changed = xencons_backend_changed,
+	.not_essential = true,
 };
 #endif /* CONFIG_HVC_XEN_FRONTEND */
 
Signature · 1 line
2.26.2
author maintainer
#7 lore raw

PATCH 4/5 xen: flag pvcalls-front to be not essential for system boot

In reply to Juergen Gross

The Xen pvcalls device is not essential for booting. Set the respective flag.

---
 drivers/xen/pvcalls-front.c | 1 +
 1 file changed, 1 insertion(+)
drivers/xen/pvcalls-front.c +1 -0
index 7984645b5956..3c9ae156b597 100644
@@ -1275,6 +1275,7 @@ static struct xenbus_driver pvcalls_front_driver = {
 	.probe = pvcalls_front_probe,
 	.remove = pvcalls_front_remove,
 	.otherend_changed = pvcalls_front_changed,
+	.not_essential = true,
 };
 
 static int __init pvcalls_frontend_init(void)
Signature · 1 line
2.26.2
author maintainer
#8 lore raw

PATCH 5/5 xen: flag xen_snd_front to be not essential for system boot

In reply to Juergen Gross

The Xen pv sound driver is not essential for booting. Set the respective flag.

---
 sound/xen/xen_snd_front.c | 1 +
 1 file changed, 1 insertion(+)
sound/xen/xen_snd_front.c +1 -0
index 2cb0a19be2b8..7be9fbcf788f 100644
@@ -358,6 +358,7 @@ static struct xenbus_driver xen_driver = {
 	.probe = xen_drv_probe,
 	.remove = xen_drv_remove,
 	.otherend_changed = sndback_changed,
+	.not_essential = true;
 };
 
 static int __init xen_drv_init(void)
Signature · 1 line
2.26.2
maintainer Reviewed-by on v1 5/5
#9 lore raw

Re: [PATCH 5/5] xen: flag xen_snd_front to be not essential for system boot

Hi, Juergen!

Quoted 4 lines · Juergen Gross

The Xen pv sound driver is not essential for booting. Set the respective flag.

Quoted 16 lines
---
  sound/xen/xen_snd_front.c | 1 +
  1 file changed, 1 insertion(+)
sound/xen/xen_snd_front.c +1 -0
index 2cb0a19be2b8..7be9fbcf788f 100644
@@ -358,6 +358,7 @@ static struct xenbus_driver xen_driver = {
  	.probe = xen_drv_probe,
  	.remove = xen_drv_remove,
  	.otherend_changed = sndback_changed,
+	.not_essential = true;
  };
 
  static int __init xen_drv_init(void)
#10 lore raw

Re: [PATCH 5/5] xen: flag xen_snd_front to be not essential for system boot

In reply to Juergen Gross
I love your patch! Yet something to improve:

Hi Juergen,

I love your patch! Yet something to improve:

[auto build test ERROR on xen-tip/linux-next]
[also build test ERROR on tty/tty-testing tiwai-sound/for-next hid/for-next linus/master v5.15 next-20211106] [If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Juergen-Gross/xen-cleanup-detection-of-non-essential-pv-devices/20211022-145043
base:   https://git.kernel.org/pub/scm/linux/kernel/git/xen/tip.git linux-next
config: arm64-randconfig-r005-20211025 (attached as .config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project a461fa64bb37cffd73f683c74f6b0780379fc2ca)

reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# install arm64 cross compiling tool for clang build
# apt-get install binutils-aarch64-linux-gnu
# https://github.com/0day-ci/linux/commit/ed8f15a6cafc5414c3821aad66273c580034c3c0
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Juergen-Gross/xen-cleanup-detection-of-non-essential-pv-devices/20211022-145043 git checkout ed8f15a6cafc5414c3821aad66273c580034c3c0
# save the attached .config to linux build tree
mkdir build_dir
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=arm64 SHELL=/bin/bash sound/xen/

If you fix the issue, kindly add following tag as appropriate

All errors (new ones prefixed by >>):

>> sound/xen/xen_snd_front.c:361:23: error: unexpected ';' before '}'
           .not_essential = true;
                                ^

1 error generated.

vim +361 sound/xen/xen_snd_front.c

355
356 static struct xenbus_driver xen_driver = {
357 .ids = xen_drv_ids,
358 .probe = xen_drv_probe,
359 .remove = xen_drv_remove,
360 .otherend_changed = sndback_changed,

 > 361		.not_essential = true;

362 };
363

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

#11 lore raw
In reply to Juergen Gross
Quoted 5 lines · Juergen Gross

Today the non-essential pv devices are hard coded in the xenbus driver and this list is lacking multiple entries.

This series reworks the detection logic of non-essential devices by adding a flag for that purpose to struct xenbus_driver.

I'm wondering whether it wouldn't better be the other way around: The (hopefully few) essential ones get flagged, thus also making it more prominent during patch review that a flag gets added (and justification provided), instead of having to spot the lack of a flag getting set.

Jan

author maintainer
#12 lore raw
Quoted 11 lines · Jan Beulich
Quoted 5 lines · Juergen Gross

Today the non-essential pv devices are hard coded in the xenbus driver and this list is lacking multiple entries.

This series reworks the detection logic of non-essential devices by adding a flag for that purpose to struct xenbus_driver.

I'm wondering whether it wouldn't better be the other way around: The (hopefully few) essential ones get flagged, thus also making it more prominent during patch review that a flag gets added (and justification provided), instead of having to spot the lack of a flag getting set.

Not flagging a non-essential one is less problematic than not flagging an essential driver IMO.

For some drivers I'm on the edge, BTW. The pv 9pfs driver ought to be non-essential in most cases, but there might be use cases where it is needed, so I didn't set its non_essential flag.

Same applies to pv-usb and maybe pv-scsi, while pv-tpm probably really is essential.

With the current series I'm ending up with 6 non-essential drivers and 6 essential ones, so either way needs the same number of drivers modified.

Juergen

author maintainer
#13 lore raw
In reply to Juergen Gross
Quoted 13 lines · Juergen Gross

Today the non-essential pv devices are hard coded in the xenbus driver and this list is lacking multiple entries.

This series reworks the detection logic of non-essential devices by adding a flag for that purpose to struct xenbus_driver.

Juergen Gross (5):
xen: add "not_essential" flag to struct xenbus_driver
xen: flag xen_drm_front to be not essential for system boot
xen: flag hvc_xen to be not essential for system boot
xen: flag pvcalls-front to be not essential for system boot
xen: flag xen_snd_front to be not essential for system boot

Quoted 10 lines
  drivers/gpu/drm/xen/xen_drm_front.c        |  1 +
  drivers/input/misc/xen-kbdfront.c          |  1 +
  drivers/tty/hvc/hvc_xen.c                  |  1 +
  drivers/video/fbdev/xen-fbfront.c          |  1 +
  drivers/xen/pvcalls-front.c                |  1 +
  drivers/xen/xenbus/xenbus_probe_frontend.c | 14 +++-----------
  include/xen/xenbus.h                       |  1 +
  sound/xen/xen_snd_front.c                  |  1 +
  8 files changed, 10 insertions(+), 11 deletions(-)

Any further comments?

Juergen

Reviewed-by
#14 lore raw
Quoted 25 lines · Juergen Gross
Quoted 21 lines · Juergen Gross

Today the non-essential pv devices are hard coded in the xenbus driver and this list is lacking multiple entries.

This series reworks the detection logic of non-essential devices by adding a flag for that purpose to struct xenbus_driver.

Juergen Gross (5):
   xen: add "not_essential" flag to struct xenbus_driver
   xen: flag xen_drm_front to be not essential for system boot
   xen: flag hvc_xen to be not essential for system boot
   xen: flag pvcalls-front to be not essential for system boot
   xen: flag xen_snd_front to be not essential for system boot

  drivers/gpu/drm/xen/xen_drm_front.c        |  1 + drivers/input/misc/xen-kbdfront.c          |  1 + drivers/tty/hvc/hvc_xen.c                  |  1 + drivers/video/fbdev/xen-fbfront.c          |  1 + drivers/xen/pvcalls-front.c                |  1 + drivers/xen/xenbus/xenbus_probe_frontend.c | 14 +++----------- include/xen/xenbus.h                       |  1 + sound/xen/xen_snd_front.c                  |  1 +

Quoted 2 lines
  8 files changed, 10 insertions(+), 11 deletions(-)
Quoted 2 lines

Any further comments?

(I'll fix the semicolon typo in the last patch, no need to resend)

#15 lore raw
In reply to Juergen Gross
Quoted 14 lines · Juergen Gross
Quoted 13 lines · Juergen Gross

Today the non-essential pv devices are hard coded in the xenbus driver and this list is lacking multiple entries.

This series reworks the detection logic of non-essential devices by adding a flag for that purpose to struct xenbus_driver.

Juergen Gross (5):
   xen: add "not_essential" flag to struct xenbus_driver
   xen: flag xen_drm_front to be not essential for system boot
   xen: flag hvc_xen to be not essential for system boot
   xen: flag pvcalls-front to be not essential for system boot
   xen: flag xen_snd_front to be not essential for system boot

Quoted 11 lines
Quoted 10 lines

  drivers/gpu/drm/xen/xen_drm_front.c        |  1 + drivers/input/misc/xen-kbdfront.c          |  1 + drivers/tty/hvc/hvc_xen.c                  |  1 + drivers/video/fbdev/xen-fbfront.c          |  1 + drivers/xen/pvcalls-front.c                |  1 + drivers/xen/xenbus/xenbus_probe_frontend.c | 14 +++----------- include/xen/xenbus.h                       |  1 + sound/xen/xen_snd_front.c                  |  1 +

  8 files changed, 10 insertions(+), 11 deletions(-)

Applied to for-linus-5.16c

-boris