Skip to content

Commit

Permalink
Merge "Improve documentation of (unpin|pin)_cpus_with_siblings()"
Browse files Browse the repository at this point in the history
  • Loading branch information
Zuul authored and openstack-gerrit committed Dec 6, 2020
2 parents f27a11f + de10c12 commit b149c30
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions nova/objects/numa.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,16 +106,34 @@ def unpin_cpus(self, cpus):
self.pinned_cpus -= cpus

def pin_cpus_with_siblings(self, cpus):
"""Pin (consume) both thread siblings if one of them is requested to
be pinned.
:param cpus: set of CPUs to pin
"""
pin_siblings = set()
for sib in self.siblings:
if cpus & sib:
# NOTE(artom) If the intersection between cpus and sib is not
# empty - IOW, the CPU we want to pin has sibligns - pin the
# sibling as well. This is because we normally got here because
# the `isolate` CPU thread policy is set, so we don't want to
# place guest CPUs on host thread siblings.
pin_siblings.update(sib)
self.pin_cpus(pin_siblings)

def unpin_cpus_with_siblings(self, cpus):
"""Unpin (free up) both thread siblings if one of them is requested to
be freed.
:param cpus: set of CPUs to unpin.
"""
pin_siblings = set()
for sib in self.siblings:
if cpus & sib:
# NOTE(artom) This is the inverse operation of
# pin_cpus_with_siblings() - see the NOTE there. If the CPU
# we're unpinning has siblings, unpin the sibling as well.
pin_siblings.update(sib)
self.unpin_cpus(pin_siblings)

Expand Down

0 comments on commit b149c30

Please sign in to comment.