Login
[x]
Log in using an account from:
Fedora Account System
Red Hat Associate
Red Hat Customer
Or login using a Red Hat Bugzilla account
Forgot Password
Login:
Hide Forgot
Create an Account
Red Hat Bugzilla – Attachment 313693 Details for
Bug 449676
Turning a CPU offline causes panic
[?]
New
Simple Search
Advanced Search
My Links
Browse
Requests
Reports
Current State
Search
Tabular reports
Graphical reports
Duplicates
Other Reports
User Changes
Plotly Reports
Bug Status
Bug Severity
Non-Defaults
|
Product Dashboard
Help
Page Help!
Bug Writing Guidelines
What's new
Browser Support Policy
5.0.4.rh83 Release notes
FAQ
Guides index
User guide
Web Services
Contact
Legal
This site requires JavaScript to be enabled to function correctly, please enable it.
sysfs CPU classes, usage example does random CPU off/onlining
sysfs.py (text/plain), 2.19 KB, created by
Arnaldo Carvalho de Melo
on 2008-08-07 14:01:48 UTC
(
hide
)
Description:
sysfs CPU classes, usage example does random CPU off/onlining
Filename:
MIME Type:
Creator:
Arnaldo Carvalho de Melo
Created:
2008-08-07 14:01:48 UTC
Size:
2.19 KB
patch
obsolete
>#! /usr/bin/python ># -*- python -*- ># -*- coding: utf-8 -*- > >import os > >class cpu: > def __init__(self, basedir, name): > self.name = name > self.dir = "%s/%s" % (basedir, name) > self.reload() > > def readfile(self, name): > try: > f = open("%s/%s" % (self.dir, name)) > value = f.readline().strip() > f.close() > except: > raise > return value > > def reload_online(self): > self.online = True > try: > self.online = self.readfile("online") == "1" > except: > # boot CPU, usually cpu0, can't be brought offline, so > # lacks the file and non root users can't read. In both > # cases assume CPU is online. > pass > > def reload(self): > self.reload_online() > if self.online: > self.physical_package_id = self.readfile("topology/physical_package_id") > else: > self.physical_package_id = None > > def set_online(self, online = True): > try: > f = open("%s/online" % self.dir, "w") > f.write("%d\n" % (online and 1 or 0)) > f.close() > except: > pass > > self.reload_online() > return online == self.online > >class cpus: > def __init__(self, basedir = "/sys/devices/system/cpu"): > self.basedir = basedir > self.cpus = {} > self.sockets = {} > self.reload() > self.nr_cpus = len(self.cpus) > > def __getitem__(self, key): > return self.cpus[key] > > def keys(self): > return self.cpus.keys() > > def has_key(self, key): > return self.cpus.has_key(key) > > def reload(self): > for name in os.listdir(self.basedir): > if name[:3] != "cpu" or not name[3].isdigit(): > continue > > if name in self.cpus: > self.cpus[name].reload(self.basedir) > else: > c = cpu(self.basedir, name) > self.cpus[name] = c > socket = c.physical_package_id > if socket in self.sockets: > self.sockets[socket].insert(0, c) > else: > self.sockets[socket] = [ c, ] > >if __name__ == '__main__': > import sys, random, time > > cpus = cpus() > > while True: > for socket in cpus.sockets.keys(): > print "Socket %s" % socket > cores = cpus.sockets[socket] > random.shuffle(cores) > for c in cores: > print " %s" % c.name > print " online: %s" % c.online > c.set_online(random.choice([False, True])) > print " online: %s" % c.online > sleeptime = random.random() / 2 > print "sleeping %f seconds..." % sleeptime > time.sleep(sleeptime)
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 449676
:
308312
|
308318
|
308373
|
308386
|
308389
| 313693