Change in vdsm[master]: scale: limit cpu usage using cpu-affinity

nsoffer at redhat.com nsoffer at redhat.com
Mon Sep 7 15:29:37 UTC 2015


Nir Soffer has posted comments on this change.

Change subject: scale: limit cpu usage using cpu-affinity
......................................................................


Patch Set 6: Code-Review-1

(8 comments)

https://gerrit.ovirt.org/#/c/45738/6/lib/vdsm/cmdutils.py
File lib/vdsm/cmdutils.py:

Line 69: 
Line 70: def taskset(cmd, cpu_list, all_tasks=True):
Line 71:     command = [constants.EXT_TASKSET,
Line 72:                '--all-tasks' if all_tasks else '',
Line 73:                '--cpu-list', ','.join(cpu_list)]
While taskset order requirements are annoying, we can write in a cleaner way easily:

    command = [constants.EXT_TASKSET]
    if all_tasks:
        command.append("--all-tasks")
    command.extend(("--cpu-list", ",".join(cpu_list)))
    ...
Line 74:     command.extend(cmd)
Line 75:     return command
Line 76: 
Line 77: 


https://gerrit.ovirt.org/#/c/45738/6/lib/vdsm/taskset.py
File lib/vdsm/taskset.py:

Line 35:         return "Process failed with rc=%d out=%r err=%r" % (
Line 36:             self.rc, self.out, self.err)
Line 37: 
Line 38: 
Line 39: def get(pid, all_tasks=True):
need to document the return value.
Line 40:     # TODO: check pid
Line 41:     cmd = [constants.EXT_TASKSET,
Line 42:            '--all-tasks' if all_tasks else '',
Line 43:            '--pid', str(pid)]


Line 38: 
Line 39: def get(pid, all_tasks=True):
Line 40:     # TODO: check pid
Line 41:     cmd = [constants.EXT_TASKSET,
Line 42:            '--all-tasks' if all_tasks else '',
Can be cleaner, see comment in cmdutils.
Line 43:            '--pid', str(pid)]
Line 44: 
Line 45:     rc, out, err = utils.execCmd(cmd, resetCpuAffinity=False)
Line 46: 


Line 46: 
Line 47:     if rc != 0:
Line 48:         raise Error(rc, out, err)
Line 49: 
Line 50:     return _cpu_list_from_output(out[0])
Are you sure that we always need the first line? Is it possible that we get a warning in the first line and the result in the second line? In this case, taking the last line is better.
Line 51: 
Line 52: 
Line 53: def set(pid, cpu_list, all_tasks=True):
Line 54:     # TODO: check pid


Line 49: 
Line 50:     return _cpu_list_from_output(out[0])
Line 51: 
Line 52: 
Line 53: def set(pid, cpu_list, all_tasks=True):
need to document that cpu_list is an iterable of strings, either cpu number ("1") or range ("1-3").
Line 54:     # TODO: check pid
Line 55:     # warning: the order of options is significant.
Line 56:     cmd = [constants.EXT_TASKSET,
Line 57:            '--all-tasks' if all_tasks else '',


Line 53: def set(pid, cpu_list, all_tasks=True):
Line 54:     # TODO: check pid
Line 55:     # warning: the order of options is significant.
Line 56:     cmd = [constants.EXT_TASKSET,
Line 57:            '--all-tasks' if all_tasks else '',
Can be cleaner, see comment in cmdutils.
Line 58:            '--pid',
Line 59:            '--cpu-list', ','.join(cpu_list),
Line 60:            str(pid)]
Line 61: 


Line 64:     if rc != 0:
Line 65:         raise Error(rc, out, err)
Line 66: 
Line 67: 
Line 68: def _cpu_list_from_output(line):
Can you show here the typical output of the command, making it easier to maintain?
Line 69:     cpu_list = line.split(': ', 1)
Line 70:     mask = int(cpu_list[1], 16)


Line 65:         raise Error(rc, out, err)
Line 66: 
Line 67: 
Line 68: def _cpu_list_from_output(line):
Line 69:     cpu_list = line.split(': ', 1)
I think we should use rsplit, in case the command format changes to something like "xxx: yyy: e".

Also, spliting on ": " is more fragile, better split on ":" and strip the result.

Also the result of the split is not cpu_list. We should use something like:

    hexmask = line.rsplit(":", 1)[1].strip()
Line 70:     mask = int(cpu_list[1], 16)


-- 
To view, visit https://gerrit.ovirt.org/45738
To unsubscribe, visit https://gerrit.ovirt.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: I3f7f68d65eddb5a21afbc3809ea79cd1dee67984
Gerrit-PatchSet: 6
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Francesco Romani <fromani at redhat.com>
Gerrit-Reviewer: Adam Litke <alitke at redhat.com>
Gerrit-Reviewer: Dan Kenigsberg <danken at redhat.com>
Gerrit-Reviewer: Francesco Romani <fromani at redhat.com>
Gerrit-Reviewer: Jenkins CI
Gerrit-Reviewer: Martin Polednik <mpolednik at redhat.com>
Gerrit-Reviewer: Martin Sivák <msivak at redhat.com>
Gerrit-Reviewer: Michal Skrivanek <michal.skrivanek at redhat.com>
Gerrit-Reviewer: Michal Skrivanek <mskrivan at redhat.com>
Gerrit-Reviewer: Nir Soffer <nsoffer at redhat.com>
Gerrit-Reviewer: Piotr Kliczewski <piotr.kliczewski at gmail.com>
Gerrit-Reviewer: Vinzenz Feenstra <vfeenstr at redhat.com>
Gerrit-Reviewer: Yaniv Bronhaim <ybronhei at redhat.com>
Gerrit-Reviewer: automation at ovirt.org
Gerrit-HasComments: Yes


More information about the vdsm-patches mailing list