xend: fix vcpu related items
PATCH RESEND 1/2 xend: fix vcpu related items
Resending, rediffed against changeset: 7701:abbe3df33774
This patch fixes a number of vcpu related issues.
1. xm vcpu-list now shows info for all vcpus by using info['max_vcpu_id']+1 as end of the range to query vcpu_info.
2. Add new vcpu fields, online_vcpus, max_vcpu_id to XendDomainInfo.sxpr()
3. Remove filter_cpump() which isn't needed now that the per vcpu cpumap field is correct.
4. Update xm/main.py to use online_vcpus as the number vcpus to display in list.
Signature · 94 lines
Ryan Harper Software Engineer; Linux Technology Center IBM Corp., Austin, Tx (512) 838-9253 T/L: 678-9253 [email protected] diffstat output: xend/XendDomainInfo.py | 15 +++++++-------- xm/main.py | 14 +++++++------- 2 files changed, 14 insertions(+), 15 deletions(-) Signed-off-by: Ryan Harper <[email protected]> --- # HG changeset patch # User [email protected] # Node ID 8780650bc95865aeea69f89511ce9b1be9dad82c # Parent 7b01938105f9090d46e6e27e0a8d218d4c0be93c fixup_vcpu_related_items. diff -r 7b01938105f9 -r 8780650bc958 tools/python/xen/xend/XendDomainInfo.py --- a/tools/python/xen/xend/XendDomainInfo.py Tue Nov 8 22:36:34 2005 +++ b/tools/python/xen/xend/XendDomainInfo.py Tue Nov 8 22:37:05 2005 @@ -428,8 +428,10 @@ defaultInfo('cpu', lambda: None) defaultInfo('cpu_weight', lambda: 1.0) defaultInfo('vcpus', lambda: int(1)) + defaultInfo('online_vcpus', lambda: self.info['vcpus']) self.info['vcpus'] = int(self.info['vcpus']) + defaultInfo('max_vcpu_id', lambda: self.info['vcpus']-1) defaultInfo('vcpu_avail', lambda: (1 << self.info['vcpus']) - 1) defaultInfo('bootloader', lambda: None) @@ -975,6 +977,7 @@ if self.infoIsSet('cpu_time'): sxpr.append(['cpu_time', self.info['cpu_time']/1e9]) sxpr.append(['vcpus', self.info['vcpus']]) + sxpr.append(['online_vcpus', self.info['online_vcpus']]) if self.infoIsSet('start_time'): up_time = time.time() - self.info['start_time'] @@ -991,16 +994,13 @@ def getVCPUInfo(self): try: - def filter_cpumap(map, max): - return filter(lambda x: x >= 0, map[0:max]) - # We include the domain name and ID, to help xm. sxpr = ['domain', ['domid', self.domid], ['name', self.info['name']], - ['vcpu_count', self.info['vcpus']]] - - for i in range(0, self.info['vcpus']): + ['vcpu_count', self.info['online_vcpus']]] + + for i in range(0, self.info['max_vcpu_id']+1): info = xc.vcpu_getinfo(self.domid, i) sxpr.append(['vcpu', @@ -1010,8 +1010,7 @@ ['running', info['running']], ['cpu_time', info['cpu_time'] / 1e9], ['cpu', info['cpu']], - ['cpumap', filter_cpumap(info['cpumap'], - self.info['vcpus'])]]) + ['cpumap', info['cpumap']]]) return sxpr diff -r 7b01938105f9 -r 8780650bc958 tools/python/xen/xm/main.py --- a/tools/python/xen/xm/main.py Tue Nov 8 22:36:34 2005 +++ b/tools/python/xen/xm/main.py Tue Nov 8 22:37:05 2005 @@ -260,13 +260,13 @@ return t(sxp.child_value(info, n, d)) return { - 'dom' : get_info('domid', int, -1), - 'name' : get_info('name', str, '??'), - 'mem' : get_info('memory', int, 0), - 'vcpus' : get_info('vcpus', int, 0), - 'state' : get_info('state', str, '??'), - 'cpu_time' : get_info('cpu_time', float, 0), - 'ssidref' : get_info('ssidref', int, 0), + 'dom' : get_info('domid', int, -1), + 'name' : get_info('name', str, '??'), + 'mem' : get_info('memory', int, 0), + 'vcpus' : get_info('online_vcpus', int, 0), + 'state' : get_info('state', str, '??'), + 'cpu_time' : get_info('cpu_time', float, 0), + 'ssidref' : get_info('ssidref', int, 0), }
Quoted 1 line · Ryan Harper
Resending, rediffed against changeset: 7701:abbe3df33774
Thanks for your resends, Ryan. Your two patches are in my tree at the moment, and I'm testing them.
There are now so many fields with "cpu" in the name that I was looking over it wondering if there were a few we could lose now. Perhaps we could review them on the list.
I count
vcpus the number of virtual CPUs this domain is configured to use. vcpu_avail VCPU availability bitmap vcpu_count same as vcpus, just in the getVCPUInfo sxpr cpumap VCPU-to-CPU bitmap list cpu configuration pinning VCPU 0 to the specified physical CPU
max_vcpu_idonline_vcpus
as well as the obvious
cpu_timecpu_weight
So could you explain the semantics of max_vcpu_id and online_vcpus, compared with vcpus and vcpu_avail in particular? I'm afraid I've lost track.
Ewan.
Quoted 6 lines · Ewan Mellor
Quoted 1 line · Ryan Harper
Resending, rediffed against changeset: 7701:abbe3df33774
Thanks for your resends, Ryan. Your two patches are in my tree at the moment, and I'm testing them.
Great!
Quoted 4 lines
There are now so many fields with "cpu" in the name that I was looking over it wondering if there were a few we could lose now. Perhaps we could review them on the list.
Yeah, as I was wading through this I was thinking the same thing.
Quoted 11 lines
I count
vcpus the number of virtual CPUs this domain is configured to use. vcpu_avail VCPU availability bitmap vcpu_count same as vcpus, just in the getVCPUInfo sxpr cpumap VCPU-to-CPU bitmap list cpu configuration pinning VCPU 0 to the specified physical CPU
max_vcpu_idonline_vcpus
Quoted 7 lines
as well as the obvious
cpu_timecpu_weightSo could you explain the semantics of
max_vcpu_idandonline_vcpus, compared with vcpus andvcpu_availin particular? I'm afraid I've lost track.
'max_vcpu_id' is the highest id of a vcpu that has been created/initialized. So, for instance, after booting dom0 SMP on a 4 way, the hypervisor's domain builder creates one VCPU for each physical cpu leaving max_vcpu_id=3.
'online_vcpus' is a count of the number of vcpus that can be scheduled in a domain (they are runnable, that is VCPUF_down is not set, which happens when we disable/unplug vcpus).
'vcpus' is the value parsed from a domain's config file, ie, the number of vcpus you want your domain to have.
'vcpu_avail' is a bitmap (probably should convert it to a list since we have been tossing the C-ism out) indicating which vcpus are available (runnable, enabled, etc.). Currently, vcpu_avail is derived from 'vcpus', (vcpu_avail = (1 << vcpus) - 1) and assumes that all possible vcpus are available.
In some cases, we don't have a configuration file which would have the 'vcpus' element (dom0 is one such example). Such domains are usually running prior to starting xend in which case the info dict returned from xc_domain_getinfo contains the run-time variables 'online_vcpus' and 'max_vcpu_id'. We can use those values to calculate vcpu_avail.
Actually, rather that using max_vcpu_id+1 to calculate vcpu_avail for running domains as I did in my patch we should build it with a loop check each vcpu if it is up or not:
for v in range(0,info['max_vcpu_id']+1):
vinfo = xc.vcpu_getinfo(domid,v)
if vinfo['online']:
vcpu_avail |= 1 << v
One of the difficulties we have is that is is not always clear in the code where we want configuration information (ie, how many vcpus did you want your domain to have) or runtime info (which vcpus in this domain are online right now). I think vcpu_count is just one of those cases, one could want access to either type but we only have one method and if you are not aware of what that means, then we are possibly introducing bugs.
Personally I'd like to see a separate dict for config and runtime info
config = parseConfig(c) # only filled with values from config file
info = dom_get(domid) # current runtime info as returned from HV
Possibly too late in the game for this sort of rework.
Signature · 5 lines
Ryan Harper Software Engineer; Linux Technology Center IBM Corp., Austin, Tx (512) 838-9253 T/L: 678-9253 [email protected]
Quoted 6 lines · Ewan Mellor
Quoted 1 line · Ryan Harper
Resending, rediffed against changeset: 7701:abbe3df33774
Thanks for your resends, Ryan. Your two patches are in my tree at the moment, and I'm testing them.
Are these patches still pending? Anything I can do to help test?
Signature · 5 lines
Ryan Harper Software Engineer; Linux Technology Center IBM Corp., Austin, Tx (512) 838-9253 T/L: 678-9253 [email protected]
Quoted 9 lines · Ryan Harper
Quoted 6 lines · Ewan Mellor
Quoted 1 line · Ryan Harper
Resending, rediffed against changeset: 7701:abbe3df33774
Thanks for your resends, Ryan. Your two patches are in my tree at the moment, and I'm testing them.
Are these patches still pending? Anything I can do to help test?
I've put them in now. As we've discussed, I think that this code could still do with some cleaning up, but for now, your patches are in, and we can worry about clean-up later.
Thanks for your work,
Ewan.
Ewan Mellor
AppliedQuoted 4 lines · Ryan Harper
Resending, rediffed against changeset: 7701:abbe3df33774
This patch fixes a number of vcpu related issues.
Quoted 9 lines
1. xm vcpu-list now shows info for all vcpus by using info['max_vcpu_id']+1 as end of the range to query
vcpu_info.
2. Add new vcpu fields,online_vcpus,max_vcpu_idtoXendDomainInfo.sxpr()
3. Removefilter_cpump()which isn't needed now that the per vcpu cpumap field is correct.
4. Updatexm/main.pyto useonline_vcpusas the number vcpus to display in list.
Applied.
Ewan.