Module: Hyperctl
- Defined in:
- lib/hyperctl.rb,
lib/hyperctl/version.rb
Defined Under Namespace
Classes: Sysfs
Constant Summary collapse
- VERSION =
'0.1.0'
Class Method Summary collapse
-
.disable(hctl) ⇒ Object
Disable all sibling cores.
-
.enable(hctl) ⇒ Object
Enable all sibling cores.
-
.status(hctl) ⇒ String
Generate a pretty formatted string of sibling core status.
Class Method Details
.disable(hctl) ⇒ Object
Disable all sibling cores
20 21 22 23 |
# File 'lib/hyperctl.rb', line 20 def self.disable(hctl) cores = hctl.sibling_cores cores.each {|core_id| Hyperctl::Sysfs.disable_core(core_id) } end |
.enable(hctl) ⇒ Object
Enable all sibling cores
8 9 10 11 12 13 14 |
# File 'lib/hyperctl.rb', line 8 def self.enable(hctl) # as far as I can tell, there's no way to discover the topology information # for which cores and siblings if either of them is disabled. So we are # just trying to enable everything that is disabled... cores = hctl.offline_cores cores.each {|core_id| Hyperctl::Sysfs.enable_core(core_id) } end |
.status(hctl) ⇒ String
Generate a pretty formatted string of sibling core status
30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/hyperctl.rb', line 30 def self.status(hctl) cpu_info = hctl.cpu_info text = "" cpu_info.each_key.sort_by {|k| cpu_info[k][:core_id] }.each do |k| cpu = cpu_info[k] state = cpu[:online] ? 'enabled' : 'disabled' ht = cpu.has_key?(:thread_siblings_list) ? 'enabled' : 'disabled' text << "#{sprintf('%-5s',k.to_s)}: #{sprintf('%-8s', state)}" text << " - hypertheading: #{ht}\n" end return text end |