Ejemplo n.º 1
0
def test_pss():
    uniques = acpi.parse_cpu_method("_PSS")
    for pss, cpupaths in uniques.iteritems():
        if not testsuite.test("_PSS must exist", pss is not None):
            testsuite.print_detail(acpi.factor_commonprefix(cpupaths))
            testsuite.print_detail('No _PSS exists')
            continue

        if not testsuite.test("_PSS must not be empty", pss.pstates):
            testsuite.print_detail(acpi.factor_commonprefix(cpupaths))
            testsuite.print_detail('_PSS is empty')
            continue

        testsuite.test("_PSS must contain at most 16 Pstates", len(pss.pstates) <= 16)
        testsuite.print_detail(acpi.factor_commonprefix(cpupaths))
        map(testsuite.print_detail, repr(pss))

        testsuite.test("_PSS must have no duplicate Pstates", len(pss.pstates) == len(set(pss.pstates)))
        testsuite.print_detail(acpi.factor_commonprefix(cpupaths))
        map(testsuite.print_detail, repr(pss))

        frequencies = [p.core_frequency for p in pss.pstates]
        testsuite.test("_PSS must list Pstates in descending order of frequency", frequencies == sorted(frequencies, reverse=True))
        testsuite.print_detail(acpi.factor_commonprefix(cpupaths))
        map(testsuite.print_detail, repr(pss))

        testsuite.test("_PSS must have Pstates with no duplicate frequencies", len(frequencies) == len(set(frequencies)))
        testsuite.print_detail(acpi.factor_commonprefix(cpupaths))
        map(testsuite.print_detail, repr(pss))

        dissipations = [p.power for p in pss.pstates]
        testsuite.test("_PSS must list Pstates in descending order of power dissipation", dissipations == sorted(dissipations, reverse=True))
        testsuite.print_detail(acpi.factor_commonprefix(cpupaths))
        map(testsuite.print_detail, repr(pss))
Ejemplo n.º 2
0
def test_pss():
    uniques = acpi.parse_cpu_method("_PSS")
    # We special-case None here to avoid a double-failure for CPUs without a _PSS
    testsuite.test("_PSS must be identical for all CPUs", len(uniques) <= 1 or (len(uniques) == 2 and None in uniques))
    for pss, cpupaths in uniques.iteritems():
        if not testsuite.test("_PSS must exist", pss is not None):
            testsuite.print_detail(acpi.factor_commonprefix(cpupaths))
            testsuite.print_detail('No _PSS exists')
            continue

        if not testsuite.test("_PSS must not be empty", pss.pstates):
            testsuite.print_detail(acpi.factor_commonprefix(cpupaths))
            testsuite.print_detail('_PSS is empty')
            continue

        testsuite.print_detail(acpi.factor_commonprefix(cpupaths))
        for index, pstate in enumerate(pss.pstates):
            testsuite.print_detail("P[{}]: {}".format(index, pstate))

        testsuite.test("_PSS must contain at most 16 Pstates", len(pss.pstates) <= 16)
        testsuite.test("_PSS must have no duplicate Pstates", len(pss.pstates) == len(set(pss.pstates)))

        frequencies = [p.core_frequency for p in pss.pstates]
        testsuite.test("_PSS must list Pstates in descending order of frequency", frequencies == sorted(frequencies, reverse=True))

        testsuite.test("_PSS must have Pstates with no duplicate frequencies", len(frequencies) == len(set(frequencies)))

        dissipations = [p.power for p in pss.pstates]
        testsuite.test("_PSS must list Pstates in descending order of power dissipation", dissipations == sorted(dissipations, reverse=True))
Ejemplo n.º 3
0
def test_psd_thread_scope():
    uniques = acpi.parse_cpu_method("_PSD")
    if not testsuite.test("_PSD (P-State Dependency) must exist for each processor", None not in uniques):
        testsuite.print_detail(acpi.factor_commonprefix(uniques[None]))
        testsuite.print_detail('No _PSD exists')
        return
    unique_num_dependencies = {}
    unique_num_entries = {}
    unique_revision = {}
    unique_domain = {}
    unique_coordination_type = {}
    unique_num_processors = {}
    for value, cpupaths in uniques.iteritems():
        unique_num_dependencies.setdefault(len(value.dependencies), []).extend(cpupaths)
        unique_num_entries.setdefault(value.dependencies[0].num_entries, []).extend(cpupaths)
        unique_revision.setdefault(value.dependencies[0].revision, []).extend(cpupaths)
        unique_domain.setdefault(value.dependencies[0].domain, []).extend(cpupaths)
        unique_coordination_type.setdefault(value.dependencies[0].coordination_type, []).extend(cpupaths)
        unique_num_processors.setdefault(value.dependencies[0].num_processors, []).extend(cpupaths)
    def detail(d, fmt):
        for value, cpupaths in sorted(d.iteritems(), key=(lambda (k,v): v)):
            testsuite.print_detail(acpi.factor_commonprefix(cpupaths))
            testsuite.print_detail(fmt.format(value))

    testsuite.test('Dependency count for each processor must be 1', unique_num_dependencies.keys() == [1])
    detail(unique_num_dependencies, 'Dependency count for each processor = {} (Expected 1)')
    testsuite.test('_PSD.num_entries must be 5', unique_num_entries.keys() == [5])
    detail(unique_num_entries, 'num_entries = {} (Expected 5)')
    testsuite.test('_PSD.revision must be 0', unique_revision.keys() == [0])
    detail(unique_revision, 'revision = {}')
    testsuite.test('_PSD.coordination_type must be 0xFE (HW_ALL)', unique_coordination_type.keys() == [0xfe])
    detail(unique_coordination_type, 'coordination_type = {:#x} (Expected 0xFE HW_ALL)')
    testsuite.test('_PSD.domain must be unique (thread-scoped) for each processor', len(unique_domain) == len(acpi.get_cpupaths()))
    detail(unique_domain, 'domain = {:#x} (Expected a unique value for each processor)')
    testsuite.test('_PSD.num_processors must be 1', unique_num_processors.keys() == [1])
    detail(unique_num_processors, 'num_processors = {} (Expected 1)')
Ejemplo n.º 4
0
def test_psd_thread_scope():
    uniques = acpi.parse_cpu_method("_PSD")
    if not testsuite.test("_PSD (P-State Dependency) must exist for each processor", None not in uniques):
        testsuite.print_detail(acpi.factor_commonprefix(uniques[None]))
        testsuite.print_detail('No _PSD exists')
        return
    unique_num_dependencies = {}
    unique_num_entries = {}
    unique_revision = {}
    unique_domain = {}
    unique_coordination_type = {}
    unique_num_processors = {}
    for value, cpupaths in uniques.iteritems():
        unique_num_dependencies.setdefault(len(value.dependencies), []).extend(cpupaths)
        unique_num_entries.setdefault(value.dependencies[0].num_entries, []).extend(cpupaths)
        unique_revision.setdefault(value.dependencies[0].revision, []).extend(cpupaths)
        unique_domain.setdefault(value.dependencies[0].domain, []).extend(cpupaths)
        unique_coordination_type.setdefault(value.dependencies[0].coordination_type, []).extend(cpupaths)
        unique_num_processors.setdefault(value.dependencies[0].num_processors, []).extend(cpupaths)
    def detail(d, fmt):
        for value, cpupaths in sorted(d.iteritems(), key=(lambda (k,v): v)):
            testsuite.print_detail(acpi.factor_commonprefix(cpupaths))
            testsuite.print_detail(fmt.format(value))

    testsuite.test('Dependency count for each processor must be 1', unique_num_dependencies.keys() == [1])
    detail(unique_num_dependencies, 'Dependency count for each processor = {} (Expected 1)')
    testsuite.test('_PSD.num_entries must be 5', unique_num_entries.keys() == [5])
    detail(unique_num_entries, 'num_entries = {} (Expected 5)')
    testsuite.test('_PSD.revision must be 0', unique_revision.keys() == [0])
    detail(unique_revision, 'revision = {}')
    testsuite.test('_PSD.coordination_type must be 0xFE (HW_ALL)', unique_coordination_type.keys() == [0xfe])
    detail(unique_coordination_type, 'coordination_type = {:#x} (Expected 0xFE HW_ALL)')
    testsuite.test('_PSD.domain must be unique (thread-scoped) for each processor', len(unique_domain) == len(acpi.get_cpupaths()))
    detail(unique_domain, 'domain = {:#x} (Expected a unique value for each processor)')
    testsuite.test('_PSD.num_processors must be 1', unique_num_processors.keys() == [1])
    detail(unique_num_processors, 'num_processors = {} (Expected 1)')
Ejemplo n.º 5
0
def test_pstates():
    """Execute and verify frequency for each Pstate in the _PSS"""
    old_mwait = {}
    try:
        IA32_PERF_CTL = 0x199

        # Force use of MWAIT C3
        hint = 0x20
        cpus = bits.cpus()
        for apicid in cpus:
            old_mwait[apicid] = bits.get_mwait(apicid)
            bits.set_mwait(apicid, True, hint)

        cpupath_procid = acpi.find_procid()
        cpupath_uid = acpi.find_uid()
        procid_apicid, uid_x2apicid = acpi.parse_apic()
        def cpupath_apicid(cpupath):
            if procid_apicid is not None:
                procid = cpupath_procid.get(cpupath, None)
                if procid is not None:
                    apicid = procid_apicid.get(procid, None)
                    if apicid is not None:
                        return apicid
            if uid_x2apicid is not None:
                uid = cpupath_uid.get(cpupath, None)
                if uid is not None:
                    apicid = uid_x2apicid.get(uid, None)
                    if apicid is not None:
                        return apicid
            return bits.cpus()[0]

        bclk = testutil.adjust_to_nearest(bits.bclk(), 100.0/12) * 1000000

        uniques = acpi.parse_cpu_method("_PSS")
        for pss, cpupaths in uniques.iteritems():
            if not testsuite.test("_PSS must exist", pss is not None):
                testsuite.print_detail(acpi.factor_commonprefix(cpupaths))
                testsuite.print_detail('No _PSS exists')
                continue

            print "Test duration is ~{} seconds...".format(len(pss.pstates) + 2)

            for n, pstate in enumerate(pss.pstates):
                for cpupath in cpupaths:
                    apicid = cpupath_apicid(cpupath)
                    if apicid is None:
                        print 'Failed to find apicid for cpupath {}'.format(cpupath)
                        continue
                    bits.wrmsr(apicid, IA32_PERF_CTL, pstate.control)

                # Detecting Turbo frequency requires at least 2 pstates
                # since turbo frequency = max non-turbo frequency + 1
                turbo = False
                if len(pss.pstates) >= 2:
                    turbo = (n == 0 and pstate.core_frequency == (pss.pstates[1].core_frequency + 1))
                    if turbo:
                        # Needs to busywait, not sleep
                        start = time.time()
                        while (time.time() - start < 2):
                            pass

                # Abort the test if no cpu frequency is not available
                if bits.cpu_frequency() is None:
                    continue
                aperf = bits.cpu_frequency()[1]

                aperf = testutil.adjust_to_nearest(aperf, bclk/2)
                aperf = int(aperf / 1000000)

                if turbo:
                    testsuite.test("P{}: Turbo measured frequency {} >= expected {} MHz".format(n, aperf, pstate.core_frequency), aperf >= pstate.core_frequency)
                else:
                    testsuite.test("P{}: measured frequency {} MHz == expected {} MHz".format(n, aperf, pstate.core_frequency), aperf == pstate.core_frequency)
    finally:
        for apicid, old_mwait_values in old_mwait.iteritems():
            bits.set_mwait(apicid, *old_mwait_values)
Ejemplo n.º 6
0
def test_pstates():
    """Execute and verify frequency for each Pstate in the _PSS"""
    IA32_PERF_CTL = 0x199
    with bits.mwait.use_hint(), bits.preserve_msr(IA32_PERF_CTL):
        cpupath_procid = acpi.find_procid()
        cpupath_uid = acpi.find_uid()
        apic = acpi.parse_apic()
        procid_apicid = apic.procid_apicid
        uid_x2apicid = apic.uid_x2apicid
        def cpupath_apicid(cpupath):
            if procid_apicid is not None:
                procid = cpupath_procid.get(cpupath, None)
                if procid is not None:
                    apicid = procid_apicid.get(procid, None)
                    if apicid is not None:
                        return apicid
            if uid_x2apicid is not None:
                uid = cpupath_uid.get(cpupath, None)
                if uid is not None:
                    apicid = uid_x2apicid.get(uid, None)
                    if apicid is not None:
                        return apicid
            return bits.cpus()[0]

        bclk = testutil.adjust_to_nearest(bits.bclk(), 100.0/12) * 1000000

        uniques = acpi.parse_cpu_method("_PSS")
        for pss, cpupaths in uniques.iteritems():
            if not testsuite.test("_PSS must exist", pss is not None):
                testsuite.print_detail(acpi.factor_commonprefix(cpupaths))
                testsuite.print_detail('No _PSS exists')
                continue

            for n, pstate in enumerate(pss.pstates):
                for cpupath in cpupaths:
                    apicid = cpupath_apicid(cpupath)
                    if apicid is None:
                        print 'Failed to find apicid for cpupath {}'.format(cpupath)
                        continue
                    bits.wrmsr(apicid, IA32_PERF_CTL, pstate.control)

                # Detecting Turbo frequency requires at least 2 pstates
                # since turbo frequency = max non-turbo frequency + 1
                turbo = False
                if len(pss.pstates) >= 2:
                    turbo = (n == 0 and pstate.core_frequency == (pss.pstates[1].core_frequency + 1))
                    if turbo:
                        # Needs to busywait, not sleep
                        start = time.time()
                        while (time.time() - start < 2):
                            pass

                for duration in (0.1, 1.0):
                    frequency_data = bits.cpu_frequency(duration)
                    # Abort the test if no cpu frequency is not available
                    if frequency_data is None:
                        continue
                    aperf = frequency_data[1]
                    aperf = testutil.adjust_to_nearest(aperf, bclk/2)
                    aperf = int(aperf / 1000000)
                    if turbo:
                        if aperf >= pstate.core_frequency:
                            break
                    else:
                        if aperf == pstate.core_frequency:
                            break

                if turbo:
                    testsuite.test("P{}: Turbo measured frequency {} >= expected {} MHz".format(n, aperf, pstate.core_frequency), aperf >= pstate.core_frequency)
                else:
                    testsuite.test("P{}: measured frequency {} MHz == expected {} MHz".format(n, aperf, pstate.core_frequency), aperf == pstate.core_frequency)