def test_pqos_l2cat_set_data(self, iface): self.run_pqos(iface, "-R l2cdp-on") default_mask = (1 << Env().get('cat', 'l2', 'ways')) - 1 max_cdp_cos = Env().get('cat', 'l2', 'cos') // 2 - 1 cos = (max_cdp_cos // 2 + max_cdp_cos) // 2 (stdout, _, exitstatus) = self.run_pqos(iface, f"-e l2:{cos}d=0xf") assert exitstatus == 0 assert f"L2ID 1 L2CA COS{cos} => DATA 0xf,CODE {hex(default_mask)}" in stdout
def test_rdtset_mba_set_command(self, iface): command = self.cmd_rdtset(iface, "-t mba=50;cpu=5-6 -c 5-6 memtester 10M") rdtset = subprocess.Popen(command.split(), stdin=subprocess.PIPE, stdout=subprocess.PIPE) time.sleep(0.1) (stdout, _, exitstatus) = self.run_pqos(iface, "-s") assert exitstatus == 0 if iface == "MSR": last_cos = Env().get('mba', 'cos') - 1 else: last_cos = Resctrl.get_ctrl_group_count() - 1 assert re.search("Core 5, L2ID [0-9]+, L3ID [0-9]+ => COS%d" % last_cos, stdout) \ is not None assert re.search("Core 6, L2ID [0-9]+, L3ID [0-9]+ => COS%d" % last_cos, stdout) \ is not None assert "MBA COS{} => 50% available".format(last_cos) in stdout self.run("killall memtester") rdtset.communicate()
def test_rdtset_l3cat_set_command(self, iface): param = "-t l3=0xf;cpu=5-6 -c 5-6 memtester 10M" command = self.cmd_rdtset(iface, param) rdtset = subprocess.Popen(command.split(), stdin=subprocess.PIPE, stdout=subprocess.PIPE) time.sleep(0.1) (stdout, _, exitstatus) = self.run_pqos(iface, "-s") assert exitstatus == 0 if iface == "MSR": last_cos = Env().get('cat', 'l3', 'cos') - 1 else: last_cos = Resctrl.get_ctrl_group_count() - 1 assert re.search( "Core 5, L2ID [0-9]+, L3ID [0-9]+ => COS%d" % last_cos, stdout) is not None assert re.search( "Core 6, L2ID [0-9]+, L3ID [0-9]+ => COS%d" % last_cos, stdout) is not None assert "L3CA COS%d => MASK 0xf" % last_cos in stdout self.run("killall memtester") rdtset.communicate()
def test_rdtset_mba_set_command(self, iface): command = self.cmd_rdtset(iface, "-t mba=50;cpu=5-6 -c 5-6 memtester 10M") with subprocess.Popen(command.split(), stdin=subprocess.PIPE, stdout=subprocess.PIPE) as rdtset: self.stdout_wait(rdtset, b"memtester version") (stdout, _, exitstatus) = self.run_pqos(iface, "-s") assert exitstatus == 0 if iface == "MSR": last_cos = Env().get('mba', 'cos') - 1 else: last_cos = Resctrl.get_ctrl_group_count() - 1 assert re.search(f"Core 5, L2ID [0-9]+, L3ID [0-9]+ => COS{last_cos}", stdout) \ is not None assert re.search(f"Core 6, L2ID [0-9]+, L3ID [0-9]+ => COS{last_cos}", stdout) \ is not None assert f"MBA COS{last_cos} => 50% available" in stdout self.run("killall memtester") rdtset.communicate()
def test_pqos_l2cat_set_data(self, iface): self.run_pqos(iface, "-R l2cdp-on") default_mask = (1 << Env().get('cat', 'l2', 'ways')) - 1 (stdout, _, exitstatus) = self.run_pqos(iface, "-e l2:3d=0xf") assert exitstatus == 0 assert ("L2ID 1 L2CA COS3 => DATA 0xf,CODE {}").format(hex(default_mask)) in stdout
def test_pqos_l3cat_set_code(self, iface): self.run_pqos(iface, "-R l3cdp-on") default_mask = (1 << Env().get('cat', 'l3', 'ways')) - 1 (stdout, _, exitstatus) = self.run_pqos(iface, "-e llc:4c=0xf") assert exitstatus == 0 assert ("SOCKET 0 L3CA COS4 => DATA {},CODE 0xf").format(hex(default_mask)) in stdout
def test_pqos_l3cat_set_data(self, iface): self.run_pqos(iface, "-R l3cdp-on") default_mask = (1 << Env().get('cat', 'l3', 'ways')) - 1 (stdout, _, exitstatus) = self.run_pqos(iface, "-e llc:3d=0xf") assert exitstatus == 0 assert f"SOCKET 0 L3CA COS3 => DATA 0xf,CODE {hex(default_mask)}" in stdout
def test_pqos_l2cat_set_code_and_data(self, iface): self.run_pqos(iface, "-R l2cdp-on") max_cdp_cos = Env().get('cat', 'l2', 'cos') // 2 - 1 cos = max_cdp_cos // 2 (stdout, _, exitstatus) = self.run_pqos(iface, f"-e l2:{cos}=0xe") assert exitstatus == 0 assert f"L2ID 1 L2CA COS{cos} => DATA 0xe,CODE 0xe" in stdout
def init(self, request): self.membw = request.config.membw self.rdtset = request.config.rdtset self.pqos = request.config.pqos if os.path.isdir("/sys/fs/resctrl/info"): subprocess.call("umount /sys/fs/resctrl".split(), stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) reset_opt = "" if Env().exists('cat', 'l3'): reset_opt += 'l3cdp-off,' if Env().exists('cat', 'l2'): reset_opt += 'l2cdp-off,' subprocess.call(f"{self.pqos} --iface=msr -R {reset_opt}".split(), stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) subprocess.call(f"{self.pqos} --iface=msr -r -t 0".split(), stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
def pytest_configure(config): config.iface_msr = config.getoption("--iface-msr") config.iface_os = config.getoption("--iface-os") env_path = config.getoption("--env") # load env file if env_path: Env().load(env_path) if not config.iface_os and not config.iface_msr: config.iface_msr = True config.iface_os = True config.features = {} if config.iface_msr: msr_features = FeaturesRdtMsr() config.features['MSR'] = msr_features.get_features() if config.iface_os: os_features = FeaturesRdtOs() config.features['OS'] = os_features.get_features()
def test_rdtset_l2cat_set_command(self, iface): param = "-t l2=0xf;cpu=5-6 -c 5-6 memtester 10M" command = self.cmd_rdtset(iface, param) with subprocess.Popen(command.split(), stdin=subprocess.PIPE, stdout=subprocess.PIPE) as rdtset: self.stdout_wait(rdtset, b"memtester version") (stdout, _, exitstatus) = self.run_pqos(iface, "-s") assert exitstatus == 0 if iface == "MSR": last_cos = Env().get('cat', 'l2', 'cos') - 1 else: last_cos = Resctrl.get_ctrl_group_count() - 1 assert re.search("Core 5, L2ID [0-9]+(, L3ID [0-9]+)? => COS%d" % last_cos, stdout) \ is not None assert re.search("Core 6, L2ID [0-9]+(, L3ID [0-9]+)? => COS%d" % last_cos, stdout) \ is not None assert "L2CA COS%d => MASK 0xf" % last_cos in stdout self.run("killall memtester") rdtset.communicate()
def test_rdtset_l2cat_set_command_same_l3id_diff_l2id(self, iface): # Get cache topology stdout, _, exitstatus = self.run_pqos(iface, '-s') assert exitstatus == 0 regex = r"Core (\d+), L2ID (\d+), L3ID (\d+) => COS(\d+)(, RMID\d+)?" match_iter = re.finditer(regex, stdout) topology = defaultdict(lambda: {'l2ids': defaultdict(lambda: [])}) for match in match_iter: core = int(match.group(1)) l2id = int(match.group(2)) l3id = int(match.group(3)) topology[l3id]['l2ids'][l2id].append(core) if len(topology) < 2: pytest.skip('Test applies for machines with at least 2 sockets') # Get cores from the same socket, but different cluster # The same L3 ID (MBA ID or socket), different L2 ID (cluster) cores = [] for _, l3id_info in topology.items(): for l2id, l2id_cores in l3id_info['l2ids'].items(): if len(cores) >= 2: break core = l2id_cores[len(l2id_cores) // 3] self.log.debug('Found core %d, L2 ID %d', core, l2id) cores.append(core) if len(cores) >= 2: break assert len(cores) >= 2 self.log.debug('Selected cores: %s', cores) param = f"-t l2=0xf;cpu={cores[0]},{cores[1]} -c {cores[0]},{cores[1]} memtester 10M" command = self.cmd_rdtset(iface, param) with subprocess.Popen(command.split(), stdin=subprocess.PIPE, stdout=subprocess.PIPE) as rdtset: self.stdout_wait(rdtset, b"memtester version") (stdout, _, exitstatus) = self.run_pqos(iface, "-s") assert exitstatus == 0 if iface == "MSR": last_cos = Env().get('cat', 'l2', 'cos') - 1 else: last_cos = Resctrl.get_ctrl_group_count() - 1 assert last_cos > 0 # Assigned two different COS regex_tpl = "Core %d, L2ID [0-9]+(, L3ID [0-9]+)? => COS(%d|%d)" regex1 = regex_tpl % (cores[0], last_cos, last_cos - 1) regex2 = regex_tpl % (cores[1], last_cos, last_cos - 1) assert re.search(regex1, stdout) is not None assert re.search(regex2, stdout) is not None assert "L2CA COS%d => MASK 0xf" % (last_cos - 1) in stdout assert "L2CA COS%d => MASK 0xf" % last_cos in stdout self.run("killall memtester") rdtset.communicate()