debuggers.hg

changeset 21893:4814e16ea410

tools/xend: Fix performance of xend with more than 10000 FC device paths

On server startup xend start or a later xend restart needs approx. 30 min to
start/restart. Without attached FC devices xend start/restart needs only some
seconds.

server type: Fujitsu Primergy RX600-S5

The time gets lost in xen/xend/XendNode.py line 329 while calling
vscsi_util.get_all_scsi_device().

329 for pscsi_record in vscsi_util.get_all_scsi_devices():
330 scsi_id = pscsi_record['scsi_id']
331 if scsi_id:
332 saved_HBA_uuid = None

I think, in most cases we don't need all the PSCSI devices registered in
xend, but only a few of it.
So a good solution for this perforamce issue is to scan only the SCSI device
paths we need, controlled by a new option in xend-config.sxp.

I have made a patch to allow specification of scsi devices we need in xend
in the config file xend-config.sxp.
The new options pscsi-device-mask expects a list of device ids oder partial
device ids like the option of lsscsi, e.g.
(pscsi-device-mask ('<partial-dev-id1' 'partial-dev-id2' ...))

Without this option set in xend-config.sxp or if lsscsi is not support, all
device paths are process like today.

Signed-off-by: Lutz Dube Lutz.Dube@ts.fujitsu.com
Comment from Masaki Kanno <kanno.masaki@jp.fujitsu.com>: "Well done"
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
author "Dube, Lutz" <lutz.dube@ts.fujitsu.com>
date Fri Jul 23 17:34:35 2010 +0100 (2010-07-23)
parents e23302fcb83c
children 267ddd7fa11f
files tools/examples/xend-config.sxp tools/python/xen/util/vscsi_util.py tools/python/xen/xend/XendNode.py tools/python/xen/xend/XendOptions.py
line diff
     1.1 --- a/tools/examples/xend-config.sxp	Fri Jul 23 17:26:28 2010 +0100
     1.2 +++ b/tools/examples/xend-config.sxp	Fri Jul 23 17:34:35 2010 +0100
     1.3 @@ -294,3 +294,11 @@
     1.4  # we have to realize this may incur security issue and we can't make sure the
     1.5  # device assignment could really work properly even after we do this.
     1.6  #(pci-passthrough-strict-check yes)
     1.7 +
     1.8 +# If we have a very big scsi device configuration, start of xend is slow,
     1.9 +# because xend scans all the device paths to build its internal PSCSI device
    1.10 +# list.  If we need only a few devices for assigning to a guest, we can reduce
    1.11 +# the scan to this device. Set list list of device paths in same syntax like in
    1.12 +# command lsscsi, e.g. ('16:0:0:0' '15:0') 
    1.13 +# (pscsi-device-mask ('*'))
    1.14 +
     2.1 --- a/tools/python/xen/util/vscsi_util.py	Fri Jul 23 17:26:28 2010 +0100
     2.2 +++ b/tools/python/xen/util/vscsi_util.py	Fri Jul 23 17:34:35 2010 +0100
     2.3 @@ -148,11 +148,12 @@ def _vscsi_get_scsidevices_by_sysfs():
     2.4      return devices
     2.5  
     2.6  
     2.7 -def vscsi_get_scsidevices():
     2.8 +def vscsi_get_scsidevices(mask=""):
     2.9      """ get all scsi devices information """
    2.10  
    2.11 -    devices = _vscsi_get_scsidevices_by_lsscsi("")
    2.12 -    if devices:
    2.13 +    devices = _vscsi_get_scsidevices_by_lsscsi("[%s]" % mask)
    2.14 +    if devices or (len(mask) and mask[0] != "*"):
    2.15 +        # devices found or partial device scan
    2.16          return devices
    2.17      return _vscsi_get_scsidevices_by_sysfs()
    2.18  
    2.19 @@ -274,9 +275,9 @@ def get_scsi_device(pHCTL):
    2.20              return _make_scsi_record(scsi_info)
    2.21      return None
    2.22  
    2.23 -def get_all_scsi_devices():
    2.24 +def get_all_scsi_devices(mask=""):
    2.25      scsi_records = []
    2.26 -    for scsi_info in vscsi_get_scsidevices():
    2.27 +    for scsi_info in vscsi_get_scsidevices(mask):
    2.28          scsi_record = _make_scsi_record(scsi_info)
    2.29          scsi_records.append(scsi_record)
    2.30      return scsi_records
     3.1 --- a/tools/python/xen/xend/XendNode.py	Fri Jul 23 17:26:28 2010 +0100
     3.2 +++ b/tools/python/xen/xend/XendNode.py	Fri Jul 23 17:34:35 2010 +0100
     3.3 @@ -326,7 +326,12 @@ class XendNode:
     3.4          pscsi_table = {}
     3.5          pscsi_HBA_table = {}
     3.6  
     3.7 -        for pscsi_record in vscsi_util.get_all_scsi_devices():
     3.8 +        pscsi_records = []
     3.9 +        for pscsi_mask in xendoptions().get_pscsi_device_mask():
    3.10 +            pscsi_records += vscsi_util.get_all_scsi_devices(pscsi_mask)
    3.11 +        log.debug("pscsi record count: %s" % len(pscsi_records))
    3.12 +
    3.13 +        for pscsi_record in pscsi_records:
    3.14              scsi_id = pscsi_record['scsi_id']
    3.15              if scsi_id:
    3.16                  saved_HBA_uuid = None
     4.1 --- a/tools/python/xen/xend/XendOptions.py	Fri Jul 23 17:26:28 2010 +0100
     4.2 +++ b/tools/python/xen/xend/XendOptions.py	Fri Jul 23 17:34:35 2010 +0100
     4.3 @@ -164,6 +164,9 @@ class XendOptions:
     4.4          """
     4.5          print >>sys.stderr, "xend [ERROR]", fmt % args
     4.6  
     4.7 +    """Default mask for pscsi device scan."""
     4.8 +    xend_pscsi_device_mask = ['*']
     4.9 +
    4.10  
    4.11      def configure(self):
    4.12          self.set_config()
    4.13 @@ -430,6 +433,10 @@ class XendOptions:
    4.14          return self.get_config_bool("pci-passthrough-strict-check",
    4.15                                      self.pci_dev_assign_strict_check_default)
    4.16  
    4.17 +    def get_pscsi_device_mask(self):
    4.18 +        return self.get_config_value("pscsi-device-mask",
    4.19 +                                      self.xend_pscsi_device_mask)
    4.20 +
    4.21  class XendOptionsFile(XendOptions):
    4.22  
    4.23      """Default path to the config file."""