wiscsee icon indicating copy to clipboard operation
wiscsee copied to clipboard

CPU Count

Open tylerharter opened this issue 8 years ago • 10 comments

When I walk through the tutorial, the example seems to assume I have more cores than I actually do, leading to the following exception:

====================================================================== ERROR: test_run (tests.test_demo.Test_TraceAndSimulateLinuxDD)

Traceback (most recent call last): File "tests/test_demo.py", line 28, in test_run obj.main() File "config_helper/experiment.py", line 235, in main self.run() File "config_helper/experiment.py", line 226, in run run_workflow(self.conf) File "workflow.py", line 14, in run_workflow wf.run() File "workflow.py", line 23, in run event_iter = self._run_workload() File "workflow.py", line 43, in _run_workload event_iter = runner.run() File "workrunner/wlrunner.py", line 168, in run return self.run_with_blktrace() File "workrunner/wlrunner.py", line 202, in run_with_blktrace cpuhandler.set_cpus(self.conf['n_online_cpus']) File "workrunner/cpuhandler.py", line 69, in set_cpus enable_all_cpus() File "workrunner/cpuhandler.py", line 62, in enable_all_cpus enable_n_cpus(len(possible_cpus)) File "workrunner/cpuhandler.py", line 93, in enable_n_cpus switch_cpu(cpuid, 'ON') File "workrunner/cpuhandler.py", line 53, in switch_cpu f = open(path, 'w') IOError: [Errno 2] No such file or directory: '/sys/devices/system/cpu/cpu8/online'

tylerharter avatar Nov 17 '17 22:11 tylerharter

I only have 8 cores, so /sys/devices/system/cpu/cpu7/online exists, but /sys/devices/system/cpu/cpu8/online does not.

tylerharter avatar Nov 17 '17 22:11 tylerharter

Weird, I thought I automatically detected number of core... Will check it later.

junhe avatar Nov 21 '17 03:11 junhe

same problem here Environment: 14.04 Ubuntu, 4.5.4 kernel cpu: i5-8500 with 6cores

IOError: [Errno 2] No such file or directory: '/sys/devices/system/cpu/cpu6/online' occured in every last line of error

attached file is log after $make test_all wiscsim error 'cpu'.txt

luminus7 avatar Feb 18 '20 04:02 luminus7

How many cores do you have? Could you do $ ls /sys/devices/system/cpu/

junhe avatar Feb 18 '20 04:02 junhe

got 6 cores in my pc

~$ ls /sys/devices/system/cpu/ cpu0 cpu2 cpu4 cpufreq isolated microcode offline possible present cpu1 cpu3 cpu5 cpuidle kernel_max modalias online power uevent

luminus7 avatar Feb 18 '20 04:02 luminus7

Also, do the following?

$ cat /sys/devices/system/cpu/online

junhe avatar Feb 18 '20 04:02 junhe

sure! ~$ cat /sys/devices/system/cpu/online 0-5

luminus7 avatar Feb 18 '20 04:02 luminus7

I think the cause of the failure is that /sys/devices/system/cpu/possible contains CPU id 6, but there is actually no CPU 6. To workaround, try change get_possible_cpus() ( https://github.com/junhe/wiscsee/blob/e0f086b04230747205056d8f4def42f9eb36c8d2/workrunner/cpuhandler.py#L4) to

def get_possible_cpus(): return range(0, 6)

I hope this works for you..

On Mon, Feb 17, 2020 at 10:58 PM luminus7 [email protected] wrote:

sure! ~$ cat /sys/devices/system/cpu/online 0-5

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/junhe/wiscsee/issues/8?email_source=notifications&email_token=AAEZ6JIFBYVIO3VP5LNJAL3RDNTIJA5CNFSM4EEKZ2F2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEMASUCQ#issuecomment-587278858, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAEZ6JL5IXRVK6PDQQHRISDRDNTIJANCNFSM4EEKZ2FQ .

junhe avatar Feb 18 '20 13:02 junhe

~$ cat /sys/devices/system/cpu/possible 0-7

in wiscsee/workrunner/cpuhandler.py

def get_possible_cpus():
    f = open("/sys/devices/system/cpu/possible", 'r')
    line = f.readline()
    f.close()

    # assuming format of 0-2,4,6-63
    items = line.split(',')
    cpus = []
    for item in items:
        if '-' in item:
            a,b = item.split('-')
            a = int(a)
            b = int(b)
            cpus.extend(range(a, b+1))
        else:
            cpus.append(int(item))

#    return cpus
    return range(0,6)

this make successful test_all, and run_demo

thank you for your fast and kind respond :)

luminus7 avatar Feb 19 '20 02:02 luminus7

:)

On Tue, Feb 18, 2020 at 8:32 PM luminus7 [email protected] wrote:

~$ cat /sys/devices/system/cpu/possible 0-7

in wiscsee/workrunner/cpuhandler.py

def get_possible_cpus(): f = open("/sys/devices/system/cpu/possible", 'r') line = f.readline() f.close()

# assuming format of 0-2,4,6-63
items = line.split(',')
cpus = []
for item in items:
    if '-' in item:
        a,b = item.split('-')
        a = int(a)
        b = int(b)
        cpus.extend(range(a, b+1))
    else:
        cpus.append(int(item))

return cpus

return range(0,6)

this make successful test_all, and run_demo

thank you for your fast and kind respond :)

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/junhe/wiscsee/issues/8?email_source=notifications&email_token=AAEZ6JPAHVL4PUVTOIQVI3TRDSK4HA5CNFSM4EEKZ2F2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEMGDWDQ#issuecomment-588004110, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAEZ6JN3HOAXE3PZAWD2OI3RDSK4HANCNFSM4EEKZ2FQ .

junhe avatar Feb 19 '20 04:02 junhe