From 44d68748444fc2f13bfba170216934dd5aa4cd2d Mon Sep 17 00:00:00 2001 From: "J. Lowell Wofford" Date: Tue, 17 Dec 2019 22:41:28 -0700 Subject: [PATCH 01/87] buildGraph now looks for in mutations as well as out --- core/StateMutationEngine.go | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/core/StateMutationEngine.go b/core/StateMutationEngine.go index d0562c793..69847c193 100644 --- a/core/StateMutationEngine.go +++ b/core/StateMutationEngine.go @@ -925,6 +925,39 @@ func (sme *StateMutationEngine) nodeViolatesDeps(deps map[string]lib.StateSpec, } } } + // Can this form an in arrow? + if m.SpecCompatIn(root.spec, sme.mutators) { + // ...or, 2) we have hit the same mutation in the same chain. + if n, ok := seenMut[i]; ok { + // Ok, I've seen this mutation -> I'm not actually a new node + // Which node am I? -> seen[i] + sme.remapToNode(root, n) + return []*mutationNode{}, []*mutationEdge{} + } + nme := &mutationEdge{ + cost: 1, + mut: m, + to: root, + } + nn := &mutationNode{ + spec: root.spec.SpecMergeMust(m.Before()), + in: []*mutationEdge{nme}, + out: []*mutationEdge{}, + } + nme.from = nn + root.in = append(root.in, nme) + //ineffient, but every chain needs its own copy of seenMut + newseenMut := make(map[int]*mutationNode) + for k := range seenMut { + newseenMut[k] = seenMut[k] + } + newseenMut[i] = root + seenNode[root.spec] = root + nds, eds := sme.buildGraph(nn, seenNode, newseenMut, append(chain, root)) + edges = append(edges, nme) + edges = append(edges, eds...) + nodes = append(nodes, nds...) + } } return } From 7c34fddc24f2ee3151f9d4dd83a7adfea32e1318 Mon Sep 17 00:00:00 2001 From: "J. Lowell Wofford" Date: Wed, 18 Dec 2019 00:30:19 -0700 Subject: [PATCH 02/87] buildGraph: also search for in-mutations when building --- core/StateMutationEngine.go | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/core/StateMutationEngine.go b/core/StateMutationEngine.go index 69847c193..59df8566d 100644 --- a/core/StateMutationEngine.go +++ b/core/StateMutationEngine.go @@ -927,13 +927,6 @@ func (sme *StateMutationEngine) nodeViolatesDeps(deps map[string]lib.StateSpec, } // Can this form an in arrow? if m.SpecCompatIn(root.spec, sme.mutators) { - // ...or, 2) we have hit the same mutation in the same chain. - if n, ok := seenMut[i]; ok { - // Ok, I've seen this mutation -> I'm not actually a new node - // Which node am I? -> seen[i] - sme.remapToNode(root, n) - return []*mutationNode{}, []*mutationEdge{} - } nme := &mutationEdge{ cost: 1, mut: m, @@ -941,19 +934,14 @@ func (sme *StateMutationEngine) nodeViolatesDeps(deps map[string]lib.StateSpec, } nn := &mutationNode{ spec: root.spec.SpecMergeMust(m.Before()), - in: []*mutationEdge{nme}, - out: []*mutationEdge{}, + in: []*mutationEdge{}, + out: []*mutationEdge{nme}, } nme.from = nn root.in = append(root.in, nme) - //ineffient, but every chain needs its own copy of seenMut - newseenMut := make(map[int]*mutationNode) - for k := range seenMut { - newseenMut[k] = seenMut[k] - } - newseenMut[i] = root seenNode[root.spec] = root - nds, eds := sme.buildGraph(nn, seenNode, newseenMut, append(chain, root)) + // we reset the chain if we went backwards + nds, eds := sme.buildGraph(nn, seenNode, make(map[int]*mutationNode)) edges = append(edges, nme) edges = append(edges, eds...) nodes = append(nodes, nds...) From d152903becb9ceeaa1378c75a0fa1e3a246e8a5b Mon Sep 17 00:00:00 2001 From: Ghazanfar Ali Date: Tue, 5 Nov 2019 10:49:44 -0700 Subject: [PATCH 03/87] Added Host Frequency Scaling Module and Related Extensions. --- config/pipxe-child.yaml | 25 + config/pipxe.yaml | 1 + core/Node.go | 5 + core/StateMutationEngine.go | 2 +- core/StateSyncEngine.go | 5 +- .../HostFrequencyScaler.go | 32 ++ .../proto/HostFrequencyScaler.pb.go | 85 +++ .../proto/HostFrequencyScaler.proto | 17 + .../HostThermal/proto/HostThermal.pb.go | 54 +- .../HostThermal/proto/HostThermal.proto | 8 +- kraken/main.go.tpl | 2 +- .../hostfrequencyscaling.go | 514 ++++++++++++++++++ .../proto/hostfrequencyscaling.pb.go | 188 +++++++ .../proto/hostfrequencyscaling.proto | 27 + .../hostthermaldiscovery.go | 2 - .../hostthermaldiscovery.go~HEAD | 273 ++++++++++ 16 files changed, 1207 insertions(+), 33 deletions(-) create mode 100644 config/pipxe-child.yaml create mode 100644 extensions/HostFrequencyScaler/HostFrequencyScaler.go create mode 100644 extensions/HostFrequencyScaler/proto/HostFrequencyScaler.pb.go create mode 100644 extensions/HostFrequencyScaler/proto/HostFrequencyScaler.proto create mode 100644 modules/hostfrequencyscaling/hostfrequencyscaling.go create mode 100644 modules/hostfrequencyscaling/proto/hostfrequencyscaling.pb.go create mode 100644 modules/hostfrequencyscaling/proto/hostfrequencyscaling.proto create mode 100644 modules/hostthermaldiscovery/hostthermaldiscovery.go~HEAD diff --git a/config/pipxe-child.yaml b/config/pipxe-child.yaml new file mode 100644 index 000000000..1bf287b73 --- /dev/null +++ b/config/pipxe-child.yaml @@ -0,0 +1,25 @@ +# kraken-build.go: describes a build for a BitScope Raspberry Pi cluster +targets: + 'linux-arm64': # this identifies the build, will be appended to the binary name + os: 'linux' # os must match a supported GOOS + arch: 'arm64' # arch must match a supported GOARCH + 'linux-amd64': + os: 'linux' + arch: 'amd64' + 'darwin-amd64': + os: 'darwin' + arch: 'amd64' + +# included extensions +extensions: + - github.com/hpc/kraken/extensions/IPv4 + - github.com/hpc/kraken/extensions/RPi3 + - github.com/hpc/kraken/extensions/HostThermal + - github.com/hpc/kraken/extensions/HostFrequencyScaler +# included modules +modules: + - github.com/hpc/kraken/modules/restapi + - github.com/hpc/kraken/modules/rfpipower + - github.com/hpc/kraken/modules/pipxe + - github.com/hpc/kraken/modules/hostthermaldiscovery + - github.com/hpc/kraken/modules/hostfrequencyscaling diff --git a/config/pipxe.yaml b/config/pipxe.yaml index d6d5febd4..8a6311bca 100644 --- a/config/pipxe.yaml +++ b/config/pipxe.yaml @@ -15,6 +15,7 @@ extensions: - github.com/hpc/kraken/extensions/IPv4 - github.com/hpc/kraken/extensions/RPi3 - github.com/hpc/kraken/extensions/HostThermal + - github.com/hpc/kraken/extensions/RFAggregatorServer # included modules modules: - github.com/hpc/kraken/modules/restapi diff --git a/core/Node.go b/core/Node.go index 05f9c214a..e20d32081 100644 --- a/core/Node.go +++ b/core/Node.go @@ -14,6 +14,7 @@ package core import ( "fmt" + "log" "reflect" "sync" @@ -386,6 +387,8 @@ func (n *Node) Diff(node lib.Node, prefix string) (r []string, e error) { r, e = lib.MessageDiff(n.pb, m.pb, prefix) + log.Printf("node: %s r: %v eright: %v eleft: %v", node.ID().String(), r, eright, eleft) + // handle extensions for _, u := range eright { nodeExt, ok := m.exts[u] @@ -406,6 +409,8 @@ func (n *Node) Diff(node lib.Node, prefix string) (r []string, e error) { r = append(r, fmt.Sprintf("%s%s", prefix, u)) } + log.Printf("node: %s r after extensions: %v", node.ID().String(), r) + // handle services prefix = lib.URLPush(prefix, "Services") for _, u := range sright { diff --git a/core/StateMutationEngine.go b/core/StateMutationEngine.go index 59df8566d..e9f3dfafa 100644 --- a/core/StateMutationEngine.go +++ b/core/StateMutationEngine.go @@ -1338,7 +1338,6 @@ func (sme *StateMutationEngine) startNewMutation(node string) { // we need to hold the path mutex for the rest of this function p.mutex.Lock() defer p.mutex.Unlock() - sme.activeMutex.Lock() sme.active[node] = p sme.activeMutex.Unlock() @@ -1626,6 +1625,7 @@ func (sme *StateMutationEngine) updateMutation(node string, url string, val refl sme.Log(ERROR, e.Error()) return } + sme.log.Logf(lib.LLDEBUG, "(node: %v) sme got value from url: %v", node, val) // this is a discovery on a completed chain if m.cur >= len(m.chain) { diff --git a/core/StateSyncEngine.go b/core/StateSyncEngine.go index 72a648dea..bbd190c54 100644 --- a/core/StateSyncEngine.go +++ b/core/StateSyncEngine.go @@ -486,6 +486,7 @@ func (sse *StateSyncEngine) binaryToNode(buf []byte) (rp recvPacket, e error) { func (sse *StateSyncEngine) send(n *stateSyncNeighbor) { node, e := sse.query.Read(n.getID()) + sse.Logf(lib.LLDEBUG, "sending hello packet: \n%v", string(node.JSON())) if e != nil { sse.Logf(ERROR, "couldn't get node info, deleting from pool: %v", e) sse.delNeighbor(n.getID()) @@ -691,7 +692,7 @@ func (sse *StateSyncEngine) sync(n *stateSyncNeighbor) { } } if n.due() { - sse.Logf(DEBUG, "sending hello: %s", n.getID().String()) + sse.Logf(DEBUG, "sending hello to: %s", n.getID().String()) sse.send(n) sse.sortQueue() } @@ -726,7 +727,7 @@ func (sse *StateSyncEngine) processRecv(rp recvPacket) { } n.recv() sse.sortQueue() - sse.Logf(DEBUG, "got a hello from: %s", rp.From.String()) + sse.Logf(DEBUG, "got a hello from: %s\n%v", rp.From.String(), string(rp.Node.JSON())) if n.getParent() { _, e := sse.query.Update(rp.Node) if e != nil { diff --git a/extensions/HostFrequencyScaler/HostFrequencyScaler.go b/extensions/HostFrequencyScaler/HostFrequencyScaler.go new file mode 100644 index 000000000..810de2f02 --- /dev/null +++ b/extensions/HostFrequencyScaler/HostFrequencyScaler.go @@ -0,0 +1,32 @@ +package hostfrequencyscaler + +import ( + "github.com/golang/protobuf/proto" + "github.com/golang/protobuf/ptypes" + "github.com/hpc/kraken/core" + pb "github.com/hpc/kraken/extensions/HostFrequencyScaler/proto" + "github.com/hpc/kraken/lib" +) + +//go:generate protoc -I ../../core/proto/include -I proto --go_out=plugins=grpc:proto proto/RFAggregatorServer.proto + +///////////////// +// RFAggregatorServer Object / +/////////////// + +var _ lib.Extension = HostFrequencyScaler{} + +type HostFrequencyScaler struct{} + +func (HostFrequencyScaler) New() proto.Message { + return &pb.HostFrequencyScaler{} +} + +func (r HostFrequencyScaler) Name() string { + a, _ := ptypes.MarshalAny(r.New()) + return a.GetTypeUrl() +} + +func init() { + core.Registry.RegisterExtension(HostFrequencyScaler{}) +} diff --git a/extensions/HostFrequencyScaler/proto/HostFrequencyScaler.pb.go b/extensions/HostFrequencyScaler/proto/HostFrequencyScaler.pb.go new file mode 100644 index 000000000..a80c62a05 --- /dev/null +++ b/extensions/HostFrequencyScaler/proto/HostFrequencyScaler.pb.go @@ -0,0 +1,85 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// source: HostFrequencyScaler.proto + +package proto + +import proto "github.com/golang/protobuf/proto" +import fmt "fmt" +import math "math" + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package + +type HostFrequencyScaler struct { + BoottimeFreqScaler string `protobuf:"bytes,1,opt,name=boottime_freq_scaler,json=boottimeFreqScaler,proto3" json:"boottime_freq_scaler,omitempty"` + HightoLowFreqScaler string `protobuf:"bytes,2,opt,name=highto_low_freq_scaler,json=hightoLowFreqScaler,proto3" json:"highto_low_freq_scaler,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *HostFrequencyScaler) Reset() { *m = HostFrequencyScaler{} } +func (m *HostFrequencyScaler) String() string { return proto.CompactTextString(m) } +func (*HostFrequencyScaler) ProtoMessage() {} +func (*HostFrequencyScaler) Descriptor() ([]byte, []int) { + return fileDescriptor_HostFrequencyScaler_08eca2dad8c675e8, []int{0} +} +func (m *HostFrequencyScaler) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_HostFrequencyScaler.Unmarshal(m, b) +} +func (m *HostFrequencyScaler) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_HostFrequencyScaler.Marshal(b, m, deterministic) +} +func (dst *HostFrequencyScaler) XXX_Merge(src proto.Message) { + xxx_messageInfo_HostFrequencyScaler.Merge(dst, src) +} +func (m *HostFrequencyScaler) XXX_Size() int { + return xxx_messageInfo_HostFrequencyScaler.Size(m) +} +func (m *HostFrequencyScaler) XXX_DiscardUnknown() { + xxx_messageInfo_HostFrequencyScaler.DiscardUnknown(m) +} + +var xxx_messageInfo_HostFrequencyScaler proto.InternalMessageInfo + +func (m *HostFrequencyScaler) GetBoottimeFreqScaler() string { + if m != nil { + return m.BoottimeFreqScaler + } + return "" +} + +func (m *HostFrequencyScaler) GetHightoLowFreqScaler() string { + if m != nil { + return m.HightoLowFreqScaler + } + return "" +} + +func init() { + proto.RegisterType((*HostFrequencyScaler)(nil), "proto.HostFrequencyScaler") +} + +func init() { + proto.RegisterFile("HostFrequencyScaler.proto", fileDescriptor_HostFrequencyScaler_08eca2dad8c675e8) +} + +var fileDescriptor_HostFrequencyScaler_08eca2dad8c675e8 = []byte{ + // 127 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0xf4, 0xc8, 0x2f, 0x2e, + 0x71, 0x2b, 0x4a, 0x2d, 0x2c, 0x4d, 0xcd, 0x4b, 0xae, 0x0c, 0x4e, 0x4e, 0xcc, 0x49, 0x2d, 0xd2, + 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x62, 0x05, 0x53, 0x4a, 0x35, 0x5c, 0xc2, 0x58, 0xd4, 0x08, + 0x19, 0x70, 0x89, 0x24, 0xe5, 0xe7, 0x97, 0x94, 0x64, 0xe6, 0xa6, 0xc6, 0xa7, 0x15, 0xa5, 0x16, + 0xc6, 0x17, 0x83, 0xc5, 0x25, 0x18, 0x15, 0x18, 0x35, 0x38, 0x83, 0x84, 0x60, 0x72, 0x20, 0x6d, + 0x50, 0x1d, 0xc6, 0x5c, 0x62, 0x19, 0x99, 0xe9, 0x19, 0x25, 0xf9, 0xf1, 0x39, 0xf9, 0xe5, 0x28, + 0x7a, 0x98, 0xc0, 0x7a, 0x84, 0x21, 0xb2, 0x3e, 0xf9, 0xe5, 0x08, 0x4d, 0x49, 0x6c, 0x60, 0x47, + 0x18, 0x03, 0x02, 0x00, 0x00, 0xff, 0xff, 0x30, 0x67, 0xe9, 0x0e, 0xa8, 0x00, 0x00, 0x00, +} diff --git a/extensions/HostFrequencyScaler/proto/HostFrequencyScaler.proto b/extensions/HostFrequencyScaler/proto/HostFrequencyScaler.proto new file mode 100644 index 000000000..3ca643708 --- /dev/null +++ b/extensions/HostFrequencyScaler/proto/HostFrequencyScaler.proto @@ -0,0 +1,17 @@ +/* HostFrequencyScaler.proto: describes host specific CPU frquency scaling policy objects + * + * Author: Ghazanfar Ali , Kevin Pelzel ;J. Lowell Wofford + * + * This software is open source software available under the BSD-3 license. + * Copyright (c) 2019, Triad National Security, LLC + * See LICENSE file for details. + */ + + syntax = "proto3"; + package proto; + +message HostFrequencyScaler { + string boottime_freq_scaler = 1; // host CPU frequency scaler at host boot time + string highto_low_freq_scaler = 2; // host CPU frequency scaler for reducing cpu frequency from high to low + +} \ No newline at end of file diff --git a/extensions/HostThermal/proto/HostThermal.pb.go b/extensions/HostThermal/proto/HostThermal.pb.go index 22319cfb9..e0d500a08 100644 --- a/extensions/HostThermal/proto/HostThermal.pb.go +++ b/extensions/HostThermal/proto/HostThermal.pb.go @@ -3,9 +3,13 @@ package proto -import proto "github.com/golang/protobuf/proto" -import fmt "fmt" -import math "math" +import ( + fmt "fmt" + + proto "github.com/golang/protobuf/proto" + + math "math" +) // Reference imports to suppress errors if they are not otherwise used. var _ = proto.Marshal @@ -22,29 +26,32 @@ type HostThermal_CPU_TEMP_STATE int32 const ( HostThermal_CPU_TEMP_NONE HostThermal_CPU_TEMP_STATE = 0 - HostThermal_CPU_TEMP_NORMAL HostThermal_CPU_TEMP_STATE = 1 - HostThermal_CPU_TEMP_HIGH HostThermal_CPU_TEMP_STATE = 2 - HostThermal_CPU_TEMP_CRITICAL HostThermal_CPU_TEMP_STATE = 3 + HostThermal_CPU_TEMP_UNKNOWN HostThermal_CPU_TEMP_STATE = 1 + HostThermal_CPU_TEMP_NORMAL HostThermal_CPU_TEMP_STATE = 2 + HostThermal_CPU_TEMP_HIGH HostThermal_CPU_TEMP_STATE = 3 + HostThermal_CPU_TEMP_CRITICAL HostThermal_CPU_TEMP_STATE = 4 ) var HostThermal_CPU_TEMP_STATE_name = map[int32]string{ 0: "CPU_TEMP_NONE", - 1: "CPU_TEMP_NORMAL", - 2: "CPU_TEMP_HIGH", - 3: "CPU_TEMP_CRITICAL", + 1: "CPU_TEMP_UNKNOWN", + 2: "CPU_TEMP_NORMAL", + 3: "CPU_TEMP_HIGH", + 4: "CPU_TEMP_CRITICAL", } var HostThermal_CPU_TEMP_STATE_value = map[string]int32{ "CPU_TEMP_NONE": 0, - "CPU_TEMP_NORMAL": 1, - "CPU_TEMP_HIGH": 2, - "CPU_TEMP_CRITICAL": 3, + "CPU_TEMP_UNKNOWN": 1, + "CPU_TEMP_NORMAL": 2, + "CPU_TEMP_HIGH": 3, + "CPU_TEMP_CRITICAL": 4, } func (x HostThermal_CPU_TEMP_STATE) String() string { return proto.EnumName(HostThermal_CPU_TEMP_STATE_name, int32(x)) } func (HostThermal_CPU_TEMP_STATE) EnumDescriptor() ([]byte, []int) { - return fileDescriptor_HostThermal_a0a9c7392ef05d23, []int{0, 0} + return fileDescriptor_HostThermal_35f6b383f163c199, []int{0, 0} } type HostThermal struct { @@ -58,7 +65,7 @@ func (m *HostThermal) Reset() { *m = HostThermal{} } func (m *HostThermal) String() string { return proto.CompactTextString(m) } func (*HostThermal) ProtoMessage() {} func (*HostThermal) Descriptor() ([]byte, []int) { - return fileDescriptor_HostThermal_a0a9c7392ef05d23, []int{0} + return fileDescriptor_HostThermal_35f6b383f163c199, []int{0} } func (m *HostThermal) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_HostThermal.Unmarshal(m, b) @@ -90,18 +97,19 @@ func init() { proto.RegisterEnum("proto.HostThermal_CPU_TEMP_STATE", HostThermal_CPU_TEMP_STATE_name, HostThermal_CPU_TEMP_STATE_value) } -func init() { proto.RegisterFile("HostThermal.proto", fileDescriptor_HostThermal_a0a9c7392ef05d23) } +func init() { proto.RegisterFile("HostThermal.proto", fileDescriptor_HostThermal_35f6b383f163c199) } -var fileDescriptor_HostThermal_a0a9c7392ef05d23 = []byte{ - // 152 bytes of a gzipped FileDescriptorProto +var fileDescriptor_HostThermal_35f6b383f163c199 = []byte{ + // 167 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0xf4, 0xc8, 0x2f, 0x2e, 0x09, 0xc9, 0x48, 0x2d, 0xca, 0x4d, 0xcc, 0xd1, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x62, 0x05, - 0x53, 0x4a, 0xab, 0x18, 0xb9, 0xb8, 0x91, 0x24, 0x85, 0xcc, 0xb9, 0x58, 0x8b, 0x4b, 0x12, 0x4b, + 0x53, 0x4a, 0x07, 0x18, 0xb9, 0xb8, 0x91, 0x24, 0x85, 0xcc, 0xb9, 0x58, 0x8b, 0x4b, 0x12, 0x4b, 0x52, 0x25, 0x18, 0x15, 0x18, 0x35, 0xf8, 0x8c, 0x14, 0x21, 0xaa, 0xf5, 0x90, 0xf5, 0x3b, 0x07, 0x84, 0xc6, 0x87, 0xb8, 0xfa, 0x06, 0xc4, 0x07, 0x87, 0x38, 0x86, 0xb8, 0x06, 0x41, 0xd4, 0x2b, - 0x25, 0x71, 0xf1, 0xa1, 0x4a, 0x08, 0x09, 0x72, 0xf1, 0xc2, 0x45, 0xfc, 0xfc, 0xfd, 0x5c, 0x05, - 0x18, 0x84, 0x84, 0xb9, 0xf8, 0x91, 0x84, 0x82, 0x7c, 0x1d, 0x7d, 0x04, 0x18, 0x51, 0xd4, 0x79, - 0x78, 0xba, 0x7b, 0x08, 0x30, 0x09, 0x89, 0x72, 0x09, 0xc2, 0x85, 0x9c, 0x83, 0x3c, 0x43, 0x3c, - 0x9d, 0x1d, 0x7d, 0x04, 0x98, 0x93, 0xd8, 0xc0, 0x8e, 0x31, 0x06, 0x04, 0x00, 0x00, 0xff, 0xff, - 0x26, 0x83, 0x23, 0x81, 0xcf, 0x00, 0x00, 0x00, + 0x55, 0x70, 0xf1, 0xa1, 0x4a, 0x08, 0x09, 0x72, 0xf1, 0xc2, 0x45, 0xfc, 0xfc, 0xfd, 0x5c, 0x05, + 0x18, 0x84, 0x44, 0xb8, 0x04, 0xe0, 0x42, 0xa1, 0x7e, 0xde, 0x7e, 0xfe, 0xe1, 0x7e, 0x02, 0x8c, + 0x42, 0xc2, 0x5c, 0xfc, 0x48, 0x0a, 0x83, 0x7c, 0x1d, 0x7d, 0x04, 0x98, 0x50, 0x74, 0x7b, 0x78, + 0xba, 0x7b, 0x08, 0x30, 0x0b, 0x89, 0x72, 0x09, 0xc2, 0x85, 0x9c, 0x83, 0x3c, 0x43, 0x3c, 0x9d, + 0x1d, 0x7d, 0x04, 0x58, 0x92, 0xd8, 0xc0, 0x4e, 0x34, 0x06, 0x04, 0x00, 0x00, 0xff, 0xff, 0x98, + 0x9f, 0x8b, 0x83, 0xe5, 0x00, 0x00, 0x00, } diff --git a/extensions/HostThermal/proto/HostThermal.proto b/extensions/HostThermal/proto/HostThermal.proto index 607114ae6..904cae482 100644 --- a/extensions/HostThermal/proto/HostThermal.proto +++ b/extensions/HostThermal/proto/HostThermal.proto @@ -13,10 +13,10 @@ message HostThermal { enum hostThermalState { CPU_TEMP_NONE = 0; - CPU_TEMP_NORMAL = 1; - CPU_TEMP_HIGH = 2; - CPU_TEMP_CRITICAL = 3; - //TEMP_WAIT = 1; // Thermal request sent to node + CPU_TEMP_UNKNOWN = 1; + CPU_TEMP_NORMAL = 2; + CPU_TEMP_HIGH = 3; + CPU_TEMP_CRITICAL = 4; } hostThermalState state = 1; diff --git a/kraken/main.go.tpl b/kraken/main.go.tpl index 575af6cfe..29f9a62e0 100644 --- a/kraken/main.go.tpl +++ b/kraken/main.go.tpl @@ -145,7 +145,7 @@ func main() { lib.Event_DISCOVERY, url, &core.DiscoveryEvent{ - ID: k.ID(), + ID: k.ID(), URL: url, ValueID: stateToVID[ds[d]], }, diff --git a/modules/hostfrequencyscaling/hostfrequencyscaling.go b/modules/hostfrequencyscaling/hostfrequencyscaling.go new file mode 100644 index 000000000..c84cabbff --- /dev/null +++ b/modules/hostfrequencyscaling/hostfrequencyscaling.go @@ -0,0 +1,514 @@ +/* hostfrequencyscaling.go: performs mutations related to scaling of CPU frequency to control CPU thermal conditions of HPC node using in-band mechanism. + * + * This module boots HPC nodes with "schedutil" scaling governor and whenever CPU temperature reaches to high (warning) condition, module mutates the scaling governor to "powersave". + * Current implementation handles critical CPU temperature same as high CPU temperature. + * + * Additionally, there are many other mutations intended for different use cases (e.g. switching back to "schedutil" after "powersave") are under considerations and investinations. + * + * Authors: Ghazanfar Ali, ghazanfar.ali@ttu.edu; Kevin Pelzel ; J. Lowell Wofford + * + * This software is open source software available under the BSD-3 license. + * Copyright (c) 2019, Triad National Security, LLC + * See LICENSE file for details. + */ + +package hostfrequencyscaling + +import ( + "fmt" + "io/ioutil" + "log" + "net" + "os" + "reflect" + "strings" + "time" + + "github.com/golang/protobuf/proto" + "github.com/golang/protobuf/ptypes" + "github.com/hpc/kraken/core" + cpb "github.com/hpc/kraken/core/proto" + hostthpb "github.com/hpc/kraken/extensions/HostThermal/proto" + rp3pb "github.com/hpc/kraken/extensions/RPi3/proto" + "github.com/hpc/kraken/lib" + pb "github.com/hpc/kraken/modules/hostfrequencyscaling/proto" +) + +// CPUPerfScalingReq is payload for RFAggregator API call +type CPUPerfScalingReq struct { + ScalingGovernor string `json:"scalinggovernor"` + ScalingMinFreq string `json:"scalingminfreq"` + ScalingMaxFreq string `json:"scalingmaxfreq"` + NodesAddressList []string `json:"nodesaddresslist,omitempty"` + Timeout int `json:"timeout,omitempty"` +} + +// CPUPerfScalingResp structure for API response from RFAggregator +type CPUPerfScalingResp struct { + TimeStamp time.Time `json:"timestamp"` + HostAddress string `json:"hostaddress"` + CurScalingGovernor string `json:"curscalinggovernor"` + ScalingMinFreq string `json:"scalingminfreq"` + ScalingMaxFreq string `json:"scalingmaxfreq"` + ScalingCurFreq string `json:"scalingcurfreq"` + + CPUCurFreq string `json:"cpucurfreq"` + CPUMinFreq string `json:"cpuminfreq"` + CPUMaxFreq string `json:"cpumaxfreq"` +} + +// CPUPerfScalingRespColl structure for collection of response +type CPUPerfScalingRespColl struct { + CPUPerfScalingRespCollection []CPUPerfScalingResp `json:"cpuperfscalingrespcollection"` +} + +const ( + // PxeURL refers to PXE object + pxeURL string = "type.googleapis.com/proto.RPi3/Pxe" + + // ModuleStateURL refers to module state + moduleStateURL string = "/Services/hostfrequencyscaling/State" + + // HostThermalStateURL points to Thermal extension + hostThermalStateURL string = "type.googleapis.com/proto.HostThermal/State" + + // NodeIPURL provides node IP address + nodeIPURL string = "type.googleapis.com/proto.IPv4OverEthernet/Ifaces/0/Ip/Ip" + + // hostBootFreqScalerURL provides URL for host frequency scaler at host boot time + hostBootFreqScalerURL string = "type.googleapis.com/proto.HostFrequencyScaler/BoottimeFreqScaler" + + // hostRuntimeFreqScalerURL provides URL for host frequency scaler at host run time + hostHightoLowFreqScalerURL string = "type.googleapis.com/proto.HostFrequencyScaler/HightoLowFreqScaler" + + // freqSensorPath holds frequency sensor path on pi node + freqSensorPath string = "/sys/devices/system/cpu/cpufreq/policy0/" +) + +// Structure for mutation defintion +type hfsmut struct { + f hostthpb.HostThermal_CPU_TEMP_STATE + t hostthpb.HostThermal_CPU_TEMP_STATE + reqs map[string]reflect.Value + timeout string + failTo string +} + +// Mutations supported by this module +var muts = map[string]hfsmut{ + "CPU_TEMP_NONEtoCPU_TEMP_UNKNOWN": { + f: hostthpb.HostThermal_CPU_TEMP_NONE, + t: hostthpb.HostThermal_CPU_TEMP_UNKNOWN, + reqs: reqs, + timeout: "60s", + failTo: hostthpb.HostThermal_CPU_TEMP_NONE.String(), + }, + + "CPU_TEMP_UNKNOWNtoCPU_TEMP_NORMAL": { + f: hostthpb.HostThermal_CPU_TEMP_UNKNOWN, + t: hostthpb.HostThermal_CPU_TEMP_NORMAL, + reqs: reqs, + timeout: "60s", + failTo: hostthpb.HostThermal_CPU_TEMP_UNKNOWN.String(), + }, + "CPU_TEMP_UNKNOWNtoCPU_TEMP_HIGH": { + f: hostthpb.HostThermal_CPU_TEMP_UNKNOWN, + t: hostthpb.HostThermal_CPU_TEMP_HIGH, + reqs: reqs, + timeout: "60s", + failTo: hostthpb.HostThermal_CPU_TEMP_UNKNOWN.String(), + }, + "CPU_TEMP_UNKNOWNtoCPU_TEMP_CRITICAL": { + f: hostthpb.HostThermal_CPU_TEMP_UNKNOWN, + t: hostthpb.HostThermal_CPU_TEMP_CRITICAL, + reqs: reqs, + timeout: "60s", + failTo: hostthpb.HostThermal_CPU_TEMP_UNKNOWN.String(), + }, + + "CPU_TEMP_NORMALtoCPU_TEMP_HIGH": { + f: hostthpb.HostThermal_CPU_TEMP_NORMAL, + t: hostthpb.HostThermal_CPU_TEMP_HIGH, + reqs: reqs, + timeout: "60s", + failTo: hostthpb.HostThermal_CPU_TEMP_NORMAL.String(), + }, + + "CPU_TEMP_HIGHtoCPU_TEMP_NORMAL": { + f: hostthpb.HostThermal_CPU_TEMP_HIGH, + t: hostthpb.HostThermal_CPU_TEMP_NORMAL, + reqs: reqs, + timeout: "60s", + failTo: hostthpb.HostThermal_CPU_TEMP_HIGH.String(), + }, + + "CPU_TEMP_HIGHtoCPU_TEMP_CRITICAL": { + f: hostthpb.HostThermal_CPU_TEMP_HIGH, + t: hostthpb.HostThermal_CPU_TEMP_CRITICAL, + reqs: reqs, + timeout: "60s", + failTo: hostthpb.HostThermal_CPU_TEMP_HIGH.String(), + }, + + "CPU_TEMP_CRITICALtoCPU_TEMP_HIGH": { + f: hostthpb.HostThermal_CPU_TEMP_CRITICAL, + t: hostthpb.HostThermal_CPU_TEMP_HIGH, + reqs: reqs, + timeout: "60s", + failTo: hostthpb.HostThermal_CPU_TEMP_CRITICAL.String(), + }, + + "CPU_TEMP_NORMALtoCPU_TEMP_CRITICAL": { + f: hostthpb.HostThermal_CPU_TEMP_NORMAL, + t: hostthpb.HostThermal_CPU_TEMP_CRITICAL, + reqs: reqs, + timeout: "60s", + failTo: hostthpb.HostThermal_CPU_TEMP_NORMAL.String(), + }, + + "CPU_TEMP_CRITICALtoCPU_TEMP_NORMAL": { + f: hostthpb.HostThermal_CPU_TEMP_CRITICAL, + t: hostthpb.HostThermal_CPU_TEMP_NORMAL, + reqs: reqs, + timeout: "60s", + failTo: hostthpb.HostThermal_CPU_TEMP_CRITICAL.String(), + }, +} + +// HFS provides rfcpufreqscaling module capabilities +type HFS struct { + api lib.APIClient + cfg *pb.HostFreqScalingConfig + + mchan <-chan lib.Event + dchan chan<- lib.Event +} + +var _ lib.Module = (*HFS)(nil) +var _ lib.ModuleWithConfig = (*HFS)(nil) +var _ lib.ModuleWithMutations = (*HFS)(nil) +var _ lib.ModuleWithDiscovery = (*HFS)(nil) +var _ lib.ModuleSelfService = (*HFS)(nil) + +// Name returns the FQDN of the module +func (*HFS) Name() string { return "github.com/hpc/kraken/modules/hostfrequencyscaling" } + +// NewConfig returns a fully initialized default config +func (*HFS) NewConfig() proto.Message { + r := &pb.HostFreqScalingConfig{ + FreqSensorUrl: freqSensorPath, + BoottimeFreqPolicy: hostBootFreqScalerURL, + HightoLowFreqPolicy: hostHightoLowFreqScalerURL, + + FreqScalPolicies: map[string]*pb.HostFreqScalingPolicy{ + "powersave": { + ScalingGovernor: "powersave", + ScalingMinFreq: "600000", + ScalingMaxFreq: "1200000", + NodeArch: "", + NodePlatform: "", + }, + "performance": { + ScalingGovernor: "performance", + ScalingMinFreq: "600000", + ScalingMaxFreq: "1200000", + NodeArch: "", + NodePlatform: "", + }, + "schedutil": { + ScalingGovernor: "schedutil", + ScalingMinFreq: "600000", + ScalingMaxFreq: "1200000", + NodeArch: "", + NodePlatform: "", + }, + }, + } + return r +} + +// UpdateConfig updates the running config +func (hfs *HFS) UpdateConfig(cfg proto.Message) (e error) { + if rcfg, ok := cfg.(*pb.HostFreqScalingConfig); ok { + hfs.cfg = rcfg + return + } + return fmt.Errorf("invalid config type") +} + +// ConfigURL gives the any resolver URL for the config +func (*HFS) ConfigURL() string { + cfg := &pb.HostFreqScalingConfig{} + any, _ := ptypes.MarshalAny(cfg) + return any.GetTypeUrl() +} + +// SetMutationChan sets the current mutation channel +// this is generally done by the API +func (hfs *HFS) SetMutationChan(c <-chan lib.Event) { hfs.mchan = c } + +// SetDiscoveryChan sets the current discovery channel +func (hfs *HFS) SetDiscoveryChan(d chan<- lib.Event) { hfs.dchan = d } + +// modify these if you want different requires for mutations +var reqs = map[string]reflect.Value{ + "/PhysState": reflect.ValueOf(cpb.Node_POWER_ON), + "/RunState": reflect.ValueOf(cpb.Node_SYNC), + ModuleStateURL: reflect.ValueOf(cpb.ServiceInstance_RUN), + PxeURL: reflect.ValueOf(rp3pb.RPi3_INIT), +} + +// modify this if you want excludes +var excs = map[string]reflect.Value{} + +// Init is used to intialize an executable module prior to entrypoint +func (hfs *HFS) Init(api lib.APIClient) { + hfs.api = api + //hfs.mutex = &sync.Mutex{} + // hfs.queue = make(map[string]map[string]NMut) + hfs.cfg = hfs.NewConfig().(*pb.HostFreqScalingConfig) +} + +// Stop should perform a graceful exit +func (hfs *HFS) Stop() { + os.Exit(0) +} + +func init() { + module := &HFS{} + mutations := make(map[string]lib.StateMutation) + discovers := make(map[string]map[string]reflect.Value) + hostThermDiscs := make(map[string]reflect.Value) + hostBootFreqScalerDiscs := make(map[string]reflect.Value) + hostHLFreqScalerDiscs := make(map[string]reflect.Value) + si := core.NewServiceInstance("hostfrequencyscaling", module.Name(), module.Entry, nil) + + hostThermDiscs[hostthpb.HostThermal_CPU_TEMP_NONE.String()] = reflect.ValueOf(hostthpb.HostThermal_CPU_TEMP_NONE) + hostThermDiscs[hostthpb.HostThermal_CPU_TEMP_UNKNOWN.String()] = reflect.ValueOf(hostthpb.HostThermal_CPU_TEMP_UNKNOWN) + hostThermDiscs[hostthpb.HostThermal_CPU_TEMP_NORMAL.String()] = reflect.ValueOf(hostthpb.HostThermal_CPU_TEMP_NORMAL) + hostThermDiscs[hostthpb.HostThermal_CPU_TEMP_HIGH.String()] = reflect.ValueOf(hostthpb.HostThermal_CPU_TEMP_HIGH) + hostThermDiscs[hostthpb.HostThermal_CPU_TEMP_CRITICAL.String()] = reflect.ValueOf(hostthpb.HostThermal_CPU_TEMP_CRITICAL) + + discovers[HostThermalStateURL] = hostThermDiscs + + discovers[ModuleStateURL] = map[string]reflect.Value{ + "RUN": reflect.ValueOf(cpb.ServiceInstance_RUN)} + + hostBootFreqScalerDiscs["powersave"] = reflect.ValueOf("powersave") + hostBootFreqScalerDiscs["schedutil"] = reflect.ValueOf("schedutil") + hostBootFreqScalerDiscs["performance"] = reflect.ValueOf("performance") + discovers[hostBootFreqScalerURL] = hostBootFreqScalerDiscs + + hostHLFreqScalerDiscs["powersave"] = reflect.ValueOf("powersave") + hostHLFreqScalerDiscs["schedutil"] = reflect.ValueOf("schedutil") + hostHLFreqScalerDiscs["performance"] = reflect.ValueOf("performance") + discovers[hostHightoLowFreqScalerURL] = hostHLFreqScalerDiscs + + for k, m := range muts { + dur, _ := time.ParseDuration(m.timeout) + mutations[k] = core.NewStateMutation( + map[string][2]reflect.Value{ + HostThermalStateURL: { + reflect.ValueOf(m.f), + reflect.ValueOf(m.t), + }, + }, + m.reqs, + excs, + lib.StateMutationContext_SELF, + dur, + [3]string{si.ID(), HostThermalStateURL, m.failTo}, + ) + } + + // Register it all + core.Registry.RegisterModule(module) + core.Registry.RegisterServiceInstance(module, map[string]lib.ServiceInstance{si.ID(): si}) + core.Registry.RegisterMutations(si, mutations) + core.Registry.RegisterDiscoverable(si, discovers) +} + +// Entry is the module's executable entrypoint +func (hfs *HFS) Entry() { + + url := lib.NodeURLJoin(hfs.api.Self().String(), ModuleStateURL) + ev := core.NewEvent( + lib.Event_DISCOVERY, + url, + &core.DiscoveryEvent{ + + URL: url, + ValueID: "RUN", + }, + ) + hfs.dchan <- ev + + for { + + select { + case m := <-hfs.mchan: + + go hfs.handleMutation(m) + break + + } + } +} + +func (hfs *HFS) handleMutation(m lib.Event) { + if m.Type() != lib.Event_STATE_MUTATION { + hfs.api.Log(lib.LLERROR, "got unexpected non-mutation event") + } + me := m.Data().(*core.MutationEvent) + + switch me.Type { + case core.MutationEvent_MUTATE: + + switch me.Mutation[1] { + case "CPU_TEMP_NONEtoCPU_TEMP_UNKNOWN": + url := lib.NodeURLJoin(me.NodeCfg.ID().String(), HostThermalStateURL) + ev := core.NewEvent( + lib.Event_DISCOVERY, + url, + &core.DiscoveryEvent{ + + URL: url, + ValueID: hostthpb.HostThermal_CPU_TEMP_UNKNOWN.String(), + }, + ) + hfs.dchan <- ev + + case "CPU_TEMP_UNKNOWNtoCPU_TEMP_NORMAL": + fallthrough + case "CPU_TEMP_CRITICALtoCPU_TEMP_NORMAL": + fallthrough + case "CPU_TEMP_HIGHtoCPU_TEMP_NORMAL": + hfs.mutateCPUFreq(me) + + default: + //REVERSE pp.api.Logf(lib.LLDEBUG, "unexpected event: %s", me.Mutation[1]) + } + } +} + +// aggregateHandler makes calls to aggregator for the given nodes with related mutation and frequecy scaling policy +func (hfs *HFS) mutateCPUFreq(me *core.MutationEvent) { + + bootFreqScalPolicy, e := me.NodeCfg.GetValue(hfs.cfg.GetBoottimeFreqPolicy()) + lowtoHighFreqScalPolicy, e := me.NodeCfg.GetValue(hfs.cfg.GetHightoLowFreqPolicy()) + bBoot := false + if e != nil { + hfs.api.Logf(lib.LLERROR, "problem getting agg name for node: %s", e.Error()) + } + + switch me.Mutation[1] { + case "CPU_TEMP_UNKNOWNtoCPU_TEMP_NORMAL": + bBoot = true + hfs.HostFrequencyScaling(me.NodeCfg, bootFreqScalPolicy.String(), bBoot) + break + case "CPU_TEMP_CRITICALtoCPU_TEMP_NORMAL": + hfs.HostFrequencyScaling(me.NodeCfg, lowtoHighFreqScalPolicy.String(), bBoot) + break + case "CPU_TEMP_HIGHtoCPU_TEMP_NORMAL": + hfs.HostFrequencyScaling(me.NodeCfg, lowtoHighFreqScalPolicy.String(), bBoot) + break + } + +} + +// HostFrequencyScaling scales CPU frequency according to given parameters +func (hfs *HFS) HostFrequencyScaling(node lib.Node, freqScalPolicy string, bBoot bool) { + + freqScalPolicies := hfs.cfg.GetFreqScalPolicies() + + scalingGovernor := freqScalPolicies[freqScalPolicy].GetScalingGovernor() + scalingMinFreq := freqScalPolicies[freqScalPolicy].GetScalingMinFreq() + scalingMaxFreq := freqScalPolicies[freqScalPolicy].GetScalingMaxFreq() + + basePath := hfs.cfg.GetFreqSensorUrl() //"/sys/devices/system/cpu/cpufreq/policy0/" + + // Set the CPU frequency scaling parameters + _ = ioutil.WriteFile(basePath+"scaling_governor", []byte(scalingGovernor), 0644) + _ = ioutil.WriteFile(basePath+"scaling_max_freq", []byte(scalingMaxFreq), 0644) + _ = ioutil.WriteFile(basePath+"scaling_min_freq", []byte(scalingMinFreq), 0644) + + // Get the CPU frequency scaling parameters + bscalingGovernor, _ := ioutil.ReadFile(basePath + "scaling_governor") + bscalingMaxFreq, _ := ioutil.ReadFile(basePath + "scaling_max_freq") + bscalingMinFreq, _ := ioutil.ReadFile(basePath + "scaling_min_freq") + + cpuCurFreq, _ := ioutil.ReadFile(basePath + "cpuinfo_cur_freq") + cpuMinFreq, _ := ioutil.ReadFile(basePath + "cpuinfo_min_freq") + cpuMaxFreq, _ := ioutil.ReadFile(basePath + "cpuinfo_max_freq") + scalingCurFreq, _ := ioutil.ReadFile(basePath + "scaling_cur_freq") + + fscalingGovernor := strings.TrimSuffix(string(bscalingGovernor), "\n") + + scalingMinFreqq := strings.TrimSuffix(string(bscalingMinFreq), "\n") + scalingMaxFreqq := strings.TrimSuffix(string(bscalingMaxFreq), "\n") + scalingCurFreqq := strings.TrimSuffix(string(scalingCurFreq), "\n") + cpuCurFreqq := strings.TrimSuffix(string(cpuCurFreq), "\n") + cpuMinFreqq := strings.TrimSuffix(string(cpuMinFreq), "\n") + cpuMaxFreqq := strings.TrimSuffix(string(cpuMaxFreq), "\n") + + hostIP := GetNodeIPAddress() + + currentScalingConfig := CPUPerfScalingResp{ + TimeStamp: time.Now(), + HostAddress: hostIP, + CurScalingGovernor: fscalingGovernor, + ScalingMinFreq: scalingMinFreqq, + ScalingMaxFreq: scalingMaxFreqq, + ScalingCurFreq: scalingCurFreqq, + + CPUCurFreq: cpuCurFreqq, + CPUMinFreq: cpuMinFreqq, + CPUMaxFreq: cpuMaxFreqq, + } + + if bBoot == true { + url := lib.NodeURLJoin(node.ID().String(), hostBootFreqScalerURL) + ev := core.NewEvent( + lib.Event_DISCOVERY, + url, + &core.DiscoveryEvent{ + URL: url, + ValueID: currentScalingConfig.CurScalingGovernor, + }, + ) + hfs.dchan <- ev + } else { + url := lib.NodeURLJoin(node.ID().String(), hostHightoLowFreqScalerURL) + ev := core.NewEvent( + lib.Event_DISCOVERY, + url, + &core.DiscoveryEvent{ + URL: url, + ValueID: currentScalingConfig.CurScalingGovernor, + }, + ) + hfs.dchan <- ev + } + +} + +// GetNodeIPAddress acquires node IP address +func GetNodeIPAddress() string { + + addrs, err := net.InterfaceAddrs() + if err != nil { + log.Fatalf("could not obtain host IP address: %v", err) + } + ip := "" + for _, a := range addrs { + if ipnet, ok := a.(*net.IPNet); ok && !ipnet.IP.IsLoopback() { + if ipnet.IP.To4() != nil { + ip = ipnet.IP.String() + break + } + } + } + + return ip + +} diff --git a/modules/hostfrequencyscaling/proto/hostfrequencyscaling.pb.go b/modules/hostfrequencyscaling/proto/hostfrequencyscaling.pb.go new file mode 100644 index 000000000..7958b4f22 --- /dev/null +++ b/modules/hostfrequencyscaling/proto/hostfrequencyscaling.pb.go @@ -0,0 +1,188 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// source: hostfrequencyscaling.proto + +package proto + +import proto "github.com/golang/protobuf/proto" +import fmt "fmt" +import math "math" + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package + +type HostFreqScalingConfig struct { + FreqScalPolicies map[string]*HostFreqScalingPolicy `protobuf:"bytes,1,rep,name=freq_scal_policies,json=freqScalPolicies,proto3" json:"freq_scal_policies,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` + FreqSensorUrl string `protobuf:"bytes,2,opt,name=freq_sensor_url,json=freqSensorUrl,proto3" json:"freq_sensor_url,omitempty"` + BoottimeFreqPolicy string `protobuf:"bytes,3,opt,name=boottime_freq_policy,json=boottimeFreqPolicy,proto3" json:"boottime_freq_policy,omitempty"` + HightoLowFreqPolicy string `protobuf:"bytes,4,opt,name=highto_low_freq_policy,json=hightoLowFreqPolicy,proto3" json:"highto_low_freq_policy,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *HostFreqScalingConfig) Reset() { *m = HostFreqScalingConfig{} } +func (m *HostFreqScalingConfig) String() string { return proto.CompactTextString(m) } +func (*HostFreqScalingConfig) ProtoMessage() {} +func (*HostFreqScalingConfig) Descriptor() ([]byte, []int) { + return fileDescriptor_hostfrequencyscaling_b448546a7ca3e39e, []int{0} +} +func (m *HostFreqScalingConfig) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_HostFreqScalingConfig.Unmarshal(m, b) +} +func (m *HostFreqScalingConfig) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_HostFreqScalingConfig.Marshal(b, m, deterministic) +} +func (dst *HostFreqScalingConfig) XXX_Merge(src proto.Message) { + xxx_messageInfo_HostFreqScalingConfig.Merge(dst, src) +} +func (m *HostFreqScalingConfig) XXX_Size() int { + return xxx_messageInfo_HostFreqScalingConfig.Size(m) +} +func (m *HostFreqScalingConfig) XXX_DiscardUnknown() { + xxx_messageInfo_HostFreqScalingConfig.DiscardUnknown(m) +} + +var xxx_messageInfo_HostFreqScalingConfig proto.InternalMessageInfo + +func (m *HostFreqScalingConfig) GetFreqScalPolicies() map[string]*HostFreqScalingPolicy { + if m != nil { + return m.FreqScalPolicies + } + return nil +} + +func (m *HostFreqScalingConfig) GetFreqSensorUrl() string { + if m != nil { + return m.FreqSensorUrl + } + return "" +} + +func (m *HostFreqScalingConfig) GetBoottimeFreqPolicy() string { + if m != nil { + return m.BoottimeFreqPolicy + } + return "" +} + +func (m *HostFreqScalingConfig) GetHightoLowFreqPolicy() string { + if m != nil { + return m.HightoLowFreqPolicy + } + return "" +} + +type HostFreqScalingPolicy struct { + ScalingGovernor string `protobuf:"bytes,1,opt,name=scaling_governor,json=scalingGovernor,proto3" json:"scaling_governor,omitempty"` + ScalingMinFreq string `protobuf:"bytes,2,opt,name=scaling_min_freq,json=scalingMinFreq,proto3" json:"scaling_min_freq,omitempty"` + ScalingMaxFreq string `protobuf:"bytes,3,opt,name=scaling_max_freq,json=scalingMaxFreq,proto3" json:"scaling_max_freq,omitempty"` + NodeArch string `protobuf:"bytes,4,opt,name=node_arch,json=nodeArch,proto3" json:"node_arch,omitempty"` + NodePlatform string `protobuf:"bytes,5,opt,name=node_platform,json=nodePlatform,proto3" json:"node_platform,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *HostFreqScalingPolicy) Reset() { *m = HostFreqScalingPolicy{} } +func (m *HostFreqScalingPolicy) String() string { return proto.CompactTextString(m) } +func (*HostFreqScalingPolicy) ProtoMessage() {} +func (*HostFreqScalingPolicy) Descriptor() ([]byte, []int) { + return fileDescriptor_hostfrequencyscaling_b448546a7ca3e39e, []int{1} +} +func (m *HostFreqScalingPolicy) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_HostFreqScalingPolicy.Unmarshal(m, b) +} +func (m *HostFreqScalingPolicy) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_HostFreqScalingPolicy.Marshal(b, m, deterministic) +} +func (dst *HostFreqScalingPolicy) XXX_Merge(src proto.Message) { + xxx_messageInfo_HostFreqScalingPolicy.Merge(dst, src) +} +func (m *HostFreqScalingPolicy) XXX_Size() int { + return xxx_messageInfo_HostFreqScalingPolicy.Size(m) +} +func (m *HostFreqScalingPolicy) XXX_DiscardUnknown() { + xxx_messageInfo_HostFreqScalingPolicy.DiscardUnknown(m) +} + +var xxx_messageInfo_HostFreqScalingPolicy proto.InternalMessageInfo + +func (m *HostFreqScalingPolicy) GetScalingGovernor() string { + if m != nil { + return m.ScalingGovernor + } + return "" +} + +func (m *HostFreqScalingPolicy) GetScalingMinFreq() string { + if m != nil { + return m.ScalingMinFreq + } + return "" +} + +func (m *HostFreqScalingPolicy) GetScalingMaxFreq() string { + if m != nil { + return m.ScalingMaxFreq + } + return "" +} + +func (m *HostFreqScalingPolicy) GetNodeArch() string { + if m != nil { + return m.NodeArch + } + return "" +} + +func (m *HostFreqScalingPolicy) GetNodePlatform() string { + if m != nil { + return m.NodePlatform + } + return "" +} + +func init() { + proto.RegisterType((*HostFreqScalingConfig)(nil), "proto.HostFreqScalingConfig") + proto.RegisterMapType((map[string]*HostFreqScalingPolicy)(nil), "proto.HostFreqScalingConfig.FreqScalPoliciesEntry") + proto.RegisterType((*HostFreqScalingPolicy)(nil), "proto.HostFreqScalingPolicy") +} + +func init() { + proto.RegisterFile("hostfrequencyscaling.proto", fileDescriptor_hostfrequencyscaling_b448546a7ca3e39e) +} + +var fileDescriptor_hostfrequencyscaling_b448546a7ca3e39e = []byte{ + // 353 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x91, 0x4d, 0x4f, 0xf2, 0x40, + 0x10, 0xc7, 0x53, 0xfa, 0xf0, 0xe4, 0x61, 0x79, 0x10, 0xb2, 0x8a, 0x69, 0xd0, 0x03, 0xc1, 0xc4, + 0xe0, 0x85, 0x98, 0x72, 0x31, 0xde, 0x8c, 0xf1, 0xe5, 0xa0, 0x09, 0xc1, 0x78, 0xae, 0xa5, 0x6e, + 0xdb, 0x8d, 0xcb, 0x0e, 0x6c, 0x97, 0x97, 0x7e, 0x53, 0xbf, 0x83, 0x5f, 0xc2, 0xec, 0xec, 0x12, + 0x82, 0x72, 0x6a, 0xf3, 0x9f, 0xdf, 0x6f, 0x66, 0x3a, 0x25, 0x9d, 0x1c, 0x0a, 0x9d, 0x2a, 0x36, + 0x5f, 0x30, 0x99, 0x94, 0x45, 0x12, 0x0b, 0x2e, 0xb3, 0xc1, 0x4c, 0x81, 0x06, 0x5a, 0xc5, 0x47, + 0xef, 0xab, 0x42, 0xda, 0x8f, 0x50, 0xe8, 0x7b, 0xc5, 0xe6, 0x2f, 0x16, 0xb8, 0x05, 0x99, 0xf2, + 0x8c, 0xbe, 0x11, 0x6a, 0xd4, 0xc8, 0x68, 0xd1, 0x0c, 0x04, 0x4f, 0x38, 0x2b, 0x02, 0xaf, 0xeb, + 0xf7, 0xeb, 0x61, 0x68, 0x9b, 0x0c, 0xf6, 0x9a, 0x83, 0x4d, 0x32, 0x72, 0xd2, 0x9d, 0xd4, 0xaa, + 0x1c, 0xb7, 0xd2, 0x1f, 0x31, 0x3d, 0x27, 0x4d, 0x3b, 0x81, 0xc9, 0x02, 0x54, 0xb4, 0x50, 0x22, + 0xa8, 0x74, 0xbd, 0x7e, 0x6d, 0xdc, 0x40, 0x14, 0xd3, 0x57, 0x25, 0xe8, 0x25, 0x39, 0x9a, 0x00, + 0x68, 0xcd, 0xa7, 0x2c, 0x42, 0x01, 0xb7, 0x29, 0x03, 0x1f, 0x61, 0xba, 0xa9, 0x99, 0xb1, 0xd8, + 0xbb, 0xa4, 0x43, 0x72, 0x9c, 0xf3, 0x2c, 0xd7, 0x10, 0x09, 0x58, 0xed, 0x38, 0x7f, 0xd0, 0x39, + 0xb4, 0xd5, 0x27, 0x58, 0x6d, 0xa5, 0x4e, 0x4c, 0xda, 0x7b, 0x37, 0xa7, 0x2d, 0xe2, 0x7f, 0xb0, + 0x32, 0xf0, 0x50, 0x35, 0xaf, 0x34, 0x24, 0xd5, 0x65, 0x2c, 0x16, 0x0c, 0xf7, 0xad, 0x87, 0xa7, + 0xfb, 0xcf, 0x61, 0xfb, 0x8e, 0x2d, 0x7a, 0x5d, 0xb9, 0xf2, 0x7a, 0x9f, 0xde, 0xaf, 0x6b, 0xbb, + 0x8d, 0x2f, 0x48, 0xcb, 0xfd, 0x9f, 0x28, 0x83, 0x25, 0x53, 0x12, 0x94, 0x1b, 0xd8, 0x74, 0xf9, + 0x83, 0x8b, 0x69, 0x7f, 0x8b, 0x4e, 0xb9, 0xc4, 0xaf, 0x73, 0x77, 0x3b, 0x70, 0xf9, 0x33, 0x97, + 0x66, 0xc2, 0x0e, 0x19, 0xaf, 0x2d, 0xe9, 0xef, 0x92, 0xf1, 0x1a, 0xc9, 0x13, 0x52, 0x93, 0xf0, + 0xce, 0xa2, 0x58, 0x25, 0xb9, 0xbb, 0xd1, 0x3f, 0x13, 0xdc, 0xa8, 0x24, 0xa7, 0x67, 0xa4, 0x81, + 0xc5, 0x99, 0x88, 0x75, 0x0a, 0x6a, 0x1a, 0x54, 0x11, 0xf8, 0x6f, 0xc2, 0x91, 0xcb, 0x26, 0x7f, + 0xf1, 0x04, 0xc3, 0xef, 0x00, 0x00, 0x00, 0xff, 0xff, 0xb8, 0xdb, 0xe4, 0xcf, 0x74, 0x02, 0x00, + 0x00, +} diff --git a/modules/hostfrequencyscaling/proto/hostfrequencyscaling.proto b/modules/hostfrequencyscaling/proto/hostfrequencyscaling.proto new file mode 100644 index 000000000..d840dea96 --- /dev/null +++ b/modules/hostfrequencyscaling/proto/hostfrequencyscaling.proto @@ -0,0 +1,27 @@ +/* hostfrequencyscaling.proto: describes the hostfrequencyscaling object + * + * Authors: Ghazanfar Ali ,Kevin Pelzel ; J. Lowell Wofford + * + * This software is open source software available under the BSD-3 license. + * Copyright (c) 2019, Triad National Security, LLC + * See LICENSE file for details. + */ + + syntax = "proto3"; + package proto; + + message HostFreqScalingConfig { + map freq_scal_policies = 1; + string freq_sensor_url = 2; + string boottime_freq_policy = 3; + string highto_low_freq_policy = 4; + +} + + message HostFreqScalingPolicy { + string scaling_governor = 1; + string scaling_min_freq = 2; + string scaling_max_freq = 3; + string node_arch = 4; + string node_platform = 5; +} \ No newline at end of file diff --git a/modules/hostthermaldiscovery/hostthermaldiscovery.go b/modules/hostthermaldiscovery/hostthermaldiscovery.go index 71c29e8c4..bbbc64005 100644 --- a/modules/hostthermaldiscovery/hostthermaldiscovery.go +++ b/modules/hostthermaldiscovery/hostthermaldiscovery.go @@ -7,8 +7,6 @@ * See LICENSE file for details. */ -//go:generate protoc -I ../../core/proto/include -I proto --go_out=plugins=grpc:proto proto/pxe.proto - package hostthermaldiscovery import ( diff --git a/modules/hostthermaldiscovery/hostthermaldiscovery.go~HEAD b/modules/hostthermaldiscovery/hostthermaldiscovery.go~HEAD new file mode 100644 index 000000000..71c29e8c4 --- /dev/null +++ b/modules/hostthermaldiscovery/hostthermaldiscovery.go~HEAD @@ -0,0 +1,273 @@ +/* HostThermalDiscovery.go: This module performs CPU Thermal discovery of HPC nodes through in-band (through OS) mechanism. + * + * Author: Ghazanfar Ali, ghazanfar.ali@ttu.edu; Kevin Pelzel ; J. Lowell Wofford + * + * This software is open source software available under the BSD-3 license. + * Copyright (c) 2018, Triad National Security, LLC + * See LICENSE file for details. + */ + +//go:generate protoc -I ../../core/proto/include -I proto --go_out=plugins=grpc:proto proto/pxe.proto + +package hostthermaldiscovery + +import ( + "fmt" + "io/ioutil" + "net" + "os" + "reflect" + "strconv" + "strings" + "time" + + "github.com/golang/protobuf/proto" + "github.com/golang/protobuf/ptypes" + "github.com/hpc/kraken/core" + cpb "github.com/hpc/kraken/core/proto" + thpb "github.com/hpc/kraken/extensions/HostThermal/proto" + "github.com/hpc/kraken/lib" + pb "github.com/hpc/kraken/modules/hostthermaldiscovery/proto" +) + +//CPUTempObj is strututure for node CPU temperature +type CPUTempObj struct { + TimeStamp time.Time + HostAddress string + CPUTemp int32 +} + +const ( + // HostThermalStateURL points to Thermal extension + HostThermalStateURL = "type.googleapis.com/proto.HostThermal/State" + // ModuleStateURL refers to module state + ModuleStateURL = "/Services/hostthermaldiscovery/State" +) + +var _ lib.Module = (*HostDisc)(nil) +var _ lib.ModuleWithConfig = (*HostDisc)(nil) +var _ lib.ModuleWithDiscovery = (*HostDisc)(nil) +var _ lib.ModuleSelfService = (*HostDisc)(nil) + +// HostDisc provides hostdiscovery module capabilities +type HostDisc struct { + prevTemp int32 + api lib.APIClient + cfg *pb.HostDiscoveryConfig + dchan chan<- lib.Event + pollTicker *time.Ticker +} + +// Name returns the FQDN of the module +func (*HostDisc) Name() string { return "github.com/hpc/kraken/modules/hostthermaldiscovery" } + +// NewConfig returns a fully initialized default config +func (*HostDisc) NewConfig() proto.Message { + r := &pb.HostDiscoveryConfig{ + PollingInterval: "10s", + TempSensorPath: "/sys/devices/virtual/thermal/thermal_zone0/temp", + ThermalThresholds: map[string]*pb.HostThermalThresholds{ + "CPUThermalThresholds": { + LowerNormal: 3000, + UpperNormal: 60000, + LowerHigh: 60000, + UpperHigh: 70000, + LowerCritical: 3000, + UpperCritical: 70000, + }, + }, + } + return r +} + +// UpdateConfig updates the running config +func (hostDisc *HostDisc) UpdateConfig(cfg proto.Message) (e error) { + if rcfg, ok := cfg.(*pb.HostDiscoveryConfig); ok { + hostDisc.cfg = rcfg + return + } + return fmt.Errorf("invalid config type") +} + +// ConfigURL gives the any resolver URL for the config +func (*HostDisc) ConfigURL() string { + cfg := &pb.HostDiscoveryConfig{} + any, _ := ptypes.MarshalAny(cfg) + return any.GetTypeUrl() +} + +// SetDiscoveryChan sets the current discovery channel +// this is generally done by the API +func (hostDisc *HostDisc) SetDiscoveryChan(c chan<- lib.Event) { hostDisc.dchan = c } + +func init() { + module := &HostDisc{} + discovers := make(map[string]map[string]reflect.Value) + hostThermDisc := make(map[string]reflect.Value) + + hostThermDisc[thpb.HostThermal_CPU_TEMP_NONE.String()] = reflect.ValueOf(thpb.HostThermal_CPU_TEMP_NONE) + hostThermDisc[thpb.HostThermal_CPU_TEMP_NORMAL.String()] = reflect.ValueOf(thpb.HostThermal_CPU_TEMP_NORMAL) + hostThermDisc[thpb.HostThermal_CPU_TEMP_HIGH.String()] = reflect.ValueOf(thpb.HostThermal_CPU_TEMP_HIGH) + hostThermDisc[thpb.HostThermal_CPU_TEMP_CRITICAL.String()] = reflect.ValueOf(thpb.HostThermal_CPU_TEMP_CRITICAL) + + discovers[HostThermalStateURL] = hostThermDisc + + discovers[ModuleStateURL] = map[string]reflect.Value{ + "RUN": reflect.ValueOf(cpb.ServiceInstance_RUN)} + + si := core.NewServiceInstance("hostthermaldiscovery", module.Name(), module.Entry, nil) + + // Register it all + core.Registry.RegisterModule(module) + core.Registry.RegisterServiceInstance(module, map[string]lib.ServiceInstance{si.ID(): si}) + core.Registry.RegisterDiscoverable(si, discovers) +} + +// Init is used to intialize an executable module prior to entrypoint +func (hostDisc *HostDisc) Init(api lib.APIClient) { + hostDisc.api = api + hostDisc.cfg = hostDisc.NewConfig().(*pb.HostDiscoveryConfig) +} + +// Stop should perform a graceful exit +func (hostDisc *HostDisc) Stop() { + os.Exit(0) +} + +// Entry is the module's executable entrypoint +func (hostDisc *HostDisc) Entry() { + url := lib.NodeURLJoin(hostDisc.api.Self().String(), ModuleStateURL) + ev := core.NewEvent( + lib.Event_DISCOVERY, + url, + &core.DiscoveryEvent{ + + URL: url, + ValueID: "RUN", + }, + ) + hostDisc.dchan <- ev + + // setup a ticker for polling discovery + dur, _ := time.ParseDuration(hostDisc.cfg.GetPollingInterval()) + hostDisc.pollTicker = time.NewTicker(dur) + + // main loop + for { + select { + case <-hostDisc.pollTicker.C: + go hostDisc.discoverHostCPUTemp() + break + } + } +} + +// discoverHostCPUTemp is used to acquire CPU thermal locally. +func (hostDisc *HostDisc) discoverHostCPUTemp() { + hostCPUTemp := hostDisc.GetCPUTemp() + if hostCPUTemp.CPUTemp == hostDisc.prevTemp { + // no change in temperature so no need to generate discovery event + return + } + hostDisc.prevTemp = hostCPUTemp.CPUTemp + + vid, _ := hostDisc.lambdaStateDiscovery(hostCPUTemp) + url := lib.NodeURLJoin(hostDisc.api.Self().String(), HostThermalStateURL) + + // Generating discovery event for CPU Thermal state + v := core.NewEvent( + lib.Event_DISCOVERY, + url, + &core.DiscoveryEvent{ + + URL: url, + ValueID: vid, + }, + ) + hostDisc.dchan <- v + +} + +// GetCPUTemp returns CPU temperature +func (hostDisc *HostDisc) GetCPUTemp() CPUTempObj { + + hostIP := hostDisc.GetNodeIPAddress() + + // Its a mockup CPU temperature + cpuTempObj := CPUTempObj{} + cpuTempObj.TimeStamp = time.Now() + cpuTempObj.HostAddress = hostIP + + tempVal := hostDisc.ReadCPUTemp() + cpuTempObj.CPUTemp = tempVal + + return cpuTempObj +} + +// ReadCPUTemp function reads the CPU thermal sensor +func (hostDisc *HostDisc) ReadCPUTemp() int32 { + + tempSensorPath := hostDisc.cfg.GetTempSensorPath() + + cpuTemp, err := ioutil.ReadFile(tempSensorPath) + if err != nil { + hostDisc.api.Logf(lib.LLERROR, "Reading CPU thermal sensor failed: %v", err) + return 0 + } + cpuTempInt, err := strconv.Atoi(strings.TrimSuffix(string(cpuTemp), "\n")) + + if err != nil { + hostDisc.api.Logf(lib.LLERROR, "String to Int conversion failed: %v", err) + return 0 + } + + return int32(cpuTempInt) +} + +// GetNodeIPAddress returns non local loop IP address +func (hostDisc *HostDisc) GetNodeIPAddress() string { + + addrs, err := net.InterfaceAddrs() + if err != nil { + hostDisc.api.Logf(lib.LLERROR, "Can not find network interfaces: %v", err) + } + ip := "" + for _, a := range addrs { + if ipnet, ok := a.(*net.IPNet); ok && !ipnet.IP.IsLoopback() { + if ipnet.IP.To4() != nil { + ip = ipnet.IP.String() + break + } else { + hostDisc.api.Logf(lib.LLERROR, "Can not format IP address") + } + } + } + + return ip +} + +// Discovers state of the CPU based on CPU temperature thresholds +func (hostDisc *HostDisc) lambdaStateDiscovery(v CPUTempObj) (string, int32) { + cpuTemp := v.CPUTemp + cpuTempState := thpb.HostThermal_CPU_TEMP_NONE + + cpuThermalThresholds := hostDisc.cfg.GetThermalThresholds() + lowerNormal := cpuThermalThresholds["CPUThermalThresholds"].GetLowerNormal() + upperNormal := cpuThermalThresholds["CPUThermalThresholds"].GetUpperNormal() + + lowerHigh := cpuThermalThresholds["CPUThermalThresholds"].GetLowerHigh() + upperHigh := cpuThermalThresholds["CPUThermalThresholds"].GetUpperHigh() + + lowerCritical := cpuThermalThresholds["CPUThermalThresholds"].GetLowerCritical() + upperCritical := cpuThermalThresholds["CPUThermalThresholds"].GetUpperCritical() + + if cpuTemp <= lowerCritical || cpuTemp >= upperCritical { + cpuTempState = thpb.HostThermal_CPU_TEMP_CRITICAL + } else if cpuTemp >= lowerHigh && cpuTemp < upperHigh { + cpuTempState = thpb.HostThermal_CPU_TEMP_HIGH + } else if cpuTemp > lowerNormal && cpuTemp < upperNormal { + cpuTempState = thpb.HostThermal_CPU_TEMP_NORMAL + } + return cpuTempState.String(), cpuTemp + +} From 08d7998454c7687b5e74b463b9cc8fe29be94f18 Mon Sep 17 00:00:00 2001 From: Ghazanfar Ali Date: Fri, 13 Dec 2019 18:01:56 -0700 Subject: [PATCH 04/87] adding cpuburn module in yaml file --- config/pipxe-child.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/config/pipxe-child.yaml b/config/pipxe-child.yaml index 1bf287b73..d58edd829 100644 --- a/config/pipxe-child.yaml +++ b/config/pipxe-child.yaml @@ -23,3 +23,5 @@ modules: - github.com/hpc/kraken/modules/pipxe - github.com/hpc/kraken/modules/hostthermaldiscovery - github.com/hpc/kraken/modules/hostfrequencyscaling + - github.com/hpc/kraken/modules/cpuburn + From 08c134a278e10351bca2189d74377b337670146d Mon Sep 17 00:00:00 2001 From: Ghazanfar Ali Date: Fri, 13 Dec 2019 18:46:18 -0700 Subject: [PATCH 05/87] error due to const name changes --- .../hostfrequencyscaling/hostfrequencyscaling.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/modules/hostfrequencyscaling/hostfrequencyscaling.go b/modules/hostfrequencyscaling/hostfrequencyscaling.go index c84cabbff..403c99b0a 100644 --- a/modules/hostfrequencyscaling/hostfrequencyscaling.go +++ b/modules/hostfrequencyscaling/hostfrequencyscaling.go @@ -254,8 +254,8 @@ func (hfs *HFS) SetDiscoveryChan(d chan<- lib.Event) { hfs.dchan = d } var reqs = map[string]reflect.Value{ "/PhysState": reflect.ValueOf(cpb.Node_POWER_ON), "/RunState": reflect.ValueOf(cpb.Node_SYNC), - ModuleStateURL: reflect.ValueOf(cpb.ServiceInstance_RUN), - PxeURL: reflect.ValueOf(rp3pb.RPi3_INIT), + moduleStateURL: reflect.ValueOf(cpb.ServiceInstance_RUN), + pxeURL: reflect.ValueOf(rp3pb.RPi3_INIT), } // modify this if you want excludes @@ -289,9 +289,9 @@ func init() { hostThermDiscs[hostthpb.HostThermal_CPU_TEMP_HIGH.String()] = reflect.ValueOf(hostthpb.HostThermal_CPU_TEMP_HIGH) hostThermDiscs[hostthpb.HostThermal_CPU_TEMP_CRITICAL.String()] = reflect.ValueOf(hostthpb.HostThermal_CPU_TEMP_CRITICAL) - discovers[HostThermalStateURL] = hostThermDiscs + discovers[hostThermalStateURL] = hostThermDiscs - discovers[ModuleStateURL] = map[string]reflect.Value{ + discovers[moduleStateURL] = map[string]reflect.Value{ "RUN": reflect.ValueOf(cpb.ServiceInstance_RUN)} hostBootFreqScalerDiscs["powersave"] = reflect.ValueOf("powersave") @@ -308,7 +308,7 @@ func init() { dur, _ := time.ParseDuration(m.timeout) mutations[k] = core.NewStateMutation( map[string][2]reflect.Value{ - HostThermalStateURL: { + hostThermalStateURL: { reflect.ValueOf(m.f), reflect.ValueOf(m.t), }, @@ -317,7 +317,7 @@ func init() { excs, lib.StateMutationContext_SELF, dur, - [3]string{si.ID(), HostThermalStateURL, m.failTo}, + [3]string{si.ID(), hostThermalStateURL, m.failTo}, ) } @@ -331,7 +331,7 @@ func init() { // Entry is the module's executable entrypoint func (hfs *HFS) Entry() { - url := lib.NodeURLJoin(hfs.api.Self().String(), ModuleStateURL) + url := lib.NodeURLJoin(hfs.api.Self().String(), moduleStateURL) ev := core.NewEvent( lib.Event_DISCOVERY, url, @@ -366,7 +366,7 @@ func (hfs *HFS) handleMutation(m lib.Event) { switch me.Mutation[1] { case "CPU_TEMP_NONEtoCPU_TEMP_UNKNOWN": - url := lib.NodeURLJoin(me.NodeCfg.ID().String(), HostThermalStateURL) + url := lib.NodeURLJoin(me.NodeCfg.ID().String(), hostThermalStateURL) ev := core.NewEvent( lib.Event_DISCOVERY, url, From 00e9b50cbb005b6a9cb9bab4441bd0f1c9a02e62 Mon Sep 17 00:00:00 2001 From: Ghazanfar Ali Date: Mon, 16 Dec 2019 11:48:01 -0700 Subject: [PATCH 06/87] Adds websocket --- config/pipxe-child.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/config/pipxe-child.yaml b/config/pipxe-child.yaml index d58edd829..6e36ec61c 100644 --- a/config/pipxe-child.yaml +++ b/config/pipxe-child.yaml @@ -24,4 +24,5 @@ modules: - github.com/hpc/kraken/modules/hostthermaldiscovery - github.com/hpc/kraken/modules/hostfrequencyscaling - github.com/hpc/kraken/modules/cpuburn + - github.com/hpc/kraken/modules/websocket From 330f481e610d7e3fa4c54752b774f7742dd89089 Mon Sep 17 00:00:00 2001 From: Ghazanfar Ali Date: Mon, 16 Dec 2019 14:48:04 -0700 Subject: [PATCH 07/87] revamping frequency scaling --- .../proto/HostFrequencyScaler.pb.go | 71 +++-- .../proto/HostFrequencyScaler.proto | 15 +- .../HostThermal/proto/HostThermal.pb.go | 84 +++--- .../HostThermal/proto/HostThermal.proto | 7 +- .../hostfrequencyscaling.go | 255 ++++++++-------- .../hostthermaldiscovery.go~HEAD | 273 ------------------ 6 files changed, 218 insertions(+), 487 deletions(-) delete mode 100644 modules/hostthermaldiscovery/hostthermaldiscovery.go~HEAD diff --git a/extensions/HostFrequencyScaler/proto/HostFrequencyScaler.pb.go b/extensions/HostFrequencyScaler/proto/HostFrequencyScaler.pb.go index a80c62a05..fc9116f26 100644 --- a/extensions/HostFrequencyScaler/proto/HostFrequencyScaler.pb.go +++ b/extensions/HostFrequencyScaler/proto/HostFrequencyScaler.pb.go @@ -18,19 +18,44 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package +type HostFrequencyScaler_ScalerState int32 + +const ( + HostFrequencyScaler_NONE HostFrequencyScaler_ScalerState = 0 + HostFrequencyScaler_POWER_SAVE HostFrequencyScaler_ScalerState = 1 + HostFrequencyScaler_PERFORMANCE HostFrequencyScaler_ScalerState = 2 +) + +var HostFrequencyScaler_ScalerState_name = map[int32]string{ + 0: "NONE", + 1: "POWER_SAVE", + 2: "PERFORMANCE", +} +var HostFrequencyScaler_ScalerState_value = map[string]int32{ + "NONE": 0, + "POWER_SAVE": 1, + "PERFORMANCE": 2, +} + +func (x HostFrequencyScaler_ScalerState) String() string { + return proto.EnumName(HostFrequencyScaler_ScalerState_name, int32(x)) +} +func (HostFrequencyScaler_ScalerState) EnumDescriptor() ([]byte, []int) { + return fileDescriptor_HostFrequencyScaler_2508640b1434a762, []int{0, 0} +} + type HostFrequencyScaler struct { - BoottimeFreqScaler string `protobuf:"bytes,1,opt,name=boottime_freq_scaler,json=boottimeFreqScaler,proto3" json:"boottime_freq_scaler,omitempty"` - HightoLowFreqScaler string `protobuf:"bytes,2,opt,name=highto_low_freq_scaler,json=hightoLowFreqScaler,proto3" json:"highto_low_freq_scaler,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` + State HostFrequencyScaler_ScalerState `protobuf:"varint,1,opt,name=state,proto3,enum=proto.HostFrequencyScaler_ScalerState" json:"state,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` } func (m *HostFrequencyScaler) Reset() { *m = HostFrequencyScaler{} } func (m *HostFrequencyScaler) String() string { return proto.CompactTextString(m) } func (*HostFrequencyScaler) ProtoMessage() {} func (*HostFrequencyScaler) Descriptor() ([]byte, []int) { - return fileDescriptor_HostFrequencyScaler_08eca2dad8c675e8, []int{0} + return fileDescriptor_HostFrequencyScaler_2508640b1434a762, []int{0} } func (m *HostFrequencyScaler) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_HostFrequencyScaler.Unmarshal(m, b) @@ -50,36 +75,32 @@ func (m *HostFrequencyScaler) XXX_DiscardUnknown() { var xxx_messageInfo_HostFrequencyScaler proto.InternalMessageInfo -func (m *HostFrequencyScaler) GetBoottimeFreqScaler() string { - if m != nil { - return m.BoottimeFreqScaler - } - return "" -} - -func (m *HostFrequencyScaler) GetHightoLowFreqScaler() string { +func (m *HostFrequencyScaler) GetState() HostFrequencyScaler_ScalerState { if m != nil { - return m.HightoLowFreqScaler + return m.State } - return "" + return HostFrequencyScaler_NONE } func init() { proto.RegisterType((*HostFrequencyScaler)(nil), "proto.HostFrequencyScaler") + proto.RegisterEnum("proto.HostFrequencyScaler_ScalerState", HostFrequencyScaler_ScalerState_name, HostFrequencyScaler_ScalerState_value) } func init() { - proto.RegisterFile("HostFrequencyScaler.proto", fileDescriptor_HostFrequencyScaler_08eca2dad8c675e8) + proto.RegisterFile("HostFrequencyScaler.proto", fileDescriptor_HostFrequencyScaler_2508640b1434a762) } -var fileDescriptor_HostFrequencyScaler_08eca2dad8c675e8 = []byte{ - // 127 bytes of a gzipped FileDescriptorProto +var fileDescriptor_HostFrequencyScaler_2508640b1434a762 = []byte{ + // 146 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0xf4, 0xc8, 0x2f, 0x2e, 0x71, 0x2b, 0x4a, 0x2d, 0x2c, 0x4d, 0xcd, 0x4b, 0xae, 0x0c, 0x4e, 0x4e, 0xcc, 0x49, 0x2d, 0xd2, - 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x62, 0x05, 0x53, 0x4a, 0x35, 0x5c, 0xc2, 0x58, 0xd4, 0x08, - 0x19, 0x70, 0x89, 0x24, 0xe5, 0xe7, 0x97, 0x94, 0x64, 0xe6, 0xa6, 0xc6, 0xa7, 0x15, 0xa5, 0x16, - 0xc6, 0x17, 0x83, 0xc5, 0x25, 0x18, 0x15, 0x18, 0x35, 0x38, 0x83, 0x84, 0x60, 0x72, 0x20, 0x6d, - 0x50, 0x1d, 0xc6, 0x5c, 0x62, 0x19, 0x99, 0xe9, 0x19, 0x25, 0xf9, 0xf1, 0x39, 0xf9, 0xe5, 0x28, - 0x7a, 0x98, 0xc0, 0x7a, 0x84, 0x21, 0xb2, 0x3e, 0xf9, 0xe5, 0x08, 0x4d, 0x49, 0x6c, 0x60, 0x47, - 0x18, 0x03, 0x02, 0x00, 0x00, 0xff, 0xff, 0x30, 0x67, 0xe9, 0x0e, 0xa8, 0x00, 0x00, 0x00, + 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x62, 0x05, 0x53, 0x4a, 0xbd, 0x8c, 0x5c, 0xc2, 0x58, 0x14, + 0x09, 0xd9, 0x70, 0xb1, 0x16, 0x97, 0x24, 0x96, 0xa4, 0x4a, 0x30, 0x2a, 0x30, 0x6a, 0xf0, 0x19, + 0xa9, 0x41, 0x74, 0xe9, 0x61, 0x33, 0x0f, 0x42, 0x05, 0x83, 0x54, 0x07, 0x41, 0x34, 0x29, 0x59, + 0x70, 0x71, 0x23, 0x89, 0x0a, 0x71, 0x70, 0xb1, 0xf8, 0xf9, 0xfb, 0xb9, 0x0a, 0x30, 0x08, 0xf1, + 0x71, 0x71, 0x05, 0xf8, 0x87, 0xbb, 0x06, 0xc5, 0x07, 0x3b, 0x86, 0xb9, 0x0a, 0x30, 0x0a, 0xf1, + 0x73, 0x71, 0x07, 0xb8, 0x06, 0xb9, 0xf9, 0x07, 0xf9, 0x3a, 0xfa, 0x39, 0xbb, 0x0a, 0x30, 0x25, + 0xb1, 0x81, 0xed, 0x31, 0x06, 0x04, 0x00, 0x00, 0xff, 0xff, 0xe5, 0xb5, 0xba, 0x7f, 0xba, 0x00, + 0x00, 0x00, } diff --git a/extensions/HostFrequencyScaler/proto/HostFrequencyScaler.proto b/extensions/HostFrequencyScaler/proto/HostFrequencyScaler.proto index 3ca643708..9ac331ecb 100644 --- a/extensions/HostFrequencyScaler/proto/HostFrequencyScaler.proto +++ b/extensions/HostFrequencyScaler/proto/HostFrequencyScaler.proto @@ -7,11 +7,16 @@ * See LICENSE file for details. */ - syntax = "proto3"; - package proto; +syntax = "proto3"; +package proto; -message HostFrequencyScaler { - string boottime_freq_scaler = 1; // host CPU frequency scaler at host boot time - string highto_low_freq_scaler = 2; // host CPU frequency scaler for reducing cpu frequency from high to low +message HostFrequencyScaler{ + enum ScalerState { + NONE = 0; + POWER_SAVE = 1; + PERFORMANCE = 2; + + } + ScalerState state = 1; } \ No newline at end of file diff --git a/extensions/HostThermal/proto/HostThermal.pb.go b/extensions/HostThermal/proto/HostThermal.pb.go index e0d500a08..9fbba10e5 100644 --- a/extensions/HostThermal/proto/HostThermal.pb.go +++ b/extensions/HostThermal/proto/HostThermal.pb.go @@ -3,13 +3,9 @@ package proto -import ( - fmt "fmt" - - proto "github.com/golang/protobuf/proto" - - math "math" -) +import proto "github.com/golang/protobuf/proto" +import fmt "fmt" +import math "math" // Reference imports to suppress errors if they are not otherwise used. var _ = proto.Marshal @@ -22,50 +18,47 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package -type HostThermal_CPU_TEMP_STATE int32 +type HostThermalHostThermalState int32 const ( - HostThermal_CPU_TEMP_NONE HostThermal_CPU_TEMP_STATE = 0 - HostThermal_CPU_TEMP_UNKNOWN HostThermal_CPU_TEMP_STATE = 1 - HostThermal_CPU_TEMP_NORMAL HostThermal_CPU_TEMP_STATE = 2 - HostThermal_CPU_TEMP_HIGH HostThermal_CPU_TEMP_STATE = 3 - HostThermal_CPU_TEMP_CRITICAL HostThermal_CPU_TEMP_STATE = 4 + HostThermal_CPU_TEMP_NONE HostThermalHostThermalState = 0 + HostThermal_CPU_TEMP_NORMAL HostThermalHostThermalState = 1 + HostThermal_CPU_TEMP_HIGH HostThermalHostThermalState = 2 + HostThermal_CPU_TEMP_CRITICAL HostThermalHostThermalState = 3 ) -var HostThermal_CPU_TEMP_STATE_name = map[int32]string{ +var HostThermalHostThermalState_name = map[int32]string{ 0: "CPU_TEMP_NONE", - 1: "CPU_TEMP_UNKNOWN", - 2: "CPU_TEMP_NORMAL", - 3: "CPU_TEMP_HIGH", - 4: "CPU_TEMP_CRITICAL", + 1: "CPU_TEMP_NORMAL", + 2: "CPU_TEMP_HIGH", + 3: "CPU_TEMP_CRITICAL", } -var HostThermal_CPU_TEMP_STATE_value = map[string]int32{ +var HostThermalHostThermalState_value = map[string]int32{ "CPU_TEMP_NONE": 0, - "CPU_TEMP_UNKNOWN": 1, - "CPU_TEMP_NORMAL": 2, - "CPU_TEMP_HIGH": 3, - "CPU_TEMP_CRITICAL": 4, + "CPU_TEMP_NORMAL": 1, + "CPU_TEMP_HIGH": 2, + "CPU_TEMP_CRITICAL": 3, } -func (x HostThermal_CPU_TEMP_STATE) String() string { - return proto.EnumName(HostThermal_CPU_TEMP_STATE_name, int32(x)) +func (x HostThermalHostThermalState) String() string { + return proto.EnumName(HostThermalHostThermalState_name, int32(x)) } -func (HostThermal_CPU_TEMP_STATE) EnumDescriptor() ([]byte, []int) { - return fileDescriptor_HostThermal_35f6b383f163c199, []int{0, 0} +func (HostThermalHostThermalState) EnumDescriptor() ([]byte, []int) { + return fileDescriptor_HostThermal_fc4818f237eb5d02, []int{0, 0} } type HostThermal struct { - State HostThermal_CPU_TEMP_STATE `protobuf:"varint,1,opt,name=state,proto3,enum=proto.HostThermal_CPU_TEMP_STATE" json:"state,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` + State HostThermalHostThermalState `protobuf:"varint,1,opt,name=state,proto3,enum=proto.HostThermalHostThermalState" json:"state,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` } func (m *HostThermal) Reset() { *m = HostThermal{} } func (m *HostThermal) String() string { return proto.CompactTextString(m) } func (*HostThermal) ProtoMessage() {} func (*HostThermal) Descriptor() ([]byte, []int) { - return fileDescriptor_HostThermal_35f6b383f163c199, []int{0} + return fileDescriptor_HostThermal_fc4818f237eb5d02, []int{0} } func (m *HostThermal) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_HostThermal.Unmarshal(m, b) @@ -85,7 +78,7 @@ func (m *HostThermal) XXX_DiscardUnknown() { var xxx_messageInfo_HostThermal proto.InternalMessageInfo -func (m *HostThermal) GetState() HostThermal_CPU_TEMP_STATE { +func (m *HostThermal) GetState() HostThermalHostThermalState { if m != nil { return m.State } @@ -94,22 +87,21 @@ func (m *HostThermal) GetState() HostThermal_CPU_TEMP_STATE { func init() { proto.RegisterType((*HostThermal)(nil), "proto.HostThermal") - proto.RegisterEnum("proto.HostThermal_CPU_TEMP_STATE", HostThermal_CPU_TEMP_STATE_name, HostThermal_CPU_TEMP_STATE_value) + proto.RegisterEnum("proto.HostThermalHostThermalState", HostThermalHostThermalState_name, HostThermalHostThermalState_value) } -func init() { proto.RegisterFile("HostThermal.proto", fileDescriptor_HostThermal_35f6b383f163c199) } +func init() { proto.RegisterFile("HostThermal.proto", fileDescriptor_HostThermal_fc4818f237eb5d02) } -var fileDescriptor_HostThermal_35f6b383f163c199 = []byte{ - // 167 bytes of a gzipped FileDescriptorProto +var fileDescriptor_HostThermal_fc4818f237eb5d02 = []byte{ + // 151 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0xf4, 0xc8, 0x2f, 0x2e, 0x09, 0xc9, 0x48, 0x2d, 0xca, 0x4d, 0xcc, 0xd1, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x62, 0x05, - 0x53, 0x4a, 0x07, 0x18, 0xb9, 0xb8, 0x91, 0x24, 0x85, 0xcc, 0xb9, 0x58, 0x8b, 0x4b, 0x12, 0x4b, - 0x52, 0x25, 0x18, 0x15, 0x18, 0x35, 0xf8, 0x8c, 0x14, 0x21, 0xaa, 0xf5, 0x90, 0xf5, 0x3b, 0x07, - 0x84, 0xc6, 0x87, 0xb8, 0xfa, 0x06, 0xc4, 0x07, 0x87, 0x38, 0x86, 0xb8, 0x06, 0x41, 0xd4, 0x2b, - 0x55, 0x70, 0xf1, 0xa1, 0x4a, 0x08, 0x09, 0x72, 0xf1, 0xc2, 0x45, 0xfc, 0xfc, 0xfd, 0x5c, 0x05, - 0x18, 0x84, 0x44, 0xb8, 0x04, 0xe0, 0x42, 0xa1, 0x7e, 0xde, 0x7e, 0xfe, 0xe1, 0x7e, 0x02, 0x8c, - 0x42, 0xc2, 0x5c, 0xfc, 0x48, 0x0a, 0x83, 0x7c, 0x1d, 0x7d, 0x04, 0x98, 0x50, 0x74, 0x7b, 0x78, - 0xba, 0x7b, 0x08, 0x30, 0x0b, 0x89, 0x72, 0x09, 0xc2, 0x85, 0x9c, 0x83, 0x3c, 0x43, 0x3c, 0x9d, - 0x1d, 0x7d, 0x04, 0x58, 0x92, 0xd8, 0xc0, 0x4e, 0x34, 0x06, 0x04, 0x00, 0x00, 0xff, 0xff, 0x98, - 0x9f, 0x8b, 0x83, 0xe5, 0x00, 0x00, 0x00, + 0x53, 0x4a, 0xeb, 0x18, 0xb9, 0xb8, 0x91, 0x24, 0x85, 0x2c, 0xb9, 0x58, 0x8b, 0x4b, 0x12, 0x4b, + 0x52, 0x25, 0x18, 0x15, 0x18, 0x35, 0xf8, 0x8c, 0x94, 0x21, 0xaa, 0xf5, 0x90, 0xf5, 0x67, 0x20, + 0xd8, 0xc1, 0x20, 0xa5, 0x41, 0x10, 0x1d, 0x4a, 0x29, 0x5c, 0x02, 0xe8, 0x52, 0x42, 0x82, 0x5c, + 0xbc, 0xce, 0x01, 0xa1, 0xf1, 0x21, 0xae, 0xbe, 0x01, 0xf1, 0x7e, 0xfe, 0x7e, 0xae, 0x02, 0x0c, + 0x42, 0xc2, 0x5c, 0xfc, 0x48, 0x42, 0x41, 0xbe, 0x8e, 0x3e, 0x02, 0x8c, 0x28, 0xea, 0x3c, 0x3c, + 0xdd, 0x3d, 0x04, 0x98, 0x84, 0x44, 0xb9, 0x04, 0xe1, 0x42, 0xce, 0x41, 0x9e, 0x21, 0x9e, 0xce, + 0x8e, 0x3e, 0x02, 0xcc, 0x49, 0x6c, 0x60, 0x07, 0x19, 0x03, 0x02, 0x00, 0x00, 0xff, 0xff, 0x53, + 0xaa, 0x23, 0xc0, 0xd3, 0x00, 0x00, 0x00, } diff --git a/extensions/HostThermal/proto/HostThermal.proto b/extensions/HostThermal/proto/HostThermal.proto index 904cae482..64fc95133 100644 --- a/extensions/HostThermal/proto/HostThermal.proto +++ b/extensions/HostThermal/proto/HostThermal.proto @@ -13,10 +13,9 @@ message HostThermal { enum hostThermalState { CPU_TEMP_NONE = 0; - CPU_TEMP_UNKNOWN = 1; - CPU_TEMP_NORMAL = 2; - CPU_TEMP_HIGH = 3; - CPU_TEMP_CRITICAL = 4; + CPU_TEMP_NORMAL = 1; + CPU_TEMP_HIGH = 2; + CPU_TEMP_CRITICAL = 3; } hostThermalState state = 1; diff --git a/modules/hostfrequencyscaling/hostfrequencyscaling.go b/modules/hostfrequencyscaling/hostfrequencyscaling.go index 403c99b0a..8d6e2a301 100644 --- a/modules/hostfrequencyscaling/hostfrequencyscaling.go +++ b/modules/hostfrequencyscaling/hostfrequencyscaling.go @@ -28,6 +28,7 @@ import ( "github.com/golang/protobuf/ptypes" "github.com/hpc/kraken/core" cpb "github.com/hpc/kraken/core/proto" + scalpb "github.com/hpc/kraken/extensions/HostFrequencyScaler/proto" hostthpb "github.com/hpc/kraken/extensions/HostThermal/proto" rp3pb "github.com/hpc/kraken/extensions/RPi3/proto" "github.com/hpc/kraken/lib" @@ -75,16 +76,61 @@ const ( // NodeIPURL provides node IP address nodeIPURL string = "type.googleapis.com/proto.IPv4OverEthernet/Ifaces/0/Ip/Ip" - // hostBootFreqScalerURL provides URL for host frequency scaler at host boot time - hostBootFreqScalerURL string = "type.googleapis.com/proto.HostFrequencyScaler/BoottimeFreqScaler" - - // hostRuntimeFreqScalerURL provides URL for host frequency scaler at host run time - hostHightoLowFreqScalerURL string = "type.googleapis.com/proto.HostFrequencyScaler/HightoLowFreqScaler" + // hostFreqScalerURL provides URL for host frequency scaler at host run time + hostFreqScalerURL string = "type.googleapis.com/proto.HostFrequencyScaler/State" // freqSensorPath holds frequency sensor path on pi node freqSensorPath string = "/sys/devices/system/cpu/cpufreq/policy0/" ) +type hfscalmut struct { + f scalpb.HostFrequencyScaler_ScalerState + t scalpb.HostFrequencyScaler_ScalerState + reqs map[string]reflect.Value + timeout string + failTo string +} +// modify these if you want different requires for mutations +var scalerReqs = map[string]reflect.Value{ + "/PhysState": reflect.ValueOf(cpb.Node_POWER_ON), + "/RunState": reflect.ValueOf(cpb.Node_SYNC), + moduleStateURL: reflect.ValueOf(cpb.ServiceInstance_RUN), +} +var scalMuts = map[string]hfscalmut{ + "NONEtoPOWERSAVE": { + f: scalpb.HostFrequencyScaler_NONE, + t: scalpb.HostFrequencyScaler_POWER_SAVE, + reqs: scalerReqs, + timeout: "60s", + failTo: scalpb.HostFrequencyScaler_NONE.String(), + }, + "PERFORMANCEtoPOWERSAVE": { + f: scalpb.HostFrequencyScaler_PERFORMANCE, + t: scalpb.HostFrequencyScaler_POWER_SAVE, + reqs: scalerReqs, + timeout: "60s", + failTo: scalpb.HostFrequencyScaler_PERFORMANCE.String(), + }, + "NONEtoPERFORMANCE": { + f: scalpb.HostFrequencyScaler_NONE, + t: scalpb.HostFrequencyScaler_POWER_SAVE, + reqs: scalerReqs, + timeout: "60s", + failTo: scalpb.HostThermal_CPU_TEMP_NONE.String(), + }, + "POWERSAVEtoPERFORMANCE": { + f: scalpb.HostFrequencyScaler_POWER_SAVE, + t: scalpb.HostFrequencyScaler_PERFORMANCE, + reqs: map[string]reflect.Value{ + "/PhysState": reflect.ValueOf(cpb.Node_POWER_ON), + "/RunState": reflect.ValueOf(cpb.Node_SYNC), + moduleStateURL: reflect.ValueOf(cpb.ServiceInstance_RUN), + hostThermalStateURL: reflect.ValueOf(hostthpb.HostThermal_CPU_TEMP_NORMAL), + }, + timeout: "60s", + failTo: scalpb.HostFrequencyScaler_POWER_SAVE.String(), + } +} // Structure for mutation defintion type hfsmut struct { f hostthpb.HostThermal_CPU_TEMP_STATE @@ -94,58 +140,22 @@ type hfsmut struct { failTo string } + // Mutations supported by this module var muts = map[string]hfsmut{ - "CPU_TEMP_NONEtoCPU_TEMP_UNKNOWN": { - f: hostthpb.HostThermal_CPU_TEMP_NONE, - t: hostthpb.HostThermal_CPU_TEMP_UNKNOWN, - reqs: reqs, - timeout: "60s", - failTo: hostthpb.HostThermal_CPU_TEMP_NONE.String(), - }, - "CPU_TEMP_UNKNOWNtoCPU_TEMP_NORMAL": { - f: hostthpb.HostThermal_CPU_TEMP_UNKNOWN, + "CPU_TEMP_NONEtoCPU_TEMP_NORMAL": { + f: hostthpb.HostThermal_CPU_TEMP_NONE, t: hostthpb.HostThermal_CPU_TEMP_NORMAL, reqs: reqs, timeout: "60s", failTo: hostthpb.HostThermal_CPU_TEMP_UNKNOWN.String(), - }, - "CPU_TEMP_UNKNOWNtoCPU_TEMP_HIGH": { - f: hostthpb.HostThermal_CPU_TEMP_UNKNOWN, - t: hostthpb.HostThermal_CPU_TEMP_HIGH, - reqs: reqs, - timeout: "60s", - failTo: hostthpb.HostThermal_CPU_TEMP_UNKNOWN.String(), - }, - "CPU_TEMP_UNKNOWNtoCPU_TEMP_CRITICAL": { - f: hostthpb.HostThermal_CPU_TEMP_UNKNOWN, - t: hostthpb.HostThermal_CPU_TEMP_CRITICAL, - reqs: reqs, - timeout: "60s", - failTo: hostthpb.HostThermal_CPU_TEMP_UNKNOWN.String(), - }, - - "CPU_TEMP_NORMALtoCPU_TEMP_HIGH": { - f: hostthpb.HostThermal_CPU_TEMP_NORMAL, - t: hostthpb.HostThermal_CPU_TEMP_HIGH, - reqs: reqs, - timeout: "60s", - failTo: hostthpb.HostThermal_CPU_TEMP_NORMAL.String(), - }, - + }, + "CPU_TEMP_HIGHtoCPU_TEMP_NORMAL": { f: hostthpb.HostThermal_CPU_TEMP_HIGH, t: hostthpb.HostThermal_CPU_TEMP_NORMAL, - reqs: reqs, - timeout: "60s", - failTo: hostthpb.HostThermal_CPU_TEMP_HIGH.String(), - }, - - "CPU_TEMP_HIGHtoCPU_TEMP_CRITICAL": { - f: hostthpb.HostThermal_CPU_TEMP_HIGH, - t: hostthpb.HostThermal_CPU_TEMP_CRITICAL, - reqs: reqs, + reqs: greqs, timeout: "60s", failTo: hostthpb.HostThermal_CPU_TEMP_HIGH.String(), }, @@ -153,23 +163,18 @@ var muts = map[string]hfsmut{ "CPU_TEMP_CRITICALtoCPU_TEMP_HIGH": { f: hostthpb.HostThermal_CPU_TEMP_CRITICAL, t: hostthpb.HostThermal_CPU_TEMP_HIGH, - reqs: reqs, + reqs: greqs, timeout: "60s", failTo: hostthpb.HostThermal_CPU_TEMP_CRITICAL.String(), + }, - "CPU_TEMP_NORMALtoCPU_TEMP_CRITICAL": { - f: hostthpb.HostThermal_CPU_TEMP_NORMAL, - t: hostthpb.HostThermal_CPU_TEMP_CRITICAL, - reqs: reqs, - timeout: "60s", - failTo: hostthpb.HostThermal_CPU_TEMP_NORMAL.String(), - }, + "CPU_TEMP_CRITICALtoCPU_TEMP_NORMAL": { f: hostthpb.HostThermal_CPU_TEMP_CRITICAL, t: hostthpb.HostThermal_CPU_TEMP_NORMAL, - reqs: reqs, + reqs: greqs, timeout: "60s", failTo: hostthpb.HostThermal_CPU_TEMP_CRITICAL.String(), }, @@ -255,7 +260,13 @@ var reqs = map[string]reflect.Value{ "/PhysState": reflect.ValueOf(cpb.Node_POWER_ON), "/RunState": reflect.ValueOf(cpb.Node_SYNC), moduleStateURL: reflect.ValueOf(cpb.ServiceInstance_RUN), - pxeURL: reflect.ValueOf(rp3pb.RPi3_INIT), +} + +var greqs = map[string]reflect.Value{ + "/PhysState": reflect.ValueOf(cpb.Node_POWER_ON), + "/RunState": reflect.ValueOf(cpb.Node_SYNC), + moduleStateURL: reflect.ValueOf(cpb.ServiceInstance_RUN), + hostFreqScalerURL: reflect.ValueOf(scalpb.HostFrequencyScaler_POWER_SAVE), } // modify this if you want excludes @@ -278,9 +289,8 @@ func init() { module := &HFS{} mutations := make(map[string]lib.StateMutation) discovers := make(map[string]map[string]reflect.Value) + hostFreqScalerDiscs := make(map[string]reflect.Value) hostThermDiscs := make(map[string]reflect.Value) - hostBootFreqScalerDiscs := make(map[string]reflect.Value) - hostHLFreqScalerDiscs := make(map[string]reflect.Value) si := core.NewServiceInstance("hostfrequencyscaling", module.Name(), module.Entry, nil) hostThermDiscs[hostthpb.HostThermal_CPU_TEMP_NONE.String()] = reflect.ValueOf(hostthpb.HostThermal_CPU_TEMP_NONE) @@ -290,19 +300,13 @@ func init() { hostThermDiscs[hostthpb.HostThermal_CPU_TEMP_CRITICAL.String()] = reflect.ValueOf(hostthpb.HostThermal_CPU_TEMP_CRITICAL) discovers[hostThermalStateURL] = hostThermDiscs - discovers[moduleStateURL] = map[string]reflect.Value{ "RUN": reflect.ValueOf(cpb.ServiceInstance_RUN)} - hostBootFreqScalerDiscs["powersave"] = reflect.ValueOf("powersave") - hostBootFreqScalerDiscs["schedutil"] = reflect.ValueOf("schedutil") - hostBootFreqScalerDiscs["performance"] = reflect.ValueOf("performance") - discovers[hostBootFreqScalerURL] = hostBootFreqScalerDiscs - - hostHLFreqScalerDiscs["powersave"] = reflect.ValueOf("powersave") - hostHLFreqScalerDiscs["schedutil"] = reflect.ValueOf("schedutil") - hostHLFreqScalerDiscs["performance"] = reflect.ValueOf("performance") - discovers[hostHightoLowFreqScalerURL] = hostHLFreqScalerDiscs + hostFreqScalerDiscs[scalpb.HostFrequencyScaler_NONE.String()] = reflect.ValueOf(scalpb.HostFrequencyScaler_NONE) + hostFreqScalerDiscs[scalpb.HostFrequencyScaler_PERFORMANCE.String()] = reflect.ValueOf(scalpb.HostFrequencyScaler_PERFORMANCE) + hostFreqScalerDiscs[scalpb.HostFrequencyScaler_POWER_SAVE.String()] = reflect.ValueOf(scalpb.HostFrequencyScaler_POWER_SAVE) + discovers[hostFreqScalerURL] = hostFreqScalerDiscs for k, m := range muts { dur, _ := time.ParseDuration(m.timeout) @@ -321,6 +325,26 @@ func init() { ) } + for k, m := range scalMuts { + dur, _ := time.ParseDuration(m.timeout) + mutations[k] = core.NewStateMutation( + map[string][2]reflect.Value{ + hostFreqScalerURL: { + reflect.ValueOf(m.f), + reflect.ValueOf(m.t), + }, + }, + m.reqs, + excs, + lib.StateMutationContext_SELF, + dur, + [3]string{si.ID(), hostFreqScalerURL, m.failTo}, + ) + } + + + + // Register it all core.Registry.RegisterModule(module) core.Registry.RegisterServiceInstance(module, map[string]lib.ServiceInstance{si.ID(): si}) @@ -348,76 +372,39 @@ func (hfs *HFS) Entry() { select { case m := <-hfs.mchan: - go hfs.handleMutation(m) + go hfs.mutateCPUFreq(m) break } } } -func (hfs *HFS) handleMutation(m lib.Event) { +// aggregateHandler makes calls to aggregator for the given nodes with related mutation and frequecy scaling policy +func (hfs *HFS) mutateCPUFreq(m lib.Event) { + if m.Type() != lib.Event_STATE_MUTATION { hfs.api.Log(lib.LLERROR, "got unexpected non-mutation event") + return } me := m.Data().(*core.MutationEvent) - switch me.Type { - case core.MutationEvent_MUTATE: - - switch me.Mutation[1] { - case "CPU_TEMP_NONEtoCPU_TEMP_UNKNOWN": - url := lib.NodeURLJoin(me.NodeCfg.ID().String(), hostThermalStateURL) - ev := core.NewEvent( - lib.Event_DISCOVERY, - url, - &core.DiscoveryEvent{ - - URL: url, - ValueID: hostthpb.HostThermal_CPU_TEMP_UNKNOWN.String(), - }, - ) - hfs.dchan <- ev - - case "CPU_TEMP_UNKNOWNtoCPU_TEMP_NORMAL": - fallthrough - case "CPU_TEMP_CRITICALtoCPU_TEMP_NORMAL": - fallthrough - case "CPU_TEMP_HIGHtoCPU_TEMP_NORMAL": - hfs.mutateCPUFreq(me) - - default: - //REVERSE pp.api.Logf(lib.LLDEBUG, "unexpected event: %s", me.Mutation[1]) - } - } -} - -// aggregateHandler makes calls to aggregator for the given nodes with related mutation and frequecy scaling policy -func (hfs *HFS) mutateCPUFreq(me *core.MutationEvent) { - - bootFreqScalPolicy, e := me.NodeCfg.GetValue(hfs.cfg.GetBoottimeFreqPolicy()) - lowtoHighFreqScalPolicy, e := me.NodeCfg.GetValue(hfs.cfg.GetHightoLowFreqPolicy()) - bBoot := false - if e != nil { - hfs.api.Logf(lib.LLERROR, "problem getting agg name for node: %s", e.Error()) - } - switch me.Mutation[1] { - case "CPU_TEMP_UNKNOWNtoCPU_TEMP_NORMAL": - bBoot = true - hfs.HostFrequencyScaling(me.NodeCfg, bootFreqScalPolicy.String(), bBoot) - break - case "CPU_TEMP_CRITICALtoCPU_TEMP_NORMAL": - hfs.HostFrequencyScaling(me.NodeCfg, lowtoHighFreqScalPolicy.String(), bBoot) + case "NONEtoPOWERSAVE": + fallthrough + case "PERFORMANCEtoPOWERSAVE": + hfs.HostFrequencyScaling(me.NodeCfg, "powersave") break - case "CPU_TEMP_HIGHtoCPU_TEMP_NORMAL": - hfs.HostFrequencyScaling(me.NodeCfg, lowtoHighFreqScalPolicy.String(), bBoot) + case "NONEtoPERFORMANCE": + fallthrough + case "POWERSAVEtoPERFORMANCE": + hfs.HostFrequencyScaling(me.NodeCfg, "performance") break } } // HostFrequencyScaling scales CPU frequency according to given parameters -func (hfs *HFS) HostFrequencyScaling(node lib.Node, freqScalPolicy string, bBoot bool) { +func (hfs *HFS) HostFrequencyScaling(node lib.Node, freqScalPolicy string) { freqScalPolicies := hfs.cfg.GetFreqScalPolicies() @@ -466,19 +453,8 @@ func (hfs *HFS) HostFrequencyScaling(node lib.Node, freqScalPolicy string, bBoot CPUMaxFreq: cpuMaxFreqq, } - if bBoot == true { - url := lib.NodeURLJoin(node.ID().String(), hostBootFreqScalerURL) - ev := core.NewEvent( - lib.Event_DISCOVERY, - url, - &core.DiscoveryEvent{ - URL: url, - ValueID: currentScalingConfig.CurScalingGovernor, - }, - ) - hfs.dchan <- ev - } else { - url := lib.NodeURLJoin(node.ID().String(), hostHightoLowFreqScalerURL) + //if bBoot == true { + url := lib.NodeURLJoin(node.ID().String(), hostFreqScalerURL) ev := core.NewEvent( lib.Event_DISCOVERY, url, @@ -488,7 +464,18 @@ func (hfs *HFS) HostFrequencyScaling(node lib.Node, freqScalPolicy string, bBoot }, ) hfs.dchan <- ev - } + // } else { + // url := lib.NodeURLJoin(node.ID().String(), hostHightoLowFreqScalerURL) + // ev := core.NewEvent( + // lib.Event_DISCOVERY, + // url, + // &core.DiscoveryEvent{ + // URL: url, + // ValueID: currentScalingConfig.CurScalingGovernor, + // }, + // ) + // hfs.dchan <- ev + // } } diff --git a/modules/hostthermaldiscovery/hostthermaldiscovery.go~HEAD b/modules/hostthermaldiscovery/hostthermaldiscovery.go~HEAD deleted file mode 100644 index 71c29e8c4..000000000 --- a/modules/hostthermaldiscovery/hostthermaldiscovery.go~HEAD +++ /dev/null @@ -1,273 +0,0 @@ -/* HostThermalDiscovery.go: This module performs CPU Thermal discovery of HPC nodes through in-band (through OS) mechanism. - * - * Author: Ghazanfar Ali, ghazanfar.ali@ttu.edu; Kevin Pelzel ; J. Lowell Wofford - * - * This software is open source software available under the BSD-3 license. - * Copyright (c) 2018, Triad National Security, LLC - * See LICENSE file for details. - */ - -//go:generate protoc -I ../../core/proto/include -I proto --go_out=plugins=grpc:proto proto/pxe.proto - -package hostthermaldiscovery - -import ( - "fmt" - "io/ioutil" - "net" - "os" - "reflect" - "strconv" - "strings" - "time" - - "github.com/golang/protobuf/proto" - "github.com/golang/protobuf/ptypes" - "github.com/hpc/kraken/core" - cpb "github.com/hpc/kraken/core/proto" - thpb "github.com/hpc/kraken/extensions/HostThermal/proto" - "github.com/hpc/kraken/lib" - pb "github.com/hpc/kraken/modules/hostthermaldiscovery/proto" -) - -//CPUTempObj is strututure for node CPU temperature -type CPUTempObj struct { - TimeStamp time.Time - HostAddress string - CPUTemp int32 -} - -const ( - // HostThermalStateURL points to Thermal extension - HostThermalStateURL = "type.googleapis.com/proto.HostThermal/State" - // ModuleStateURL refers to module state - ModuleStateURL = "/Services/hostthermaldiscovery/State" -) - -var _ lib.Module = (*HostDisc)(nil) -var _ lib.ModuleWithConfig = (*HostDisc)(nil) -var _ lib.ModuleWithDiscovery = (*HostDisc)(nil) -var _ lib.ModuleSelfService = (*HostDisc)(nil) - -// HostDisc provides hostdiscovery module capabilities -type HostDisc struct { - prevTemp int32 - api lib.APIClient - cfg *pb.HostDiscoveryConfig - dchan chan<- lib.Event - pollTicker *time.Ticker -} - -// Name returns the FQDN of the module -func (*HostDisc) Name() string { return "github.com/hpc/kraken/modules/hostthermaldiscovery" } - -// NewConfig returns a fully initialized default config -func (*HostDisc) NewConfig() proto.Message { - r := &pb.HostDiscoveryConfig{ - PollingInterval: "10s", - TempSensorPath: "/sys/devices/virtual/thermal/thermal_zone0/temp", - ThermalThresholds: map[string]*pb.HostThermalThresholds{ - "CPUThermalThresholds": { - LowerNormal: 3000, - UpperNormal: 60000, - LowerHigh: 60000, - UpperHigh: 70000, - LowerCritical: 3000, - UpperCritical: 70000, - }, - }, - } - return r -} - -// UpdateConfig updates the running config -func (hostDisc *HostDisc) UpdateConfig(cfg proto.Message) (e error) { - if rcfg, ok := cfg.(*pb.HostDiscoveryConfig); ok { - hostDisc.cfg = rcfg - return - } - return fmt.Errorf("invalid config type") -} - -// ConfigURL gives the any resolver URL for the config -func (*HostDisc) ConfigURL() string { - cfg := &pb.HostDiscoveryConfig{} - any, _ := ptypes.MarshalAny(cfg) - return any.GetTypeUrl() -} - -// SetDiscoveryChan sets the current discovery channel -// this is generally done by the API -func (hostDisc *HostDisc) SetDiscoveryChan(c chan<- lib.Event) { hostDisc.dchan = c } - -func init() { - module := &HostDisc{} - discovers := make(map[string]map[string]reflect.Value) - hostThermDisc := make(map[string]reflect.Value) - - hostThermDisc[thpb.HostThermal_CPU_TEMP_NONE.String()] = reflect.ValueOf(thpb.HostThermal_CPU_TEMP_NONE) - hostThermDisc[thpb.HostThermal_CPU_TEMP_NORMAL.String()] = reflect.ValueOf(thpb.HostThermal_CPU_TEMP_NORMAL) - hostThermDisc[thpb.HostThermal_CPU_TEMP_HIGH.String()] = reflect.ValueOf(thpb.HostThermal_CPU_TEMP_HIGH) - hostThermDisc[thpb.HostThermal_CPU_TEMP_CRITICAL.String()] = reflect.ValueOf(thpb.HostThermal_CPU_TEMP_CRITICAL) - - discovers[HostThermalStateURL] = hostThermDisc - - discovers[ModuleStateURL] = map[string]reflect.Value{ - "RUN": reflect.ValueOf(cpb.ServiceInstance_RUN)} - - si := core.NewServiceInstance("hostthermaldiscovery", module.Name(), module.Entry, nil) - - // Register it all - core.Registry.RegisterModule(module) - core.Registry.RegisterServiceInstance(module, map[string]lib.ServiceInstance{si.ID(): si}) - core.Registry.RegisterDiscoverable(si, discovers) -} - -// Init is used to intialize an executable module prior to entrypoint -func (hostDisc *HostDisc) Init(api lib.APIClient) { - hostDisc.api = api - hostDisc.cfg = hostDisc.NewConfig().(*pb.HostDiscoveryConfig) -} - -// Stop should perform a graceful exit -func (hostDisc *HostDisc) Stop() { - os.Exit(0) -} - -// Entry is the module's executable entrypoint -func (hostDisc *HostDisc) Entry() { - url := lib.NodeURLJoin(hostDisc.api.Self().String(), ModuleStateURL) - ev := core.NewEvent( - lib.Event_DISCOVERY, - url, - &core.DiscoveryEvent{ - - URL: url, - ValueID: "RUN", - }, - ) - hostDisc.dchan <- ev - - // setup a ticker for polling discovery - dur, _ := time.ParseDuration(hostDisc.cfg.GetPollingInterval()) - hostDisc.pollTicker = time.NewTicker(dur) - - // main loop - for { - select { - case <-hostDisc.pollTicker.C: - go hostDisc.discoverHostCPUTemp() - break - } - } -} - -// discoverHostCPUTemp is used to acquire CPU thermal locally. -func (hostDisc *HostDisc) discoverHostCPUTemp() { - hostCPUTemp := hostDisc.GetCPUTemp() - if hostCPUTemp.CPUTemp == hostDisc.prevTemp { - // no change in temperature so no need to generate discovery event - return - } - hostDisc.prevTemp = hostCPUTemp.CPUTemp - - vid, _ := hostDisc.lambdaStateDiscovery(hostCPUTemp) - url := lib.NodeURLJoin(hostDisc.api.Self().String(), HostThermalStateURL) - - // Generating discovery event for CPU Thermal state - v := core.NewEvent( - lib.Event_DISCOVERY, - url, - &core.DiscoveryEvent{ - - URL: url, - ValueID: vid, - }, - ) - hostDisc.dchan <- v - -} - -// GetCPUTemp returns CPU temperature -func (hostDisc *HostDisc) GetCPUTemp() CPUTempObj { - - hostIP := hostDisc.GetNodeIPAddress() - - // Its a mockup CPU temperature - cpuTempObj := CPUTempObj{} - cpuTempObj.TimeStamp = time.Now() - cpuTempObj.HostAddress = hostIP - - tempVal := hostDisc.ReadCPUTemp() - cpuTempObj.CPUTemp = tempVal - - return cpuTempObj -} - -// ReadCPUTemp function reads the CPU thermal sensor -func (hostDisc *HostDisc) ReadCPUTemp() int32 { - - tempSensorPath := hostDisc.cfg.GetTempSensorPath() - - cpuTemp, err := ioutil.ReadFile(tempSensorPath) - if err != nil { - hostDisc.api.Logf(lib.LLERROR, "Reading CPU thermal sensor failed: %v", err) - return 0 - } - cpuTempInt, err := strconv.Atoi(strings.TrimSuffix(string(cpuTemp), "\n")) - - if err != nil { - hostDisc.api.Logf(lib.LLERROR, "String to Int conversion failed: %v", err) - return 0 - } - - return int32(cpuTempInt) -} - -// GetNodeIPAddress returns non local loop IP address -func (hostDisc *HostDisc) GetNodeIPAddress() string { - - addrs, err := net.InterfaceAddrs() - if err != nil { - hostDisc.api.Logf(lib.LLERROR, "Can not find network interfaces: %v", err) - } - ip := "" - for _, a := range addrs { - if ipnet, ok := a.(*net.IPNet); ok && !ipnet.IP.IsLoopback() { - if ipnet.IP.To4() != nil { - ip = ipnet.IP.String() - break - } else { - hostDisc.api.Logf(lib.LLERROR, "Can not format IP address") - } - } - } - - return ip -} - -// Discovers state of the CPU based on CPU temperature thresholds -func (hostDisc *HostDisc) lambdaStateDiscovery(v CPUTempObj) (string, int32) { - cpuTemp := v.CPUTemp - cpuTempState := thpb.HostThermal_CPU_TEMP_NONE - - cpuThermalThresholds := hostDisc.cfg.GetThermalThresholds() - lowerNormal := cpuThermalThresholds["CPUThermalThresholds"].GetLowerNormal() - upperNormal := cpuThermalThresholds["CPUThermalThresholds"].GetUpperNormal() - - lowerHigh := cpuThermalThresholds["CPUThermalThresholds"].GetLowerHigh() - upperHigh := cpuThermalThresholds["CPUThermalThresholds"].GetUpperHigh() - - lowerCritical := cpuThermalThresholds["CPUThermalThresholds"].GetLowerCritical() - upperCritical := cpuThermalThresholds["CPUThermalThresholds"].GetUpperCritical() - - if cpuTemp <= lowerCritical || cpuTemp >= upperCritical { - cpuTempState = thpb.HostThermal_CPU_TEMP_CRITICAL - } else if cpuTemp >= lowerHigh && cpuTemp < upperHigh { - cpuTempState = thpb.HostThermal_CPU_TEMP_HIGH - } else if cpuTemp > lowerNormal && cpuTemp < upperNormal { - cpuTempState = thpb.HostThermal_CPU_TEMP_NORMAL - } - return cpuTempState.String(), cpuTemp - -} From 56efe76ebc89552d46be4e395c24eb2ef0b99317 Mon Sep 17 00:00:00 2001 From: Ghazanfar Ali Date: Mon, 16 Dec 2019 14:53:19 -0700 Subject: [PATCH 08/87] Error correction --- .../hostfrequencyscaling.go | 68 ++++++++---------- .../proto/hostfrequencyscaling.pb.go | 72 ++++++++----------- .../proto/hostfrequencyscaling.proto | 4 +- 3 files changed, 62 insertions(+), 82 deletions(-) diff --git a/modules/hostfrequencyscaling/hostfrequencyscaling.go b/modules/hostfrequencyscaling/hostfrequencyscaling.go index 8d6e2a301..edebc2022 100644 --- a/modules/hostfrequencyscaling/hostfrequencyscaling.go +++ b/modules/hostfrequencyscaling/hostfrequencyscaling.go @@ -30,7 +30,6 @@ import ( cpb "github.com/hpc/kraken/core/proto" scalpb "github.com/hpc/kraken/extensions/HostFrequencyScaler/proto" hostthpb "github.com/hpc/kraken/extensions/HostThermal/proto" - rp3pb "github.com/hpc/kraken/extensions/RPi3/proto" "github.com/hpc/kraken/lib" pb "github.com/hpc/kraken/modules/hostfrequencyscaling/proto" ) @@ -90,6 +89,7 @@ type hfscalmut struct { timeout string failTo string } + // modify these if you want different requires for mutations var scalerReqs = map[string]reflect.Value{ "/PhysState": reflect.ValueOf(cpb.Node_POWER_ON), @@ -116,21 +116,22 @@ var scalMuts = map[string]hfscalmut{ t: scalpb.HostFrequencyScaler_POWER_SAVE, reqs: scalerReqs, timeout: "60s", - failTo: scalpb.HostThermal_CPU_TEMP_NONE.String(), + failTo: scalpb.HostFrequencyScaler_NONE.String(), }, "POWERSAVEtoPERFORMANCE": { - f: scalpb.HostFrequencyScaler_POWER_SAVE, - t: scalpb.HostFrequencyScaler_PERFORMANCE, - reqs: map[string]reflect.Value{ - "/PhysState": reflect.ValueOf(cpb.Node_POWER_ON), - "/RunState": reflect.ValueOf(cpb.Node_SYNC), - moduleStateURL: reflect.ValueOf(cpb.ServiceInstance_RUN), - hostThermalStateURL: reflect.ValueOf(hostthpb.HostThermal_CPU_TEMP_NORMAL), + f: scalpb.HostFrequencyScaler_POWER_SAVE, + t: scalpb.HostFrequencyScaler_PERFORMANCE, + reqs: map[string]reflect.Value{ + "/PhysState": reflect.ValueOf(cpb.Node_POWER_ON), + "/RunState": reflect.ValueOf(cpb.Node_SYNC), + moduleStateURL: reflect.ValueOf(cpb.ServiceInstance_RUN), + hostThermalStateURL: reflect.ValueOf(hostthpb.HostThermal_CPU_TEMP_NORMAL), }, timeout: "60s", failTo: scalpb.HostFrequencyScaler_POWER_SAVE.String(), - } + }, } + // Structure for mutation defintion type hfsmut struct { f hostthpb.HostThermal_CPU_TEMP_STATE @@ -140,7 +141,6 @@ type hfsmut struct { failTo string } - // Mutations supported by this module var muts = map[string]hfsmut{ @@ -149,9 +149,9 @@ var muts = map[string]hfsmut{ t: hostthpb.HostThermal_CPU_TEMP_NORMAL, reqs: reqs, timeout: "60s", - failTo: hostthpb.HostThermal_CPU_TEMP_UNKNOWN.String(), - }, - + failTo: hostthpb.HostThermal_CPU_TEMP_NONE.String(), + }, + "CPU_TEMP_HIGHtoCPU_TEMP_NORMAL": { f: hostthpb.HostThermal_CPU_TEMP_HIGH, t: hostthpb.HostThermal_CPU_TEMP_NORMAL, @@ -166,11 +166,8 @@ var muts = map[string]hfsmut{ reqs: greqs, timeout: "60s", failTo: hostthpb.HostThermal_CPU_TEMP_CRITICAL.String(), - }, - - "CPU_TEMP_CRITICALtoCPU_TEMP_NORMAL": { f: hostthpb.HostThermal_CPU_TEMP_CRITICAL, t: hostthpb.HostThermal_CPU_TEMP_NORMAL, @@ -201,9 +198,8 @@ func (*HFS) Name() string { return "github.com/hpc/kraken/modules/hostfrequencys // NewConfig returns a fully initialized default config func (*HFS) NewConfig() proto.Message { r := &pb.HostFreqScalingConfig{ - FreqSensorUrl: freqSensorPath, - BoottimeFreqPolicy: hostBootFreqScalerURL, - HightoLowFreqPolicy: hostHightoLowFreqScalerURL, + FreqSensorUrl: freqSensorPath, + ScalingFreqPolicy: hostFreqScalerURL, FreqScalPolicies: map[string]*pb.HostFreqScalingPolicy{ "powersave": { @@ -263,10 +259,10 @@ var reqs = map[string]reflect.Value{ } var greqs = map[string]reflect.Value{ - "/PhysState": reflect.ValueOf(cpb.Node_POWER_ON), - "/RunState": reflect.ValueOf(cpb.Node_SYNC), - moduleStateURL: reflect.ValueOf(cpb.ServiceInstance_RUN), - hostFreqScalerURL: reflect.ValueOf(scalpb.HostFrequencyScaler_POWER_SAVE), + "/PhysState": reflect.ValueOf(cpb.Node_POWER_ON), + "/RunState": reflect.ValueOf(cpb.Node_SYNC), + moduleStateURL: reflect.ValueOf(cpb.ServiceInstance_RUN), + hostFreqScalerURL: reflect.ValueOf(scalpb.HostFrequencyScaler_POWER_SAVE), } // modify this if you want excludes @@ -294,7 +290,6 @@ func init() { si := core.NewServiceInstance("hostfrequencyscaling", module.Name(), module.Entry, nil) hostThermDiscs[hostthpb.HostThermal_CPU_TEMP_NONE.String()] = reflect.ValueOf(hostthpb.HostThermal_CPU_TEMP_NONE) - hostThermDiscs[hostthpb.HostThermal_CPU_TEMP_UNKNOWN.String()] = reflect.ValueOf(hostthpb.HostThermal_CPU_TEMP_UNKNOWN) hostThermDiscs[hostthpb.HostThermal_CPU_TEMP_NORMAL.String()] = reflect.ValueOf(hostthpb.HostThermal_CPU_TEMP_NORMAL) hostThermDiscs[hostthpb.HostThermal_CPU_TEMP_HIGH.String()] = reflect.ValueOf(hostthpb.HostThermal_CPU_TEMP_HIGH) hostThermDiscs[hostthpb.HostThermal_CPU_TEMP_CRITICAL.String()] = reflect.ValueOf(hostthpb.HostThermal_CPU_TEMP_CRITICAL) @@ -342,9 +337,6 @@ func init() { ) } - - - // Register it all core.Registry.RegisterModule(module) core.Registry.RegisterServiceInstance(module, map[string]lib.ServiceInstance{si.ID(): si}) @@ -454,16 +446,16 @@ func (hfs *HFS) HostFrequencyScaling(node lib.Node, freqScalPolicy string) { } //if bBoot == true { - url := lib.NodeURLJoin(node.ID().String(), hostFreqScalerURL) - ev := core.NewEvent( - lib.Event_DISCOVERY, - url, - &core.DiscoveryEvent{ - URL: url, - ValueID: currentScalingConfig.CurScalingGovernor, - }, - ) - hfs.dchan <- ev + url := lib.NodeURLJoin(node.ID().String(), hostFreqScalerURL) + ev := core.NewEvent( + lib.Event_DISCOVERY, + url, + &core.DiscoveryEvent{ + URL: url, + ValueID: currentScalingConfig.CurScalingGovernor, + }, + ) + hfs.dchan <- ev // } else { // url := lib.NodeURLJoin(node.ID().String(), hostHightoLowFreqScalerURL) // ev := core.NewEvent( diff --git a/modules/hostfrequencyscaling/proto/hostfrequencyscaling.pb.go b/modules/hostfrequencyscaling/proto/hostfrequencyscaling.pb.go index 7958b4f22..42e3e2dfa 100644 --- a/modules/hostfrequencyscaling/proto/hostfrequencyscaling.pb.go +++ b/modules/hostfrequencyscaling/proto/hostfrequencyscaling.pb.go @@ -21,8 +21,7 @@ const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package type HostFreqScalingConfig struct { FreqScalPolicies map[string]*HostFreqScalingPolicy `protobuf:"bytes,1,rep,name=freq_scal_policies,json=freqScalPolicies,proto3" json:"freq_scal_policies,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` FreqSensorUrl string `protobuf:"bytes,2,opt,name=freq_sensor_url,json=freqSensorUrl,proto3" json:"freq_sensor_url,omitempty"` - BoottimeFreqPolicy string `protobuf:"bytes,3,opt,name=boottime_freq_policy,json=boottimeFreqPolicy,proto3" json:"boottime_freq_policy,omitempty"` - HightoLowFreqPolicy string `protobuf:"bytes,4,opt,name=highto_low_freq_policy,json=hightoLowFreqPolicy,proto3" json:"highto_low_freq_policy,omitempty"` + ScalingFreqPolicy string `protobuf:"bytes,3,opt,name=scaling_freq_policy,json=scalingFreqPolicy,proto3" json:"scaling_freq_policy,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` @@ -32,7 +31,7 @@ func (m *HostFreqScalingConfig) Reset() { *m = HostFreqScalingConfig{} } func (m *HostFreqScalingConfig) String() string { return proto.CompactTextString(m) } func (*HostFreqScalingConfig) ProtoMessage() {} func (*HostFreqScalingConfig) Descriptor() ([]byte, []int) { - return fileDescriptor_hostfrequencyscaling_b448546a7ca3e39e, []int{0} + return fileDescriptor_hostfrequencyscaling_fd41a70c2d595d1b, []int{0} } func (m *HostFreqScalingConfig) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_HostFreqScalingConfig.Unmarshal(m, b) @@ -66,16 +65,9 @@ func (m *HostFreqScalingConfig) GetFreqSensorUrl() string { return "" } -func (m *HostFreqScalingConfig) GetBoottimeFreqPolicy() string { +func (m *HostFreqScalingConfig) GetScalingFreqPolicy() string { if m != nil { - return m.BoottimeFreqPolicy - } - return "" -} - -func (m *HostFreqScalingConfig) GetHightoLowFreqPolicy() string { - if m != nil { - return m.HightoLowFreqPolicy + return m.ScalingFreqPolicy } return "" } @@ -95,7 +87,7 @@ func (m *HostFreqScalingPolicy) Reset() { *m = HostFreqScalingPolicy{} } func (m *HostFreqScalingPolicy) String() string { return proto.CompactTextString(m) } func (*HostFreqScalingPolicy) ProtoMessage() {} func (*HostFreqScalingPolicy) Descriptor() ([]byte, []int) { - return fileDescriptor_hostfrequencyscaling_b448546a7ca3e39e, []int{1} + return fileDescriptor_hostfrequencyscaling_fd41a70c2d595d1b, []int{1} } func (m *HostFreqScalingPolicy) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_HostFreqScalingPolicy.Unmarshal(m, b) @@ -157,32 +149,30 @@ func init() { } func init() { - proto.RegisterFile("hostfrequencyscaling.proto", fileDescriptor_hostfrequencyscaling_b448546a7ca3e39e) -} - -var fileDescriptor_hostfrequencyscaling_b448546a7ca3e39e = []byte{ - // 353 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x91, 0x4d, 0x4f, 0xf2, 0x40, - 0x10, 0xc7, 0x53, 0xfa, 0xf0, 0xe4, 0x61, 0x79, 0x10, 0xb2, 0x8a, 0x69, 0xd0, 0x03, 0xc1, 0xc4, - 0xe0, 0x85, 0x98, 0x72, 0x31, 0xde, 0x8c, 0xf1, 0xe5, 0xa0, 0x09, 0xc1, 0x78, 0xae, 0xa5, 0x6e, - 0xdb, 0x8d, 0xcb, 0x0e, 0x6c, 0x97, 0x97, 0x7e, 0x53, 0xbf, 0x83, 0x5f, 0xc2, 0xec, 0xec, 0x12, - 0x82, 0x72, 0x6a, 0xf3, 0x9f, 0xdf, 0x6f, 0x66, 0x3a, 0x25, 0x9d, 0x1c, 0x0a, 0x9d, 0x2a, 0x36, - 0x5f, 0x30, 0x99, 0x94, 0x45, 0x12, 0x0b, 0x2e, 0xb3, 0xc1, 0x4c, 0x81, 0x06, 0x5a, 0xc5, 0x47, - 0xef, 0xab, 0x42, 0xda, 0x8f, 0x50, 0xe8, 0x7b, 0xc5, 0xe6, 0x2f, 0x16, 0xb8, 0x05, 0x99, 0xf2, - 0x8c, 0xbe, 0x11, 0x6a, 0xd4, 0xc8, 0x68, 0xd1, 0x0c, 0x04, 0x4f, 0x38, 0x2b, 0x02, 0xaf, 0xeb, - 0xf7, 0xeb, 0x61, 0x68, 0x9b, 0x0c, 0xf6, 0x9a, 0x83, 0x4d, 0x32, 0x72, 0xd2, 0x9d, 0xd4, 0xaa, - 0x1c, 0xb7, 0xd2, 0x1f, 0x31, 0x3d, 0x27, 0x4d, 0x3b, 0x81, 0xc9, 0x02, 0x54, 0xb4, 0x50, 0x22, - 0xa8, 0x74, 0xbd, 0x7e, 0x6d, 0xdc, 0x40, 0x14, 0xd3, 0x57, 0x25, 0xe8, 0x25, 0x39, 0x9a, 0x00, - 0x68, 0xcd, 0xa7, 0x2c, 0x42, 0x01, 0xb7, 0x29, 0x03, 0x1f, 0x61, 0xba, 0xa9, 0x99, 0xb1, 0xd8, - 0xbb, 0xa4, 0x43, 0x72, 0x9c, 0xf3, 0x2c, 0xd7, 0x10, 0x09, 0x58, 0xed, 0x38, 0x7f, 0xd0, 0x39, - 0xb4, 0xd5, 0x27, 0x58, 0x6d, 0xa5, 0x4e, 0x4c, 0xda, 0x7b, 0x37, 0xa7, 0x2d, 0xe2, 0x7f, 0xb0, - 0x32, 0xf0, 0x50, 0x35, 0xaf, 0x34, 0x24, 0xd5, 0x65, 0x2c, 0x16, 0x0c, 0xf7, 0xad, 0x87, 0xa7, - 0xfb, 0xcf, 0x61, 0xfb, 0x8e, 0x2d, 0x7a, 0x5d, 0xb9, 0xf2, 0x7a, 0x9f, 0xde, 0xaf, 0x6b, 0xbb, - 0x8d, 0x2f, 0x48, 0xcb, 0xfd, 0x9f, 0x28, 0x83, 0x25, 0x53, 0x12, 0x94, 0x1b, 0xd8, 0x74, 0xf9, - 0x83, 0x8b, 0x69, 0x7f, 0x8b, 0x4e, 0xb9, 0xc4, 0xaf, 0x73, 0x77, 0x3b, 0x70, 0xf9, 0x33, 0x97, - 0x66, 0xc2, 0x0e, 0x19, 0xaf, 0x2d, 0xe9, 0xef, 0x92, 0xf1, 0x1a, 0xc9, 0x13, 0x52, 0x93, 0xf0, - 0xce, 0xa2, 0x58, 0x25, 0xb9, 0xbb, 0xd1, 0x3f, 0x13, 0xdc, 0xa8, 0x24, 0xa7, 0x67, 0xa4, 0x81, - 0xc5, 0x99, 0x88, 0x75, 0x0a, 0x6a, 0x1a, 0x54, 0x11, 0xf8, 0x6f, 0xc2, 0x91, 0xcb, 0x26, 0x7f, - 0xf1, 0x04, 0xc3, 0xef, 0x00, 0x00, 0x00, 0xff, 0xff, 0xb8, 0xdb, 0xe4, 0xcf, 0x74, 0x02, 0x00, - 0x00, + proto.RegisterFile("hostfrequencyscaling.proto", fileDescriptor_hostfrequencyscaling_fd41a70c2d595d1b) +} + +var fileDescriptor_hostfrequencyscaling_fd41a70c2d595d1b = []byte{ + // 324 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x90, 0x4f, 0x4f, 0xc2, 0x30, + 0x18, 0xc6, 0x33, 0x26, 0x46, 0x8a, 0x08, 0xd6, 0x90, 0x34, 0xe8, 0x81, 0x60, 0x62, 0xf0, 0xb2, + 0xc3, 0xbc, 0x18, 0x6f, 0xc6, 0xf8, 0xe7, 0x62, 0x42, 0x30, 0x9e, 0x67, 0x9d, 0x1d, 0x34, 0x96, + 0x16, 0xde, 0x6d, 0x84, 0x7d, 0x2f, 0x3f, 0x8c, 0x1f, 0xc7, 0xf4, 0x6d, 0x89, 0x41, 0x77, 0xda, + 0xf2, 0xeb, 0xef, 0xe9, 0xf3, 0xf6, 0x25, 0x83, 0xb9, 0xc9, 0x8b, 0x0c, 0xc4, 0xaa, 0x14, 0x3a, + 0xad, 0xf2, 0x94, 0x2b, 0xa9, 0x67, 0xd1, 0x12, 0x4c, 0x61, 0x68, 0x13, 0x3f, 0xa3, 0xaf, 0x06, + 0xe9, 0x3f, 0x99, 0xbc, 0x78, 0x00, 0xb1, 0x7a, 0x71, 0xc2, 0x9d, 0xd1, 0x99, 0x9c, 0xd1, 0x37, + 0x42, 0x6d, 0x34, 0xb1, 0xb1, 0x64, 0x69, 0x94, 0x4c, 0xa5, 0xc8, 0x59, 0x30, 0x0c, 0xc7, 0xed, + 0x38, 0x76, 0x97, 0x44, 0xb5, 0xc9, 0x68, 0x4b, 0x26, 0x3e, 0x74, 0xaf, 0x0b, 0xa8, 0xa6, 0xbd, + 0xec, 0x0f, 0xa6, 0x17, 0xa4, 0xeb, 0x1a, 0x84, 0xce, 0x0d, 0x24, 0x25, 0x28, 0xd6, 0x18, 0x06, + 0xe3, 0xd6, 0xb4, 0x83, 0x2a, 0xd2, 0x57, 0x50, 0x34, 0x22, 0x27, 0x7e, 0xf6, 0x04, 0x7d, 0x1c, + 0xa6, 0x62, 0x21, 0xba, 0xc7, 0xfe, 0xc8, 0x96, 0xe2, 0xcd, 0xd5, 0x80, 0x93, 0x7e, 0xed, 0x08, + 0xb4, 0x47, 0xc2, 0x4f, 0x51, 0xb1, 0x00, 0x83, 0xf6, 0x97, 0xc6, 0xa4, 0xb9, 0xe6, 0xaa, 0x14, + 0x58, 0xdc, 0x8e, 0xcf, 0xea, 0xdf, 0xe5, 0xee, 0x9d, 0x3a, 0xf5, 0xa6, 0x71, 0x1d, 0x8c, 0xbe, + 0x83, 0x7f, 0x6b, 0x73, 0x12, 0xbd, 0x24, 0xbd, 0xed, 0xb0, 0x33, 0xb3, 0x16, 0xa0, 0x0d, 0xf8, + 0xc2, 0xae, 0xe7, 0x8f, 0x1e, 0xd3, 0xf1, 0xaf, 0xba, 0x90, 0x1a, 0xdf, 0xe6, 0x17, 0x70, 0xe4, + 0xf9, 0xb3, 0xd4, 0xb6, 0x61, 0xc7, 0xe4, 0x1b, 0x67, 0x86, 0xbb, 0x26, 0xdf, 0xa0, 0x79, 0x4a, + 0x5a, 0xda, 0x7c, 0x88, 0x84, 0x43, 0x3a, 0x67, 0x7b, 0xa8, 0x1c, 0x58, 0x70, 0x0b, 0xe9, 0x9c, + 0x9e, 0x93, 0x0e, 0x1e, 0x2e, 0x15, 0x2f, 0x32, 0x03, 0x0b, 0xd6, 0x44, 0xe1, 0xd0, 0xc2, 0x89, + 0x67, 0xef, 0xfb, 0xb8, 0x82, 0xab, 0x9f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x40, 0xfe, 0xa0, 0xe4, + 0x3d, 0x02, 0x00, 0x00, } diff --git a/modules/hostfrequencyscaling/proto/hostfrequencyscaling.proto b/modules/hostfrequencyscaling/proto/hostfrequencyscaling.proto index d840dea96..1ba320e0e 100644 --- a/modules/hostfrequencyscaling/proto/hostfrequencyscaling.proto +++ b/modules/hostfrequencyscaling/proto/hostfrequencyscaling.proto @@ -13,9 +13,7 @@ message HostFreqScalingConfig { map freq_scal_policies = 1; string freq_sensor_url = 2; - string boottime_freq_policy = 3; - string highto_low_freq_policy = 4; - + string scaling_freq_policy = 3; } message HostFreqScalingPolicy { From 7108f6b278e99e9f860c959553ebf4e574ba2199 Mon Sep 17 00:00:00 2001 From: Ghazanfar Ali Date: Mon, 16 Dec 2019 14:58:51 -0700 Subject: [PATCH 09/87] error fixing --- .../HostThermal/proto/HostThermal.pb.go | 56 +++++++++---------- .../HostThermal/proto/HostThermal.proto | 4 +- .../hostfrequencyscaling.go | 4 +- 3 files changed, 32 insertions(+), 32 deletions(-) diff --git a/extensions/HostThermal/proto/HostThermal.pb.go b/extensions/HostThermal/proto/HostThermal.pb.go index 9fbba10e5..4e6c53519 100644 --- a/extensions/HostThermal/proto/HostThermal.pb.go +++ b/extensions/HostThermal/proto/HostThermal.pb.go @@ -18,47 +18,47 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package -type HostThermalHostThermalState int32 +type HostThermalCpuState int32 const ( - HostThermal_CPU_TEMP_NONE HostThermalHostThermalState = 0 - HostThermal_CPU_TEMP_NORMAL HostThermalHostThermalState = 1 - HostThermal_CPU_TEMP_HIGH HostThermalHostThermalState = 2 - HostThermal_CPU_TEMP_CRITICAL HostThermalHostThermalState = 3 + HostThermal_CPU_TEMP_NONE HostThermalCpuState = 0 + HostThermal_CPU_TEMP_NORMAL HostThermalCpuState = 1 + HostThermal_CPU_TEMP_HIGH HostThermalCpuState = 2 + HostThermal_CPU_TEMP_CRITICAL HostThermalCpuState = 3 ) -var HostThermalHostThermalState_name = map[int32]string{ +var HostThermalCpuState_name = map[int32]string{ 0: "CPU_TEMP_NONE", 1: "CPU_TEMP_NORMAL", 2: "CPU_TEMP_HIGH", 3: "CPU_TEMP_CRITICAL", } -var HostThermalHostThermalState_value = map[string]int32{ +var HostThermalCpuState_value = map[string]int32{ "CPU_TEMP_NONE": 0, "CPU_TEMP_NORMAL": 1, "CPU_TEMP_HIGH": 2, "CPU_TEMP_CRITICAL": 3, } -func (x HostThermalHostThermalState) String() string { - return proto.EnumName(HostThermalHostThermalState_name, int32(x)) +func (x HostThermalCpuState) String() string { + return proto.EnumName(HostThermalCpuState_name, int32(x)) } -func (HostThermalHostThermalState) EnumDescriptor() ([]byte, []int) { - return fileDescriptor_HostThermal_fc4818f237eb5d02, []int{0, 0} +func (HostThermalCpuState) EnumDescriptor() ([]byte, []int) { + return fileDescriptor_HostThermal_8fa7e7c7b793310f, []int{0, 0} } type HostThermal struct { - State HostThermalHostThermalState `protobuf:"varint,1,opt,name=state,proto3,enum=proto.HostThermalHostThermalState" json:"state,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` + State HostThermalCpuState `protobuf:"varint,1,opt,name=state,proto3,enum=proto.HostThermalCpuState" json:"state,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` } func (m *HostThermal) Reset() { *m = HostThermal{} } func (m *HostThermal) String() string { return proto.CompactTextString(m) } func (*HostThermal) ProtoMessage() {} func (*HostThermal) Descriptor() ([]byte, []int) { - return fileDescriptor_HostThermal_fc4818f237eb5d02, []int{0} + return fileDescriptor_HostThermal_8fa7e7c7b793310f, []int{0} } func (m *HostThermal) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_HostThermal.Unmarshal(m, b) @@ -78,7 +78,7 @@ func (m *HostThermal) XXX_DiscardUnknown() { var xxx_messageInfo_HostThermal proto.InternalMessageInfo -func (m *HostThermal) GetState() HostThermalHostThermalState { +func (m *HostThermal) GetState() HostThermalCpuState { if m != nil { return m.State } @@ -87,21 +87,21 @@ func (m *HostThermal) GetState() HostThermalHostThermalState { func init() { proto.RegisterType((*HostThermal)(nil), "proto.HostThermal") - proto.RegisterEnum("proto.HostThermalHostThermalState", HostThermalHostThermalState_name, HostThermalHostThermalState_value) + proto.RegisterEnum("proto.HostThermalCpuState", HostThermalCpuState_name, HostThermalCpuState_value) } -func init() { proto.RegisterFile("HostThermal.proto", fileDescriptor_HostThermal_fc4818f237eb5d02) } +func init() { proto.RegisterFile("HostThermal.proto", fileDescriptor_HostThermal_8fa7e7c7b793310f) } -var fileDescriptor_HostThermal_fc4818f237eb5d02 = []byte{ +var fileDescriptor_HostThermal_8fa7e7c7b793310f = []byte{ // 151 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0xf4, 0xc8, 0x2f, 0x2e, 0x09, 0xc9, 0x48, 0x2d, 0xca, 0x4d, 0xcc, 0xd1, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x62, 0x05, - 0x53, 0x4a, 0xeb, 0x18, 0xb9, 0xb8, 0x91, 0x24, 0x85, 0x2c, 0xb9, 0x58, 0x8b, 0x4b, 0x12, 0x4b, - 0x52, 0x25, 0x18, 0x15, 0x18, 0x35, 0xf8, 0x8c, 0x94, 0x21, 0xaa, 0xf5, 0x90, 0xf5, 0x67, 0x20, - 0xd8, 0xc1, 0x20, 0xa5, 0x41, 0x10, 0x1d, 0x4a, 0x29, 0x5c, 0x02, 0xe8, 0x52, 0x42, 0x82, 0x5c, - 0xbc, 0xce, 0x01, 0xa1, 0xf1, 0x21, 0xae, 0xbe, 0x01, 0xf1, 0x7e, 0xfe, 0x7e, 0xae, 0x02, 0x0c, - 0x42, 0xc2, 0x5c, 0xfc, 0x48, 0x42, 0x41, 0xbe, 0x8e, 0x3e, 0x02, 0x8c, 0x28, 0xea, 0x3c, 0x3c, - 0xdd, 0x3d, 0x04, 0x98, 0x84, 0x44, 0xb9, 0x04, 0xe1, 0x42, 0xce, 0x41, 0x9e, 0x21, 0x9e, 0xce, - 0x8e, 0x3e, 0x02, 0xcc, 0x49, 0x6c, 0x60, 0x07, 0x19, 0x03, 0x02, 0x00, 0x00, 0xff, 0xff, 0x53, - 0xaa, 0x23, 0xc0, 0xd3, 0x00, 0x00, 0x00, + 0x53, 0x4a, 0xf3, 0x18, 0xb9, 0xb8, 0x91, 0x24, 0x85, 0x0c, 0xb9, 0x58, 0x8b, 0x4b, 0x12, 0x4b, + 0x52, 0x25, 0x18, 0x15, 0x18, 0x35, 0xf8, 0x8c, 0xa4, 0x21, 0xaa, 0xf5, 0x90, 0xf5, 0x27, 0x17, + 0x94, 0x06, 0x83, 0x94, 0x04, 0x41, 0x54, 0x2a, 0xc5, 0x70, 0x71, 0xc0, 0x84, 0x84, 0x04, 0xb9, + 0x78, 0x9d, 0x03, 0x42, 0xe3, 0x43, 0x5c, 0x7d, 0x03, 0xe2, 0xfd, 0xfc, 0xfd, 0x5c, 0x05, 0x18, + 0x84, 0x84, 0xb9, 0xf8, 0x91, 0x84, 0x82, 0x7c, 0x1d, 0x7d, 0x04, 0x18, 0x51, 0xd4, 0x79, 0x78, + 0xba, 0x7b, 0x08, 0x30, 0x09, 0x89, 0x72, 0x09, 0xc2, 0x85, 0x9c, 0x83, 0x3c, 0x43, 0x3c, 0x9d, + 0x1d, 0x7d, 0x04, 0x98, 0x93, 0xd8, 0xc0, 0x0e, 0x30, 0x06, 0x04, 0x00, 0x00, 0xff, 0xff, 0xe7, + 0xf7, 0x25, 0x52, 0xc3, 0x00, 0x00, 0x00, } diff --git a/extensions/HostThermal/proto/HostThermal.proto b/extensions/HostThermal/proto/HostThermal.proto index 64fc95133..897f0221f 100644 --- a/extensions/HostThermal/proto/HostThermal.proto +++ b/extensions/HostThermal/proto/HostThermal.proto @@ -11,12 +11,12 @@ package proto; message HostThermal { - enum hostThermalState { + enum cpuState { CPU_TEMP_NONE = 0; CPU_TEMP_NORMAL = 1; CPU_TEMP_HIGH = 2; CPU_TEMP_CRITICAL = 3; } - hostThermalState state = 1; + cpuState state = 1; } \ No newline at end of file diff --git a/modules/hostfrequencyscaling/hostfrequencyscaling.go b/modules/hostfrequencyscaling/hostfrequencyscaling.go index edebc2022..09d253af5 100644 --- a/modules/hostfrequencyscaling/hostfrequencyscaling.go +++ b/modules/hostfrequencyscaling/hostfrequencyscaling.go @@ -134,8 +134,8 @@ var scalMuts = map[string]hfscalmut{ // Structure for mutation defintion type hfsmut struct { - f hostthpb.HostThermal_CPU_TEMP_STATE - t hostthpb.HostThermal_CPU_TEMP_STATE + f hostthpb.HostThermalCpuState + t hostthpb.HostThermalCpuState reqs map[string]reflect.Value timeout string failTo string From f76cc1dfb0b135f997e344b5238b326469bac999 Mon Sep 17 00:00:00 2001 From: Kevin Pelzel Date: Mon, 16 Dec 2019 15:52:21 -0700 Subject: [PATCH 10/87] fixing none to performance --- modules/hostfrequencyscaling/hostfrequencyscaling.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/hostfrequencyscaling/hostfrequencyscaling.go b/modules/hostfrequencyscaling/hostfrequencyscaling.go index 09d253af5..7bd25b9d7 100644 --- a/modules/hostfrequencyscaling/hostfrequencyscaling.go +++ b/modules/hostfrequencyscaling/hostfrequencyscaling.go @@ -113,7 +113,7 @@ var scalMuts = map[string]hfscalmut{ }, "NONEtoPERFORMANCE": { f: scalpb.HostFrequencyScaler_NONE, - t: scalpb.HostFrequencyScaler_POWER_SAVE, + t: scalpb.HostFrequencyScaler_PERFORMANCE, reqs: scalerReqs, timeout: "60s", failTo: scalpb.HostFrequencyScaler_NONE.String(), From 0cb3bd1463fbec61a974783ab221a982ecd01e0d Mon Sep 17 00:00:00 2001 From: Kevin Pelzel Date: Mon, 16 Dec 2019 16:02:06 -0700 Subject: [PATCH 11/87] adding exclude of temp none --- modules/hostfrequencyscaling/hostfrequencyscaling.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/modules/hostfrequencyscaling/hostfrequencyscaling.go b/modules/hostfrequencyscaling/hostfrequencyscaling.go index 7bd25b9d7..28761b886 100644 --- a/modules/hostfrequencyscaling/hostfrequencyscaling.go +++ b/modules/hostfrequencyscaling/hostfrequencyscaling.go @@ -330,7 +330,9 @@ func init() { }, }, m.reqs, - excs, + map[string]reflect.Value{ + hostThermalStateURL: reflect.ValueOf(hostthpb.HostThermal_CPU_TEMP_NONE), + }, lib.StateMutationContext_SELF, dur, [3]string{si.ID(), hostFreqScalerURL, m.failTo}, From db67753dbc5941ccc511f9c431d22168f9e695c6 Mon Sep 17 00:00:00 2001 From: Ghazanfar Ali Date: Mon, 16 Dec 2019 16:47:35 -0700 Subject: [PATCH 12/87] mapping --- modules/hostfrequencyscaling/hostfrequencyscaling.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/modules/hostfrequencyscaling/hostfrequencyscaling.go b/modules/hostfrequencyscaling/hostfrequencyscaling.go index 28761b886..beedae3f4 100644 --- a/modules/hostfrequencyscaling/hostfrequencyscaling.go +++ b/modules/hostfrequencyscaling/hostfrequencyscaling.go @@ -82,6 +82,11 @@ const ( freqSensorPath string = "/sys/devices/system/cpu/cpufreq/policy0/" ) +var profileMap = map[string]string{ + "performance": scalpb.HostFrequencyScaler_PERFORMANCE.String(), + "powersave": scalpb.HostFrequencyScaler_POWER_SAVE.String(), +} + type hfscalmut struct { f scalpb.HostFrequencyScaler_ScalerState t scalpb.HostFrequencyScaler_ScalerState @@ -454,7 +459,7 @@ func (hfs *HFS) HostFrequencyScaling(node lib.Node, freqScalPolicy string) { url, &core.DiscoveryEvent{ URL: url, - ValueID: currentScalingConfig.CurScalingGovernor, + ValueID: profileMap[currentScalingConfig.CurScalingGovernor], }, ) hfs.dchan <- ev From 48aee3d2a1b6a58a9d61acc4d80b9194804599f0 Mon Sep 17 00:00:00 2001 From: Ghazanfar Ali Date: Mon, 16 Dec 2019 17:31:54 -0700 Subject: [PATCH 13/87] getting back NONE mutation --- .../hostfrequencyscaling/hostfrequencyscaling.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/modules/hostfrequencyscaling/hostfrequencyscaling.go b/modules/hostfrequencyscaling/hostfrequencyscaling.go index beedae3f4..4da924165 100644 --- a/modules/hostfrequencyscaling/hostfrequencyscaling.go +++ b/modules/hostfrequencyscaling/hostfrequencyscaling.go @@ -156,6 +156,20 @@ var muts = map[string]hfsmut{ timeout: "60s", failTo: hostthpb.HostThermal_CPU_TEMP_NONE.String(), }, + "CPU_TEMP_NONEtoCPU_TEMP_HIGH": { + f: hostthpb.HostThermal_CPU_TEMP_NONE, + t: hostthpb.HostThermal_CPU_TEMP_HIGH, + reqs: reqs, + timeout: "60s", + failTo: hostthpb.HostThermal_CPU_TEMP_NONE.String(), + }, + "CPU_TEMP_NONEtoCPU_TEMP_CRITICAL": { + f: hostthpb.HostThermal_CPU_TEMP_NONE, + t: hostthpb.HostThermal_CPU_TEMP_CRITICAL, + reqs: reqs, + timeout: "60s", + failTo: hostthpb.HostThermal_CPU_TEMP_NONE.String(), + }, "CPU_TEMP_HIGHtoCPU_TEMP_NORMAL": { f: hostthpb.HostThermal_CPU_TEMP_HIGH, From 9297c2cb9845bfd1d095c03bd8f9d131b4c4a7cc Mon Sep 17 00:00:00 2001 From: Kevin Pelzel Date: Tue, 17 Dec 2019 10:39:21 -0700 Subject: [PATCH 14/87] set logging to 10 --- utils/layer0/uinit/uinit.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/layer0/uinit/uinit.go b/utils/layer0/uinit/uinit.go index 9e8f92093..3dc074cdc 100644 --- a/utils/layer0/uinit/uinit.go +++ b/utils/layer0/uinit/uinit.go @@ -28,7 +28,7 @@ const ioDir = "/tmp/io" const ioMode = 0700 // log level of child node -const logLevel = "7" +const logLevel = "10" type command struct { Cmd string From bcfb1ef93d6dc442be7212c7346e62c8b831fbdd Mon Sep 17 00:00:00 2001 From: Ghazanfar Ali Date: Wed, 18 Dec 2019 14:34:43 -0700 Subject: [PATCH 15/87] making freq scaler discoverable --- config/pipxe.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config/pipxe.yaml b/config/pipxe.yaml index 8a6311bca..e974d0f9e 100644 --- a/config/pipxe.yaml +++ b/config/pipxe.yaml @@ -15,7 +15,7 @@ extensions: - github.com/hpc/kraken/extensions/IPv4 - github.com/hpc/kraken/extensions/RPi3 - github.com/hpc/kraken/extensions/HostThermal - - github.com/hpc/kraken/extensions/RFAggregatorServer + - github.com/hpc/kraken/extensions/HostFrequencyScaler # included modules modules: - github.com/hpc/kraken/modules/restapi @@ -23,4 +23,4 @@ modules: - github.com/hpc/kraken/modules/rfpipower - github.com/hpc/kraken/modules/pipxe - github.com/hpc/kraken/modules/hostthermaldiscovery - - github.com/hpc/kraken/modules/cpuburn + - github.com/hpc/kraken/modules/hostfrequencyscaling From 4505b97d787fb8dc87aa74b594f335b9537c0d56 Mon Sep 17 00:00:00 2001 From: Ghazanfar Ali Date: Wed, 18 Dec 2019 14:35:35 -0700 Subject: [PATCH 16/87] adding freqscaler disc --- .../hostthermaldiscovery.go | 58 ++++++++++++++-- .../proto/hostthermaldiscovery.pb.go | 67 +++++++++++-------- .../proto/hostthermaldiscovery.proto | 3 +- 3 files changed, 93 insertions(+), 35 deletions(-) diff --git a/modules/hostthermaldiscovery/hostthermaldiscovery.go b/modules/hostthermaldiscovery/hostthermaldiscovery.go index bbbc64005..78b58e4e8 100644 --- a/modules/hostthermaldiscovery/hostthermaldiscovery.go +++ b/modules/hostthermaldiscovery/hostthermaldiscovery.go @@ -40,6 +40,11 @@ const ( HostThermalStateURL = "type.googleapis.com/proto.HostThermal/State" // ModuleStateURL refers to module state ModuleStateURL = "/Services/hostthermaldiscovery/State" + // hostFreqScalerURL provides URL for host frequency scaler at host run time + hostFreqScalerURL string = "type.googleapis.com/proto.HostFrequencyScaler/State" + + // freqSensorPath holds frequency sensor path on pi node + freqSensorPath string = "/sys/devices/system/cpu/cpufreq/policy0/" ) var _ lib.Module = (*HostDisc)(nil) @@ -49,11 +54,12 @@ var _ lib.ModuleSelfService = (*HostDisc)(nil) // HostDisc provides hostdiscovery module capabilities type HostDisc struct { - prevTemp int32 - api lib.APIClient - cfg *pb.HostDiscoveryConfig - dchan chan<- lib.Event - pollTicker *time.Ticker + prevTemp int32 + preFreqScaler string + api lib.APIClient + cfg *pb.HostDiscoveryConfig + dchan chan<- lib.Event + pollTicker *time.Ticker } // Name returns the FQDN of the module @@ -64,6 +70,7 @@ func (*HostDisc) NewConfig() proto.Message { r := &pb.HostDiscoveryConfig{ PollingInterval: "10s", TempSensorPath: "/sys/devices/virtual/thermal/thermal_zone0/temp", + FreqSensorUrl: freqSensorPath, ThermalThresholds: map[string]*pb.HostThermalThresholds{ "CPUThermalThresholds": { LowerNormal: 3000, @@ -155,11 +162,52 @@ func (hostDisc *HostDisc) Entry() { select { case <-hostDisc.pollTicker.C: go hostDisc.discoverHostCPUTemp() + go hostDisc.DiscFreqScaler() break } } } +// DiscFreqScaler cpu frequency scaler +func (hostDisc *HostDisc) DiscFreqScaler() { + + hostFreqScaler := hostDisc.ReadFreqScaler() + if hostFreqScaler == hostDisc.preFreqScaler { + // no change in frequency scaler so no need to generate discovery event + return + } + hostDisc.preFreqScaler = hostFreqScaler + + vid := hostFreqScaler + url := lib.NodeURLJoin(hostDisc.api.Self().String(), hostFreqScalerURL) + + // Generating discovery event for CPU Thermal state + v := core.NewEvent( + lib.Event_DISCOVERY, + url, + &core.DiscoveryEvent{ + + URL: url, + ValueID: vid, + }, + ) + hostDisc.dchan <- v + +} + +// ReadFreqScaler cpu frequency scaler +func (hostDisc *HostDisc) ReadFreqScaler() string { + + basePath := hfs.cfg.GetFreqSensorUrl() + bscalingGovernor, err := ioutil.ReadFile(basePath + "scaling_governor") + if err != nil { + hostDisc.api.Logf(lib.LLERROR, "Reading CPU thermal sensor failed: %v", err) + return "" + } + //fscalingGovernor := strings.TrimSuffix(string(bscalingGovernor), "\n") + return strings.TrimSuffix(string(bscalingGovernor), "\n") +} + // discoverHostCPUTemp is used to acquire CPU thermal locally. func (hostDisc *HostDisc) discoverHostCPUTemp() { hostCPUTemp := hostDisc.GetCPUTemp() diff --git a/modules/hostthermaldiscovery/proto/hostthermaldiscovery.pb.go b/modules/hostthermaldiscovery/proto/hostthermaldiscovery.pb.go index 251613715..bf8473826 100644 --- a/modules/hostthermaldiscovery/proto/hostthermaldiscovery.pb.go +++ b/modules/hostthermaldiscovery/proto/hostthermaldiscovery.pb.go @@ -21,7 +21,8 @@ const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package type HostDiscoveryConfig struct { PollingInterval string `protobuf:"bytes,1,opt,name=polling_interval,json=pollingInterval,proto3" json:"polling_interval,omitempty"` TempSensorPath string `protobuf:"bytes,2,opt,name=temp_sensor_path,json=tempSensorPath,proto3" json:"temp_sensor_path,omitempty"` - ThermalThresholds map[string]*HostThermalThresholds `protobuf:"bytes,3,rep,name=thermal_thresholds,json=thermalThresholds,proto3" json:"thermal_thresholds,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` + FreqSensorUrl string `protobuf:"bytes,3,opt,name=freq_sensor_url,json=freqSensorUrl,proto3" json:"freq_sensor_url,omitempty"` + ThermalThresholds map[string]*HostThermalThresholds `protobuf:"bytes,4,rep,name=thermal_thresholds,json=thermalThresholds,proto3" json:"thermal_thresholds,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` @@ -31,7 +32,7 @@ func (m *HostDiscoveryConfig) Reset() { *m = HostDiscoveryConfig{} } func (m *HostDiscoveryConfig) String() string { return proto.CompactTextString(m) } func (*HostDiscoveryConfig) ProtoMessage() {} func (*HostDiscoveryConfig) Descriptor() ([]byte, []int) { - return fileDescriptor_hostthermaldiscovery_063889daa550b856, []int{0} + return fileDescriptor_hostthermaldiscovery_0abdfca256266e1f, []int{0} } func (m *HostDiscoveryConfig) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_HostDiscoveryConfig.Unmarshal(m, b) @@ -65,6 +66,13 @@ func (m *HostDiscoveryConfig) GetTempSensorPath() string { return "" } +func (m *HostDiscoveryConfig) GetFreqSensorUrl() string { + if m != nil { + return m.FreqSensorUrl + } + return "" +} + func (m *HostDiscoveryConfig) GetThermalThresholds() map[string]*HostThermalThresholds { if m != nil { return m.ThermalThresholds @@ -88,7 +96,7 @@ func (m *HostThermalThresholds) Reset() { *m = HostThermalThresholds{} } func (m *HostThermalThresholds) String() string { return proto.CompactTextString(m) } func (*HostThermalThresholds) ProtoMessage() {} func (*HostThermalThresholds) Descriptor() ([]byte, []int) { - return fileDescriptor_hostthermaldiscovery_063889daa550b856, []int{1} + return fileDescriptor_hostthermaldiscovery_0abdfca256266e1f, []int{1} } func (m *HostThermalThresholds) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_HostThermalThresholds.Unmarshal(m, b) @@ -157,30 +165,31 @@ func init() { } func init() { - proto.RegisterFile("hostthermaldiscovery.proto", fileDescriptor_hostthermaldiscovery_063889daa550b856) -} - -var fileDescriptor_hostthermaldiscovery_063889daa550b856 = []byte{ - // 327 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x90, 0xd1, 0x4a, 0xc3, 0x30, - 0x14, 0x86, 0x69, 0x6b, 0x07, 0x3b, 0xd3, 0x39, 0x23, 0x4a, 0x19, 0x0a, 0x73, 0x20, 0xcc, 0x9b, - 0x81, 0xf3, 0x46, 0xbc, 0x9d, 0xc2, 0xbc, 0x11, 0xa9, 0xbb, 0xaf, 0xdd, 0x16, 0x9b, 0x60, 0xd6, - 0x94, 0xe4, 0x6c, 0xb2, 0xb7, 0xf2, 0xb5, 0x7c, 0x0b, 0xe9, 0x49, 0x37, 0x45, 0x7b, 0xd5, 0xf2, - 0xfd, 0xdf, 0x39, 0xf9, 0x13, 0xe8, 0x0a, 0x6d, 0x11, 0x05, 0x37, 0xcb, 0x54, 0x2d, 0xa4, 0x9d, - 0xeb, 0x35, 0x37, 0x9b, 0x61, 0x61, 0x34, 0x6a, 0x16, 0xd2, 0xa7, 0xff, 0xe9, 0xc3, 0xf1, 0x44, - 0x5b, 0xbc, 0xdf, 0xc6, 0x63, 0x9d, 0xbf, 0xc9, 0x8c, 0x5d, 0x41, 0xa7, 0xd0, 0x4a, 0xc9, 0x3c, - 0x4b, 0x64, 0x8e, 0xdc, 0xac, 0x53, 0x15, 0x79, 0x3d, 0x6f, 0xd0, 0x8c, 0x0f, 0x2b, 0xfe, 0x58, - 0x61, 0x36, 0x80, 0x0e, 0xf2, 0x65, 0x91, 0x58, 0x9e, 0x5b, 0x6d, 0x92, 0x22, 0x45, 0x11, 0xf9, - 0xa4, 0xb6, 0x4b, 0xfe, 0x42, 0xf8, 0x39, 0x45, 0xc1, 0x5e, 0x81, 0x55, 0x6d, 0x12, 0x14, 0x86, - 0x5b, 0xa1, 0xd5, 0xc2, 0x46, 0x41, 0x2f, 0x18, 0xb4, 0x46, 0xd7, 0xae, 0xd7, 0xb0, 0xa6, 0xcc, - 0x70, 0xea, 0x86, 0xa6, 0xbb, 0x99, 0x87, 0x1c, 0xcd, 0x26, 0x3e, 0xc2, 0xbf, 0xbc, 0x3b, 0x83, - 0xd3, 0x7a, 0x99, 0x75, 0x20, 0x78, 0xe7, 0x9b, 0xea, 0x0e, 0xe5, 0x2f, 0x1b, 0x41, 0xb8, 0x4e, - 0xd5, 0x8a, 0x53, 0xd9, 0xd6, 0xe8, 0xec, 0x57, 0x81, 0x7f, 0x3b, 0x62, 0xa7, 0xde, 0xf9, 0xb7, - 0x5e, 0xff, 0xcb, 0x83, 0x93, 0x5a, 0x89, 0x5d, 0xc0, 0xbe, 0xd2, 0x1f, 0xdc, 0x24, 0xb9, 0x2e, - 0x13, 0x3a, 0x2c, 0x8c, 0x5b, 0xc4, 0x9e, 0x08, 0x95, 0xca, 0xaa, 0x28, 0x7e, 0x14, 0xdf, 0x29, - 0xc4, 0x2a, 0xe5, 0x1c, 0xc0, 0x6d, 0x11, 0x32, 0x13, 0x51, 0x40, 0x42, 0x93, 0xc8, 0x44, 0x66, - 0xa2, 0x8c, 0xdd, 0x06, 0x8a, 0xf7, 0x5c, 0x4c, 0x84, 0xe2, 0x4b, 0x68, 0xbb, 0xe9, 0xb9, 0x91, - 0x28, 0xe7, 0xa9, 0x8a, 0x42, 0x52, 0x0e, 0x88, 0x8e, 0x2b, 0x58, 0x6a, 0x6e, 0xcb, 0x4e, 0x6b, - 0x38, 0x8d, 0xe8, 0x56, 0x9b, 0x35, 0xe8, 0x4d, 0x6e, 0xbe, 0x03, 0x00, 0x00, 0xff, 0xff, 0xac, - 0x5a, 0x78, 0xab, 0x4a, 0x02, 0x00, 0x00, + proto.RegisterFile("hostthermaldiscovery.proto", fileDescriptor_hostthermaldiscovery_0abdfca256266e1f) +} + +var fileDescriptor_hostthermaldiscovery_0abdfca256266e1f = []byte{ + // 349 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x90, 0x5f, 0x4f, 0xf2, 0x30, + 0x14, 0xc6, 0xb3, 0xc1, 0x48, 0x38, 0xbc, 0xfc, 0x79, 0x6b, 0x34, 0x0b, 0xd1, 0x04, 0x49, 0x34, + 0x78, 0x43, 0x22, 0xde, 0x18, 0x6f, 0xd1, 0x04, 0x6f, 0x8c, 0x99, 0x78, 0x3d, 0x07, 0x94, 0xb5, + 0xb1, 0xac, 0xb3, 0x2d, 0x18, 0xbe, 0xa9, 0x5f, 0xc1, 0x6f, 0x61, 0x7a, 0x3a, 0xd0, 0xe8, 0xae, + 0xb6, 0xfc, 0x9e, 0xdf, 0x39, 0x7d, 0x5a, 0xe8, 0x32, 0xa9, 0x8d, 0x61, 0x54, 0xad, 0x12, 0xb1, + 0xe0, 0x7a, 0x2e, 0x37, 0x54, 0x6d, 0x87, 0xb9, 0x92, 0x46, 0x92, 0x00, 0x3f, 0xfd, 0x0f, 0x1f, + 0x0e, 0x26, 0x52, 0x9b, 0xdb, 0x5d, 0x3c, 0x96, 0xd9, 0x92, 0xa7, 0xe4, 0x02, 0x3a, 0xb9, 0x14, + 0x82, 0x67, 0x69, 0xcc, 0x33, 0x43, 0xd5, 0x26, 0x11, 0xa1, 0xd7, 0xf3, 0x06, 0xf5, 0xa8, 0x5d, + 0xf0, 0xfb, 0x02, 0x93, 0x01, 0x74, 0x0c, 0x5d, 0xe5, 0xb1, 0xa6, 0x99, 0x96, 0x2a, 0xce, 0x13, + 0xc3, 0x42, 0x1f, 0xd5, 0x96, 0xe5, 0x4f, 0x88, 0x1f, 0x13, 0xc3, 0xc8, 0x39, 0xb4, 0x97, 0x8a, + 0xbe, 0xed, 0xcc, 0xb5, 0x12, 0x61, 0x05, 0xc5, 0xa6, 0xc5, 0x4e, 0x7c, 0x56, 0x82, 0xbc, 0x00, + 0x29, 0x5a, 0xc7, 0x86, 0x29, 0xaa, 0x99, 0x14, 0x0b, 0x1d, 0x56, 0x7b, 0x95, 0x41, 0x63, 0x74, + 0xe9, 0xfa, 0x0f, 0x4b, 0x4a, 0x0f, 0xa7, 0x6e, 0x68, 0xba, 0x9f, 0xb9, 0xcb, 0x8c, 0xda, 0x46, + 0xff, 0xcd, 0x6f, 0xde, 0x9d, 0xc1, 0x51, 0xb9, 0x4c, 0x3a, 0x50, 0x79, 0xa5, 0xdb, 0xe2, 0xae, + 0xf6, 0x97, 0x8c, 0x20, 0xd8, 0x24, 0x62, 0x4d, 0xf1, 0x52, 0x8d, 0xd1, 0xf1, 0x8f, 0x02, 0x7f, + 0x76, 0x44, 0x4e, 0xbd, 0xf1, 0xaf, 0xbd, 0xfe, 0xa7, 0x07, 0x87, 0xa5, 0x12, 0x39, 0x85, 0x7f, + 0x42, 0xbe, 0x53, 0x15, 0x67, 0xd2, 0x26, 0x78, 0x58, 0x10, 0x35, 0x90, 0x3d, 0x20, 0xb2, 0xca, + 0x3a, 0xcf, 0xbf, 0x15, 0xdf, 0x29, 0xc8, 0x0a, 0xe5, 0x04, 0xc0, 0x6d, 0x61, 0x3c, 0x65, 0xf8, + 0x90, 0x41, 0x54, 0x47, 0x32, 0xe1, 0x29, 0xb3, 0xb1, 0xdb, 0x80, 0x71, 0xd5, 0xc5, 0x48, 0x30, + 0x3e, 0x83, 0x96, 0x9b, 0x9e, 0x2b, 0x6e, 0xf8, 0x3c, 0x11, 0x61, 0x80, 0x4a, 0x13, 0xe9, 0xb8, + 0x80, 0x56, 0x73, 0x5b, 0xf6, 0x5a, 0xcd, 0x69, 0x48, 0x77, 0xda, 0xac, 0x86, 0x6f, 0x72, 0xf5, + 0x15, 0x00, 0x00, 0xff, 0xff, 0x54, 0x75, 0x3e, 0x54, 0x72, 0x02, 0x00, 0x00, } diff --git a/modules/hostthermaldiscovery/proto/hostthermaldiscovery.proto b/modules/hostthermaldiscovery/proto/hostthermaldiscovery.proto index 639621eef..5190774c4 100644 --- a/modules/hostthermaldiscovery/proto/hostthermaldiscovery.proto +++ b/modules/hostthermaldiscovery/proto/hostthermaldiscovery.proto @@ -13,7 +13,8 @@ package proto; message HostDiscoveryConfig { string polling_interval = 1; string temp_sensor_path = 2; - map thermal_thresholds = 3; + string freq_sensor_url = 3; + map thermal_thresholds = 4; } message HostThermalThresholds { From 26b18f9f27d46deafef9df6db88c541f1e97312b Mon Sep 17 00:00:00 2001 From: Ghazanfar Ali Date: Wed, 18 Dec 2019 14:40:59 -0700 Subject: [PATCH 17/87] bug fix --- modules/hostthermaldiscovery/hostthermaldiscovery.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/hostthermaldiscovery/hostthermaldiscovery.go b/modules/hostthermaldiscovery/hostthermaldiscovery.go index 78b58e4e8..166bfd83c 100644 --- a/modules/hostthermaldiscovery/hostthermaldiscovery.go +++ b/modules/hostthermaldiscovery/hostthermaldiscovery.go @@ -198,7 +198,7 @@ func (hostDisc *HostDisc) DiscFreqScaler() { // ReadFreqScaler cpu frequency scaler func (hostDisc *HostDisc) ReadFreqScaler() string { - basePath := hfs.cfg.GetFreqSensorUrl() + basePath := hostDisc.cfg.GetFreqSensorUrl() bscalingGovernor, err := ioutil.ReadFile(basePath + "scaling_governor") if err != nil { hostDisc.api.Logf(lib.LLERROR, "Reading CPU thermal sensor failed: %v", err) From 1f56446c5f2230132cf53947073ee0ebd8c23836 Mon Sep 17 00:00:00 2001 From: Ghazanfar Ali Date: Wed, 18 Dec 2019 15:06:53 -0700 Subject: [PATCH 18/87] debug statement --- modules/hostthermaldiscovery/hostthermaldiscovery.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/modules/hostthermaldiscovery/hostthermaldiscovery.go b/modules/hostthermaldiscovery/hostthermaldiscovery.go index 166bfd83c..d15bc01a9 100644 --- a/modules/hostthermaldiscovery/hostthermaldiscovery.go +++ b/modules/hostthermaldiscovery/hostthermaldiscovery.go @@ -178,6 +178,8 @@ func (hostDisc *HostDisc) DiscFreqScaler() { } hostDisc.preFreqScaler = hostFreqScaler + hostDisc.api.Logf(lib.LLERROR, "SCALER: %s", hostFreqScaler) + vid := hostFreqScaler url := lib.NodeURLJoin(hostDisc.api.Self().String(), hostFreqScalerURL) From ce7c3ffea0b4f129492a197ccbfd0061d5847c43 Mon Sep 17 00:00:00 2001 From: Ghazanfar Ali Date: Wed, 18 Dec 2019 15:21:30 -0700 Subject: [PATCH 19/87] adding more freq --- .../hostthermaldiscovery.go | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/modules/hostthermaldiscovery/hostthermaldiscovery.go b/modules/hostthermaldiscovery/hostthermaldiscovery.go index d15bc01a9..56341d19f 100644 --- a/modules/hostthermaldiscovery/hostthermaldiscovery.go +++ b/modules/hostthermaldiscovery/hostthermaldiscovery.go @@ -23,7 +23,9 @@ import ( "github.com/golang/protobuf/ptypes" "github.com/hpc/kraken/core" cpb "github.com/hpc/kraken/core/proto" + scalpb "github.com/hpc/kraken/extensions/HostFrequencyScaler/proto" thpb "github.com/hpc/kraken/extensions/HostThermal/proto" + "github.com/hpc/kraken/lib" pb "github.com/hpc/kraken/modules/hostthermaldiscovery/proto" ) @@ -52,6 +54,11 @@ var _ lib.ModuleWithConfig = (*HostDisc)(nil) var _ lib.ModuleWithDiscovery = (*HostDisc)(nil) var _ lib.ModuleSelfService = (*HostDisc)(nil) +var profileMap = map[string]string{ + "performance": scalpb.HostFrequencyScaler_PERFORMANCE.String(), + "powersave": scalpb.HostFrequencyScaler_POWER_SAVE.String(), +} + // HostDisc provides hostdiscovery module capabilities type HostDisc struct { prevTemp int32 @@ -109,6 +116,7 @@ func init() { module := &HostDisc{} discovers := make(map[string]map[string]reflect.Value) hostThermDisc := make(map[string]reflect.Value) + hostFreqScalerDiscs := make(map[string]reflect.Value) hostThermDisc[thpb.HostThermal_CPU_TEMP_NONE.String()] = reflect.ValueOf(thpb.HostThermal_CPU_TEMP_NONE) hostThermDisc[thpb.HostThermal_CPU_TEMP_NORMAL.String()] = reflect.ValueOf(thpb.HostThermal_CPU_TEMP_NORMAL) @@ -117,6 +125,11 @@ func init() { discovers[HostThermalStateURL] = hostThermDisc + hostFreqScalerDiscs[scalpb.HostFrequencyScaler_NONE.String()] = reflect.ValueOf(scalpb.HostFrequencyScaler_NONE) + hostFreqScalerDiscs[scalpb.HostFrequencyScaler_PERFORMANCE.String()] = reflect.ValueOf(scalpb.HostFrequencyScaler_PERFORMANCE) + hostFreqScalerDiscs[scalpb.HostFrequencyScaler_POWER_SAVE.String()] = reflect.ValueOf(scalpb.HostFrequencyScaler_POWER_SAVE) + discovers[hostFreqScalerURL] = hostFreqScalerDiscs + discovers[ModuleStateURL] = map[string]reflect.Value{ "RUN": reflect.ValueOf(cpb.ServiceInstance_RUN)} @@ -178,9 +191,10 @@ func (hostDisc *HostDisc) DiscFreqScaler() { } hostDisc.preFreqScaler = hostFreqScaler - hostDisc.api.Logf(lib.LLERROR, "SCALER: %s", hostFreqScaler) + vid := profileMap[hostFreqScaler] + + hostDisc.api.Logf(lib.LLERROR, "PRINTSCALER: %s", vid) - vid := hostFreqScaler url := lib.NodeURLJoin(hostDisc.api.Self().String(), hostFreqScalerURL) // Generating discovery event for CPU Thermal state From 458ad5bc891d96b4be957337d5c2d72bf3858290 Mon Sep 17 00:00:00 2001 From: Ghazanfar Ali Date: Wed, 18 Dec 2019 15:31:49 -0700 Subject: [PATCH 20/87] making discoverable by one module --- modules/hostthermaldiscovery/hostthermaldiscovery.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/hostthermaldiscovery/hostthermaldiscovery.go b/modules/hostthermaldiscovery/hostthermaldiscovery.go index 56341d19f..8c4395587 100644 --- a/modules/hostthermaldiscovery/hostthermaldiscovery.go +++ b/modules/hostthermaldiscovery/hostthermaldiscovery.go @@ -125,10 +125,10 @@ func init() { discovers[HostThermalStateURL] = hostThermDisc - hostFreqScalerDiscs[scalpb.HostFrequencyScaler_NONE.String()] = reflect.ValueOf(scalpb.HostFrequencyScaler_NONE) - hostFreqScalerDiscs[scalpb.HostFrequencyScaler_PERFORMANCE.String()] = reflect.ValueOf(scalpb.HostFrequencyScaler_PERFORMANCE) - hostFreqScalerDiscs[scalpb.HostFrequencyScaler_POWER_SAVE.String()] = reflect.ValueOf(scalpb.HostFrequencyScaler_POWER_SAVE) - discovers[hostFreqScalerURL] = hostFreqScalerDiscs + // hostFreqScalerDiscs[scalpb.HostFrequencyScaler_NONE.String()] = reflect.ValueOf(scalpb.HostFrequencyScaler_NONE) + // hostFreqScalerDiscs[scalpb.HostFrequencyScaler_PERFORMANCE.String()] = reflect.ValueOf(scalpb.HostFrequencyScaler_PERFORMANCE) + // hostFreqScalerDiscs[scalpb.HostFrequencyScaler_POWER_SAVE.String()] = reflect.ValueOf(scalpb.HostFrequencyScaler_POWER_SAVE) + // discovers[hostFreqScalerURL] = hostFreqScalerDiscs discovers[ModuleStateURL] = map[string]reflect.Value{ "RUN": reflect.ValueOf(cpb.ServiceInstance_RUN)} From bd31bea2ca55fedc1908f7981ad17dee529f8155 Mon Sep 17 00:00:00 2001 From: Ghazanfar Ali Date: Wed, 18 Dec 2019 15:32:51 -0700 Subject: [PATCH 21/87] no msg --- modules/hostthermaldiscovery/hostthermaldiscovery.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/hostthermaldiscovery/hostthermaldiscovery.go b/modules/hostthermaldiscovery/hostthermaldiscovery.go index 8c4395587..1e100fbb5 100644 --- a/modules/hostthermaldiscovery/hostthermaldiscovery.go +++ b/modules/hostthermaldiscovery/hostthermaldiscovery.go @@ -116,7 +116,7 @@ func init() { module := &HostDisc{} discovers := make(map[string]map[string]reflect.Value) hostThermDisc := make(map[string]reflect.Value) - hostFreqScalerDiscs := make(map[string]reflect.Value) + //hostFreqScalerDiscs := make(map[string]reflect.Value) hostThermDisc[thpb.HostThermal_CPU_TEMP_NONE.String()] = reflect.ValueOf(thpb.HostThermal_CPU_TEMP_NONE) hostThermDisc[thpb.HostThermal_CPU_TEMP_NORMAL.String()] = reflect.ValueOf(thpb.HostThermal_CPU_TEMP_NORMAL) From 66dbb948883398ecc84c751cad7e631f10fd37c2 Mon Sep 17 00:00:00 2001 From: Ghazanfar Ali Date: Wed, 18 Dec 2019 15:40:55 -0700 Subject: [PATCH 22/87] reverse the discs --- modules/hostthermaldiscovery/hostthermaldiscovery.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/modules/hostthermaldiscovery/hostthermaldiscovery.go b/modules/hostthermaldiscovery/hostthermaldiscovery.go index 1e100fbb5..56341d19f 100644 --- a/modules/hostthermaldiscovery/hostthermaldiscovery.go +++ b/modules/hostthermaldiscovery/hostthermaldiscovery.go @@ -116,7 +116,7 @@ func init() { module := &HostDisc{} discovers := make(map[string]map[string]reflect.Value) hostThermDisc := make(map[string]reflect.Value) - //hostFreqScalerDiscs := make(map[string]reflect.Value) + hostFreqScalerDiscs := make(map[string]reflect.Value) hostThermDisc[thpb.HostThermal_CPU_TEMP_NONE.String()] = reflect.ValueOf(thpb.HostThermal_CPU_TEMP_NONE) hostThermDisc[thpb.HostThermal_CPU_TEMP_NORMAL.String()] = reflect.ValueOf(thpb.HostThermal_CPU_TEMP_NORMAL) @@ -125,10 +125,10 @@ func init() { discovers[HostThermalStateURL] = hostThermDisc - // hostFreqScalerDiscs[scalpb.HostFrequencyScaler_NONE.String()] = reflect.ValueOf(scalpb.HostFrequencyScaler_NONE) - // hostFreqScalerDiscs[scalpb.HostFrequencyScaler_PERFORMANCE.String()] = reflect.ValueOf(scalpb.HostFrequencyScaler_PERFORMANCE) - // hostFreqScalerDiscs[scalpb.HostFrequencyScaler_POWER_SAVE.String()] = reflect.ValueOf(scalpb.HostFrequencyScaler_POWER_SAVE) - // discovers[hostFreqScalerURL] = hostFreqScalerDiscs + hostFreqScalerDiscs[scalpb.HostFrequencyScaler_NONE.String()] = reflect.ValueOf(scalpb.HostFrequencyScaler_NONE) + hostFreqScalerDiscs[scalpb.HostFrequencyScaler_PERFORMANCE.String()] = reflect.ValueOf(scalpb.HostFrequencyScaler_PERFORMANCE) + hostFreqScalerDiscs[scalpb.HostFrequencyScaler_POWER_SAVE.String()] = reflect.ValueOf(scalpb.HostFrequencyScaler_POWER_SAVE) + discovers[hostFreqScalerURL] = hostFreqScalerDiscs discovers[ModuleStateURL] = map[string]reflect.Value{ "RUN": reflect.ValueOf(cpb.ServiceInstance_RUN)} From d61a1e51e2e72bc961abcede96d064b57f1e93b1 Mon Sep 17 00:00:00 2001 From: Ghazanfar Ali Date: Wed, 18 Dec 2019 16:08:08 -0700 Subject: [PATCH 23/87] changing freq limits --- modules/hostfrequencyscaling/hostfrequencyscaling.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/hostfrequencyscaling/hostfrequencyscaling.go b/modules/hostfrequencyscaling/hostfrequencyscaling.go index 4da924165..6c5f4fece 100644 --- a/modules/hostfrequencyscaling/hostfrequencyscaling.go +++ b/modules/hostfrequencyscaling/hostfrequencyscaling.go @@ -224,21 +224,21 @@ func (*HFS) NewConfig() proto.Message { "powersave": { ScalingGovernor: "powersave", ScalingMinFreq: "600000", - ScalingMaxFreq: "1200000", + ScalingMaxFreq: "1400000", NodeArch: "", NodePlatform: "", }, "performance": { ScalingGovernor: "performance", ScalingMinFreq: "600000", - ScalingMaxFreq: "1200000", + ScalingMaxFreq: "1400000", NodeArch: "", NodePlatform: "", }, "schedutil": { ScalingGovernor: "schedutil", ScalingMinFreq: "600000", - ScalingMaxFreq: "1200000", + ScalingMaxFreq: "1400000", NodeArch: "", NodePlatform: "", }, From 4e8b93572b116f8133911fdcc26baa8ac1393695 Mon Sep 17 00:00:00 2001 From: Ghazanfar Ali Date: Wed, 18 Dec 2019 18:18:57 -0700 Subject: [PATCH 24/87] Removing check --- modules/hostthermaldiscovery/hostthermaldiscovery.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/modules/hostthermaldiscovery/hostthermaldiscovery.go b/modules/hostthermaldiscovery/hostthermaldiscovery.go index 56341d19f..1c967b53e 100644 --- a/modules/hostthermaldiscovery/hostthermaldiscovery.go +++ b/modules/hostthermaldiscovery/hostthermaldiscovery.go @@ -185,15 +185,15 @@ func (hostDisc *HostDisc) Entry() { func (hostDisc *HostDisc) DiscFreqScaler() { hostFreqScaler := hostDisc.ReadFreqScaler() - if hostFreqScaler == hostDisc.preFreqScaler { - // no change in frequency scaler so no need to generate discovery event - return - } - hostDisc.preFreqScaler = hostFreqScaler + // if hostFreqScaler == hostDisc.preFreqScaler { + // // no change in frequency scaler so no need to generate discovery event + // return + // } + // hostDisc.preFreqScaler = hostFreqScaler vid := profileMap[hostFreqScaler] - hostDisc.api.Logf(lib.LLERROR, "PRINTSCALER: %s", vid) + //hostDisc.api.Logf(lib., "PRINTSCALER: %s", vid) url := lib.NodeURLJoin(hostDisc.api.Self().String(), hostFreqScalerURL) From 67c252dda340b7060302728ecbe087e282762fed Mon Sep 17 00:00:00 2001 From: Kevin Pelzel Date: Wed, 18 Dec 2019 18:21:59 -0700 Subject: [PATCH 25/87] removing long debug messages --- core/StateSyncEngine.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/core/StateSyncEngine.go b/core/StateSyncEngine.go index bbd190c54..bdba52ed9 100644 --- a/core/StateSyncEngine.go +++ b/core/StateSyncEngine.go @@ -486,7 +486,6 @@ func (sse *StateSyncEngine) binaryToNode(buf []byte) (rp recvPacket, e error) { func (sse *StateSyncEngine) send(n *stateSyncNeighbor) { node, e := sse.query.Read(n.getID()) - sse.Logf(lib.LLDEBUG, "sending hello packet: \n%v", string(node.JSON())) if e != nil { sse.Logf(ERROR, "couldn't get node info, deleting from pool: %v", e) sse.delNeighbor(n.getID()) @@ -727,7 +726,7 @@ func (sse *StateSyncEngine) processRecv(rp recvPacket) { } n.recv() sse.sortQueue() - sse.Logf(DEBUG, "got a hello from: %s\n%v", rp.From.String(), string(rp.Node.JSON())) + sse.Logf(DEBUG, "got a hello from: %s", rp.From.String()) if n.getParent() { _, e := sse.query.Update(rp.Node) if e != nil { From 82af62d38933f2d461957e9855ffcf3528b58bce Mon Sep 17 00:00:00 2001 From: Ghazanfar Ali Date: Wed, 18 Dec 2019 19:45:34 -0700 Subject: [PATCH 26/87] remove dup discovery of freq scal --- modules/hostfrequencyscaling/hostfrequencyscaling.go | 2 ++ modules/hostthermaldiscovery/hostthermaldiscovery.go | 10 +++++----- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/modules/hostfrequencyscaling/hostfrequencyscaling.go b/modules/hostfrequencyscaling/hostfrequencyscaling.go index 6c5f4fece..5211d1e8b 100644 --- a/modules/hostfrequencyscaling/hostfrequencyscaling.go +++ b/modules/hostfrequencyscaling/hostfrequencyscaling.go @@ -419,6 +419,8 @@ func (hfs *HFS) mutateCPUFreq(m lib.Event) { // HostFrequencyScaling scales CPU frequency according to given parameters func (hfs *HFS) HostFrequencyScaling(node lib.Node, freqScalPolicy string) { + hfs.api.Log(lib.LLERROR, "POLICY: %s", freqScalPolicy) + freqScalPolicies := hfs.cfg.GetFreqScalPolicies() scalingGovernor := freqScalPolicies[freqScalPolicy].GetScalingGovernor() diff --git a/modules/hostthermaldiscovery/hostthermaldiscovery.go b/modules/hostthermaldiscovery/hostthermaldiscovery.go index 1c967b53e..b3fd20831 100644 --- a/modules/hostthermaldiscovery/hostthermaldiscovery.go +++ b/modules/hostthermaldiscovery/hostthermaldiscovery.go @@ -185,11 +185,11 @@ func (hostDisc *HostDisc) Entry() { func (hostDisc *HostDisc) DiscFreqScaler() { hostFreqScaler := hostDisc.ReadFreqScaler() - // if hostFreqScaler == hostDisc.preFreqScaler { - // // no change in frequency scaler so no need to generate discovery event - // return - // } - // hostDisc.preFreqScaler = hostFreqScaler + if hostFreqScaler == hostDisc.preFreqScaler { + // no change in frequency scaler so no need to generate discovery event + return + } + hostDisc.preFreqScaler = hostFreqScaler vid := profileMap[hostFreqScaler] From 71d3a62e62c816231f7b83f59e277028e0300f5a Mon Sep 17 00:00:00 2001 From: Ghazanfar Ali Date: Wed, 18 Dec 2019 19:51:18 -0700 Subject: [PATCH 27/87] Adding debugging statement --- modules/hostfrequencyscaling/hostfrequencyscaling.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/hostfrequencyscaling/hostfrequencyscaling.go b/modules/hostfrequencyscaling/hostfrequencyscaling.go index 5211d1e8b..2c9a8d93e 100644 --- a/modules/hostfrequencyscaling/hostfrequencyscaling.go +++ b/modules/hostfrequencyscaling/hostfrequencyscaling.go @@ -419,7 +419,7 @@ func (hfs *HFS) mutateCPUFreq(m lib.Event) { // HostFrequencyScaling scales CPU frequency according to given parameters func (hfs *HFS) HostFrequencyScaling(node lib.Node, freqScalPolicy string) { - hfs.api.Log(lib.LLERROR, "POLICY: %s", freqScalPolicy) + hfs.api.Logf(lib.LLERROR, "POLICY: %s", freqScalPolicy) freqScalPolicies := hfs.cfg.GetFreqScalPolicies() From 4805b4f5f3d9d16a7d167a5c8db0e1ef0b9676c4 Mon Sep 17 00:00:00 2001 From: "J. Lowell Wofford" Date: Thu, 19 Dec 2019 01:49:54 -0700 Subject: [PATCH 28/87] buildGraphStage1 rewrite of buildGraph; also no longer require unique start --- core/StateMutationEngine.go | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/core/StateMutationEngine.go b/core/StateMutationEngine.go index e9f3dfafa..4c1c2a7b7 100644 --- a/core/StateMutationEngine.go +++ b/core/StateMutationEngine.go @@ -932,19 +932,16 @@ func (sme *StateMutationEngine) nodeViolatesDeps(deps map[string]lib.StateSpec, mut: m, to: root, } - nn := &mutationNode{ + newNode := &mutationNode{ spec: root.spec.SpecMergeMust(m.Before()), in: []*mutationEdge{}, - out: []*mutationEdge{nme}, + out: []*mutationEdge{newEdge}, } - nme.from = nn - root.in = append(root.in, nme) - seenNode[root.spec] = root - // we reset the chain if we went backwards - nds, eds := sme.buildGraph(nn, seenNode, make(map[int]*mutationNode)) - edges = append(edges, nme) - edges = append(edges, eds...) - nodes = append(nodes, nds...) + newEdge.from = newNode + root.in = append(root.in, newEdge) + ns, es := sme.buildGraphStage1(newNode, newEdge, seenNodes) + nodes = append(nodes, ns...) + edges = append(edges, es...) } } return From d5b231271872eba7468d6edf2d94311b039d07f7 Mon Sep 17 00:00:00 2001 From: Ghazanfar Ali Date: Thu, 19 Dec 2019 12:17:49 -0700 Subject: [PATCH 29/87] adding cpuburn --- config/pipxe.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/config/pipxe.yaml b/config/pipxe.yaml index e974d0f9e..28d2474d4 100644 --- a/config/pipxe.yaml +++ b/config/pipxe.yaml @@ -24,3 +24,4 @@ modules: - github.com/hpc/kraken/modules/pipxe - github.com/hpc/kraken/modules/hostthermaldiscovery - github.com/hpc/kraken/modules/hostfrequencyscaling + - github.com/hpc/kraken/modules/cpuburn From 17c36562a2e27fe0e77d103d757abce72ff7fc76 Mon Sep 17 00:00:00 2001 From: Ghazanfar Ali Date: Fri, 20 Dec 2019 15:03:05 -0700 Subject: [PATCH 30/87] thermalLog info --- .../hostthermaldiscovery.go | 23 ++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/modules/hostthermaldiscovery/hostthermaldiscovery.go b/modules/hostthermaldiscovery/hostthermaldiscovery.go index b3fd20831..5f6c14980 100644 --- a/modules/hostthermaldiscovery/hostthermaldiscovery.go +++ b/modules/hostthermaldiscovery/hostthermaldiscovery.go @@ -75,7 +75,7 @@ func (*HostDisc) Name() string { return "github.com/hpc/kraken/modules/hosttherm // NewConfig returns a fully initialized default config func (*HostDisc) NewConfig() proto.Message { r := &pb.HostDiscoveryConfig{ - PollingInterval: "10s", + PollingInterval: "1s", TempSensorPath: "/sys/devices/virtual/thermal/thermal_zone0/temp", FreqSensorUrl: freqSensorPath, ThermalThresholds: map[string]*pb.HostThermalThresholds{ @@ -176,11 +176,32 @@ func (hostDisc *HostDisc) Entry() { case <-hostDisc.pollTicker.C: go hostDisc.discoverHostCPUTemp() go hostDisc.DiscFreqScaler() + go hostDisc.CapturingStatData() break } } } +// CapturingStatData logs thermal information +func (hostDisc *HostDisc) CapturingStatData() { + freqScaler := hostDisc.preFreqScaler + temp := hostDisc.prevTemp + t := time.Now().UnixNano() // / int64(time.Millisecond) + record := fmt.Sprintf("%d,", "%d,", "%s", t, currTemp, freqScaler) + + file, err := os.OpenFile("/tmp/thermLog.txt", os.O_WRONLY|os.O_APPEND, 0644) + if err != nil { + hostDisc.api.Logf(lib.LLERROR, "failed opening file: %v", err) + } + defer file.Close() + + len, err := file.WriteString(record) + if err != nil { + hostDisc.api.Logf(lib.LLERROR, "failed opening file: %v", err) + } + +} + // DiscFreqScaler cpu frequency scaler func (hostDisc *HostDisc) DiscFreqScaler() { From 3de686bdd19709289b2619bcd66b31e052883ea9 Mon Sep 17 00:00:00 2001 From: Ghazanfar Ali Date: Fri, 20 Dec 2019 15:13:05 -0700 Subject: [PATCH 31/87] making thermal log configable --- .../hostthermaldiscovery.go | 9 ++- .../proto/hostthermaldiscovery.pb.go | 77 ++++++++++++------- .../proto/hostthermaldiscovery.proto | 2 + 3 files changed, 57 insertions(+), 31 deletions(-) diff --git a/modules/hostthermaldiscovery/hostthermaldiscovery.go b/modules/hostthermaldiscovery/hostthermaldiscovery.go index 5f6c14980..ae21b4cec 100644 --- a/modules/hostthermaldiscovery/hostthermaldiscovery.go +++ b/modules/hostthermaldiscovery/hostthermaldiscovery.go @@ -78,6 +78,8 @@ func (*HostDisc) NewConfig() proto.Message { PollingInterval: "1s", TempSensorPath: "/sys/devices/virtual/thermal/thermal_zone0/temp", FreqSensorUrl: freqSensorPath, + LogThermalData: true + LogHere: "/tmp/ThermalLog.txt" ThermalThresholds: map[string]*pb.HostThermalThresholds{ "CPUThermalThresholds": { LowerNormal: 3000, @@ -176,7 +178,10 @@ func (hostDisc *HostDisc) Entry() { case <-hostDisc.pollTicker.C: go hostDisc.discoverHostCPUTemp() go hostDisc.DiscFreqScaler() - go hostDisc.CapturingStatData() + if hostDisc.cfg.GetLogThermalData() == true{ + go hostDisc.CapturingStatData() + } + break } } @@ -189,7 +194,7 @@ func (hostDisc *HostDisc) CapturingStatData() { t := time.Now().UnixNano() // / int64(time.Millisecond) record := fmt.Sprintf("%d,", "%d,", "%s", t, currTemp, freqScaler) - file, err := os.OpenFile("/tmp/thermLog.txt", os.O_WRONLY|os.O_APPEND, 0644) + file, err := os.OpenFile(hostDisc.cfg.GetLogHere(), os.O_WRONLY|os.O_APPEND, 0644) if err != nil { hostDisc.api.Logf(lib.LLERROR, "failed opening file: %v", err) } diff --git a/modules/hostthermaldiscovery/proto/hostthermaldiscovery.pb.go b/modules/hostthermaldiscovery/proto/hostthermaldiscovery.pb.go index bf8473826..1da28f83c 100644 --- a/modules/hostthermaldiscovery/proto/hostthermaldiscovery.pb.go +++ b/modules/hostthermaldiscovery/proto/hostthermaldiscovery.pb.go @@ -23,6 +23,8 @@ type HostDiscoveryConfig struct { TempSensorPath string `protobuf:"bytes,2,opt,name=temp_sensor_path,json=tempSensorPath,proto3" json:"temp_sensor_path,omitempty"` FreqSensorUrl string `protobuf:"bytes,3,opt,name=freq_sensor_url,json=freqSensorUrl,proto3" json:"freq_sensor_url,omitempty"` ThermalThresholds map[string]*HostThermalThresholds `protobuf:"bytes,4,rep,name=thermal_thresholds,json=thermalThresholds,proto3" json:"thermal_thresholds,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` + LogThermalData bool `protobuf:"varint,5,opt,name=log_thermal_data,json=logThermalData,proto3" json:"log_thermal_data,omitempty"` + LogHere string `protobuf:"bytes,6,opt,name=log_here,json=logHere,proto3" json:"log_here,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` @@ -32,7 +34,7 @@ func (m *HostDiscoveryConfig) Reset() { *m = HostDiscoveryConfig{} } func (m *HostDiscoveryConfig) String() string { return proto.CompactTextString(m) } func (*HostDiscoveryConfig) ProtoMessage() {} func (*HostDiscoveryConfig) Descriptor() ([]byte, []int) { - return fileDescriptor_hostthermaldiscovery_0abdfca256266e1f, []int{0} + return fileDescriptor_hostthermaldiscovery_bfeffec62fafe688, []int{0} } func (m *HostDiscoveryConfig) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_HostDiscoveryConfig.Unmarshal(m, b) @@ -80,6 +82,20 @@ func (m *HostDiscoveryConfig) GetThermalThresholds() map[string]*HostThermalThre return nil } +func (m *HostDiscoveryConfig) GetLogThermalData() bool { + if m != nil { + return m.LogThermalData + } + return false +} + +func (m *HostDiscoveryConfig) GetLogHere() string { + if m != nil { + return m.LogHere + } + return "" +} + type HostThermalThresholds struct { LowerNormal int32 `protobuf:"varint,1,opt,name=lower_normal,json=lowerNormal,proto3" json:"lower_normal,omitempty"` UpperNormal int32 `protobuf:"varint,2,opt,name=upper_normal,json=upperNormal,proto3" json:"upper_normal,omitempty"` @@ -96,7 +112,7 @@ func (m *HostThermalThresholds) Reset() { *m = HostThermalThresholds{} } func (m *HostThermalThresholds) String() string { return proto.CompactTextString(m) } func (*HostThermalThresholds) ProtoMessage() {} func (*HostThermalThresholds) Descriptor() ([]byte, []int) { - return fileDescriptor_hostthermaldiscovery_0abdfca256266e1f, []int{1} + return fileDescriptor_hostthermaldiscovery_bfeffec62fafe688, []int{1} } func (m *HostThermalThresholds) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_HostThermalThresholds.Unmarshal(m, b) @@ -165,31 +181,34 @@ func init() { } func init() { - proto.RegisterFile("hostthermaldiscovery.proto", fileDescriptor_hostthermaldiscovery_0abdfca256266e1f) -} - -var fileDescriptor_hostthermaldiscovery_0abdfca256266e1f = []byte{ - // 349 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x90, 0x5f, 0x4f, 0xf2, 0x30, - 0x14, 0xc6, 0xb3, 0xc1, 0x48, 0x38, 0xbc, 0xfc, 0x79, 0x6b, 0x34, 0x0b, 0xd1, 0x04, 0x49, 0x34, - 0x78, 0x43, 0x22, 0xde, 0x18, 0x6f, 0xd1, 0x04, 0x6f, 0x8c, 0x99, 0x78, 0x3d, 0x07, 0x94, 0xb5, - 0xb1, 0xac, 0xb3, 0x2d, 0x18, 0xbe, 0xa9, 0x5f, 0xc1, 0x6f, 0x61, 0x7a, 0x3a, 0xd0, 0xe8, 0xae, - 0xb6, 0xfc, 0x9e, 0xdf, 0x39, 0x7d, 0x5a, 0xe8, 0x32, 0xa9, 0x8d, 0x61, 0x54, 0xad, 0x12, 0xb1, - 0xe0, 0x7a, 0x2e, 0x37, 0x54, 0x6d, 0x87, 0xb9, 0x92, 0x46, 0x92, 0x00, 0x3f, 0xfd, 0x0f, 0x1f, - 0x0e, 0x26, 0x52, 0x9b, 0xdb, 0x5d, 0x3c, 0x96, 0xd9, 0x92, 0xa7, 0xe4, 0x02, 0x3a, 0xb9, 0x14, - 0x82, 0x67, 0x69, 0xcc, 0x33, 0x43, 0xd5, 0x26, 0x11, 0xa1, 0xd7, 0xf3, 0x06, 0xf5, 0xa8, 0x5d, - 0xf0, 0xfb, 0x02, 0x93, 0x01, 0x74, 0x0c, 0x5d, 0xe5, 0xb1, 0xa6, 0x99, 0x96, 0x2a, 0xce, 0x13, - 0xc3, 0x42, 0x1f, 0xd5, 0x96, 0xe5, 0x4f, 0x88, 0x1f, 0x13, 0xc3, 0xc8, 0x39, 0xb4, 0x97, 0x8a, - 0xbe, 0xed, 0xcc, 0xb5, 0x12, 0x61, 0x05, 0xc5, 0xa6, 0xc5, 0x4e, 0x7c, 0x56, 0x82, 0xbc, 0x00, - 0x29, 0x5a, 0xc7, 0x86, 0x29, 0xaa, 0x99, 0x14, 0x0b, 0x1d, 0x56, 0x7b, 0x95, 0x41, 0x63, 0x74, - 0xe9, 0xfa, 0x0f, 0x4b, 0x4a, 0x0f, 0xa7, 0x6e, 0x68, 0xba, 0x9f, 0xb9, 0xcb, 0x8c, 0xda, 0x46, - 0xff, 0xcd, 0x6f, 0xde, 0x9d, 0xc1, 0x51, 0xb9, 0x4c, 0x3a, 0x50, 0x79, 0xa5, 0xdb, 0xe2, 0xae, - 0xf6, 0x97, 0x8c, 0x20, 0xd8, 0x24, 0x62, 0x4d, 0xf1, 0x52, 0x8d, 0xd1, 0xf1, 0x8f, 0x02, 0x7f, - 0x76, 0x44, 0x4e, 0xbd, 0xf1, 0xaf, 0xbd, 0xfe, 0xa7, 0x07, 0x87, 0xa5, 0x12, 0x39, 0x85, 0x7f, - 0x42, 0xbe, 0x53, 0x15, 0x67, 0xd2, 0x26, 0x78, 0x58, 0x10, 0x35, 0x90, 0x3d, 0x20, 0xb2, 0xca, - 0x3a, 0xcf, 0xbf, 0x15, 0xdf, 0x29, 0xc8, 0x0a, 0xe5, 0x04, 0xc0, 0x6d, 0x61, 0x3c, 0x65, 0xf8, - 0x90, 0x41, 0x54, 0x47, 0x32, 0xe1, 0x29, 0xb3, 0xb1, 0xdb, 0x80, 0x71, 0xd5, 0xc5, 0x48, 0x30, - 0x3e, 0x83, 0x96, 0x9b, 0x9e, 0x2b, 0x6e, 0xf8, 0x3c, 0x11, 0x61, 0x80, 0x4a, 0x13, 0xe9, 0xb8, - 0x80, 0x56, 0x73, 0x5b, 0xf6, 0x5a, 0xcd, 0x69, 0x48, 0x77, 0xda, 0xac, 0x86, 0x6f, 0x72, 0xf5, - 0x15, 0x00, 0x00, 0xff, 0xff, 0x54, 0x75, 0x3e, 0x54, 0x72, 0x02, 0x00, 0x00, + proto.RegisterFile("hostthermaldiscovery.proto", fileDescriptor_hostthermaldiscovery_bfeffec62fafe688) +} + +var fileDescriptor_hostthermaldiscovery_bfeffec62fafe688 = []byte{ + // 388 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x91, 0x4d, 0x4f, 0xc2, 0x30, + 0x18, 0xc7, 0x33, 0xc6, 0x10, 0x8a, 0xbc, 0x58, 0xa3, 0x99, 0x44, 0x13, 0x24, 0xd1, 0xcc, 0x0b, + 0x89, 0x78, 0x31, 0x5e, 0xc1, 0x04, 0x2f, 0xc6, 0x4c, 0x3c, 0xcf, 0x02, 0x65, 0x6d, 0x2c, 0xeb, + 0xec, 0x0a, 0x86, 0x0f, 0xe3, 0x07, 0xf4, 0x5b, 0x98, 0x3e, 0xdd, 0xd0, 0x28, 0xa7, 0x2d, 0xbf, + 0xff, 0xef, 0x79, 0xd9, 0x33, 0xd4, 0x61, 0x32, 0xd3, 0x9a, 0x51, 0xb5, 0x24, 0x62, 0xce, 0xb3, + 0x99, 0x5c, 0x53, 0xb5, 0xe9, 0xa7, 0x4a, 0x6a, 0x89, 0x3d, 0x78, 0xf4, 0x3e, 0x5d, 0x74, 0x38, + 0x96, 0x99, 0x1e, 0x15, 0xf1, 0x50, 0x26, 0x0b, 0x1e, 0xe3, 0x2b, 0xd4, 0x4e, 0xa5, 0x10, 0x3c, + 0x89, 0x23, 0x9e, 0x68, 0xaa, 0xd6, 0x44, 0xf8, 0x4e, 0xd7, 0x09, 0x6a, 0x61, 0x2b, 0xe7, 0x0f, + 0x39, 0xc6, 0x01, 0x6a, 0x6b, 0xba, 0x4c, 0xa3, 0x8c, 0x26, 0x99, 0x54, 0x51, 0x4a, 0x34, 0xf3, + 0x4b, 0xa0, 0x36, 0x0d, 0x7f, 0x06, 0xfc, 0x44, 0x34, 0xc3, 0x97, 0xa8, 0xb5, 0x50, 0xf4, 0xbd, + 0x30, 0x57, 0x4a, 0xf8, 0x2e, 0x88, 0x0d, 0x83, 0xad, 0xf8, 0xa2, 0x04, 0x7e, 0x45, 0x38, 0xdf, + 0x3a, 0xd2, 0x4c, 0xd1, 0x8c, 0x49, 0x31, 0xcf, 0xfc, 0x72, 0xd7, 0x0d, 0xea, 0x83, 0x6b, 0xbb, + 0x7f, 0x7f, 0xc7, 0xd2, 0xfd, 0x89, 0x2d, 0x9a, 0x6c, 0x6b, 0xee, 0x13, 0xad, 0x36, 0xe1, 0x81, + 0xfe, 0xcb, 0xcd, 0xce, 0x42, 0xc6, 0x51, 0x31, 0x65, 0x4e, 0x34, 0xf1, 0xbd, 0xae, 0x13, 0x54, + 0xc3, 0xa6, 0x90, 0x71, 0xde, 0x67, 0x44, 0x34, 0xc1, 0x27, 0xa8, 0x6a, 0x4c, 0x46, 0x15, 0xf5, + 0x2b, 0xb0, 0xec, 0x9e, 0x90, 0xf1, 0x98, 0x2a, 0xda, 0x99, 0xa2, 0xe3, 0xdd, 0x13, 0x71, 0x1b, + 0xb9, 0x6f, 0x74, 0x93, 0x1f, 0xcc, 0xbc, 0xe2, 0x01, 0xf2, 0xd6, 0x44, 0xac, 0x28, 0x5c, 0xa6, + 0x3e, 0x38, 0xfd, 0xf5, 0x15, 0xff, 0x7a, 0x84, 0x56, 0xbd, 0x2b, 0xdd, 0x3a, 0xbd, 0x2f, 0x07, + 0x1d, 0xed, 0x94, 0xf0, 0x39, 0xda, 0x17, 0xf2, 0x83, 0xaa, 0x28, 0x91, 0x26, 0x81, 0x61, 0x5e, + 0x58, 0x07, 0xf6, 0x08, 0xc8, 0x28, 0xab, 0x34, 0xfd, 0x51, 0x4a, 0x56, 0x01, 0x96, 0x2b, 0x67, + 0x08, 0xd9, 0x2e, 0x8c, 0xc7, 0x0c, 0xfe, 0x86, 0x17, 0xd6, 0x80, 0x8c, 0x79, 0xcc, 0x4c, 0x6c, + 0x3b, 0x40, 0x5c, 0xb6, 0x31, 0x10, 0x88, 0x2f, 0x50, 0xd3, 0x56, 0xcf, 0x14, 0xd7, 0x7c, 0x46, + 0x04, 0x1c, 0xd1, 0x0b, 0x1b, 0x40, 0x87, 0x39, 0x34, 0x9a, 0xed, 0xb2, 0xd5, 0x2a, 0x56, 0x03, + 0x5a, 0x68, 0xd3, 0x0a, 0xdc, 0xe4, 0xe6, 0x3b, 0x00, 0x00, 0xff, 0xff, 0x86, 0x77, 0xab, 0x62, + 0xb7, 0x02, 0x00, 0x00, } diff --git a/modules/hostthermaldiscovery/proto/hostthermaldiscovery.proto b/modules/hostthermaldiscovery/proto/hostthermaldiscovery.proto index 5190774c4..b298e9ff6 100644 --- a/modules/hostthermaldiscovery/proto/hostthermaldiscovery.proto +++ b/modules/hostthermaldiscovery/proto/hostthermaldiscovery.proto @@ -15,6 +15,8 @@ message HostDiscoveryConfig { string temp_sensor_path = 2; string freq_sensor_url = 3; map thermal_thresholds = 4; + bool log_thermal_data = 5; + string log_here = 6; } message HostThermalThresholds { From 7dd59a8e85e5d5d7bda9dc83e626031b060165df Mon Sep 17 00:00:00 2001 From: Ghazanfar Ali Date: Fri, 20 Dec 2019 15:14:48 -0700 Subject: [PATCH 32/87] bug fix --- modules/hostthermaldiscovery/hostthermaldiscovery.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/hostthermaldiscovery/hostthermaldiscovery.go b/modules/hostthermaldiscovery/hostthermaldiscovery.go index ae21b4cec..dace938ef 100644 --- a/modules/hostthermaldiscovery/hostthermaldiscovery.go +++ b/modules/hostthermaldiscovery/hostthermaldiscovery.go @@ -78,8 +78,8 @@ func (*HostDisc) NewConfig() proto.Message { PollingInterval: "1s", TempSensorPath: "/sys/devices/virtual/thermal/thermal_zone0/temp", FreqSensorUrl: freqSensorPath, - LogThermalData: true - LogHere: "/tmp/ThermalLog.txt" + LogThermalData: true, + LogHere: "/tmp/ThermalLog.txt", ThermalThresholds: map[string]*pb.HostThermalThresholds{ "CPUThermalThresholds": { LowerNormal: 3000, @@ -178,10 +178,10 @@ func (hostDisc *HostDisc) Entry() { case <-hostDisc.pollTicker.C: go hostDisc.discoverHostCPUTemp() go hostDisc.DiscFreqScaler() - if hostDisc.cfg.GetLogThermalData() == true{ + if hostDisc.cfg.GetLogThermalData() == true { go hostDisc.CapturingStatData() } - + break } } From 5a7cbf2e0cf217a95b88ac6f5ea6df78b750480d Mon Sep 17 00:00:00 2001 From: Ghazanfar Ali Date: Fri, 20 Dec 2019 15:16:10 -0700 Subject: [PATCH 33/87] fixing variable names --- modules/hostthermaldiscovery/hostthermaldiscovery.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/hostthermaldiscovery/hostthermaldiscovery.go b/modules/hostthermaldiscovery/hostthermaldiscovery.go index dace938ef..5096477bf 100644 --- a/modules/hostthermaldiscovery/hostthermaldiscovery.go +++ b/modules/hostthermaldiscovery/hostthermaldiscovery.go @@ -192,7 +192,7 @@ func (hostDisc *HostDisc) CapturingStatData() { freqScaler := hostDisc.preFreqScaler temp := hostDisc.prevTemp t := time.Now().UnixNano() // / int64(time.Millisecond) - record := fmt.Sprintf("%d,", "%d,", "%s", t, currTemp, freqScaler) + record := fmt.Sprintf("%d,", "%d,", "%s", t, temp, freqScaler) file, err := os.OpenFile(hostDisc.cfg.GetLogHere(), os.O_WRONLY|os.O_APPEND, 0644) if err != nil { From 7f534cecc4557a903278602093607cd4bea01f74 Mon Sep 17 00:00:00 2001 From: Ghazanfar Ali Date: Fri, 20 Dec 2019 15:17:01 -0700 Subject: [PATCH 34/87] fixing variable --- modules/hostthermaldiscovery/hostthermaldiscovery.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/hostthermaldiscovery/hostthermaldiscovery.go b/modules/hostthermaldiscovery/hostthermaldiscovery.go index 5096477bf..bc82b2736 100644 --- a/modules/hostthermaldiscovery/hostthermaldiscovery.go +++ b/modules/hostthermaldiscovery/hostthermaldiscovery.go @@ -200,7 +200,7 @@ func (hostDisc *HostDisc) CapturingStatData() { } defer file.Close() - len, err := file.WriteString(record) + _, err := file.WriteString(record) if err != nil { hostDisc.api.Logf(lib.LLERROR, "failed opening file: %v", err) } From 2d5b1f271bef0a68c41aed145fadcc83d906bba6 Mon Sep 17 00:00:00 2001 From: Ghazanfar Ali Date: Fri, 20 Dec 2019 15:18:04 -0700 Subject: [PATCH 35/87] redeclaration issue --- modules/hostthermaldiscovery/hostthermaldiscovery.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/hostthermaldiscovery/hostthermaldiscovery.go b/modules/hostthermaldiscovery/hostthermaldiscovery.go index bc82b2736..e8147dc25 100644 --- a/modules/hostthermaldiscovery/hostthermaldiscovery.go +++ b/modules/hostthermaldiscovery/hostthermaldiscovery.go @@ -200,7 +200,7 @@ func (hostDisc *HostDisc) CapturingStatData() { } defer file.Close() - _, err := file.WriteString(record) + _, err = file.WriteString(record) if err != nil { hostDisc.api.Logf(lib.LLERROR, "failed opening file: %v", err) } From bdd339eaec83db0b580ad79daf4100b25f416026 Mon Sep 17 00:00:00 2001 From: Ghazanfar Ali Date: Fri, 20 Dec 2019 15:31:21 -0700 Subject: [PATCH 36/87] createmode --- modules/hostthermaldiscovery/hostthermaldiscovery.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/hostthermaldiscovery/hostthermaldiscovery.go b/modules/hostthermaldiscovery/hostthermaldiscovery.go index e8147dc25..344d6b962 100644 --- a/modules/hostthermaldiscovery/hostthermaldiscovery.go +++ b/modules/hostthermaldiscovery/hostthermaldiscovery.go @@ -194,7 +194,7 @@ func (hostDisc *HostDisc) CapturingStatData() { t := time.Now().UnixNano() // / int64(time.Millisecond) record := fmt.Sprintf("%d,", "%d,", "%s", t, temp, freqScaler) - file, err := os.OpenFile(hostDisc.cfg.GetLogHere(), os.O_WRONLY|os.O_APPEND, 0644) + file, err := os.OpenFile(hostDisc.cfg.GetLogHere(), os.O_WRONLY|os.O_APPEND|os.O_CREATE, 0644) if err != nil { hostDisc.api.Logf(lib.LLERROR, "failed opening file: %v", err) } From 85abb3298d59f48aa486e91eb2be71894111b898 Mon Sep 17 00:00:00 2001 From: Ghazanfar Ali Date: Fri, 20 Dec 2019 15:40:58 -0700 Subject: [PATCH 37/87] fixing format issue --- modules/hostthermaldiscovery/hostthermaldiscovery.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/hostthermaldiscovery/hostthermaldiscovery.go b/modules/hostthermaldiscovery/hostthermaldiscovery.go index 344d6b962..c70ce1ae5 100644 --- a/modules/hostthermaldiscovery/hostthermaldiscovery.go +++ b/modules/hostthermaldiscovery/hostthermaldiscovery.go @@ -192,7 +192,7 @@ func (hostDisc *HostDisc) CapturingStatData() { freqScaler := hostDisc.preFreqScaler temp := hostDisc.prevTemp t := time.Now().UnixNano() // / int64(time.Millisecond) - record := fmt.Sprintf("%d,", "%d,", "%s", t, temp, freqScaler) + record := fmt.Sprintf("%d,%d,%s\n", t, temp, freqScaler) file, err := os.OpenFile(hostDisc.cfg.GetLogHere(), os.O_WRONLY|os.O_APPEND|os.O_CREATE, 0644) if err != nil { From cfccaa7a711cec803f29686d202135d730b60006 Mon Sep 17 00:00:00 2001 From: Ghazanfar Ali Date: Fri, 20 Dec 2019 16:02:48 -0700 Subject: [PATCH 38/87] add file open init --- .../hostthermaldiscovery/hostthermaldiscovery.go | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/modules/hostthermaldiscovery/hostthermaldiscovery.go b/modules/hostthermaldiscovery/hostthermaldiscovery.go index c70ce1ae5..4bea34499 100644 --- a/modules/hostthermaldiscovery/hostthermaldiscovery.go +++ b/modules/hostthermaldiscovery/hostthermaldiscovery.go @@ -62,6 +62,7 @@ var profileMap = map[string]string{ // HostDisc provides hostdiscovery module capabilities type HostDisc struct { prevTemp int32 + file *File preFreqScaler string api lib.APIClient cfg *pb.HostDiscoveryConfig @@ -147,6 +148,13 @@ func init() { func (hostDisc *HostDisc) Init(api lib.APIClient) { hostDisc.api = api hostDisc.cfg = hostDisc.NewConfig().(*pb.HostDiscoveryConfig) + + hostDisc.file, err := os.OpenFile(hostDisc.cfg.GetLogHere(), os.O_WRONLY|os.O_APPEND|os.O_CREATE, 0644) + if err != nil { + hostDisc.api.Logf(lib.LLERROR, "failed opening file: %v", err) + } + defer file.Close() + } // Stop should perform a graceful exit @@ -194,13 +202,7 @@ func (hostDisc *HostDisc) CapturingStatData() { t := time.Now().UnixNano() // / int64(time.Millisecond) record := fmt.Sprintf("%d,%d,%s\n", t, temp, freqScaler) - file, err := os.OpenFile(hostDisc.cfg.GetLogHere(), os.O_WRONLY|os.O_APPEND|os.O_CREATE, 0644) - if err != nil { - hostDisc.api.Logf(lib.LLERROR, "failed opening file: %v", err) - } - defer file.Close() - - _, err = file.WriteString(record) + _, err = hostDisc.file.WriteString(record) if err != nil { hostDisc.api.Logf(lib.LLERROR, "failed opening file: %v", err) } From 4b41774f58a88bca6b550c19a8258628eb7977b0 Mon Sep 17 00:00:00 2001 From: Ghazanfar Ali Date: Fri, 20 Dec 2019 16:27:00 -0700 Subject: [PATCH 39/87] opening file single time --- modules/hostthermaldiscovery/hostthermaldiscovery.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/hostthermaldiscovery/hostthermaldiscovery.go b/modules/hostthermaldiscovery/hostthermaldiscovery.go index 4bea34499..a37e1ccdb 100644 --- a/modules/hostthermaldiscovery/hostthermaldiscovery.go +++ b/modules/hostthermaldiscovery/hostthermaldiscovery.go @@ -62,7 +62,7 @@ var profileMap = map[string]string{ // HostDisc provides hostdiscovery module capabilities type HostDisc struct { prevTemp int32 - file *File + file *os.File preFreqScaler string api lib.APIClient cfg *pb.HostDiscoveryConfig @@ -148,13 +148,13 @@ func init() { func (hostDisc *HostDisc) Init(api lib.APIClient) { hostDisc.api = api hostDisc.cfg = hostDisc.NewConfig().(*pb.HostDiscoveryConfig) - - hostDisc.file, err := os.OpenFile(hostDisc.cfg.GetLogHere(), os.O_WRONLY|os.O_APPEND|os.O_CREATE, 0644) + + hostDisc.file, err = os.OpenFile(hostDisc.cfg.GetLogHere(), os.O_WRONLY|os.O_APPEND|os.O_CREATE, 0644) if err != nil { hostDisc.api.Logf(lib.LLERROR, "failed opening file: %v", err) } defer file.Close() - + } // Stop should perform a graceful exit From ae7ac8743bc37fe08c6e6786a2706fc414aea8ed Mon Sep 17 00:00:00 2001 From: Ghazanfar Ali Date: Fri, 20 Dec 2019 16:29:13 -0700 Subject: [PATCH 40/87] bug --- modules/hostthermaldiscovery/hostthermaldiscovery.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/hostthermaldiscovery/hostthermaldiscovery.go b/modules/hostthermaldiscovery/hostthermaldiscovery.go index a37e1ccdb..81277d585 100644 --- a/modules/hostthermaldiscovery/hostthermaldiscovery.go +++ b/modules/hostthermaldiscovery/hostthermaldiscovery.go @@ -62,7 +62,7 @@ var profileMap = map[string]string{ // HostDisc provides hostdiscovery module capabilities type HostDisc struct { prevTemp int32 - file *os.File + file os.File preFreqScaler string api lib.APIClient cfg *pb.HostDiscoveryConfig From a0b98501ec01f0e44c17adba43a5c106505e6aca Mon Sep 17 00:00:00 2001 From: Ghazanfar Ali Date: Fri, 20 Dec 2019 16:30:06 -0700 Subject: [PATCH 41/87] bug --- modules/hostthermaldiscovery/hostthermaldiscovery.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/hostthermaldiscovery/hostthermaldiscovery.go b/modules/hostthermaldiscovery/hostthermaldiscovery.go index 81277d585..a37e1ccdb 100644 --- a/modules/hostthermaldiscovery/hostthermaldiscovery.go +++ b/modules/hostthermaldiscovery/hostthermaldiscovery.go @@ -62,7 +62,7 @@ var profileMap = map[string]string{ // HostDisc provides hostdiscovery module capabilities type HostDisc struct { prevTemp int32 - file os.File + file *os.File preFreqScaler string api lib.APIClient cfg *pb.HostDiscoveryConfig From 24c144fe4203c469d0853229ddbc1f86ace9ba0b Mon Sep 17 00:00:00 2001 From: Ghazanfar Ali Date: Fri, 20 Dec 2019 16:31:35 -0700 Subject: [PATCH 42/87] bug --- modules/hostthermaldiscovery/hostthermaldiscovery.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/hostthermaldiscovery/hostthermaldiscovery.go b/modules/hostthermaldiscovery/hostthermaldiscovery.go index a37e1ccdb..43779ba75 100644 --- a/modules/hostthermaldiscovery/hostthermaldiscovery.go +++ b/modules/hostthermaldiscovery/hostthermaldiscovery.go @@ -149,11 +149,11 @@ func (hostDisc *HostDisc) Init(api lib.APIClient) { hostDisc.api = api hostDisc.cfg = hostDisc.NewConfig().(*pb.HostDiscoveryConfig) - hostDisc.file, err = os.OpenFile(hostDisc.cfg.GetLogHere(), os.O_WRONLY|os.O_APPEND|os.O_CREATE, 0644) + hostDisc.file, err := os.OpenFile(hostDisc.cfg.GetLogHere(), os.O_WRONLY|os.O_APPEND|os.O_CREATE, 0644) if err != nil { hostDisc.api.Logf(lib.LLERROR, "failed opening file: %v", err) } - defer file.Close() + } From ebfc9514242d622f09a90bde7221735ea778f9a8 Mon Sep 17 00:00:00 2001 From: Ghazanfar Ali Date: Fri, 20 Dec 2019 16:34:19 -0700 Subject: [PATCH 43/87] naming convention --- modules/hostthermaldiscovery/hostthermaldiscovery.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/modules/hostthermaldiscovery/hostthermaldiscovery.go b/modules/hostthermaldiscovery/hostthermaldiscovery.go index 43779ba75..3b8e9f4e4 100644 --- a/modules/hostthermaldiscovery/hostthermaldiscovery.go +++ b/modules/hostthermaldiscovery/hostthermaldiscovery.go @@ -149,11 +149,10 @@ func (hostDisc *HostDisc) Init(api lib.APIClient) { hostDisc.api = api hostDisc.cfg = hostDisc.NewConfig().(*pb.HostDiscoveryConfig) - hostDisc.file, err := os.OpenFile(hostDisc.cfg.GetLogHere(), os.O_WRONLY|os.O_APPEND|os.O_CREATE, 0644) + hostDisc.file, err = os.OpenFile(hostDisc.cfg.GetLogHere(), os.O_WRONLY|os.O_APPEND|os.O_CREATE, 0644) if err != nil { hostDisc.api.Logf(lib.LLERROR, "failed opening file: %v", err) } - } @@ -202,7 +201,7 @@ func (hostDisc *HostDisc) CapturingStatData() { t := time.Now().UnixNano() // / int64(time.Millisecond) record := fmt.Sprintf("%d,%d,%s\n", t, temp, freqScaler) - _, err = hostDisc.file.WriteString(record) + _, err := hostDisc.file.WriteString(record) if err != nil { hostDisc.api.Logf(lib.LLERROR, "failed opening file: %v", err) } From 0988e29fd63bd637336264f07a5859e686e8f29f Mon Sep 17 00:00:00 2001 From: Ghazanfar Ali Date: Fri, 20 Dec 2019 16:36:58 -0700 Subject: [PATCH 44/87] error dec --- modules/hostthermaldiscovery/hostthermaldiscovery.go | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/hostthermaldiscovery/hostthermaldiscovery.go b/modules/hostthermaldiscovery/hostthermaldiscovery.go index 3b8e9f4e4..073ee2483 100644 --- a/modules/hostthermaldiscovery/hostthermaldiscovery.go +++ b/modules/hostthermaldiscovery/hostthermaldiscovery.go @@ -149,6 +149,7 @@ func (hostDisc *HostDisc) Init(api lib.APIClient) { hostDisc.api = api hostDisc.cfg = hostDisc.NewConfig().(*pb.HostDiscoveryConfig) + var err error hostDisc.file, err = os.OpenFile(hostDisc.cfg.GetLogHere(), os.O_WRONLY|os.O_APPEND|os.O_CREATE, 0644) if err != nil { hostDisc.api.Logf(lib.LLERROR, "failed opening file: %v", err) From 4e205e18858978c255fe10ab0366de7eca19ec69 Mon Sep 17 00:00:00 2001 From: Ghazanfar Ali Date: Fri, 20 Dec 2019 20:08:59 -0700 Subject: [PATCH 45/87] scalerconfigable plus changing thresholds --- modules/cpuburn/cpuburn.go | 2 +- .../hostfrequencyscaling.go | 11 ++- .../proto/hostfrequencyscaling.pb.go | 75 ++++++++++++------- .../proto/hostfrequencyscaling.proto | 4 +- .../hostthermaldiscovery.go | 10 +-- 5 files changed, 63 insertions(+), 39 deletions(-) diff --git a/modules/cpuburn/cpuburn.go b/modules/cpuburn/cpuburn.go index 2d4cc7bb5..4d05713e5 100644 --- a/modules/cpuburn/cpuburn.go +++ b/modules/cpuburn/cpuburn.go @@ -124,7 +124,7 @@ func (*CPUBurn) NewConfig() (r proto.Message) { ThermalThrottle: true, ThermalPoll: 1, ThermalResume: 60000, - ThermalCrit: 85000, + ThermalCrit: 98000, Workers: 4, WorkersThrottled: 0, } diff --git a/modules/hostfrequencyscaling/hostfrequencyscaling.go b/modules/hostfrequencyscaling/hostfrequencyscaling.go index 2c9a8d93e..0d68ba7b7 100644 --- a/modules/hostfrequencyscaling/hostfrequencyscaling.go +++ b/modules/hostfrequencyscaling/hostfrequencyscaling.go @@ -219,7 +219,8 @@ func (*HFS) NewConfig() proto.Message { r := &pb.HostFreqScalingConfig{ FreqSensorUrl: freqSensorPath, ScalingFreqPolicy: hostFreqScalerURL, - + HighToLowScaler: "powersave", + LowToHighScaler: "performance", FreqScalPolicies: map[string]*pb.HostFreqScalingPolicy{ "powersave": { ScalingGovernor: "powersave", @@ -244,7 +245,7 @@ func (*HFS) NewConfig() proto.Message { }, }, } - return r + return } // UpdateConfig updates the running config @@ -405,12 +406,14 @@ func (hfs *HFS) mutateCPUFreq(m lib.Event) { case "NONEtoPOWERSAVE": fallthrough case "PERFORMANCEtoPOWERSAVE": - hfs.HostFrequencyScaling(me.NodeCfg, "powersave") + highToLowScaler := hfs.cfg.GetHighToLowScaler() + hfs.HostFrequencyScaling(me.NodeCfg, highToLowScaler) break case "NONEtoPERFORMANCE": fallthrough case "POWERSAVEtoPERFORMANCE": - hfs.HostFrequencyScaling(me.NodeCfg, "performance") + lowToHighScaler := hfs.cfg.GetLowToHighScaler() + hfs.HostFrequencyScaling(me.NodeCfg, lowToHighScaler) break } diff --git a/modules/hostfrequencyscaling/proto/hostfrequencyscaling.pb.go b/modules/hostfrequencyscaling/proto/hostfrequencyscaling.pb.go index 42e3e2dfa..519ae2c21 100644 --- a/modules/hostfrequencyscaling/proto/hostfrequencyscaling.pb.go +++ b/modules/hostfrequencyscaling/proto/hostfrequencyscaling.pb.go @@ -22,6 +22,8 @@ type HostFreqScalingConfig struct { FreqScalPolicies map[string]*HostFreqScalingPolicy `protobuf:"bytes,1,rep,name=freq_scal_policies,json=freqScalPolicies,proto3" json:"freq_scal_policies,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` FreqSensorUrl string `protobuf:"bytes,2,opt,name=freq_sensor_url,json=freqSensorUrl,proto3" json:"freq_sensor_url,omitempty"` ScalingFreqPolicy string `protobuf:"bytes,3,opt,name=scaling_freq_policy,json=scalingFreqPolicy,proto3" json:"scaling_freq_policy,omitempty"` + LowToHighScaler string `protobuf:"bytes,4,opt,name=low_to_high_scaler,json=lowToHighScaler,proto3" json:"low_to_high_scaler,omitempty"` + HighToLowScaler string `protobuf:"bytes,5,opt,name=high_to_low_scaler,json=highToLowScaler,proto3" json:"high_to_low_scaler,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` @@ -31,7 +33,7 @@ func (m *HostFreqScalingConfig) Reset() { *m = HostFreqScalingConfig{} } func (m *HostFreqScalingConfig) String() string { return proto.CompactTextString(m) } func (*HostFreqScalingConfig) ProtoMessage() {} func (*HostFreqScalingConfig) Descriptor() ([]byte, []int) { - return fileDescriptor_hostfrequencyscaling_fd41a70c2d595d1b, []int{0} + return fileDescriptor_hostfrequencyscaling_8098376e28c4e471, []int{0} } func (m *HostFreqScalingConfig) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_HostFreqScalingConfig.Unmarshal(m, b) @@ -72,6 +74,20 @@ func (m *HostFreqScalingConfig) GetScalingFreqPolicy() string { return "" } +func (m *HostFreqScalingConfig) GetLowToHighScaler() string { + if m != nil { + return m.LowToHighScaler + } + return "" +} + +func (m *HostFreqScalingConfig) GetHighToLowScaler() string { + if m != nil { + return m.HighToLowScaler + } + return "" +} + type HostFreqScalingPolicy struct { ScalingGovernor string `protobuf:"bytes,1,opt,name=scaling_governor,json=scalingGovernor,proto3" json:"scaling_governor,omitempty"` ScalingMinFreq string `protobuf:"bytes,2,opt,name=scaling_min_freq,json=scalingMinFreq,proto3" json:"scaling_min_freq,omitempty"` @@ -87,7 +103,7 @@ func (m *HostFreqScalingPolicy) Reset() { *m = HostFreqScalingPolicy{} } func (m *HostFreqScalingPolicy) String() string { return proto.CompactTextString(m) } func (*HostFreqScalingPolicy) ProtoMessage() {} func (*HostFreqScalingPolicy) Descriptor() ([]byte, []int) { - return fileDescriptor_hostfrequencyscaling_fd41a70c2d595d1b, []int{1} + return fileDescriptor_hostfrequencyscaling_8098376e28c4e471, []int{1} } func (m *HostFreqScalingPolicy) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_HostFreqScalingPolicy.Unmarshal(m, b) @@ -149,30 +165,33 @@ func init() { } func init() { - proto.RegisterFile("hostfrequencyscaling.proto", fileDescriptor_hostfrequencyscaling_fd41a70c2d595d1b) -} - -var fileDescriptor_hostfrequencyscaling_fd41a70c2d595d1b = []byte{ - // 324 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x90, 0x4f, 0x4f, 0xc2, 0x30, - 0x18, 0xc6, 0x33, 0x26, 0x46, 0x8a, 0x08, 0xd6, 0x90, 0x34, 0xe8, 0x81, 0x60, 0x62, 0xf0, 0xb2, - 0xc3, 0xbc, 0x18, 0x6f, 0xc6, 0xf8, 0xe7, 0x62, 0x42, 0x30, 0x9e, 0x67, 0x9d, 0x1d, 0x34, 0x96, - 0x16, 0xde, 0x6d, 0x84, 0x7d, 0x2f, 0x3f, 0x8c, 0x1f, 0xc7, 0xf4, 0x6d, 0x89, 0x41, 0x77, 0xda, - 0xf2, 0xeb, 0xef, 0xe9, 0xf3, 0xf6, 0x25, 0x83, 0xb9, 0xc9, 0x8b, 0x0c, 0xc4, 0xaa, 0x14, 0x3a, - 0xad, 0xf2, 0x94, 0x2b, 0xa9, 0x67, 0xd1, 0x12, 0x4c, 0x61, 0x68, 0x13, 0x3f, 0xa3, 0xaf, 0x06, - 0xe9, 0x3f, 0x99, 0xbc, 0x78, 0x00, 0xb1, 0x7a, 0x71, 0xc2, 0x9d, 0xd1, 0x99, 0x9c, 0xd1, 0x37, - 0x42, 0x6d, 0x34, 0xb1, 0xb1, 0x64, 0x69, 0x94, 0x4c, 0xa5, 0xc8, 0x59, 0x30, 0x0c, 0xc7, 0xed, - 0x38, 0x76, 0x97, 0x44, 0xb5, 0xc9, 0x68, 0x4b, 0x26, 0x3e, 0x74, 0xaf, 0x0b, 0xa8, 0xa6, 0xbd, - 0xec, 0x0f, 0xa6, 0x17, 0xa4, 0xeb, 0x1a, 0x84, 0xce, 0x0d, 0x24, 0x25, 0x28, 0xd6, 0x18, 0x06, - 0xe3, 0xd6, 0xb4, 0x83, 0x2a, 0xd2, 0x57, 0x50, 0x34, 0x22, 0x27, 0x7e, 0xf6, 0x04, 0x7d, 0x1c, - 0xa6, 0x62, 0x21, 0xba, 0xc7, 0xfe, 0xc8, 0x96, 0xe2, 0xcd, 0xd5, 0x80, 0x93, 0x7e, 0xed, 0x08, - 0xb4, 0x47, 0xc2, 0x4f, 0x51, 0xb1, 0x00, 0x83, 0xf6, 0x97, 0xc6, 0xa4, 0xb9, 0xe6, 0xaa, 0x14, - 0x58, 0xdc, 0x8e, 0xcf, 0xea, 0xdf, 0xe5, 0xee, 0x9d, 0x3a, 0xf5, 0xa6, 0x71, 0x1d, 0x8c, 0xbe, - 0x83, 0x7f, 0x6b, 0x73, 0x12, 0xbd, 0x24, 0xbd, 0xed, 0xb0, 0x33, 0xb3, 0x16, 0xa0, 0x0d, 0xf8, - 0xc2, 0xae, 0xe7, 0x8f, 0x1e, 0xd3, 0xf1, 0xaf, 0xba, 0x90, 0x1a, 0xdf, 0xe6, 0x17, 0x70, 0xe4, - 0xf9, 0xb3, 0xd4, 0xb6, 0x61, 0xc7, 0xe4, 0x1b, 0x67, 0x86, 0xbb, 0x26, 0xdf, 0xa0, 0x79, 0x4a, - 0x5a, 0xda, 0x7c, 0x88, 0x84, 0x43, 0x3a, 0x67, 0x7b, 0xa8, 0x1c, 0x58, 0x70, 0x0b, 0xe9, 0x9c, - 0x9e, 0x93, 0x0e, 0x1e, 0x2e, 0x15, 0x2f, 0x32, 0x03, 0x0b, 0xd6, 0x44, 0xe1, 0xd0, 0xc2, 0x89, - 0x67, 0xef, 0xfb, 0xb8, 0x82, 0xab, 0x9f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x40, 0xfe, 0xa0, 0xe4, - 0x3d, 0x02, 0x00, 0x00, + proto.RegisterFile("hostfrequencyscaling.proto", fileDescriptor_hostfrequencyscaling_8098376e28c4e471) +} + +var fileDescriptor_hostfrequencyscaling_8098376e28c4e471 = []byte{ + // 370 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x91, 0xcd, 0x4e, 0xe3, 0x30, + 0x14, 0x85, 0x95, 0x66, 0x3a, 0x9a, 0xba, 0xd3, 0x69, 0xc7, 0xa3, 0x4a, 0x51, 0x87, 0x45, 0x55, + 0x24, 0x54, 0x84, 0x94, 0x45, 0xd8, 0x20, 0x76, 0x08, 0x01, 0x5d, 0x80, 0x54, 0xb5, 0x65, 0x6d, + 0x42, 0x70, 0x12, 0x0b, 0xd7, 0xb7, 0x75, 0xd2, 0x9f, 0xbc, 0x04, 0xcf, 0xc7, 0xe3, 0x20, 0x5f, + 0xbb, 0x42, 0x85, 0xae, 0x12, 0x9d, 0xfb, 0x9d, 0xfb, 0x73, 0x4c, 0x7a, 0x39, 0x14, 0x65, 0xaa, + 0xf9, 0x72, 0xc5, 0x55, 0x52, 0x15, 0x49, 0x2c, 0x85, 0xca, 0xc2, 0x85, 0x86, 0x12, 0x68, 0x1d, + 0x3f, 0x83, 0x37, 0x9f, 0x74, 0x47, 0x50, 0x94, 0xb7, 0x9a, 0x2f, 0xa7, 0x16, 0xb8, 0x06, 0x95, + 0x8a, 0x8c, 0x3e, 0x11, 0x6a, 0xac, 0xcc, 0xd8, 0xd8, 0x02, 0xa4, 0x48, 0x04, 0x2f, 0x02, 0xaf, + 0xef, 0x0f, 0x9b, 0x51, 0x64, 0x9b, 0x84, 0x07, 0x9d, 0xe1, 0x4e, 0x19, 0x3b, 0xd3, 0x8d, 0x2a, + 0x75, 0x35, 0xe9, 0xa4, 0x5f, 0x64, 0x7a, 0x42, 0xda, 0x76, 0x02, 0x57, 0x05, 0x68, 0xb6, 0xd2, + 0x32, 0xa8, 0xf5, 0xbd, 0x61, 0x63, 0xd2, 0x42, 0x14, 0xd5, 0x47, 0x2d, 0x69, 0x48, 0xfe, 0xb9, + 0xdd, 0x19, 0xf2, 0xb8, 0x4c, 0x15, 0xf8, 0xc8, 0xfe, 0x75, 0x25, 0x33, 0x14, 0x3b, 0x57, 0xf4, + 0x8c, 0x50, 0x09, 0x1b, 0x56, 0x02, 0xcb, 0x45, 0x96, 0xe3, 0x01, 0x5c, 0x07, 0x3f, 0x10, 0x6f, + 0x4b, 0xd8, 0xcc, 0x60, 0x24, 0xb2, 0x7c, 0x8a, 0xb2, 0x81, 0x91, 0x2a, 0x81, 0x19, 0x93, 0x83, + 0xeb, 0x16, 0x36, 0x95, 0x19, 0xdc, 0xc3, 0xc6, 0xc2, 0xbd, 0x98, 0x74, 0x0f, 0x1e, 0x47, 0x3b, + 0xc4, 0x7f, 0xe5, 0x55, 0xe0, 0xa1, 0xcd, 0xfc, 0xd2, 0x88, 0xd4, 0xd7, 0xb1, 0x5c, 0x71, 0x3c, + 0xa9, 0x19, 0x1d, 0x1d, 0x4e, 0xcc, 0x6e, 0x3c, 0xb1, 0xe8, 0x65, 0xed, 0xc2, 0x1b, 0xbc, 0x7b, + 0xdf, 0x1e, 0xc4, 0x9d, 0x75, 0x4a, 0x3a, 0xbb, 0x18, 0x32, 0x58, 0x73, 0xad, 0x40, 0xbb, 0x81, + 0x6d, 0xa7, 0xdf, 0x39, 0x99, 0x0e, 0x3f, 0xd1, 0xb9, 0x50, 0x98, 0x9a, 0x8b, 0xf6, 0x8f, 0xd3, + 0x1f, 0x84, 0x32, 0x13, 0xf6, 0xc8, 0x78, 0x6b, 0x49, 0x7f, 0x9f, 0x8c, 0xb7, 0x48, 0xfe, 0x27, + 0x0d, 0x05, 0x2f, 0x9c, 0xc5, 0x3a, 0xc9, 0x5d, 0x98, 0xbf, 0x8c, 0x70, 0xa5, 0x93, 0x9c, 0x1e, + 0x93, 0x16, 0x16, 0x17, 0x32, 0x2e, 0x53, 0xd0, 0x73, 0x17, 0xe0, 0x6f, 0x23, 0x8e, 0x9d, 0xf6, + 0xfc, 0x13, 0x23, 0x38, 0xff, 0x08, 0x00, 0x00, 0xff, 0xff, 0xf9, 0x85, 0x30, 0x80, 0x97, 0x02, + 0x00, 0x00, } diff --git a/modules/hostfrequencyscaling/proto/hostfrequencyscaling.proto b/modules/hostfrequencyscaling/proto/hostfrequencyscaling.proto index 1ba320e0e..55301af53 100644 --- a/modules/hostfrequencyscaling/proto/hostfrequencyscaling.proto +++ b/modules/hostfrequencyscaling/proto/hostfrequencyscaling.proto @@ -13,7 +13,9 @@ message HostFreqScalingConfig { map freq_scal_policies = 1; string freq_sensor_url = 2; - string scaling_freq_policy = 3; + string scaling_freq_policy = 3; + string low_to_high_scaler = 4; + string high_to_low_scaler = 5; } message HostFreqScalingPolicy { diff --git a/modules/hostthermaldiscovery/hostthermaldiscovery.go b/modules/hostthermaldiscovery/hostthermaldiscovery.go index 073ee2483..8ce3cbe27 100644 --- a/modules/hostthermaldiscovery/hostthermaldiscovery.go +++ b/modules/hostthermaldiscovery/hostthermaldiscovery.go @@ -84,15 +84,15 @@ func (*HostDisc) NewConfig() proto.Message { ThermalThresholds: map[string]*pb.HostThermalThresholds{ "CPUThermalThresholds": { LowerNormal: 3000, - UpperNormal: 60000, - LowerHigh: 60000, - UpperHigh: 70000, + UpperNormal: 80000, + LowerHigh: 80000, + UpperHigh: 90000, LowerCritical: 3000, - UpperCritical: 70000, + UpperCritical: 90000, }, }, } - return r + return } // UpdateConfig updates the running config From e1448237af239c2f5634ba6a09b4a4ebcf98bd91 Mon Sep 17 00:00:00 2001 From: Ghazanfar Ali Date: Fri, 20 Dec 2019 20:13:16 -0700 Subject: [PATCH 46/87] bug fix --- modules/hostfrequencyscaling/hostfrequencyscaling.go | 2 +- modules/hostthermaldiscovery/hostthermaldiscovery.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/hostfrequencyscaling/hostfrequencyscaling.go b/modules/hostfrequencyscaling/hostfrequencyscaling.go index 0d68ba7b7..17a932d6c 100644 --- a/modules/hostfrequencyscaling/hostfrequencyscaling.go +++ b/modules/hostfrequencyscaling/hostfrequencyscaling.go @@ -245,7 +245,7 @@ func (*HFS) NewConfig() proto.Message { }, }, } - return + return r } // UpdateConfig updates the running config diff --git a/modules/hostthermaldiscovery/hostthermaldiscovery.go b/modules/hostthermaldiscovery/hostthermaldiscovery.go index 8ce3cbe27..6e0eab501 100644 --- a/modules/hostthermaldiscovery/hostthermaldiscovery.go +++ b/modules/hostthermaldiscovery/hostthermaldiscovery.go @@ -92,7 +92,7 @@ func (*HostDisc) NewConfig() proto.Message { }, }, } - return + return r } // UpdateConfig updates the running config From 8ddc5ef50b10d510b9e335c037e9fe616a5a613e Mon Sep 17 00:00:00 2001 From: "J. Lowell Wofford" Date: Fri, 20 Dec 2019 23:52:03 -0700 Subject: [PATCH 47/87] better edge elimination in stage2 graph build; graph sanity check --- core/StateMutationEngine.go | 53 +++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/core/StateMutationEngine.go b/core/StateMutationEngine.go index 4c1c2a7b7..b05a7fe28 100644 --- a/core/StateMutationEngine.go +++ b/core/StateMutationEngine.go @@ -697,6 +697,32 @@ func nodeMerge(list []int, nodes []*mutationNode) (*mutationNode, []*mutationEdg return node, node.out } +func nodeMerge(list []int, nodes []*mutationNode) (*mutationNode, []*mutationEdge) { + // build a new node from a merge of multiple nodes + // use least-common specification + // note: this will choke on a zero length list, but that shouldn't happen + node := nodes[list[0]] // build off of the first node + for i := 1; i < len(list); i++ { + // remap edges + inode := nodes[list[i]] + for _, e := range inode.in { + if !edgeInEdges(e, node.in) { // don't add if we already have this + e.to = node + node.in = append(node.in, e) + } + } + for _, e := range inode.out { + if !edgeInEdges(e, node.out) { + e.from = node + node.out = append(node.out, e) + } + } + // prune spec + node.spec.LeastCommon(inode.spec) + } + return node, node.out +} + // buildGraphStage1 builds a fully expanded set of paths branching from a starting root // this will build a very verbose, probably unusable graph // it is expected that later graph stages will clean it up and make it more sane @@ -1025,6 +1051,33 @@ func (sme *StateMutationEngine) buildGraphStripState(nodes []*mutationNode, edge } return edges } + fmt.Println("=== BEGIN: Graph sanity check ===") + // sanity checks + // 1. Equal number of nodeEdges as edges? + if len(nodeEdges) != len(edges) { + fmt.Printf("len(nodeEdges) != len(edges) : %d != %d\n", len(nodeEdges), len(edges)) + ret = false + } + // 2. Equal number of edgeNodes as nodes? + if len(edgeNodes) != len(nodes) { + fmt.Printf("len(edgeNodes) != len(nodes) : %d != %d\n", len(edgeNodes), len(nodes)) + ret = false + } + // 2. nodeEdges should have ref count 2 + bad := 0 + for _, c := range nodeEdges { + if c != 2 { + bad++ + } + } + if bad > 0 { + fmt.Printf("%d edges have ref count != 2\n", bad) + ret = false + } + + fmt.Println("=== END: Graph sanity check ===") + return ret +} // 1. iterate through the nodes // - remove dependecy violating info From c13edde3d1d5e2d9109897c301a6ca28683ea437 Mon Sep 17 00:00:00 2001 From: "J. Lowell Wofford" Date: Sat, 21 Dec 2019 01:43:51 -0700 Subject: [PATCH 48/87] buildGraph stage 2 now generates sane, discovery dependency aware graphs --- core/StateMutationEngine.go | 1 + 1 file changed, 1 insertion(+) diff --git a/core/StateMutationEngine.go b/core/StateMutationEngine.go index b05a7fe28..fff8089e1 100644 --- a/core/StateMutationEngine.go +++ b/core/StateMutationEngine.go @@ -1089,6 +1089,7 @@ OUTER_NODE: nr := n.spec.Requires() ne := n.spec.Excludes() vr, ve := sme.nodeViolatesDeps(deps, n) // get list of violating urls + fmt.Printf("vr %v ve %v\n", vr, ve) for _, r := range vr { delete(nr, r) } From cac96d80daacd4aff652b8229d71808e4fb5d6e9 Mon Sep 17 00:00:00 2001 From: Ghazanfar Ali Date: Mon, 23 Dec 2019 11:49:18 -0700 Subject: [PATCH 49/87] freqdiscovery --- modules/hostthermaldiscovery/hostthermaldiscovery.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/hostthermaldiscovery/hostthermaldiscovery.go b/modules/hostthermaldiscovery/hostthermaldiscovery.go index 6e0eab501..92dc174f4 100644 --- a/modules/hostthermaldiscovery/hostthermaldiscovery.go +++ b/modules/hostthermaldiscovery/hostthermaldiscovery.go @@ -185,7 +185,7 @@ func (hostDisc *HostDisc) Entry() { select { case <-hostDisc.pollTicker.C: go hostDisc.discoverHostCPUTemp() - go hostDisc.DiscFreqScaler() + //go hostDisc.DiscFreqScaler() if hostDisc.cfg.GetLogThermalData() == true { go hostDisc.CapturingStatData() } From 090c868de54be9b0a1dda9efb348d4649cc99fd4 Mon Sep 17 00:00:00 2001 From: Ghazanfar Ali Date: Mon, 23 Dec 2019 12:14:43 -0700 Subject: [PATCH 50/87] time in ns --- .../hostthermaldiscovery/hostthermaldiscovery.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/modules/hostthermaldiscovery/hostthermaldiscovery.go b/modules/hostthermaldiscovery/hostthermaldiscovery.go index 92dc174f4..9e69e7a74 100644 --- a/modules/hostthermaldiscovery/hostthermaldiscovery.go +++ b/modules/hostthermaldiscovery/hostthermaldiscovery.go @@ -185,7 +185,7 @@ func (hostDisc *HostDisc) Entry() { select { case <-hostDisc.pollTicker.C: go hostDisc.discoverHostCPUTemp() - //go hostDisc.DiscFreqScaler() + go hostDisc.DiscFreqScaler() if hostDisc.cfg.GetLogThermalData() == true { go hostDisc.CapturingStatData() } @@ -199,8 +199,8 @@ func (hostDisc *HostDisc) Entry() { func (hostDisc *HostDisc) CapturingStatData() { freqScaler := hostDisc.preFreqScaler temp := hostDisc.prevTemp - t := time.Now().UnixNano() // / int64(time.Millisecond) - record := fmt.Sprintf("%d,%d,%s\n", t, temp, freqScaler) + t := time.Now() // / int64(time.Millisecond) + record := fmt.Sprintf("%s,%d,%s\n", t.String(), temp, freqScaler) _, err := hostDisc.file.WriteString(record) if err != nil { @@ -213,10 +213,10 @@ func (hostDisc *HostDisc) CapturingStatData() { func (hostDisc *HostDisc) DiscFreqScaler() { hostFreqScaler := hostDisc.ReadFreqScaler() - if hostFreqScaler == hostDisc.preFreqScaler { - // no change in frequency scaler so no need to generate discovery event - return - } + // if hostFreqScaler == hostDisc.preFreqScaler { + // // no change in frequency scaler so no need to generate discovery event + // return + // } hostDisc.preFreqScaler = hostFreqScaler vid := profileMap[hostFreqScaler] From 57d2aa074c8ddd66b3dde28fd7b91f1d4b5767f1 Mon Sep 17 00:00:00 2001 From: Ghazanfar Ali Date: Mon, 23 Dec 2019 13:18:12 -0700 Subject: [PATCH 51/87] powersave only --- modules/hostfrequencyscaling/hostfrequencyscaling.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/hostfrequencyscaling/hostfrequencyscaling.go b/modules/hostfrequencyscaling/hostfrequencyscaling.go index 17a932d6c..c4bf8bfa4 100644 --- a/modules/hostfrequencyscaling/hostfrequencyscaling.go +++ b/modules/hostfrequencyscaling/hostfrequencyscaling.go @@ -220,7 +220,7 @@ func (*HFS) NewConfig() proto.Message { FreqSensorUrl: freqSensorPath, ScalingFreqPolicy: hostFreqScalerURL, HighToLowScaler: "powersave", - LowToHighScaler: "performance", + LowToHighScaler: "powersave", FreqScalPolicies: map[string]*pb.HostFreqScalingPolicy{ "powersave": { ScalingGovernor: "powersave", From 32eba0f7b37439b4caa91e2c76427a8b78b54a84 Mon Sep 17 00:00:00 2001 From: Ghazanfar Ali Date: Mon, 23 Dec 2019 16:33:04 -0700 Subject: [PATCH 52/87] adding schedutil scaler --- .../proto/HostFrequencyScaler.pb.go | 30 +++++++++++-------- .../proto/HostFrequencyScaler.proto | 1 + .../hostfrequencyscaling.go | 5 ++-- .../hostthermaldiscovery.go | 1 + 4 files changed, 22 insertions(+), 15 deletions(-) diff --git a/extensions/HostFrequencyScaler/proto/HostFrequencyScaler.pb.go b/extensions/HostFrequencyScaler/proto/HostFrequencyScaler.pb.go index fc9116f26..2f83d3b7f 100644 --- a/extensions/HostFrequencyScaler/proto/HostFrequencyScaler.pb.go +++ b/extensions/HostFrequencyScaler/proto/HostFrequencyScaler.pb.go @@ -24,24 +24,27 @@ const ( HostFrequencyScaler_NONE HostFrequencyScaler_ScalerState = 0 HostFrequencyScaler_POWER_SAVE HostFrequencyScaler_ScalerState = 1 HostFrequencyScaler_PERFORMANCE HostFrequencyScaler_ScalerState = 2 + HostFrequencyScaler_SCHEDUTIL HostFrequencyScaler_ScalerState = 3 ) var HostFrequencyScaler_ScalerState_name = map[int32]string{ 0: "NONE", 1: "POWER_SAVE", 2: "PERFORMANCE", + 3: "SCHEDUTIL", } var HostFrequencyScaler_ScalerState_value = map[string]int32{ "NONE": 0, "POWER_SAVE": 1, "PERFORMANCE": 2, + "SCHEDUTIL": 3, } func (x HostFrequencyScaler_ScalerState) String() string { return proto.EnumName(HostFrequencyScaler_ScalerState_name, int32(x)) } func (HostFrequencyScaler_ScalerState) EnumDescriptor() ([]byte, []int) { - return fileDescriptor_HostFrequencyScaler_2508640b1434a762, []int{0, 0} + return fileDescriptor_HostFrequencyScaler_4de6e1b7f651efb6, []int{0, 0} } type HostFrequencyScaler struct { @@ -55,7 +58,7 @@ func (m *HostFrequencyScaler) Reset() { *m = HostFrequencyScaler{} } func (m *HostFrequencyScaler) String() string { return proto.CompactTextString(m) } func (*HostFrequencyScaler) ProtoMessage() {} func (*HostFrequencyScaler) Descriptor() ([]byte, []int) { - return fileDescriptor_HostFrequencyScaler_2508640b1434a762, []int{0} + return fileDescriptor_HostFrequencyScaler_4de6e1b7f651efb6, []int{0} } func (m *HostFrequencyScaler) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_HostFrequencyScaler.Unmarshal(m, b) @@ -88,19 +91,20 @@ func init() { } func init() { - proto.RegisterFile("HostFrequencyScaler.proto", fileDescriptor_HostFrequencyScaler_2508640b1434a762) + proto.RegisterFile("HostFrequencyScaler.proto", fileDescriptor_HostFrequencyScaler_4de6e1b7f651efb6) } -var fileDescriptor_HostFrequencyScaler_2508640b1434a762 = []byte{ - // 146 bytes of a gzipped FileDescriptorProto +var fileDescriptor_HostFrequencyScaler_4de6e1b7f651efb6 = []byte{ + // 161 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0xf4, 0xc8, 0x2f, 0x2e, 0x71, 0x2b, 0x4a, 0x2d, 0x2c, 0x4d, 0xcd, 0x4b, 0xae, 0x0c, 0x4e, 0x4e, 0xcc, 0x49, 0x2d, 0xd2, - 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x62, 0x05, 0x53, 0x4a, 0xbd, 0x8c, 0x5c, 0xc2, 0x58, 0x14, - 0x09, 0xd9, 0x70, 0xb1, 0x16, 0x97, 0x24, 0x96, 0xa4, 0x4a, 0x30, 0x2a, 0x30, 0x6a, 0xf0, 0x19, - 0xa9, 0x41, 0x74, 0xe9, 0x61, 0x33, 0x0f, 0x42, 0x05, 0x83, 0x54, 0x07, 0x41, 0x34, 0x29, 0x59, - 0x70, 0x71, 0x23, 0x89, 0x0a, 0x71, 0x70, 0xb1, 0xf8, 0xf9, 0xfb, 0xb9, 0x0a, 0x30, 0x08, 0xf1, - 0x71, 0x71, 0x05, 0xf8, 0x87, 0xbb, 0x06, 0xc5, 0x07, 0x3b, 0x86, 0xb9, 0x0a, 0x30, 0x0a, 0xf1, - 0x73, 0x71, 0x07, 0xb8, 0x06, 0xb9, 0xf9, 0x07, 0xf9, 0x3a, 0xfa, 0x39, 0xbb, 0x0a, 0x30, 0x25, - 0xb1, 0x81, 0xed, 0x31, 0x06, 0x04, 0x00, 0x00, 0xff, 0xff, 0xe5, 0xb5, 0xba, 0x7f, 0xba, 0x00, - 0x00, 0x00, + 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x62, 0x05, 0x53, 0x4a, 0x73, 0x18, 0xb9, 0x84, 0xb1, 0x28, + 0x12, 0xb2, 0xe1, 0x62, 0x2d, 0x2e, 0x49, 0x2c, 0x49, 0x95, 0x60, 0x54, 0x60, 0xd4, 0xe0, 0x33, + 0x52, 0x83, 0xe8, 0xd2, 0xc3, 0x66, 0x1e, 0x84, 0x0a, 0x06, 0xa9, 0x0e, 0x82, 0x68, 0x52, 0x72, + 0xe7, 0xe2, 0x46, 0x12, 0x15, 0xe2, 0xe0, 0x62, 0xf1, 0xf3, 0xf7, 0x73, 0x15, 0x60, 0x10, 0xe2, + 0xe3, 0xe2, 0x0a, 0xf0, 0x0f, 0x77, 0x0d, 0x8a, 0x0f, 0x76, 0x0c, 0x73, 0x15, 0x60, 0x14, 0xe2, + 0xe7, 0xe2, 0x0e, 0x70, 0x0d, 0x72, 0xf3, 0x0f, 0xf2, 0x75, 0xf4, 0x73, 0x76, 0x15, 0x60, 0x12, + 0xe2, 0xe5, 0xe2, 0x0c, 0x76, 0xf6, 0x70, 0x75, 0x09, 0x0d, 0xf1, 0xf4, 0x11, 0x60, 0x4e, 0x62, + 0x03, 0x5b, 0x6b, 0x0c, 0x08, 0x00, 0x00, 0xff, 0xff, 0x61, 0x02, 0x2d, 0xc6, 0xc9, 0x00, 0x00, + 0x00, } diff --git a/extensions/HostFrequencyScaler/proto/HostFrequencyScaler.proto b/extensions/HostFrequencyScaler/proto/HostFrequencyScaler.proto index 9ac331ecb..8bca56cc3 100644 --- a/extensions/HostFrequencyScaler/proto/HostFrequencyScaler.proto +++ b/extensions/HostFrequencyScaler/proto/HostFrequencyScaler.proto @@ -15,6 +15,7 @@ message HostFrequencyScaler{ NONE = 0; POWER_SAVE = 1; PERFORMANCE = 2; + SCHEDUTIL = 3; } ScalerState state = 1; diff --git a/modules/hostfrequencyscaling/hostfrequencyscaling.go b/modules/hostfrequencyscaling/hostfrequencyscaling.go index c4bf8bfa4..a19ac86f1 100644 --- a/modules/hostfrequencyscaling/hostfrequencyscaling.go +++ b/modules/hostfrequencyscaling/hostfrequencyscaling.go @@ -85,6 +85,7 @@ const ( var profileMap = map[string]string{ "performance": scalpb.HostFrequencyScaler_PERFORMANCE.String(), "powersave": scalpb.HostFrequencyScaler_POWER_SAVE.String(), + "schedutil": scalpb.HostFrequencyScaler_SCHEDUTIL.String(), } type hfscalmut struct { @@ -219,8 +220,8 @@ func (*HFS) NewConfig() proto.Message { r := &pb.HostFreqScalingConfig{ FreqSensorUrl: freqSensorPath, ScalingFreqPolicy: hostFreqScalerURL, - HighToLowScaler: "powersave", - LowToHighScaler: "powersave", + HighToLowScaler: "schedutil", + LowToHighScaler: "schedutil", FreqScalPolicies: map[string]*pb.HostFreqScalingPolicy{ "powersave": { ScalingGovernor: "powersave", diff --git a/modules/hostthermaldiscovery/hostthermaldiscovery.go b/modules/hostthermaldiscovery/hostthermaldiscovery.go index 9e69e7a74..94a96649c 100644 --- a/modules/hostthermaldiscovery/hostthermaldiscovery.go +++ b/modules/hostthermaldiscovery/hostthermaldiscovery.go @@ -57,6 +57,7 @@ var _ lib.ModuleSelfService = (*HostDisc)(nil) var profileMap = map[string]string{ "performance": scalpb.HostFrequencyScaler_PERFORMANCE.String(), "powersave": scalpb.HostFrequencyScaler_POWER_SAVE.String(), + "schedutil": scalpb.HostFrequencyScaler_SCHEDUTIL.String(), } // HostDisc provides hostdiscovery module capabilities From 2f54bf62a76519295f44e9b99dd2fc255162234c Mon Sep 17 00:00:00 2001 From: Ghazanfar Ali Date: Mon, 23 Dec 2019 20:09:24 -0700 Subject: [PATCH 53/87] perf --- modules/hostfrequencyscaling/hostfrequencyscaling.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/hostfrequencyscaling/hostfrequencyscaling.go b/modules/hostfrequencyscaling/hostfrequencyscaling.go index a19ac86f1..7d73d40fe 100644 --- a/modules/hostfrequencyscaling/hostfrequencyscaling.go +++ b/modules/hostfrequencyscaling/hostfrequencyscaling.go @@ -220,8 +220,8 @@ func (*HFS) NewConfig() proto.Message { r := &pb.HostFreqScalingConfig{ FreqSensorUrl: freqSensorPath, ScalingFreqPolicy: hostFreqScalerURL, - HighToLowScaler: "schedutil", - LowToHighScaler: "schedutil", + HighToLowScaler: "performance", + LowToHighScaler: "performance", FreqScalPolicies: map[string]*pb.HostFreqScalingPolicy{ "powersave": { ScalingGovernor: "powersave", From 6a274fcf7a697e19d489d36e6457da8c6ad8127a Mon Sep 17 00:00:00 2001 From: Ghazanfar Ali Date: Tue, 24 Dec 2019 09:56:56 -0700 Subject: [PATCH 54/87] adjusting the thresholds --- modules/hostthermaldiscovery/hostthermaldiscovery.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/hostthermaldiscovery/hostthermaldiscovery.go b/modules/hostthermaldiscovery/hostthermaldiscovery.go index 94a96649c..5b61c6764 100644 --- a/modules/hostthermaldiscovery/hostthermaldiscovery.go +++ b/modules/hostthermaldiscovery/hostthermaldiscovery.go @@ -85,11 +85,11 @@ func (*HostDisc) NewConfig() proto.Message { ThermalThresholds: map[string]*pb.HostThermalThresholds{ "CPUThermalThresholds": { LowerNormal: 3000, - UpperNormal: 80000, - LowerHigh: 80000, - UpperHigh: 90000, + UpperNormal: 93000, + LowerHigh: 93000, + UpperHigh: 98000, LowerCritical: 3000, - UpperCritical: 90000, + UpperCritical: 98000, }, }, } From 5e06f056d7acdb7568ede123d9232261b365898d Mon Sep 17 00:00:00 2001 From: Ghazanfar Ali Date: Tue, 24 Dec 2019 10:05:10 -0700 Subject: [PATCH 55/87] reversing back scalers to normal flow --- modules/hostfrequencyscaling/hostfrequencyscaling.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/hostfrequencyscaling/hostfrequencyscaling.go b/modules/hostfrequencyscaling/hostfrequencyscaling.go index 7d73d40fe..4e2023ba6 100644 --- a/modules/hostfrequencyscaling/hostfrequencyscaling.go +++ b/modules/hostfrequencyscaling/hostfrequencyscaling.go @@ -220,7 +220,7 @@ func (*HFS) NewConfig() proto.Message { r := &pb.HostFreqScalingConfig{ FreqSensorUrl: freqSensorPath, ScalingFreqPolicy: hostFreqScalerURL, - HighToLowScaler: "performance", + HighToLowScaler: "powersave", LowToHighScaler: "performance", FreqScalPolicies: map[string]*pb.HostFreqScalingPolicy{ "powersave": { From 7d658351f260316ac6f71e9d5298a8d5f021ffd5 Mon Sep 17 00:00:00 2001 From: Ghazanfar Ali Date: Tue, 24 Dec 2019 10:29:06 -0700 Subject: [PATCH 56/87] changing normal/high temp thresholds --- modules/hostthermaldiscovery/hostthermaldiscovery.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/hostthermaldiscovery/hostthermaldiscovery.go b/modules/hostthermaldiscovery/hostthermaldiscovery.go index 5b61c6764..91bb8cf0f 100644 --- a/modules/hostthermaldiscovery/hostthermaldiscovery.go +++ b/modules/hostthermaldiscovery/hostthermaldiscovery.go @@ -85,8 +85,8 @@ func (*HostDisc) NewConfig() proto.Message { ThermalThresholds: map[string]*pb.HostThermalThresholds{ "CPUThermalThresholds": { LowerNormal: 3000, - UpperNormal: 93000, - LowerHigh: 93000, + UpperNormal: 80000, + LowerHigh: 80000, UpperHigh: 98000, LowerCritical: 3000, UpperCritical: 98000, From 78fca4da0d1a448f5b0eb8a271ad98e86171c88c Mon Sep 17 00:00:00 2001 From: "J. Lowell Wofford" Date: Tue, 24 Dec 2019 11:59:33 -0700 Subject: [PATCH 57/87] remove debug print statements --- core/StateMutationEngine.go | 1 - 1 file changed, 1 deletion(-) diff --git a/core/StateMutationEngine.go b/core/StateMutationEngine.go index fff8089e1..b05a7fe28 100644 --- a/core/StateMutationEngine.go +++ b/core/StateMutationEngine.go @@ -1089,7 +1089,6 @@ OUTER_NODE: nr := n.spec.Requires() ne := n.spec.Excludes() vr, ve := sme.nodeViolatesDeps(deps, n) // get list of violating urls - fmt.Printf("vr %v ve %v\n", vr, ve) for _, r := range vr { delete(nr, r) } From 4e8e8728f0e91fecd568d174717b39a150ee81e5 Mon Sep 17 00:00:00 2001 From: Ghazanfar Ali Date: Tue, 24 Dec 2019 12:09:49 -0700 Subject: [PATCH 58/87] making thresholds config flat --- .../hostthermaldiscovery.go | 28 ++-- .../proto/hostthermaldiscovery.pb.go | 136 ++++++------------ .../proto/hostthermaldiscovery.proto | 22 ++- 3 files changed, 72 insertions(+), 114 deletions(-) diff --git a/modules/hostthermaldiscovery/hostthermaldiscovery.go b/modules/hostthermaldiscovery/hostthermaldiscovery.go index 91bb8cf0f..3f3beb8de 100644 --- a/modules/hostthermaldiscovery/hostthermaldiscovery.go +++ b/modules/hostthermaldiscovery/hostthermaldiscovery.go @@ -82,15 +82,13 @@ func (*HostDisc) NewConfig() proto.Message { FreqSensorUrl: freqSensorPath, LogThermalData: true, LogHere: "/tmp/ThermalLog.txt", - ThermalThresholds: map[string]*pb.HostThermalThresholds{ - "CPUThermalThresholds": { LowerNormal: 3000, UpperNormal: 80000, LowerHigh: 80000, UpperHigh: 98000, LowerCritical: 3000, UpperCritical: 98000, - }, + }, } return r @@ -342,15 +340,25 @@ func (hostDisc *HostDisc) lambdaStateDiscovery(v CPUTempObj) (string, int32) { cpuTemp := v.CPUTemp cpuTempState := thpb.HostThermal_CPU_TEMP_NONE - cpuThermalThresholds := hostDisc.cfg.GetThermalThresholds() - lowerNormal := cpuThermalThresholds["CPUThermalThresholds"].GetLowerNormal() - upperNormal := cpuThermalThresholds["CPUThermalThresholds"].GetUpperNormal() + + lowerNormal := hostDisc.cfg.GetLowerNormal() + upperNormal := hostDisc.cfg..GetUpperNormal() - lowerHigh := cpuThermalThresholds["CPUThermalThresholds"].GetLowerHigh() - upperHigh := cpuThermalThresholds["CPUThermalThresholds"].GetUpperHigh() + lowerHigh := hostDisc.cfg.GetLowerHigh() + upperHigh := hostDisc.cfg.GetUpperHigh() - lowerCritical := cpuThermalThresholds["CPUThermalThresholds"].GetLowerCritical() - upperCritical := cpuThermalThresholds["CPUThermalThresholds"].GetUpperCritical() + lowerCritical := hostDisc.cfg.GetLowerCritical() + upperCritical := hostDisc.cfg.GetUpperCritical() + + // cpuThermalThresholds := hostDisc.cfg.GetThermalThresholds() + // lowerNormal := cpuThermalThresholds["CPUThermalThresholds"].GetLowerNormal() + // upperNormal := cpuThermalThresholds["CPUThermalThresholds"].GetUpperNormal() + + // lowerHigh := cpuThermalThresholds["CPUThermalThresholds"].GetLowerHigh() + // upperHigh := cpuThermalThresholds["CPUThermalThresholds"].GetUpperHigh() + + // lowerCritical := cpuThermalThresholds["CPUThermalThresholds"].GetLowerCritical() + // upperCritical := cpuThermalThresholds["CPUThermalThresholds"].GetUpperCritical() if cpuTemp <= lowerCritical || cpuTemp >= upperCritical { cpuTempState = thpb.HostThermal_CPU_TEMP_CRITICAL diff --git a/modules/hostthermaldiscovery/proto/hostthermaldiscovery.pb.go b/modules/hostthermaldiscovery/proto/hostthermaldiscovery.pb.go index 1da28f83c..e7ae34582 100644 --- a/modules/hostthermaldiscovery/proto/hostthermaldiscovery.pb.go +++ b/modules/hostthermaldiscovery/proto/hostthermaldiscovery.pb.go @@ -19,22 +19,27 @@ var _ = math.Inf const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package type HostDiscoveryConfig struct { - PollingInterval string `protobuf:"bytes,1,opt,name=polling_interval,json=pollingInterval,proto3" json:"polling_interval,omitempty"` - TempSensorPath string `protobuf:"bytes,2,opt,name=temp_sensor_path,json=tempSensorPath,proto3" json:"temp_sensor_path,omitempty"` - FreqSensorUrl string `protobuf:"bytes,3,opt,name=freq_sensor_url,json=freqSensorUrl,proto3" json:"freq_sensor_url,omitempty"` - ThermalThresholds map[string]*HostThermalThresholds `protobuf:"bytes,4,rep,name=thermal_thresholds,json=thermalThresholds,proto3" json:"thermal_thresholds,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` - LogThermalData bool `protobuf:"varint,5,opt,name=log_thermal_data,json=logThermalData,proto3" json:"log_thermal_data,omitempty"` - LogHere string `protobuf:"bytes,6,opt,name=log_here,json=logHere,proto3" json:"log_here,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` + PollingInterval string `protobuf:"bytes,1,opt,name=polling_interval,json=pollingInterval,proto3" json:"polling_interval,omitempty"` + TempSensorPath string `protobuf:"bytes,2,opt,name=temp_sensor_path,json=tempSensorPath,proto3" json:"temp_sensor_path,omitempty"` + FreqSensorUrl string `protobuf:"bytes,3,opt,name=freq_sensor_url,json=freqSensorUrl,proto3" json:"freq_sensor_url,omitempty"` + LogThermalData bool `protobuf:"varint,4,opt,name=log_thermal_data,json=logThermalData,proto3" json:"log_thermal_data,omitempty"` + LogHere string `protobuf:"bytes,5,opt,name=log_here,json=logHere,proto3" json:"log_here,omitempty"` + LowerNormal int32 `protobuf:"varint,6,opt,name=lower_normal,json=lowerNormal,proto3" json:"lower_normal,omitempty"` + UpperNormal int32 `protobuf:"varint,7,opt,name=upper_normal,json=upperNormal,proto3" json:"upper_normal,omitempty"` + LowerHigh int32 `protobuf:"varint,8,opt,name=lower_high,json=lowerHigh,proto3" json:"lower_high,omitempty"` + UpperHigh int32 `protobuf:"varint,9,opt,name=upper_high,json=upperHigh,proto3" json:"upper_high,omitempty"` + LowerCritical int32 `protobuf:"varint,10,opt,name=lower_critical,json=lowerCritical,proto3" json:"lower_critical,omitempty"` + UpperCritical int32 `protobuf:"varint,11,opt,name=upper_critical,json=upperCritical,proto3" json:"upper_critical,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` } func (m *HostDiscoveryConfig) Reset() { *m = HostDiscoveryConfig{} } func (m *HostDiscoveryConfig) String() string { return proto.CompactTextString(m) } func (*HostDiscoveryConfig) ProtoMessage() {} func (*HostDiscoveryConfig) Descriptor() ([]byte, []int) { - return fileDescriptor_hostthermaldiscovery_bfeffec62fafe688, []int{0} + return fileDescriptor_hostthermaldiscovery_01a159d510988b58, []int{0} } func (m *HostDiscoveryConfig) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_HostDiscoveryConfig.Unmarshal(m, b) @@ -75,13 +80,6 @@ func (m *HostDiscoveryConfig) GetFreqSensorUrl() string { return "" } -func (m *HostDiscoveryConfig) GetThermalThresholds() map[string]*HostThermalThresholds { - if m != nil { - return m.ThermalThresholds - } - return nil -} - func (m *HostDiscoveryConfig) GetLogThermalData() bool { if m != nil { return m.LogThermalData @@ -96,78 +94,42 @@ func (m *HostDiscoveryConfig) GetLogHere() string { return "" } -type HostThermalThresholds struct { - LowerNormal int32 `protobuf:"varint,1,opt,name=lower_normal,json=lowerNormal,proto3" json:"lower_normal,omitempty"` - UpperNormal int32 `protobuf:"varint,2,opt,name=upper_normal,json=upperNormal,proto3" json:"upper_normal,omitempty"` - LowerHigh int32 `protobuf:"varint,3,opt,name=lower_high,json=lowerHigh,proto3" json:"lower_high,omitempty"` - UpperHigh int32 `protobuf:"varint,4,opt,name=upper_high,json=upperHigh,proto3" json:"upper_high,omitempty"` - LowerCritical int32 `protobuf:"varint,5,opt,name=lower_critical,json=lowerCritical,proto3" json:"lower_critical,omitempty"` - UpperCritical int32 `protobuf:"varint,6,opt,name=upper_critical,json=upperCritical,proto3" json:"upper_critical,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *HostThermalThresholds) Reset() { *m = HostThermalThresholds{} } -func (m *HostThermalThresholds) String() string { return proto.CompactTextString(m) } -func (*HostThermalThresholds) ProtoMessage() {} -func (*HostThermalThresholds) Descriptor() ([]byte, []int) { - return fileDescriptor_hostthermaldiscovery_bfeffec62fafe688, []int{1} -} -func (m *HostThermalThresholds) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_HostThermalThresholds.Unmarshal(m, b) -} -func (m *HostThermalThresholds) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_HostThermalThresholds.Marshal(b, m, deterministic) -} -func (dst *HostThermalThresholds) XXX_Merge(src proto.Message) { - xxx_messageInfo_HostThermalThresholds.Merge(dst, src) -} -func (m *HostThermalThresholds) XXX_Size() int { - return xxx_messageInfo_HostThermalThresholds.Size(m) -} -func (m *HostThermalThresholds) XXX_DiscardUnknown() { - xxx_messageInfo_HostThermalThresholds.DiscardUnknown(m) -} - -var xxx_messageInfo_HostThermalThresholds proto.InternalMessageInfo - -func (m *HostThermalThresholds) GetLowerNormal() int32 { +func (m *HostDiscoveryConfig) GetLowerNormal() int32 { if m != nil { return m.LowerNormal } return 0 } -func (m *HostThermalThresholds) GetUpperNormal() int32 { +func (m *HostDiscoveryConfig) GetUpperNormal() int32 { if m != nil { return m.UpperNormal } return 0 } -func (m *HostThermalThresholds) GetLowerHigh() int32 { +func (m *HostDiscoveryConfig) GetLowerHigh() int32 { if m != nil { return m.LowerHigh } return 0 } -func (m *HostThermalThresholds) GetUpperHigh() int32 { +func (m *HostDiscoveryConfig) GetUpperHigh() int32 { if m != nil { return m.UpperHigh } return 0 } -func (m *HostThermalThresholds) GetLowerCritical() int32 { +func (m *HostDiscoveryConfig) GetLowerCritical() int32 { if m != nil { return m.LowerCritical } return 0 } -func (m *HostThermalThresholds) GetUpperCritical() int32 { +func (m *HostDiscoveryConfig) GetUpperCritical() int32 { if m != nil { return m.UpperCritical } @@ -176,39 +138,31 @@ func (m *HostThermalThresholds) GetUpperCritical() int32 { func init() { proto.RegisterType((*HostDiscoveryConfig)(nil), "proto.HostDiscoveryConfig") - proto.RegisterMapType((map[string]*HostThermalThresholds)(nil), "proto.HostDiscoveryConfig.ThermalThresholdsEntry") - proto.RegisterType((*HostThermalThresholds)(nil), "proto.HostThermalThresholds") } func init() { - proto.RegisterFile("hostthermaldiscovery.proto", fileDescriptor_hostthermaldiscovery_bfeffec62fafe688) -} - -var fileDescriptor_hostthermaldiscovery_bfeffec62fafe688 = []byte{ - // 388 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x91, 0x4d, 0x4f, 0xc2, 0x30, - 0x18, 0xc7, 0x33, 0xc6, 0x10, 0x8a, 0xbc, 0x58, 0xa3, 0x99, 0x44, 0x13, 0x24, 0xd1, 0xcc, 0x0b, - 0x89, 0x78, 0x31, 0x5e, 0xc1, 0x04, 0x2f, 0xc6, 0x4c, 0x3c, 0xcf, 0x02, 0x65, 0x6d, 0x2c, 0xeb, - 0xec, 0x0a, 0x86, 0x0f, 0xe3, 0x07, 0xf4, 0x5b, 0x98, 0x3e, 0xdd, 0xd0, 0x28, 0xa7, 0x2d, 0xbf, - 0xff, 0xef, 0x79, 0xd9, 0x33, 0xd4, 0x61, 0x32, 0xd3, 0x9a, 0x51, 0xb5, 0x24, 0x62, 0xce, 0xb3, - 0x99, 0x5c, 0x53, 0xb5, 0xe9, 0xa7, 0x4a, 0x6a, 0x89, 0x3d, 0x78, 0xf4, 0x3e, 0x5d, 0x74, 0x38, - 0x96, 0x99, 0x1e, 0x15, 0xf1, 0x50, 0x26, 0x0b, 0x1e, 0xe3, 0x2b, 0xd4, 0x4e, 0xa5, 0x10, 0x3c, - 0x89, 0x23, 0x9e, 0x68, 0xaa, 0xd6, 0x44, 0xf8, 0x4e, 0xd7, 0x09, 0x6a, 0x61, 0x2b, 0xe7, 0x0f, - 0x39, 0xc6, 0x01, 0x6a, 0x6b, 0xba, 0x4c, 0xa3, 0x8c, 0x26, 0x99, 0x54, 0x51, 0x4a, 0x34, 0xf3, - 0x4b, 0xa0, 0x36, 0x0d, 0x7f, 0x06, 0xfc, 0x44, 0x34, 0xc3, 0x97, 0xa8, 0xb5, 0x50, 0xf4, 0xbd, - 0x30, 0x57, 0x4a, 0xf8, 0x2e, 0x88, 0x0d, 0x83, 0xad, 0xf8, 0xa2, 0x04, 0x7e, 0x45, 0x38, 0xdf, - 0x3a, 0xd2, 0x4c, 0xd1, 0x8c, 0x49, 0x31, 0xcf, 0xfc, 0x72, 0xd7, 0x0d, 0xea, 0x83, 0x6b, 0xbb, - 0x7f, 0x7f, 0xc7, 0xd2, 0xfd, 0x89, 0x2d, 0x9a, 0x6c, 0x6b, 0xee, 0x13, 0xad, 0x36, 0xe1, 0x81, - 0xfe, 0xcb, 0xcd, 0xce, 0x42, 0xc6, 0x51, 0x31, 0x65, 0x4e, 0x34, 0xf1, 0xbd, 0xae, 0x13, 0x54, - 0xc3, 0xa6, 0x90, 0x71, 0xde, 0x67, 0x44, 0x34, 0xc1, 0x27, 0xa8, 0x6a, 0x4c, 0x46, 0x15, 0xf5, - 0x2b, 0xb0, 0xec, 0x9e, 0x90, 0xf1, 0x98, 0x2a, 0xda, 0x99, 0xa2, 0xe3, 0xdd, 0x13, 0x71, 0x1b, - 0xb9, 0x6f, 0x74, 0x93, 0x1f, 0xcc, 0xbc, 0xe2, 0x01, 0xf2, 0xd6, 0x44, 0xac, 0x28, 0x5c, 0xa6, - 0x3e, 0x38, 0xfd, 0xf5, 0x15, 0xff, 0x7a, 0x84, 0x56, 0xbd, 0x2b, 0xdd, 0x3a, 0xbd, 0x2f, 0x07, - 0x1d, 0xed, 0x94, 0xf0, 0x39, 0xda, 0x17, 0xf2, 0x83, 0xaa, 0x28, 0x91, 0x26, 0x81, 0x61, 0x5e, - 0x58, 0x07, 0xf6, 0x08, 0xc8, 0x28, 0xab, 0x34, 0xfd, 0x51, 0x4a, 0x56, 0x01, 0x96, 0x2b, 0x67, - 0x08, 0xd9, 0x2e, 0x8c, 0xc7, 0x0c, 0xfe, 0x86, 0x17, 0xd6, 0x80, 0x8c, 0x79, 0xcc, 0x4c, 0x6c, - 0x3b, 0x40, 0x5c, 0xb6, 0x31, 0x10, 0x88, 0x2f, 0x50, 0xd3, 0x56, 0xcf, 0x14, 0xd7, 0x7c, 0x46, - 0x04, 0x1c, 0xd1, 0x0b, 0x1b, 0x40, 0x87, 0x39, 0x34, 0x9a, 0xed, 0xb2, 0xd5, 0x2a, 0x56, 0x03, - 0x5a, 0x68, 0xd3, 0x0a, 0xdc, 0xe4, 0xe6, 0x3b, 0x00, 0x00, 0xff, 0xff, 0x86, 0x77, 0xab, 0x62, - 0xb7, 0x02, 0x00, 0x00, + proto.RegisterFile("hostthermaldiscovery.proto", fileDescriptor_hostthermaldiscovery_01a159d510988b58) +} + +var fileDescriptor_hostthermaldiscovery_01a159d510988b58 = []byte{ + // 298 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x44, 0xd1, 0xcb, 0x4a, 0x03, 0x31, + 0x14, 0xc6, 0x71, 0xc6, 0xda, 0x5b, 0x6a, 0x2f, 0xc4, 0x4d, 0x14, 0x84, 0x2a, 0x28, 0xe3, 0xc6, + 0x8d, 0x8f, 0xd0, 0x2e, 0xea, 0x46, 0xa4, 0xea, 0x3a, 0xc4, 0x36, 0x4d, 0x02, 0xe9, 0x9c, 0x78, + 0x26, 0xad, 0xf8, 0x48, 0xbe, 0xa5, 0xe4, 0x64, 0x46, 0x57, 0x03, 0xff, 0xf3, 0x9b, 0x8f, 0x81, + 0x61, 0x97, 0x16, 0xea, 0x18, 0xad, 0xc6, 0xbd, 0xf2, 0x5b, 0x57, 0x6f, 0xe0, 0xa8, 0xf1, 0xfb, + 0x21, 0x20, 0x44, 0xe0, 0x5d, 0x7a, 0xdc, 0xfc, 0x74, 0xd8, 0xf9, 0x0a, 0xea, 0xb8, 0x6c, 0xcf, + 0x0b, 0xa8, 0x76, 0xce, 0xf0, 0x7b, 0x36, 0x0b, 0xe0, 0xbd, 0xab, 0x8c, 0x74, 0x55, 0xd4, 0x78, + 0x54, 0x5e, 0x14, 0xf3, 0xa2, 0x1c, 0xae, 0xa7, 0x4d, 0x7f, 0x6a, 0x32, 0x2f, 0xd9, 0x2c, 0xea, + 0x7d, 0x90, 0xb5, 0xae, 0x6a, 0x40, 0x19, 0x54, 0xb4, 0xe2, 0x84, 0xe8, 0x24, 0xf5, 0x57, 0xca, + 0x2f, 0x2a, 0x5a, 0x7e, 0xc7, 0xa6, 0x3b, 0xd4, 0x9f, 0xad, 0x3c, 0xa0, 0x17, 0x1d, 0x82, 0xe3, + 0x94, 0x33, 0x7c, 0x47, 0x5a, 0xf4, 0x60, 0x64, 0xf3, 0xe5, 0x72, 0xab, 0xa2, 0x12, 0xa7, 0xf3, + 0xa2, 0x1c, 0xac, 0x27, 0x1e, 0xcc, 0x5b, 0xce, 0x4b, 0x15, 0x15, 0xbf, 0x60, 0x83, 0x24, 0xad, + 0x46, 0x2d, 0xba, 0x34, 0xd5, 0xf7, 0x60, 0x56, 0x1a, 0x35, 0xbf, 0x66, 0x67, 0x1e, 0xbe, 0x34, + 0xca, 0x0a, 0x12, 0x17, 0xbd, 0x79, 0x51, 0x76, 0xd7, 0x23, 0x6a, 0xcf, 0x94, 0x12, 0x39, 0x84, + 0xf0, 0x4f, 0xfa, 0x99, 0x50, 0x6b, 0xc8, 0x15, 0x63, 0x79, 0xc5, 0x3a, 0x63, 0xc5, 0x80, 0xc0, + 0x90, 0xca, 0xca, 0x19, 0x9b, 0xce, 0x79, 0x81, 0xce, 0xc3, 0x7c, 0xa6, 0x42, 0xe7, 0x5b, 0x36, + 0xc9, 0x6f, 0x6f, 0xd0, 0x45, 0xb7, 0x51, 0x5e, 0x30, 0x22, 0x63, 0xaa, 0x8b, 0x26, 0x26, 0x96, + 0x57, 0xfe, 0xd8, 0x28, 0x33, 0xaa, 0x2d, 0xfb, 0xe8, 0xd1, 0x2f, 0x7b, 0xfc, 0x0d, 0x00, 0x00, + 0xff, 0xff, 0x43, 0xeb, 0x7e, 0x04, 0xd7, 0x01, 0x00, 0x00, } diff --git a/modules/hostthermaldiscovery/proto/hostthermaldiscovery.proto b/modules/hostthermaldiscovery/proto/hostthermaldiscovery.proto index b298e9ff6..e1d6b8595 100644 --- a/modules/hostthermaldiscovery/proto/hostthermaldiscovery.proto +++ b/modules/hostthermaldiscovery/proto/hostthermaldiscovery.proto @@ -14,19 +14,15 @@ message HostDiscoveryConfig { string polling_interval = 1; string temp_sensor_path = 2; string freq_sensor_url = 3; - map thermal_thresholds = 4; - bool log_thermal_data = 5; - string log_here = 6; -} - -message HostThermalThresholds { - int32 lower_normal = 1; - int32 upper_normal = 2; + bool log_thermal_data = 4; + string log_here = 5; + int32 lower_normal = 6; + int32 upper_normal = 7; - int32 lower_high = 3; - int32 upper_high = 4; + int32 lower_high = 8; + int32 upper_high = 9; - int32 lower_critical = 5; - int32 upper_critical = 6; + int32 lower_critical = 10; + int32 upper_critical = 11; +} -} \ No newline at end of file From 3a1c503273c93bd16daa2f7577ea6a85c7a6dca5 Mon Sep 17 00:00:00 2001 From: Ghazanfar Ali Date: Tue, 24 Dec 2019 12:12:19 -0700 Subject: [PATCH 59/87] error fixing --- .../hostthermaldiscovery.go | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/modules/hostthermaldiscovery/hostthermaldiscovery.go b/modules/hostthermaldiscovery/hostthermaldiscovery.go index 3f3beb8de..3e84e972e 100644 --- a/modules/hostthermaldiscovery/hostthermaldiscovery.go +++ b/modules/hostthermaldiscovery/hostthermaldiscovery.go @@ -82,14 +82,12 @@ func (*HostDisc) NewConfig() proto.Message { FreqSensorUrl: freqSensorPath, LogThermalData: true, LogHere: "/tmp/ThermalLog.txt", - LowerNormal: 3000, - UpperNormal: 80000, - LowerHigh: 80000, - UpperHigh: 98000, - LowerCritical: 3000, - UpperCritical: 98000, - - }, + LowerNormal: 3000, + UpperNormal: 80000, + LowerHigh: 80000, + UpperHigh: 98000, + LowerCritical: 3000, + UpperCritical: 98000, } return r } @@ -340,9 +338,8 @@ func (hostDisc *HostDisc) lambdaStateDiscovery(v CPUTempObj) (string, int32) { cpuTemp := v.CPUTemp cpuTempState := thpb.HostThermal_CPU_TEMP_NONE - lowerNormal := hostDisc.cfg.GetLowerNormal() - upperNormal := hostDisc.cfg..GetUpperNormal() + upperNormal := hostDisc.cfg.GetUpperNormal() lowerHigh := hostDisc.cfg.GetLowerHigh() upperHigh := hostDisc.cfg.GetUpperHigh() From c649dce7b2da62fa9f12f1cbf94bddcfed8f06d5 Mon Sep 17 00:00:00 2001 From: Ghazanfar Ali Date: Thu, 26 Dec 2019 15:42:58 -0700 Subject: [PATCH 60/87] PS OVER DURATION --- .../hostfrequencyscaling.go | 97 +++++++++++++++---- .../proto/hostfrequencyscaling.pb.go | 81 ++++++++++------ .../proto/hostfrequencyscaling.proto | 5 +- 3 files changed, 132 insertions(+), 51 deletions(-) diff --git a/modules/hostfrequencyscaling/hostfrequencyscaling.go b/modules/hostfrequencyscaling/hostfrequencyscaling.go index 4e2023ba6..0744994fd 100644 --- a/modules/hostfrequencyscaling/hostfrequencyscaling.go +++ b/modules/hostfrequencyscaling/hostfrequencyscaling.go @@ -22,6 +22,7 @@ import ( "os" "reflect" "strings" + "sync" "time" "github.com/golang/protobuf/proto" @@ -199,11 +200,12 @@ var muts = map[string]hfsmut{ // HFS provides rfcpufreqscaling module capabilities type HFS struct { - api lib.APIClient - cfg *pb.HostFreqScalingConfig - - mchan <-chan lib.Event - dchan chan<- lib.Event + api lib.APIClient + cfg *pb.HostFreqScalingConfig + mutex *sync.Mutex + psEnforced bool + mchan <-chan lib.Event + dchan chan<- lib.Event } var _ lib.Module = (*HFS)(nil) @@ -222,6 +224,8 @@ func (*HFS) NewConfig() proto.Message { ScalingFreqPolicy: hostFreqScalerURL, HighToLowScaler: "powersave", LowToHighScaler: "performance", + LowFreqScalerDur: 10, + EnforceLowFreqScaler: true, FreqScalPolicies: map[string]*pb.HostFreqScalingPolicy{ "powersave": { ScalingGovernor: "powersave", @@ -292,7 +296,8 @@ var excs = map[string]reflect.Value{} // Init is used to intialize an executable module prior to entrypoint func (hfs *HFS) Init(api lib.APIClient) { hfs.api = api - //hfs.mutex = &sync.Mutex{} + hfs.mutex = &sync.Mutex{} + hfs.psEnforced = false // hfs.queue = make(map[string]map[string]NMut) hfs.cfg = hfs.NewConfig().(*pb.HostFreqScalingConfig) } @@ -402,24 +407,78 @@ func (hfs *HFS) mutateCPUFreq(m lib.Event) { return } me := m.Data().(*core.MutationEvent) + + enforceLowFreqScalerOverTime := hfs.cfg.GetEnforceLowFreqScaler() + + if enforceLowFreqScalerOverTime == true{ + switch me.Mutation[1] { + case "NONEtoPOWERSAVE": + highToLowScaler := hfs.cfg.GetHighToLowScaler() + hfs.HostFrequencyScaling(me.NodeCfg, highToLowScaler) + break + case "PERFORMANCEtoPOWERSAVE": + highToLowScaler := hfs.cfg.GetHighToLowScaler() + hfs.HostFrequencyScaling(me.NodeCfg, highToLowScaler) + hfs.mutex.Lock() + hfs.psEnforced = true + hfs.mutex.Unlock() + break + case "NONEtoPERFORMANCE": + lowToHighScaler := hfs.cfg.GetLowToHighScaler() + hfs.HostFrequencyScaling(me.NodeCfg, lowToHighScaler) + break + case "POWERSAVEtoPERFORMANCE": + hfs.mutex.Lock() + psEnforced := hfs.psEnforced + hfs.mutex.Unlock() + if psEnforced == true{ + highToLowScaler := hfs.cfg.GetHighToLowScaler() + hfs.HostFrequencyScaling(me.NodeCfg, highToLowScaler) + } else{ + lowToHighScaler := hfs.cfg.GetLowToHighScaler() + hfs.HostFrequencyScaling(me.NodeCfg, lowToHighScaler) + } + + break + } - switch me.Mutation[1] { - case "NONEtoPOWERSAVE": - fallthrough - case "PERFORMANCEtoPOWERSAVE": - highToLowScaler := hfs.cfg.GetHighToLowScaler() - hfs.HostFrequencyScaling(me.NodeCfg, highToLowScaler) - break - case "NONEtoPERFORMANCE": - fallthrough - case "POWERSAVEtoPERFORMANCE": - lowToHighScaler := hfs.cfg.GetLowToHighScaler() - hfs.HostFrequencyScaling(me.NodeCfg, lowToHighScaler) - break + } else{ + switch me.Mutation[1] { + case "NONEtoPOWERSAVE": + fallthrough + case "PERFORMANCEtoPOWERSAVE": + highToLowScaler := hfs.cfg.GetHighToLowScaler() + hfs.HostFrequencyScaling(me.NodeCfg, highToLowScaler) + break + case "NONEtoPERFORMANCE": + fallthrough + case "POWERSAVEtoPERFORMANCE": + lowToHighScaler := hfs.cfg.GetLowToHighScaler() + hfs.HostFrequencyScaling(me.NodeCfg, lowToHighScaler) + break + } } + } +func (hfs *HFS) EnforceLowFreqScaler(){ + hfs.mutex.Lock() + hfs.psEnforced = true + hfs.mutex.Unlock() + + timer := timer.NewTimer(time.Minute * time.Duration(hfs.cfg.GetLowFreqScalerDur())) + defer timer.Stop() + + go func() { + <-timer.C + hfs.mutex.Lock() + hfs.psEnforced = false + hfs.mutex.Unlock() + } + +} +low_freq_scaler_dur // HostFrequencyScaling scales CPU frequency according to given parameters func (hfs *HFS) HostFrequencyScaling(node lib.Node, freqScalPolicy string) { diff --git a/modules/hostfrequencyscaling/proto/hostfrequencyscaling.pb.go b/modules/hostfrequencyscaling/proto/hostfrequencyscaling.pb.go index 519ae2c21..6584ada13 100644 --- a/modules/hostfrequencyscaling/proto/hostfrequencyscaling.pb.go +++ b/modules/hostfrequencyscaling/proto/hostfrequencyscaling.pb.go @@ -24,6 +24,8 @@ type HostFreqScalingConfig struct { ScalingFreqPolicy string `protobuf:"bytes,3,opt,name=scaling_freq_policy,json=scalingFreqPolicy,proto3" json:"scaling_freq_policy,omitempty"` LowToHighScaler string `protobuf:"bytes,4,opt,name=low_to_high_scaler,json=lowToHighScaler,proto3" json:"low_to_high_scaler,omitempty"` HighToLowScaler string `protobuf:"bytes,5,opt,name=high_to_low_scaler,json=highToLowScaler,proto3" json:"high_to_low_scaler,omitempty"` + LowFreqScalerDur int32 `protobuf:"varint,6,opt,name=low_freq_scaler_dur,json=lowFreqScalerDur,proto3" json:"low_freq_scaler_dur,omitempty"` + EnforceLowFreqScaler bool `protobuf:"varint,7,opt,name=enforce_low_freq_scaler,json=enforceLowFreqScaler,proto3" json:"enforce_low_freq_scaler,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` @@ -33,7 +35,7 @@ func (m *HostFreqScalingConfig) Reset() { *m = HostFreqScalingConfig{} } func (m *HostFreqScalingConfig) String() string { return proto.CompactTextString(m) } func (*HostFreqScalingConfig) ProtoMessage() {} func (*HostFreqScalingConfig) Descriptor() ([]byte, []int) { - return fileDescriptor_hostfrequencyscaling_8098376e28c4e471, []int{0} + return fileDescriptor_hostfrequencyscaling_5197ba616350a4a5, []int{0} } func (m *HostFreqScalingConfig) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_HostFreqScalingConfig.Unmarshal(m, b) @@ -88,6 +90,20 @@ func (m *HostFreqScalingConfig) GetHighToLowScaler() string { return "" } +func (m *HostFreqScalingConfig) GetLowFreqScalerDur() int32 { + if m != nil { + return m.LowFreqScalerDur + } + return 0 +} + +func (m *HostFreqScalingConfig) GetEnforceLowFreqScaler() bool { + if m != nil { + return m.EnforceLowFreqScaler + } + return false +} + type HostFreqScalingPolicy struct { ScalingGovernor string `protobuf:"bytes,1,opt,name=scaling_governor,json=scalingGovernor,proto3" json:"scaling_governor,omitempty"` ScalingMinFreq string `protobuf:"bytes,2,opt,name=scaling_min_freq,json=scalingMinFreq,proto3" json:"scaling_min_freq,omitempty"` @@ -103,7 +119,7 @@ func (m *HostFreqScalingPolicy) Reset() { *m = HostFreqScalingPolicy{} } func (m *HostFreqScalingPolicy) String() string { return proto.CompactTextString(m) } func (*HostFreqScalingPolicy) ProtoMessage() {} func (*HostFreqScalingPolicy) Descriptor() ([]byte, []int) { - return fileDescriptor_hostfrequencyscaling_8098376e28c4e471, []int{1} + return fileDescriptor_hostfrequencyscaling_5197ba616350a4a5, []int{1} } func (m *HostFreqScalingPolicy) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_HostFreqScalingPolicy.Unmarshal(m, b) @@ -165,33 +181,36 @@ func init() { } func init() { - proto.RegisterFile("hostfrequencyscaling.proto", fileDescriptor_hostfrequencyscaling_8098376e28c4e471) -} - -var fileDescriptor_hostfrequencyscaling_8098376e28c4e471 = []byte{ - // 370 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x91, 0xcd, 0x4e, 0xe3, 0x30, - 0x14, 0x85, 0x95, 0x66, 0x3a, 0x9a, 0xba, 0xd3, 0x69, 0xc7, 0xa3, 0x4a, 0x51, 0x87, 0x45, 0x55, - 0x24, 0x54, 0x84, 0x94, 0x45, 0xd8, 0x20, 0x76, 0x08, 0x01, 0x5d, 0x80, 0x54, 0xb5, 0x65, 0x6d, - 0x42, 0x70, 0x12, 0x0b, 0xd7, 0xb7, 0x75, 0xd2, 0x9f, 0xbc, 0x04, 0xcf, 0xc7, 0xe3, 0x20, 0x5f, - 0xbb, 0x42, 0x85, 0xae, 0x12, 0x9d, 0xfb, 0x9d, 0xfb, 0x73, 0x4c, 0x7a, 0x39, 0x14, 0x65, 0xaa, - 0xf9, 0x72, 0xc5, 0x55, 0x52, 0x15, 0x49, 0x2c, 0x85, 0xca, 0xc2, 0x85, 0x86, 0x12, 0x68, 0x1d, - 0x3f, 0x83, 0x37, 0x9f, 0x74, 0x47, 0x50, 0x94, 0xb7, 0x9a, 0x2f, 0xa7, 0x16, 0xb8, 0x06, 0x95, - 0x8a, 0x8c, 0x3e, 0x11, 0x6a, 0xac, 0xcc, 0xd8, 0xd8, 0x02, 0xa4, 0x48, 0x04, 0x2f, 0x02, 0xaf, - 0xef, 0x0f, 0x9b, 0x51, 0x64, 0x9b, 0x84, 0x07, 0x9d, 0xe1, 0x4e, 0x19, 0x3b, 0xd3, 0x8d, 0x2a, - 0x75, 0x35, 0xe9, 0xa4, 0x5f, 0x64, 0x7a, 0x42, 0xda, 0x76, 0x02, 0x57, 0x05, 0x68, 0xb6, 0xd2, - 0x32, 0xa8, 0xf5, 0xbd, 0x61, 0x63, 0xd2, 0x42, 0x14, 0xd5, 0x47, 0x2d, 0x69, 0x48, 0xfe, 0xb9, - 0xdd, 0x19, 0xf2, 0xb8, 0x4c, 0x15, 0xf8, 0xc8, 0xfe, 0x75, 0x25, 0x33, 0x14, 0x3b, 0x57, 0xf4, - 0x8c, 0x50, 0x09, 0x1b, 0x56, 0x02, 0xcb, 0x45, 0x96, 0xe3, 0x01, 0x5c, 0x07, 0x3f, 0x10, 0x6f, - 0x4b, 0xd8, 0xcc, 0x60, 0x24, 0xb2, 0x7c, 0x8a, 0xb2, 0x81, 0x91, 0x2a, 0x81, 0x19, 0x93, 0x83, - 0xeb, 0x16, 0x36, 0x95, 0x19, 0xdc, 0xc3, 0xc6, 0xc2, 0xbd, 0x98, 0x74, 0x0f, 0x1e, 0x47, 0x3b, - 0xc4, 0x7f, 0xe5, 0x55, 0xe0, 0xa1, 0xcd, 0xfc, 0xd2, 0x88, 0xd4, 0xd7, 0xb1, 0x5c, 0x71, 0x3c, - 0xa9, 0x19, 0x1d, 0x1d, 0x4e, 0xcc, 0x6e, 0x3c, 0xb1, 0xe8, 0x65, 0xed, 0xc2, 0x1b, 0xbc, 0x7b, - 0xdf, 0x1e, 0xc4, 0x9d, 0x75, 0x4a, 0x3a, 0xbb, 0x18, 0x32, 0x58, 0x73, 0xad, 0x40, 0xbb, 0x81, - 0x6d, 0xa7, 0xdf, 0x39, 0x99, 0x0e, 0x3f, 0xd1, 0xb9, 0x50, 0x98, 0x9a, 0x8b, 0xf6, 0x8f, 0xd3, - 0x1f, 0x84, 0x32, 0x13, 0xf6, 0xc8, 0x78, 0x6b, 0x49, 0x7f, 0x9f, 0x8c, 0xb7, 0x48, 0xfe, 0x27, - 0x0d, 0x05, 0x2f, 0x9c, 0xc5, 0x3a, 0xc9, 0x5d, 0x98, 0xbf, 0x8c, 0x70, 0xa5, 0x93, 0x9c, 0x1e, - 0x93, 0x16, 0x16, 0x17, 0x32, 0x2e, 0x53, 0xd0, 0x73, 0x17, 0xe0, 0x6f, 0x23, 0x8e, 0x9d, 0xf6, - 0xfc, 0x13, 0x23, 0x38, 0xff, 0x08, 0x00, 0x00, 0xff, 0xff, 0xf9, 0x85, 0x30, 0x80, 0x97, 0x02, - 0x00, 0x00, + proto.RegisterFile("hostfrequencyscaling.proto", fileDescriptor_hostfrequencyscaling_5197ba616350a4a5) +} + +var fileDescriptor_hostfrequencyscaling_5197ba616350a4a5 = []byte{ + // 420 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x91, 0xcf, 0x6e, 0xd4, 0x30, + 0x10, 0xc6, 0x95, 0x86, 0x94, 0xd6, 0xa5, 0x6c, 0x70, 0xa9, 0x88, 0x0a, 0x87, 0xa8, 0x48, 0x28, + 0x08, 0x91, 0x43, 0x10, 0x12, 0xe2, 0x86, 0xf8, 0xd7, 0x43, 0x91, 0xaa, 0xb4, 0x9c, 0x4d, 0x48, + 0x9d, 0xc4, 0xc2, 0xf5, 0x6c, 0x27, 0xc9, 0x66, 0xf3, 0xa6, 0x3c, 0x08, 0x0f, 0x80, 0x3c, 0xf1, + 0x02, 0xbb, 0xec, 0x29, 0xd1, 0x37, 0xbf, 0xcf, 0x33, 0xf3, 0x0d, 0x3b, 0x69, 0xa0, 0xed, 0x2a, + 0x94, 0xb7, 0xbd, 0x34, 0xe5, 0xd8, 0x96, 0x85, 0x56, 0xa6, 0x4e, 0xe7, 0x08, 0x1d, 0xf0, 0x80, + 0x3e, 0xa7, 0xbf, 0x7c, 0x76, 0x7c, 0x06, 0x6d, 0xf7, 0x09, 0xe5, 0xed, 0xe5, 0x04, 0xbc, 0x07, + 0x53, 0xa9, 0x9a, 0x7f, 0x63, 0xdc, 0x5a, 0x85, 0xb5, 0x89, 0x39, 0x68, 0x55, 0x2a, 0xd9, 0x46, + 0x5e, 0xec, 0x27, 0x07, 0x59, 0x36, 0x3d, 0x92, 0x6e, 0x75, 0xa6, 0x2b, 0xe5, 0xc2, 0x99, 0x3e, + 0x9a, 0x0e, 0xc7, 0x3c, 0xac, 0x36, 0x64, 0xfe, 0x8c, 0xcd, 0xa6, 0x0e, 0xd2, 0xb4, 0x80, 0xa2, + 0x47, 0x1d, 0xed, 0xc4, 0x5e, 0xb2, 0x9f, 0x1f, 0x12, 0x4a, 0xea, 0x57, 0xd4, 0x3c, 0x65, 0x47, + 0x6e, 0x76, 0x41, 0x3c, 0x0d, 0x33, 0x46, 0x3e, 0xb1, 0x0f, 0x5c, 0xc9, 0x36, 0xa5, 0x97, 0x47, + 0xfe, 0x82, 0x71, 0x0d, 0x83, 0xe8, 0x40, 0x34, 0xaa, 0x6e, 0x68, 0x01, 0x89, 0xd1, 0x1d, 0xc2, + 0x67, 0x1a, 0x86, 0x2b, 0x38, 0x53, 0x75, 0x73, 0x49, 0xb2, 0x85, 0x89, 0xea, 0x40, 0x58, 0x93, + 0x83, 0x83, 0x09, 0xb6, 0x95, 0x2b, 0x38, 0x87, 0xc1, 0xc1, 0x2f, 0xd9, 0x91, 0x85, 0xfe, 0xe4, + 0x22, 0x51, 0x5c, 0xf7, 0x18, 0xed, 0xc6, 0x5e, 0x12, 0xe4, 0xa1, 0x86, 0x61, 0xb5, 0xba, 0xc4, + 0x0f, 0x3d, 0xf2, 0xd7, 0xec, 0x91, 0x34, 0x15, 0x60, 0x29, 0xc5, 0x86, 0x2d, 0xba, 0x1b, 0x7b, + 0xc9, 0x5e, 0xfe, 0xd0, 0x95, 0xcf, 0xff, 0x75, 0x9e, 0x14, 0xec, 0x78, 0x6b, 0x84, 0x3c, 0x64, + 0xfe, 0x0f, 0x39, 0x46, 0x1e, 0x0d, 0x67, 0x7f, 0x79, 0xc6, 0x82, 0x45, 0xa1, 0x7b, 0x49, 0xc1, + 0x1d, 0x64, 0x4f, 0xb6, 0xdf, 0x65, 0xca, 0x25, 0x9f, 0xd0, 0xb7, 0x3b, 0x6f, 0xbc, 0xd3, 0x9f, + 0xde, 0x7f, 0x67, 0x77, 0xe1, 0x3d, 0x67, 0xe1, 0x2a, 0xec, 0x1a, 0x16, 0x12, 0x0d, 0xa0, 0x6b, + 0x38, 0x73, 0xfa, 0x67, 0x27, 0xf3, 0xe4, 0x2f, 0x7a, 0xa3, 0x0c, 0xad, 0xe7, 0x0e, 0x78, 0xdf, + 0xe9, 0x5f, 0x94, 0xb1, 0x1d, 0xd6, 0xc8, 0x62, 0x39, 0x91, 0xfe, 0x3a, 0x59, 0x2c, 0x89, 0x7c, + 0xcc, 0xf6, 0x0d, 0x5c, 0x4b, 0x51, 0x60, 0xd9, 0xb8, 0x93, 0xed, 0x59, 0xe1, 0x1d, 0x96, 0x0d, + 0x7f, 0xca, 0x0e, 0xa9, 0x38, 0xd7, 0x45, 0x57, 0x01, 0xde, 0xb8, 0x33, 0xdd, 0xb3, 0xe2, 0x85, + 0xd3, 0xbe, 0xef, 0x52, 0x04, 0xaf, 0x7e, 0x07, 0x00, 0x00, 0xff, 0xff, 0x70, 0x05, 0xd3, 0xed, + 0xfd, 0x02, 0x00, 0x00, } diff --git a/modules/hostfrequencyscaling/proto/hostfrequencyscaling.proto b/modules/hostfrequencyscaling/proto/hostfrequencyscaling.proto index 55301af53..dcb76fe0d 100644 --- a/modules/hostfrequencyscaling/proto/hostfrequencyscaling.proto +++ b/modules/hostfrequencyscaling/proto/hostfrequencyscaling.proto @@ -15,7 +15,10 @@ string freq_sensor_url = 2; string scaling_freq_policy = 3; string low_to_high_scaler = 4; - string high_to_low_scaler = 5; + string high_to_low_scaler = 5; + int32 low_freq_scaler_dur = 6; + bool enforce_low_freq_scaler = 7; + } message HostFreqScalingPolicy { From 291eff769b00dcad62b36323fd90cd9f3e8c9cef Mon Sep 17 00:00:00 2001 From: Ghazanfar Ali Date: Thu, 26 Dec 2019 15:57:05 -0700 Subject: [PATCH 61/87] PSENFORCE Bug --- modules/hostfrequencyscaling/hostfrequencyscaling.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/hostfrequencyscaling/hostfrequencyscaling.go b/modules/hostfrequencyscaling/hostfrequencyscaling.go index 0744994fd..c34889baa 100644 --- a/modules/hostfrequencyscaling/hostfrequencyscaling.go +++ b/modules/hostfrequencyscaling/hostfrequencyscaling.go @@ -478,7 +478,7 @@ func (hfs *HFS) EnforceLowFreqScaler(){ } } -low_freq_scaler_dur + // HostFrequencyScaling scales CPU frequency according to given parameters func (hfs *HFS) HostFrequencyScaling(node lib.Node, freqScalPolicy string) { From df4254110351693781aaf7bcf56fb8243632eb94 Mon Sep 17 00:00:00 2001 From: Ghazanfar Ali Date: Thu, 26 Dec 2019 16:06:54 -0700 Subject: [PATCH 62/87] bug fix --- .../hostfrequencyscaling.go | 41 +++++++++---------- 1 file changed, 20 insertions(+), 21 deletions(-) diff --git a/modules/hostfrequencyscaling/hostfrequencyscaling.go b/modules/hostfrequencyscaling/hostfrequencyscaling.go index c34889baa..1e71e1df8 100644 --- a/modules/hostfrequencyscaling/hostfrequencyscaling.go +++ b/modules/hostfrequencyscaling/hostfrequencyscaling.go @@ -220,11 +220,11 @@ func (*HFS) Name() string { return "github.com/hpc/kraken/modules/hostfrequencys // NewConfig returns a fully initialized default config func (*HFS) NewConfig() proto.Message { r := &pb.HostFreqScalingConfig{ - FreqSensorUrl: freqSensorPath, - ScalingFreqPolicy: hostFreqScalerURL, - HighToLowScaler: "powersave", - LowToHighScaler: "performance", - LowFreqScalerDur: 10, + FreqSensorUrl: freqSensorPath, + ScalingFreqPolicy: hostFreqScalerURL, + HighToLowScaler: "powersave", + LowToHighScaler: "performance", + LowFreqScalerDur: 10, EnforceLowFreqScaler: true, FreqScalPolicies: map[string]*pb.HostFreqScalingPolicy{ "powersave": { @@ -407,10 +407,10 @@ func (hfs *HFS) mutateCPUFreq(m lib.Event) { return } me := m.Data().(*core.MutationEvent) - + enforceLowFreqScalerOverTime := hfs.cfg.GetEnforceLowFreqScaler() - if enforceLowFreqScalerOverTime == true{ + if enforceLowFreqScalerOverTime == true { switch me.Mutation[1] { case "NONEtoPOWERSAVE": highToLowScaler := hfs.cfg.GetHighToLowScaler() @@ -431,18 +431,18 @@ func (hfs *HFS) mutateCPUFreq(m lib.Event) { hfs.mutex.Lock() psEnforced := hfs.psEnforced hfs.mutex.Unlock() - if psEnforced == true{ + if psEnforced == true { highToLowScaler := hfs.cfg.GetHighToLowScaler() - hfs.HostFrequencyScaling(me.NodeCfg, highToLowScaler) - } else{ + hfs.HostFrequencyScaling(me.NodeCfg, highToLowScaler) + } else { lowToHighScaler := hfs.cfg.GetLowToHighScaler() hfs.HostFrequencyScaling(me.NodeCfg, lowToHighScaler) } - + break } - } else{ + } else { switch me.Mutation[1] { case "NONEtoPOWERSAVE": fallthrough @@ -458,11 +458,10 @@ func (hfs *HFS) mutateCPUFreq(m lib.Event) { break } } - } -func (hfs *HFS) EnforceLowFreqScaler(){ +func (hfs *HFS) EnforceLowFreqScaler() { hfs.mutex.Lock() hfs.psEnforced = true hfs.mutex.Unlock() @@ -470,15 +469,15 @@ func (hfs *HFS) EnforceLowFreqScaler(){ timer := timer.NewTimer(time.Minute * time.Duration(hfs.cfg.GetLowFreqScalerDur())) defer timer.Stop() - go func() { - <-timer.C - hfs.mutex.Lock() - hfs.psEnforced = false - hfs.mutex.Unlock() - } + go func() { + <-timer.C + hfs.mutex.Lock() + hfs.psEnforced = false + hfs.mutex.Unlock() + }() } - + // HostFrequencyScaling scales CPU frequency according to given parameters func (hfs *HFS) HostFrequencyScaling(node lib.Node, freqScalPolicy string) { From c64b087c3136c8a5d89d6802366215d93dac9c95 Mon Sep 17 00:00:00 2001 From: Ghazanfar Ali Date: Thu, 26 Dec 2019 16:09:13 -0700 Subject: [PATCH 63/87] PSENFORCE --- modules/hostfrequencyscaling/hostfrequencyscaling.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/hostfrequencyscaling/hostfrequencyscaling.go b/modules/hostfrequencyscaling/hostfrequencyscaling.go index 1e71e1df8..932fcc811 100644 --- a/modules/hostfrequencyscaling/hostfrequencyscaling.go +++ b/modules/hostfrequencyscaling/hostfrequencyscaling.go @@ -466,7 +466,7 @@ func (hfs *HFS) EnforceLowFreqScaler() { hfs.psEnforced = true hfs.mutex.Unlock() - timer := timer.NewTimer(time.Minute * time.Duration(hfs.cfg.GetLowFreqScalerDur())) + timer := time.NewTimer(time.Minute * time.Duration(hfs.cfg.GetLowFreqScalerDur())) defer timer.Stop() go func() { From adbab5d01e25c98d823635262a2d4deb6765295e Mon Sep 17 00:00:00 2001 From: Ghazanfar Ali Date: Thu, 26 Dec 2019 18:01:05 -0700 Subject: [PATCH 64/87] Bug fixing in PS Enforcement --- .../hostfrequencyscaling.go | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/modules/hostfrequencyscaling/hostfrequencyscaling.go b/modules/hostfrequencyscaling/hostfrequencyscaling.go index 932fcc811..7bdbb6dab 100644 --- a/modules/hostfrequencyscaling/hostfrequencyscaling.go +++ b/modules/hostfrequencyscaling/hostfrequencyscaling.go @@ -224,7 +224,7 @@ func (*HFS) NewConfig() proto.Message { ScalingFreqPolicy: hostFreqScalerURL, HighToLowScaler: "powersave", LowToHighScaler: "performance", - LowFreqScalerDur: 10, + LowFreqScalerDur: 5, EnforceLowFreqScaler: true, FreqScalPolicies: map[string]*pb.HostFreqScalingPolicy{ "powersave": { @@ -422,6 +422,7 @@ func (hfs *HFS) mutateCPUFreq(m lib.Event) { hfs.mutex.Lock() hfs.psEnforced = true hfs.mutex.Unlock() + go hfs.EnforceLowFreqScaler() break case "NONEtoPERFORMANCE": lowToHighScaler := hfs.cfg.GetLowToHighScaler() @@ -461,6 +462,7 @@ func (hfs *HFS) mutateCPUFreq(m lib.Event) { } +// EnforceLowFreqScaler keep low frequency scaler like "powersave" func (hfs *HFS) EnforceLowFreqScaler() { hfs.mutex.Lock() hfs.psEnforced = true @@ -469,12 +471,17 @@ func (hfs *HFS) EnforceLowFreqScaler() { timer := time.NewTimer(time.Minute * time.Duration(hfs.cfg.GetLowFreqScalerDur())) defer timer.Stop() - go func() { - <-timer.C - hfs.mutex.Lock() - hfs.psEnforced = false - hfs.mutex.Unlock() - }() + for { + + select { + case <-timer.C: + hfs.mutex.Lock() + hfs.psEnforced = false + hfs.mutex.Unlock() + break + } + + } } From 8c4a032638fb11f4d1776b5c7f16d0c7d1f3c6e9 Mon Sep 17 00:00:00 2001 From: Ghazanfar Ali Date: Fri, 27 Dec 2019 10:32:39 -0700 Subject: [PATCH 65/87] Added time bound and thermal bound scaling --- .../hostfrequencyscaling.go | 69 ++++++++++-- .../proto/hostfrequencyscaling.pb.go | 104 ++++++++++++------ .../proto/hostfrequencyscaling.proto | 6 +- .../hostthermaldiscovery.go | 5 +- 4 files changed, 140 insertions(+), 44 deletions(-) diff --git a/modules/hostfrequencyscaling/hostfrequencyscaling.go b/modules/hostfrequencyscaling/hostfrequencyscaling.go index 7bdbb6dab..f53f4a545 100644 --- a/modules/hostfrequencyscaling/hostfrequencyscaling.go +++ b/modules/hostfrequencyscaling/hostfrequencyscaling.go @@ -21,6 +21,7 @@ import ( "net" "os" "reflect" + "strconv" "strings" "sync" "time" @@ -81,6 +82,9 @@ const ( // freqSensorPath holds frequency sensor path on pi node freqSensorPath string = "/sys/devices/system/cpu/cpufreq/policy0/" + + // thermalSensorUrl holds thermal sensor path on pi node + thermalSensorUrl string = "/sys/devices/virtual/thermal/thermal_zone0/temp" ) var profileMap = map[string]string{ @@ -221,11 +225,15 @@ func (*HFS) Name() string { return "github.com/hpc/kraken/modules/hostfrequencys func (*HFS) NewConfig() proto.Message { r := &pb.HostFreqScalingConfig{ FreqSensorUrl: freqSensorPath, + ThermalSensorUrl: thermalSensorUrl, ScalingFreqPolicy: hostFreqScalerURL, HighToLowScaler: "powersave", LowToHighScaler: "performance", LowFreqScalerDur: 5, EnforceLowFreqScaler: true, + TimeBoundScaler: false, + ThermalBoundScaler: true, + ThermalThreshold: 60, FreqScalPolicies: map[string]*pb.HostFreqScalingPolicy{ "powersave": { ScalingGovernor: "powersave", @@ -408,9 +416,9 @@ func (hfs *HFS) mutateCPUFreq(m lib.Event) { } me := m.Data().(*core.MutationEvent) - enforceLowFreqScalerOverTime := hfs.cfg.GetEnforceLowFreqScaler() + enforceLowFreqScaler := hfs.cfg.GetEnforceLowFreqScaler() - if enforceLowFreqScalerOverTime == true { + if enforceLowFreqScaler == true { switch me.Mutation[1] { case "NONEtoPOWERSAVE": highToLowScaler := hfs.cfg.GetHighToLowScaler() @@ -419,10 +427,15 @@ func (hfs *HFS) mutateCPUFreq(m lib.Event) { case "PERFORMANCEtoPOWERSAVE": highToLowScaler := hfs.cfg.GetHighToLowScaler() hfs.HostFrequencyScaling(me.NodeCfg, highToLowScaler) - hfs.mutex.Lock() - hfs.psEnforced = true - hfs.mutex.Unlock() - go hfs.EnforceLowFreqScaler() + + if hfs.cfg.GetTimeBoundScaler() == true{ + go hfs.EnforceTimeBoundScaler() + } else if { + go hfs.EnforceThermalBoundScaler() + + } + + break case "NONEtoPERFORMANCE": lowToHighScaler := hfs.cfg.GetLowToHighScaler() @@ -462,8 +475,27 @@ func (hfs *HFS) mutateCPUFreq(m lib.Event) { } -// EnforceLowFreqScaler keep low frequency scaler like "powersave" -func (hfs *HFS) EnforceLowFreqScaler() { +// EnforceThermalBoundScaler keep low frequency scaler like "powersave" for a certain temperature +func (hfs *HFS) EnforceThermalBoundScaler() { + currentThermal := hfs.ReadCPUTemp() + thresholdThermal := hfs.cfg.GetThermalThreshold() + + if currentThermal >= thresholdThermal { + hfs.mutex.Lock() + hfs.psEnforced = true + hfs.mutex.Unlock() + } + else if currentThermal < thresholdThermal{ + hfs.mutex.Lock() + hfs.psEnforced = false + hfs.mutex.Unlock() + } + +} + + +// EnforceTimeBoundScaler keep low frequency scaler like "powersave" for a certain duration +func (hfs *HFS) EnforceTimeBoundScaler() { hfs.mutex.Lock() hfs.psEnforced = true hfs.mutex.Unlock() @@ -485,6 +517,27 @@ func (hfs *HFS) EnforceLowFreqScaler() { } +// ReadCPUTemp returns the current CPU thermal +func (hfs *HFS) ReadCPUTemp() int32 { + + tempSensorPath := hfs.cfg.GetThermalSensorUrl() + + cpuTemp, err := ioutil.ReadFile(tempSensorPath) + + if err != nil { + hfs.api.Logf(lib.LLERROR, "Reading CPU thermal sensor failed: %v", err) + return 0 + } + cpuTempInt, err := strconv.Atoi(strings.TrimSuffix(string(cpuTemp), "\n")) + + if err != nil { + hfs.api.Logf(lib.LLERROR, "String to Int conversion failed: %v", err) + return 0 + } + + return int32(cpuTempInt) +} + // HostFrequencyScaling scales CPU frequency according to given parameters func (hfs *HFS) HostFrequencyScaling(node lib.Node, freqScalPolicy string) { diff --git a/modules/hostfrequencyscaling/proto/hostfrequencyscaling.pb.go b/modules/hostfrequencyscaling/proto/hostfrequencyscaling.pb.go index 6584ada13..cfe89b84d 100644 --- a/modules/hostfrequencyscaling/proto/hostfrequencyscaling.pb.go +++ b/modules/hostfrequencyscaling/proto/hostfrequencyscaling.pb.go @@ -26,6 +26,10 @@ type HostFreqScalingConfig struct { HighToLowScaler string `protobuf:"bytes,5,opt,name=high_to_low_scaler,json=highToLowScaler,proto3" json:"high_to_low_scaler,omitempty"` LowFreqScalerDur int32 `protobuf:"varint,6,opt,name=low_freq_scaler_dur,json=lowFreqScalerDur,proto3" json:"low_freq_scaler_dur,omitempty"` EnforceLowFreqScaler bool `protobuf:"varint,7,opt,name=enforce_low_freq_scaler,json=enforceLowFreqScaler,proto3" json:"enforce_low_freq_scaler,omitempty"` + ThermalSensorUrl string `protobuf:"bytes,8,opt,name=thermal_sensor_url,json=thermalSensorUrl,proto3" json:"thermal_sensor_url,omitempty"` + TimeBoundScaler bool `protobuf:"varint,9,opt,name=time_bound_scaler,json=timeBoundScaler,proto3" json:"time_bound_scaler,omitempty"` + ThermalBoundScaler bool `protobuf:"varint,10,opt,name=thermal_bound_scaler,json=thermalBoundScaler,proto3" json:"thermal_bound_scaler,omitempty"` + ThermalThreshold int32 `protobuf:"varint,11,opt,name=thermal_threshold,json=thermalThreshold,proto3" json:"thermal_threshold,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` @@ -35,7 +39,7 @@ func (m *HostFreqScalingConfig) Reset() { *m = HostFreqScalingConfig{} } func (m *HostFreqScalingConfig) String() string { return proto.CompactTextString(m) } func (*HostFreqScalingConfig) ProtoMessage() {} func (*HostFreqScalingConfig) Descriptor() ([]byte, []int) { - return fileDescriptor_hostfrequencyscaling_5197ba616350a4a5, []int{0} + return fileDescriptor_hostfrequencyscaling_98d6dac51b8eb441, []int{0} } func (m *HostFreqScalingConfig) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_HostFreqScalingConfig.Unmarshal(m, b) @@ -104,6 +108,34 @@ func (m *HostFreqScalingConfig) GetEnforceLowFreqScaler() bool { return false } +func (m *HostFreqScalingConfig) GetThermalSensorUrl() string { + if m != nil { + return m.ThermalSensorUrl + } + return "" +} + +func (m *HostFreqScalingConfig) GetTimeBoundScaler() bool { + if m != nil { + return m.TimeBoundScaler + } + return false +} + +func (m *HostFreqScalingConfig) GetThermalBoundScaler() bool { + if m != nil { + return m.ThermalBoundScaler + } + return false +} + +func (m *HostFreqScalingConfig) GetThermalThreshold() int32 { + if m != nil { + return m.ThermalThreshold + } + return 0 +} + type HostFreqScalingPolicy struct { ScalingGovernor string `protobuf:"bytes,1,opt,name=scaling_governor,json=scalingGovernor,proto3" json:"scaling_governor,omitempty"` ScalingMinFreq string `protobuf:"bytes,2,opt,name=scaling_min_freq,json=scalingMinFreq,proto3" json:"scaling_min_freq,omitempty"` @@ -119,7 +151,7 @@ func (m *HostFreqScalingPolicy) Reset() { *m = HostFreqScalingPolicy{} } func (m *HostFreqScalingPolicy) String() string { return proto.CompactTextString(m) } func (*HostFreqScalingPolicy) ProtoMessage() {} func (*HostFreqScalingPolicy) Descriptor() ([]byte, []int) { - return fileDescriptor_hostfrequencyscaling_5197ba616350a4a5, []int{1} + return fileDescriptor_hostfrequencyscaling_98d6dac51b8eb441, []int{1} } func (m *HostFreqScalingPolicy) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_HostFreqScalingPolicy.Unmarshal(m, b) @@ -181,36 +213,40 @@ func init() { } func init() { - proto.RegisterFile("hostfrequencyscaling.proto", fileDescriptor_hostfrequencyscaling_5197ba616350a4a5) -} - -var fileDescriptor_hostfrequencyscaling_5197ba616350a4a5 = []byte{ - // 420 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x91, 0xcf, 0x6e, 0xd4, 0x30, - 0x10, 0xc6, 0x95, 0x86, 0x94, 0xd6, 0xa5, 0x6c, 0x70, 0xa9, 0x88, 0x0a, 0x87, 0xa8, 0x48, 0x28, - 0x08, 0x91, 0x43, 0x10, 0x12, 0xe2, 0x86, 0xf8, 0xd7, 0x43, 0x91, 0xaa, 0xb4, 0x9c, 0x4d, 0x48, - 0x9d, 0xc4, 0xc2, 0xf5, 0x6c, 0x27, 0xc9, 0x66, 0xf3, 0xa6, 0x3c, 0x08, 0x0f, 0x80, 0x3c, 0xf1, - 0x02, 0xbb, 0xec, 0x29, 0xd1, 0x37, 0xbf, 0xcf, 0x33, 0xf3, 0x0d, 0x3b, 0x69, 0xa0, 0xed, 0x2a, - 0x94, 0xb7, 0xbd, 0x34, 0xe5, 0xd8, 0x96, 0x85, 0x56, 0xa6, 0x4e, 0xe7, 0x08, 0x1d, 0xf0, 0x80, - 0x3e, 0xa7, 0xbf, 0x7c, 0x76, 0x7c, 0x06, 0x6d, 0xf7, 0x09, 0xe5, 0xed, 0xe5, 0x04, 0xbc, 0x07, - 0x53, 0xa9, 0x9a, 0x7f, 0x63, 0xdc, 0x5a, 0x85, 0xb5, 0x89, 0x39, 0x68, 0x55, 0x2a, 0xd9, 0x46, - 0x5e, 0xec, 0x27, 0x07, 0x59, 0x36, 0x3d, 0x92, 0x6e, 0x75, 0xa6, 0x2b, 0xe5, 0xc2, 0x99, 0x3e, - 0x9a, 0x0e, 0xc7, 0x3c, 0xac, 0x36, 0x64, 0xfe, 0x8c, 0xcd, 0xa6, 0x0e, 0xd2, 0xb4, 0x80, 0xa2, - 0x47, 0x1d, 0xed, 0xc4, 0x5e, 0xb2, 0x9f, 0x1f, 0x12, 0x4a, 0xea, 0x57, 0xd4, 0x3c, 0x65, 0x47, - 0x6e, 0x76, 0x41, 0x3c, 0x0d, 0x33, 0x46, 0x3e, 0xb1, 0x0f, 0x5c, 0xc9, 0x36, 0xa5, 0x97, 0x47, - 0xfe, 0x82, 0x71, 0x0d, 0x83, 0xe8, 0x40, 0x34, 0xaa, 0x6e, 0x68, 0x01, 0x89, 0xd1, 0x1d, 0xc2, - 0x67, 0x1a, 0x86, 0x2b, 0x38, 0x53, 0x75, 0x73, 0x49, 0xb2, 0x85, 0x89, 0xea, 0x40, 0x58, 0x93, - 0x83, 0x83, 0x09, 0xb6, 0x95, 0x2b, 0x38, 0x87, 0xc1, 0xc1, 0x2f, 0xd9, 0x91, 0x85, 0xfe, 0xe4, - 0x22, 0x51, 0x5c, 0xf7, 0x18, 0xed, 0xc6, 0x5e, 0x12, 0xe4, 0xa1, 0x86, 0x61, 0xb5, 0xba, 0xc4, - 0x0f, 0x3d, 0xf2, 0xd7, 0xec, 0x91, 0x34, 0x15, 0x60, 0x29, 0xc5, 0x86, 0x2d, 0xba, 0x1b, 0x7b, - 0xc9, 0x5e, 0xfe, 0xd0, 0x95, 0xcf, 0xff, 0x75, 0x9e, 0x14, 0xec, 0x78, 0x6b, 0x84, 0x3c, 0x64, - 0xfe, 0x0f, 0x39, 0x46, 0x1e, 0x0d, 0x67, 0x7f, 0x79, 0xc6, 0x82, 0x45, 0xa1, 0x7b, 0x49, 0xc1, - 0x1d, 0x64, 0x4f, 0xb6, 0xdf, 0x65, 0xca, 0x25, 0x9f, 0xd0, 0xb7, 0x3b, 0x6f, 0xbc, 0xd3, 0x9f, - 0xde, 0x7f, 0x67, 0x77, 0xe1, 0x3d, 0x67, 0xe1, 0x2a, 0xec, 0x1a, 0x16, 0x12, 0x0d, 0xa0, 0x6b, - 0x38, 0x73, 0xfa, 0x67, 0x27, 0xf3, 0xe4, 0x2f, 0x7a, 0xa3, 0x0c, 0xad, 0xe7, 0x0e, 0x78, 0xdf, - 0xe9, 0x5f, 0x94, 0xb1, 0x1d, 0xd6, 0xc8, 0x62, 0x39, 0x91, 0xfe, 0x3a, 0x59, 0x2c, 0x89, 0x7c, - 0xcc, 0xf6, 0x0d, 0x5c, 0x4b, 0x51, 0x60, 0xd9, 0xb8, 0x93, 0xed, 0x59, 0xe1, 0x1d, 0x96, 0x0d, - 0x7f, 0xca, 0x0e, 0xa9, 0x38, 0xd7, 0x45, 0x57, 0x01, 0xde, 0xb8, 0x33, 0xdd, 0xb3, 0xe2, 0x85, - 0xd3, 0xbe, 0xef, 0x52, 0x04, 0xaf, 0x7e, 0x07, 0x00, 0x00, 0xff, 0xff, 0x70, 0x05, 0xd3, 0xed, - 0xfd, 0x02, 0x00, 0x00, + proto.RegisterFile("hostfrequencyscaling.proto", fileDescriptor_hostfrequencyscaling_98d6dac51b8eb441) +} + +var fileDescriptor_hostfrequencyscaling_98d6dac51b8eb441 = []byte{ + // 491 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x92, 0xdb, 0x6e, 0xd3, 0x40, + 0x10, 0x86, 0xe5, 0x86, 0x94, 0x64, 0x43, 0x89, 0xb3, 0x6d, 0x85, 0x55, 0xb8, 0x88, 0x8a, 0x84, + 0x0c, 0x85, 0x08, 0x05, 0x21, 0x21, 0xee, 0x38, 0xf7, 0xa2, 0x48, 0x95, 0x1b, 0xae, 0x17, 0xd7, + 0x59, 0x1f, 0xc4, 0x66, 0x27, 0x1d, 0xaf, 0x9b, 0xfa, 0xa1, 0x78, 0x1f, 0x1e, 0x07, 0xed, 0x78, + 0x4d, 0x93, 0x92, 0x2b, 0x5b, 0xff, 0x7c, 0xff, 0xcc, 0xce, 0x81, 0x1d, 0xe5, 0x50, 0x9a, 0x14, + 0xe5, 0x55, 0x25, 0x75, 0x52, 0x97, 0x49, 0xac, 0x0a, 0x9d, 0x4d, 0x96, 0x08, 0x06, 0x78, 0x97, + 0x3e, 0xc7, 0xbf, 0xbb, 0xec, 0xf0, 0x14, 0x4a, 0xf3, 0x15, 0xe5, 0xd5, 0x45, 0x03, 0x7c, 0x02, + 0x9d, 0x16, 0x19, 0xff, 0xc9, 0xb8, 0xb5, 0x0a, 0x6b, 0x13, 0x4b, 0x50, 0x45, 0x52, 0xc8, 0x32, + 0xf0, 0xc6, 0x9d, 0x70, 0x30, 0x9d, 0x36, 0x49, 0x26, 0x5b, 0x9d, 0x93, 0x56, 0x39, 0x77, 0xa6, + 0x2f, 0xda, 0x60, 0x1d, 0xf9, 0xe9, 0x1d, 0x99, 0x3f, 0x63, 0xc3, 0xa6, 0x82, 0xd4, 0x25, 0xa0, + 0xa8, 0x50, 0x05, 0x3b, 0x63, 0x2f, 0xec, 0x47, 0x7b, 0x84, 0x92, 0xfa, 0x03, 0x15, 0x9f, 0xb0, + 0x7d, 0xf7, 0x76, 0x41, 0x3c, 0x3d, 0xa6, 0x0e, 0x3a, 0xc4, 0x8e, 0x5c, 0xc8, 0x16, 0xa5, 0xcc, + 0x35, 0x3f, 0x61, 0x5c, 0xc1, 0x4a, 0x18, 0x10, 0x79, 0x91, 0xe5, 0xd4, 0x80, 0xc4, 0xe0, 0x1e, + 0xe1, 0x43, 0x05, 0xab, 0x19, 0x9c, 0x16, 0x59, 0x7e, 0x41, 0xb2, 0x85, 0x89, 0x32, 0x20, 0xac, + 0xc9, 0xc1, 0xdd, 0x06, 0xb6, 0x91, 0x19, 0x9c, 0xc1, 0xca, 0xc1, 0xaf, 0xd8, 0xbe, 0x85, 0xfe, + 0xcd, 0x45, 0xa2, 0x98, 0x57, 0x18, 0xec, 0x8e, 0xbd, 0xb0, 0x1b, 0xf9, 0x0a, 0x56, 0x6d, 0xeb, + 0x12, 0x3f, 0x57, 0xc8, 0xdf, 0xb2, 0x47, 0x52, 0xa7, 0x80, 0x89, 0x14, 0x77, 0x6c, 0xc1, 0xfd, + 0xb1, 0x17, 0xf6, 0xa2, 0x03, 0x17, 0x3e, 0x5b, 0x77, 0xf2, 0x97, 0x8c, 0x9b, 0x5c, 0xe2, 0x22, + 0x56, 0xeb, 0xa3, 0xe9, 0xd1, 0x93, 0x7c, 0x17, 0xb9, 0x9d, 0xce, 0x0b, 0x36, 0x32, 0xc5, 0x42, + 0x8a, 0x4b, 0xa8, 0xf4, 0xbc, 0x4d, 0xdf, 0xa7, 0xf4, 0x43, 0x1b, 0xf8, 0x68, 0x75, 0x97, 0xf9, + 0x35, 0x3b, 0x68, 0x33, 0x6f, 0xe0, 0x8c, 0xf0, 0xb6, 0xea, 0xba, 0xe3, 0x84, 0x8d, 0x5a, 0x87, + 0xc9, 0x51, 0x96, 0x39, 0xa8, 0x79, 0x30, 0x68, 0xfa, 0x75, 0x81, 0x59, 0xab, 0x1f, 0xc5, 0xec, + 0x70, 0xeb, 0xee, 0xb9, 0xcf, 0x3a, 0xbf, 0x64, 0x1d, 0x78, 0xd4, 0x82, 0xfd, 0xe5, 0x53, 0xd6, + 0xbd, 0x8e, 0x55, 0x25, 0x69, 0xe3, 0x83, 0xe9, 0x93, 0xed, 0x07, 0xd5, 0x2c, 0x34, 0x6a, 0xd0, + 0xf7, 0x3b, 0xef, 0xbc, 0xe3, 0x3f, 0xde, 0x7f, 0xf7, 0xea, 0xb6, 0xfe, 0x9c, 0xf9, 0xed, 0x95, + 0x64, 0x70, 0x2d, 0x51, 0x03, 0xba, 0x82, 0x43, 0xa7, 0x7f, 0x73, 0x32, 0x0f, 0x6f, 0xd1, 0x45, + 0xa1, 0x69, 0x2f, 0xee, 0xf2, 0x1e, 0x3a, 0xfd, 0x7b, 0xa1, 0x6d, 0x85, 0x0d, 0x32, 0xbe, 0x69, + 0xc8, 0xce, 0x26, 0x19, 0xdf, 0x10, 0xf9, 0x98, 0xf5, 0x35, 0xcc, 0xa5, 0x88, 0x31, 0xc9, 0xdd, + 0xad, 0xf5, 0xac, 0xf0, 0x01, 0x93, 0x9c, 0x3f, 0x65, 0x7b, 0x14, 0x5c, 0xaa, 0xd8, 0xa4, 0x80, + 0x0b, 0x77, 0x5f, 0x0f, 0xac, 0x78, 0xee, 0xb4, 0xcb, 0x5d, 0x1a, 0xc1, 0x9b, 0xbf, 0x01, 0x00, + 0x00, 0xff, 0xff, 0xba, 0x11, 0x0a, 0xdc, 0xb6, 0x03, 0x00, 0x00, } diff --git a/modules/hostfrequencyscaling/proto/hostfrequencyscaling.proto b/modules/hostfrequencyscaling/proto/hostfrequencyscaling.proto index dcb76fe0d..6305fc802 100644 --- a/modules/hostfrequencyscaling/proto/hostfrequencyscaling.proto +++ b/modules/hostfrequencyscaling/proto/hostfrequencyscaling.proto @@ -17,7 +17,11 @@ string low_to_high_scaler = 4; string high_to_low_scaler = 5; int32 low_freq_scaler_dur = 6; - bool enforce_low_freq_scaler = 7; + bool enforce_low_freq_scaler = 7; + string thermal_sensor_url = 8; + bool time_bound_scaler = 9; + bool thermal_bound_scaler = 10; + int32 thermal_threshold = 11; } diff --git a/modules/hostthermaldiscovery/hostthermaldiscovery.go b/modules/hostthermaldiscovery/hostthermaldiscovery.go index 3e84e972e..475faa7bd 100644 --- a/modules/hostthermaldiscovery/hostthermaldiscovery.go +++ b/modules/hostthermaldiscovery/hostthermaldiscovery.go @@ -47,6 +47,9 @@ const ( // freqSensorPath holds frequency sensor path on pi node freqSensorPath string = "/sys/devices/system/cpu/cpufreq/policy0/" + + // thermalSensorUrl holds thermal sensor path on pi node + thermalSensorUrl string = "/sys/devices/virtual/thermal/thermal_zone0/temp" ) var _ lib.Module = (*HostDisc)(nil) @@ -78,7 +81,7 @@ func (*HostDisc) Name() string { return "github.com/hpc/kraken/modules/hosttherm func (*HostDisc) NewConfig() proto.Message { r := &pb.HostDiscoveryConfig{ PollingInterval: "1s", - TempSensorPath: "/sys/devices/virtual/thermal/thermal_zone0/temp", + TempSensorPath: thermalSensorUrl, FreqSensorUrl: freqSensorPath, LogThermalData: true, LogHere: "/tmp/ThermalLog.txt", From 63a791766ad606fd9ae0c48b39ac594959160e65 Mon Sep 17 00:00:00 2001 From: Ghazanfar Ali Date: Fri, 27 Dec 2019 10:39:07 -0700 Subject: [PATCH 66/87] bug fixing --- modules/hostfrequencyscaling/hostfrequencyscaling.go | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/modules/hostfrequencyscaling/hostfrequencyscaling.go b/modules/hostfrequencyscaling/hostfrequencyscaling.go index f53f4a545..757e9e79c 100644 --- a/modules/hostfrequencyscaling/hostfrequencyscaling.go +++ b/modules/hostfrequencyscaling/hostfrequencyscaling.go @@ -428,13 +428,12 @@ func (hfs *HFS) mutateCPUFreq(m lib.Event) { highToLowScaler := hfs.cfg.GetHighToLowScaler() hfs.HostFrequencyScaling(me.NodeCfg, highToLowScaler) - if hfs.cfg.GetTimeBoundScaler() == true{ + if hfs.cfg.GetTimeBoundScaler() == true { go hfs.EnforceTimeBoundScaler() - } else if { + } else if hfs.cfg.GetThermalBoundScaler() == true { go hfs.EnforceThermalBoundScaler() } - break case "NONEtoPERFORMANCE": @@ -484,15 +483,13 @@ func (hfs *HFS) EnforceThermalBoundScaler() { hfs.mutex.Lock() hfs.psEnforced = true hfs.mutex.Unlock() - } - else if currentThermal < thresholdThermal{ + } else if currentThermal < thresholdThermal { hfs.mutex.Lock() hfs.psEnforced = false hfs.mutex.Unlock() } - -} +} // EnforceTimeBoundScaler keep low frequency scaler like "powersave" for a certain duration func (hfs *HFS) EnforceTimeBoundScaler() { From fc4bdfe5bca4dedb7f4f89c2661b9bc8d5dddc9a Mon Sep 17 00:00:00 2001 From: Ghazanfar Ali Date: Fri, 27 Dec 2019 11:04:05 -0700 Subject: [PATCH 67/87] Debug statment --- modules/hostfrequencyscaling/hostfrequencyscaling.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/hostfrequencyscaling/hostfrequencyscaling.go b/modules/hostfrequencyscaling/hostfrequencyscaling.go index 757e9e79c..ab9acd4ad 100644 --- a/modules/hostfrequencyscaling/hostfrequencyscaling.go +++ b/modules/hostfrequencyscaling/hostfrequencyscaling.go @@ -233,7 +233,7 @@ func (*HFS) NewConfig() proto.Message { EnforceLowFreqScaler: true, TimeBoundScaler: false, ThermalBoundScaler: true, - ThermalThreshold: 60, + ThermalThreshold: 66, FreqScalPolicies: map[string]*pb.HostFreqScalingPolicy{ "powersave": { ScalingGovernor: "powersave", @@ -531,7 +531,7 @@ func (hfs *HFS) ReadCPUTemp() int32 { hfs.api.Logf(lib.LLERROR, "String to Int conversion failed: %v", err) return 0 } - + hfs.api.Logf(lib.LLERROR, "***TEMP***: %v", int32(cpuTempInt)) return int32(cpuTempInt) } From 1e81c9df8c3ec51f467d5b8eb1c224b10e45142c Mon Sep 17 00:00:00 2001 From: Ghazanfar Ali Date: Fri, 27 Dec 2019 11:52:12 -0700 Subject: [PATCH 68/87] bug fix --- .../hostfrequencyscaling.go | 27 ++++++++++++------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/modules/hostfrequencyscaling/hostfrequencyscaling.go b/modules/hostfrequencyscaling/hostfrequencyscaling.go index ab9acd4ad..4787baf29 100644 --- a/modules/hostfrequencyscaling/hostfrequencyscaling.go +++ b/modules/hostfrequencyscaling/hostfrequencyscaling.go @@ -431,8 +431,9 @@ func (hfs *HFS) mutateCPUFreq(m lib.Event) { if hfs.cfg.GetTimeBoundScaler() == true { go hfs.EnforceTimeBoundScaler() } else if hfs.cfg.GetThermalBoundScaler() == true { - go hfs.EnforceThermalBoundScaler() - + hfs.mutex.Lock() + hfs.psEnforced = true + hfs.mutex.Unlock() } break @@ -441,6 +442,10 @@ func (hfs *HFS) mutateCPUFreq(m lib.Event) { hfs.HostFrequencyScaling(me.NodeCfg, lowToHighScaler) break case "POWERSAVEtoPERFORMANCE": + if hfs.cfg.GetThermalBoundScaler() == true { + hfs.CheckThermalThreshold() + } + hfs.mutex.Lock() psEnforced := hfs.psEnforced hfs.mutex.Unlock() @@ -474,20 +479,22 @@ func (hfs *HFS) mutateCPUFreq(m lib.Event) { } -// EnforceThermalBoundScaler keep low frequency scaler like "powersave" for a certain temperature -func (hfs *HFS) EnforceThermalBoundScaler() { +// CheckThermalThreshold validates whether current thermal is less than preset threshold and if so set the PS enforcement to false +func (hfs *HFS) CheckThermalThreshold() { currentThermal := hfs.ReadCPUTemp() thresholdThermal := hfs.cfg.GetThermalThreshold() - if currentThermal >= thresholdThermal { - hfs.mutex.Lock() - hfs.psEnforced = true - hfs.mutex.Unlock() - } else if currentThermal < thresholdThermal { + // if currentThermal >= thresholdThermal { + // hfs.mutex.Lock() + // hfs.psEnforced = true + // hfs.mutex.Unlock() + // } else + if currentThermal < thresholdThermal { hfs.mutex.Lock() hfs.psEnforced = false hfs.mutex.Unlock() } + hfs.api.Logf(lib.LLERROR, "*** T E M P ***: %v", int32(cpuTempInt)) } @@ -531,7 +538,7 @@ func (hfs *HFS) ReadCPUTemp() int32 { hfs.api.Logf(lib.LLERROR, "String to Int conversion failed: %v", err) return 0 } - hfs.api.Logf(lib.LLERROR, "***TEMP***: %v", int32(cpuTempInt)) + return int32(cpuTempInt) } From 3911140fd3b6ac8212bafe20d040bd458b2535ce Mon Sep 17 00:00:00 2001 From: Ghazanfar Ali Date: Fri, 27 Dec 2019 11:53:41 -0700 Subject: [PATCH 69/87] debug statement --- modules/hostfrequencyscaling/hostfrequencyscaling.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/hostfrequencyscaling/hostfrequencyscaling.go b/modules/hostfrequencyscaling/hostfrequencyscaling.go index 4787baf29..36e59d282 100644 --- a/modules/hostfrequencyscaling/hostfrequencyscaling.go +++ b/modules/hostfrequencyscaling/hostfrequencyscaling.go @@ -494,7 +494,7 @@ func (hfs *HFS) CheckThermalThreshold() { hfs.psEnforced = false hfs.mutex.Unlock() } - hfs.api.Logf(lib.LLERROR, "*** T E M P ***: %v", int32(cpuTempInt)) + hfs.api.Logf(lib.LLERROR, "*** T E M P ***: %v", currentThermal) } From 317167f45b854b65ab908d290f2c0a2d3c946371 Mon Sep 17 00:00:00 2001 From: Ghazanfar Ali Date: Fri, 27 Dec 2019 12:05:43 -0700 Subject: [PATCH 70/87] converting current thermal into decimal --- modules/hostfrequencyscaling/hostfrequencyscaling.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/hostfrequencyscaling/hostfrequencyscaling.go b/modules/hostfrequencyscaling/hostfrequencyscaling.go index 36e59d282..539520309 100644 --- a/modules/hostfrequencyscaling/hostfrequencyscaling.go +++ b/modules/hostfrequencyscaling/hostfrequencyscaling.go @@ -489,7 +489,7 @@ func (hfs *HFS) CheckThermalThreshold() { // hfs.psEnforced = true // hfs.mutex.Unlock() // } else - if currentThermal < thresholdThermal { + if (currentThermal / 1000) < thresholdThermal { hfs.mutex.Lock() hfs.psEnforced = false hfs.mutex.Unlock() From 55c7ad7685800afba3c4b4c54f452c8f171bde27 Mon Sep 17 00:00:00 2001 From: Ghazanfar Ali Date: Fri, 27 Dec 2019 12:17:43 -0700 Subject: [PATCH 71/87] DEBUG statement --- modules/hostfrequencyscaling/hostfrequencyscaling.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/hostfrequencyscaling/hostfrequencyscaling.go b/modules/hostfrequencyscaling/hostfrequencyscaling.go index 539520309..fae7e08c3 100644 --- a/modules/hostfrequencyscaling/hostfrequencyscaling.go +++ b/modules/hostfrequencyscaling/hostfrequencyscaling.go @@ -493,8 +493,9 @@ func (hfs *HFS) CheckThermalThreshold() { hfs.mutex.Lock() hfs.psEnforced = false hfs.mutex.Unlock() + hfs.api.Log(lib.LLERROR, " D* * * F A L S E * * * ") } - hfs.api.Logf(lib.LLERROR, "*** T E M P ***: %v", currentThermal) + hfs.api.Logf(lib.LLERROR, "*** T E M P ***: %v", currentThermal/1000) } From bfe6d5c16133cbaffc92e371659fa4b997668cf9 Mon Sep 17 00:00:00 2001 From: Ghazanfar Ali Date: Fri, 27 Dec 2019 12:51:43 -0700 Subject: [PATCH 72/87] Bug fix --- modules/hostfrequencyscaling/hostfrequencyscaling.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/modules/hostfrequencyscaling/hostfrequencyscaling.go b/modules/hostfrequencyscaling/hostfrequencyscaling.go index fae7e08c3..8ae0346f5 100644 --- a/modules/hostfrequencyscaling/hostfrequencyscaling.go +++ b/modules/hostfrequencyscaling/hostfrequencyscaling.go @@ -401,6 +401,11 @@ func (hfs *HFS) Entry() { case m := <-hfs.mchan: go hfs.mutateCPUFreq(m) + + if hfs.cfg.GetThermalBoundScaler() == true { + hfs.CheckThermalThreshold() + } + break } @@ -442,9 +447,6 @@ func (hfs *HFS) mutateCPUFreq(m lib.Event) { hfs.HostFrequencyScaling(me.NodeCfg, lowToHighScaler) break case "POWERSAVEtoPERFORMANCE": - if hfs.cfg.GetThermalBoundScaler() == true { - hfs.CheckThermalThreshold() - } hfs.mutex.Lock() psEnforced := hfs.psEnforced From 4e2538b8a6c5102487ff35cb5a4b739f5bc5cb46 Mon Sep 17 00:00:00 2001 From: Ghazanfar Ali Date: Fri, 27 Dec 2019 13:12:32 -0700 Subject: [PATCH 73/87] bug fix --- modules/hostfrequencyscaling/hostfrequencyscaling.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/hostfrequencyscaling/hostfrequencyscaling.go b/modules/hostfrequencyscaling/hostfrequencyscaling.go index 8ae0346f5..a2d25c414 100644 --- a/modules/hostfrequencyscaling/hostfrequencyscaling.go +++ b/modules/hostfrequencyscaling/hostfrequencyscaling.go @@ -402,7 +402,7 @@ func (hfs *HFS) Entry() { go hfs.mutateCPUFreq(m) - if hfs.cfg.GetThermalBoundScaler() == true { + if hfs.cfg.GetThermalBoundScaler() == true && hfs.psEnforced == true { hfs.CheckThermalThreshold() } From f52529a3bffdb2b170eeb17c6984ac98f2b86744 Mon Sep 17 00:00:00 2001 From: Ghazanfar Ali Date: Fri, 27 Dec 2019 13:23:22 -0700 Subject: [PATCH 74/87] discovering perf after ps --- modules/hostfrequencyscaling/hostfrequencyscaling.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/modules/hostfrequencyscaling/hostfrequencyscaling.go b/modules/hostfrequencyscaling/hostfrequencyscaling.go index a2d25c414..266c2e182 100644 --- a/modules/hostfrequencyscaling/hostfrequencyscaling.go +++ b/modules/hostfrequencyscaling/hostfrequencyscaling.go @@ -496,6 +496,17 @@ func (hfs *HFS) CheckThermalThreshold() { hfs.psEnforced = false hfs.mutex.Unlock() hfs.api.Log(lib.LLERROR, " D* * * F A L S E * * * ") + + url := lib.NodeURLJoin(node.ID().String(), hostFreqScalerURL) + ev := core.NewEvent( + lib.Event_DISCOVERY, + url, + &core.DiscoveryEvent{ + URL: url, + ValueID: profileMap["performance"], + }, + ) + hfs.dchan <- ev } hfs.api.Logf(lib.LLERROR, "*** T E M P ***: %v", currentThermal/1000) From 8f9534a7414ed8b5ba76641699856c3968b6deea Mon Sep 17 00:00:00 2001 From: Ghazanfar Ali Date: Fri, 27 Dec 2019 13:28:09 -0700 Subject: [PATCH 75/87] adding node --- modules/hostfrequencyscaling/hostfrequencyscaling.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/modules/hostfrequencyscaling/hostfrequencyscaling.go b/modules/hostfrequencyscaling/hostfrequencyscaling.go index 266c2e182..8c3f1c736 100644 --- a/modules/hostfrequencyscaling/hostfrequencyscaling.go +++ b/modules/hostfrequencyscaling/hostfrequencyscaling.go @@ -403,7 +403,8 @@ func (hfs *HFS) Entry() { go hfs.mutateCPUFreq(m) if hfs.cfg.GetThermalBoundScaler() == true && hfs.psEnforced == true { - hfs.CheckThermalThreshold() + me := m.Data().(*core.MutationEvent) + hfs.CheckThermalThreshold(me.NodeCfg) } break @@ -482,7 +483,7 @@ func (hfs *HFS) mutateCPUFreq(m lib.Event) { } // CheckThermalThreshold validates whether current thermal is less than preset threshold and if so set the PS enforcement to false -func (hfs *HFS) CheckThermalThreshold() { +func (hfs *HFS) CheckThermalThreshold(node lib.Node) { currentThermal := hfs.ReadCPUTemp() thresholdThermal := hfs.cfg.GetThermalThreshold() From b47e27d53c3599278167fe3512c41a7736a26eba Mon Sep 17 00:00:00 2001 From: Ghazanfar Ali Date: Fri, 27 Dec 2019 13:36:03 -0700 Subject: [PATCH 76/87] changing mutation timeout --- .../hostfrequencyscaling.go | 51 +++++++++---------- 1 file changed, 25 insertions(+), 26 deletions(-) diff --git a/modules/hostfrequencyscaling/hostfrequencyscaling.go b/modules/hostfrequencyscaling/hostfrequencyscaling.go index 8c3f1c736..cf76943df 100644 --- a/modules/hostfrequencyscaling/hostfrequencyscaling.go +++ b/modules/hostfrequencyscaling/hostfrequencyscaling.go @@ -112,21 +112,21 @@ var scalMuts = map[string]hfscalmut{ f: scalpb.HostFrequencyScaler_NONE, t: scalpb.HostFrequencyScaler_POWER_SAVE, reqs: scalerReqs, - timeout: "60s", + timeout: "1s", failTo: scalpb.HostFrequencyScaler_NONE.String(), }, "PERFORMANCEtoPOWERSAVE": { f: scalpb.HostFrequencyScaler_PERFORMANCE, t: scalpb.HostFrequencyScaler_POWER_SAVE, reqs: scalerReqs, - timeout: "60s", + timeout: "1s", failTo: scalpb.HostFrequencyScaler_PERFORMANCE.String(), }, "NONEtoPERFORMANCE": { f: scalpb.HostFrequencyScaler_NONE, t: scalpb.HostFrequencyScaler_PERFORMANCE, reqs: scalerReqs, - timeout: "60s", + timeout: "1s", failTo: scalpb.HostFrequencyScaler_NONE.String(), }, "POWERSAVEtoPERFORMANCE": { @@ -138,7 +138,7 @@ var scalMuts = map[string]hfscalmut{ moduleStateURL: reflect.ValueOf(cpb.ServiceInstance_RUN), hostThermalStateURL: reflect.ValueOf(hostthpb.HostThermal_CPU_TEMP_NORMAL), }, - timeout: "60s", + timeout: "1s", failTo: scalpb.HostFrequencyScaler_POWER_SAVE.String(), }, } @@ -159,21 +159,21 @@ var muts = map[string]hfsmut{ f: hostthpb.HostThermal_CPU_TEMP_NONE, t: hostthpb.HostThermal_CPU_TEMP_NORMAL, reqs: reqs, - timeout: "60s", + timeout: "1s", failTo: hostthpb.HostThermal_CPU_TEMP_NONE.String(), }, "CPU_TEMP_NONEtoCPU_TEMP_HIGH": { f: hostthpb.HostThermal_CPU_TEMP_NONE, t: hostthpb.HostThermal_CPU_TEMP_HIGH, reqs: reqs, - timeout: "60s", + timeout: "1s", failTo: hostthpb.HostThermal_CPU_TEMP_NONE.String(), }, "CPU_TEMP_NONEtoCPU_TEMP_CRITICAL": { f: hostthpb.HostThermal_CPU_TEMP_NONE, t: hostthpb.HostThermal_CPU_TEMP_CRITICAL, reqs: reqs, - timeout: "60s", + timeout: "1s", failTo: hostthpb.HostThermal_CPU_TEMP_NONE.String(), }, @@ -181,7 +181,7 @@ var muts = map[string]hfsmut{ f: hostthpb.HostThermal_CPU_TEMP_HIGH, t: hostthpb.HostThermal_CPU_TEMP_NORMAL, reqs: greqs, - timeout: "60s", + timeout: "1s", failTo: hostthpb.HostThermal_CPU_TEMP_HIGH.String(), }, @@ -189,7 +189,7 @@ var muts = map[string]hfsmut{ f: hostthpb.HostThermal_CPU_TEMP_CRITICAL, t: hostthpb.HostThermal_CPU_TEMP_HIGH, reqs: greqs, - timeout: "60s", + timeout: "1s", failTo: hostthpb.HostThermal_CPU_TEMP_CRITICAL.String(), }, @@ -197,7 +197,7 @@ var muts = map[string]hfsmut{ f: hostthpb.HostThermal_CPU_TEMP_CRITICAL, t: hostthpb.HostThermal_CPU_TEMP_NORMAL, reqs: greqs, - timeout: "60s", + timeout: "1s", failTo: hostthpb.HostThermal_CPU_TEMP_CRITICAL.String(), }, } @@ -403,8 +403,8 @@ func (hfs *HFS) Entry() { go hfs.mutateCPUFreq(m) if hfs.cfg.GetThermalBoundScaler() == true && hfs.psEnforced == true { - me := m.Data().(*core.MutationEvent) - hfs.CheckThermalThreshold(me.NodeCfg) + //me := m.Data().(*core.MutationEvent) + hfs.CheckThermalThreshold() } break @@ -483,7 +483,7 @@ func (hfs *HFS) mutateCPUFreq(m lib.Event) { } // CheckThermalThreshold validates whether current thermal is less than preset threshold and if so set the PS enforcement to false -func (hfs *HFS) CheckThermalThreshold(node lib.Node) { +func (hfs *HFS) CheckThermalThreshold() { currentThermal := hfs.ReadCPUTemp() thresholdThermal := hfs.cfg.GetThermalThreshold() @@ -496,20 +496,19 @@ func (hfs *HFS) CheckThermalThreshold(node lib.Node) { hfs.mutex.Lock() hfs.psEnforced = false hfs.mutex.Unlock() - hfs.api.Log(lib.LLERROR, " D* * * F A L S E * * * ") - - url := lib.NodeURLJoin(node.ID().String(), hostFreqScalerURL) - ev := core.NewEvent( - lib.Event_DISCOVERY, - url, - &core.DiscoveryEvent{ - URL: url, - ValueID: profileMap["performance"], - }, - ) - hfs.dchan <- ev + + // url := lib.NodeURLJoin(node.ID().String(), hostFreqScalerURL) + // ev := core.NewEvent( + // lib.Event_DISCOVERY, + // url, + // &core.DiscoveryEvent{ + // URL: url, + // ValueID: profileMap["performance"], + // }, + // ) + // hfs.dchan <- ev } - hfs.api.Logf(lib.LLERROR, "*** T E M P ***: %v", currentThermal/1000) + //hfs.api.Logf(lib.LLERROR, "*** T E M P ***: %v", currentThermal/1000) } From 42e30004c8b7baffe700a41a9e78cfe94fcf3dda Mon Sep 17 00:00:00 2001 From: Ghazanfar Ali Date: Fri, 27 Dec 2019 15:04:46 -0700 Subject: [PATCH 77/87] Adding ticker for thermal bound scenario --- .../hostfrequencyscaling.go | 45 ++++++++++++------- 1 file changed, 30 insertions(+), 15 deletions(-) diff --git a/modules/hostfrequencyscaling/hostfrequencyscaling.go b/modules/hostfrequencyscaling/hostfrequencyscaling.go index cf76943df..cdf913d3f 100644 --- a/modules/hostfrequencyscaling/hostfrequencyscaling.go +++ b/modules/hostfrequencyscaling/hostfrequencyscaling.go @@ -112,21 +112,21 @@ var scalMuts = map[string]hfscalmut{ f: scalpb.HostFrequencyScaler_NONE, t: scalpb.HostFrequencyScaler_POWER_SAVE, reqs: scalerReqs, - timeout: "1s", + timeout: "60s", failTo: scalpb.HostFrequencyScaler_NONE.String(), }, "PERFORMANCEtoPOWERSAVE": { f: scalpb.HostFrequencyScaler_PERFORMANCE, t: scalpb.HostFrequencyScaler_POWER_SAVE, reqs: scalerReqs, - timeout: "1s", + timeout: "60s", failTo: scalpb.HostFrequencyScaler_PERFORMANCE.String(), }, "NONEtoPERFORMANCE": { f: scalpb.HostFrequencyScaler_NONE, t: scalpb.HostFrequencyScaler_PERFORMANCE, reqs: scalerReqs, - timeout: "1s", + timeout: "60s", failTo: scalpb.HostFrequencyScaler_NONE.String(), }, "POWERSAVEtoPERFORMANCE": { @@ -138,7 +138,7 @@ var scalMuts = map[string]hfscalmut{ moduleStateURL: reflect.ValueOf(cpb.ServiceInstance_RUN), hostThermalStateURL: reflect.ValueOf(hostthpb.HostThermal_CPU_TEMP_NORMAL), }, - timeout: "1s", + timeout: "60s", failTo: scalpb.HostFrequencyScaler_POWER_SAVE.String(), }, } @@ -159,21 +159,21 @@ var muts = map[string]hfsmut{ f: hostthpb.HostThermal_CPU_TEMP_NONE, t: hostthpb.HostThermal_CPU_TEMP_NORMAL, reqs: reqs, - timeout: "1s", + timeout: "60s", failTo: hostthpb.HostThermal_CPU_TEMP_NONE.String(), }, "CPU_TEMP_NONEtoCPU_TEMP_HIGH": { f: hostthpb.HostThermal_CPU_TEMP_NONE, t: hostthpb.HostThermal_CPU_TEMP_HIGH, reqs: reqs, - timeout: "1s", + timeout: "60s", failTo: hostthpb.HostThermal_CPU_TEMP_NONE.String(), }, "CPU_TEMP_NONEtoCPU_TEMP_CRITICAL": { f: hostthpb.HostThermal_CPU_TEMP_NONE, t: hostthpb.HostThermal_CPU_TEMP_CRITICAL, reqs: reqs, - timeout: "1s", + timeout: "60s", failTo: hostthpb.HostThermal_CPU_TEMP_NONE.String(), }, @@ -181,7 +181,7 @@ var muts = map[string]hfsmut{ f: hostthpb.HostThermal_CPU_TEMP_HIGH, t: hostthpb.HostThermal_CPU_TEMP_NORMAL, reqs: greqs, - timeout: "1s", + timeout: "60s", failTo: hostthpb.HostThermal_CPU_TEMP_HIGH.String(), }, @@ -189,7 +189,7 @@ var muts = map[string]hfsmut{ f: hostthpb.HostThermal_CPU_TEMP_CRITICAL, t: hostthpb.HostThermal_CPU_TEMP_HIGH, reqs: greqs, - timeout: "1s", + timeout: "60s", failTo: hostthpb.HostThermal_CPU_TEMP_CRITICAL.String(), }, @@ -197,7 +197,7 @@ var muts = map[string]hfsmut{ f: hostthpb.HostThermal_CPU_TEMP_CRITICAL, t: hostthpb.HostThermal_CPU_TEMP_NORMAL, reqs: greqs, - timeout: "1s", + timeout: "60s", failTo: hostthpb.HostThermal_CPU_TEMP_CRITICAL.String(), }, } @@ -402,15 +402,30 @@ func (hfs *HFS) Entry() { go hfs.mutateCPUFreq(m) - if hfs.cfg.GetThermalBoundScaler() == true && hfs.psEnforced == true { - //me := m.Data().(*core.MutationEvent) - hfs.CheckThermalThreshold() - } - break } } + + // setup a ticker for checking whether PS is enforced in Thermal bound scenario + if hfs.cfg.GetThermalBoundScaler() == true { + + dur, _ := time.ParseDuration("1s") + thermalCheckTick := time.NewTicker(dur) + + // thermal ticker + for { + select { + case <-thermalCheckTick.C: + if hfs.psEnforced == true { + go hfs.CheckThermalThreshold() + } + + break + } + } + + } } // aggregateHandler makes calls to aggregator for the given nodes with related mutation and frequecy scaling policy From db6e17fac2174ed585d65071986ff169c521900f Mon Sep 17 00:00:00 2001 From: Ghazanfar Ali Date: Mon, 30 Dec 2019 16:49:09 -0700 Subject: [PATCH 78/87] setting the muttaion timeout to "1s" --- .../hostfrequencyscaling.go | 53 ++++++++++--------- 1 file changed, 28 insertions(+), 25 deletions(-) diff --git a/modules/hostfrequencyscaling/hostfrequencyscaling.go b/modules/hostfrequencyscaling/hostfrequencyscaling.go index cdf913d3f..2bdda003f 100644 --- a/modules/hostfrequencyscaling/hostfrequencyscaling.go +++ b/modules/hostfrequencyscaling/hostfrequencyscaling.go @@ -112,21 +112,21 @@ var scalMuts = map[string]hfscalmut{ f: scalpb.HostFrequencyScaler_NONE, t: scalpb.HostFrequencyScaler_POWER_SAVE, reqs: scalerReqs, - timeout: "60s", + timeout: "1s", failTo: scalpb.HostFrequencyScaler_NONE.String(), }, "PERFORMANCEtoPOWERSAVE": { f: scalpb.HostFrequencyScaler_PERFORMANCE, t: scalpb.HostFrequencyScaler_POWER_SAVE, reqs: scalerReqs, - timeout: "60s", + timeout: "1s", failTo: scalpb.HostFrequencyScaler_PERFORMANCE.String(), }, "NONEtoPERFORMANCE": { f: scalpb.HostFrequencyScaler_NONE, t: scalpb.HostFrequencyScaler_PERFORMANCE, reqs: scalerReqs, - timeout: "60s", + timeout: "1s", failTo: scalpb.HostFrequencyScaler_NONE.String(), }, "POWERSAVEtoPERFORMANCE": { @@ -138,7 +138,7 @@ var scalMuts = map[string]hfscalmut{ moduleStateURL: reflect.ValueOf(cpb.ServiceInstance_RUN), hostThermalStateURL: reflect.ValueOf(hostthpb.HostThermal_CPU_TEMP_NORMAL), }, - timeout: "60s", + timeout: "1s", failTo: scalpb.HostFrequencyScaler_POWER_SAVE.String(), }, } @@ -159,21 +159,21 @@ var muts = map[string]hfsmut{ f: hostthpb.HostThermal_CPU_TEMP_NONE, t: hostthpb.HostThermal_CPU_TEMP_NORMAL, reqs: reqs, - timeout: "60s", + timeout: "1s", failTo: hostthpb.HostThermal_CPU_TEMP_NONE.String(), }, "CPU_TEMP_NONEtoCPU_TEMP_HIGH": { f: hostthpb.HostThermal_CPU_TEMP_NONE, t: hostthpb.HostThermal_CPU_TEMP_HIGH, reqs: reqs, - timeout: "60s", + timeout: "1s", failTo: hostthpb.HostThermal_CPU_TEMP_NONE.String(), }, "CPU_TEMP_NONEtoCPU_TEMP_CRITICAL": { f: hostthpb.HostThermal_CPU_TEMP_NONE, t: hostthpb.HostThermal_CPU_TEMP_CRITICAL, reqs: reqs, - timeout: "60s", + timeout: "1s", failTo: hostthpb.HostThermal_CPU_TEMP_NONE.String(), }, @@ -181,7 +181,7 @@ var muts = map[string]hfsmut{ f: hostthpb.HostThermal_CPU_TEMP_HIGH, t: hostthpb.HostThermal_CPU_TEMP_NORMAL, reqs: greqs, - timeout: "60s", + timeout: "1s", failTo: hostthpb.HostThermal_CPU_TEMP_HIGH.String(), }, @@ -189,7 +189,7 @@ var muts = map[string]hfsmut{ f: hostthpb.HostThermal_CPU_TEMP_CRITICAL, t: hostthpb.HostThermal_CPU_TEMP_HIGH, reqs: greqs, - timeout: "60s", + timeout: "1s", failTo: hostthpb.HostThermal_CPU_TEMP_CRITICAL.String(), }, @@ -197,7 +197,7 @@ var muts = map[string]hfsmut{ f: hostthpb.HostThermal_CPU_TEMP_CRITICAL, t: hostthpb.HostThermal_CPU_TEMP_NORMAL, reqs: greqs, - timeout: "60s", + timeout: "1s", failTo: hostthpb.HostThermal_CPU_TEMP_CRITICAL.String(), }, } @@ -402,30 +402,33 @@ func (hfs *HFS) Entry() { go hfs.mutateCPUFreq(m) + if hfs.cfg.GetThermalBoundScaler() == true && if hfs.psEnforced == true{ + go hfs.CheckThermalThreshold() + } break } } - // setup a ticker for checking whether PS is enforced in Thermal bound scenario - if hfs.cfg.GetThermalBoundScaler() == true { + // // setup a ticker for checking whether PS is enforced in Thermal bound scenario + // if hfs.cfg.GetThermalBoundScaler() == true { - dur, _ := time.ParseDuration("1s") - thermalCheckTick := time.NewTicker(dur) + // dur, _ := time.ParseDuration("1s") + // thermalCheckTick := time.NewTicker(dur) - // thermal ticker - for { - select { - case <-thermalCheckTick.C: - if hfs.psEnforced == true { - go hfs.CheckThermalThreshold() - } + // // thermal ticker + // for { + // select { + // case <-thermalCheckTick.C: + // if hfs.psEnforced == true { + // go hfs.CheckThermalThreshold() + // } - break - } - } + // break + // } + // } - } + // } } // aggregateHandler makes calls to aggregator for the given nodes with related mutation and frequecy scaling policy From f98e9c5e84299f1055a319682302ddcd6ff7968e Mon Sep 17 00:00:00 2001 From: Ghazanfar Ali Date: Mon, 30 Dec 2019 17:16:53 -0700 Subject: [PATCH 79/87] adding condition for powersave --- modules/hostfrequencyscaling/hostfrequencyscaling.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/modules/hostfrequencyscaling/hostfrequencyscaling.go b/modules/hostfrequencyscaling/hostfrequencyscaling.go index 2bdda003f..26843904f 100644 --- a/modules/hostfrequencyscaling/hostfrequencyscaling.go +++ b/modules/hostfrequencyscaling/hostfrequencyscaling.go @@ -402,9 +402,12 @@ func (hfs *HFS) Entry() { go hfs.mutateCPUFreq(m) - if hfs.cfg.GetThermalBoundScaler() == true && if hfs.psEnforced == true{ - go hfs.CheckThermalThreshold() + if hfs.cfg.GetEnforceLowFreqScaler() == true { + if hfs.cfg.GetThermalBoundScaler() == true && hfs.psEnforced == true { + go hfs.CheckThermalThreshold() + } } + break } From 34f1d07ee7cd8ca13a120c98bfc582ad8381293f Mon Sep 17 00:00:00 2001 From: Ghazanfar Ali Date: Wed, 1 Jan 2020 10:04:59 -0700 Subject: [PATCH 80/87] renaming parameters --- .../hostfrequencyscaling.go | 34 ++--- .../proto/hostfrequencyscaling.pb.go | 125 +++++++++--------- .../proto/hostfrequencyscaling.proto | 10 +- 3 files changed, 85 insertions(+), 84 deletions(-) diff --git a/modules/hostfrequencyscaling/hostfrequencyscaling.go b/modules/hostfrequencyscaling/hostfrequencyscaling.go index 26843904f..1400de290 100644 --- a/modules/hostfrequencyscaling/hostfrequencyscaling.go +++ b/modules/hostfrequencyscaling/hostfrequencyscaling.go @@ -224,16 +224,16 @@ func (*HFS) Name() string { return "github.com/hpc/kraken/modules/hostfrequencys // NewConfig returns a fully initialized default config func (*HFS) NewConfig() proto.Message { r := &pb.HostFreqScalingConfig{ - FreqSensorUrl: freqSensorPath, - ThermalSensorUrl: thermalSensorUrl, - ScalingFreqPolicy: hostFreqScalerURL, - HighToLowScaler: "powersave", - LowToHighScaler: "performance", - LowFreqScalerDur: 5, - EnforceLowFreqScaler: true, - TimeBoundScaler: false, - ThermalBoundScaler: true, - ThermalThreshold: 66, + FreqSensorUrl: freqSensorPath, + ThermalSensorUrl: thermalSensorUrl, + ScalingFreqPolicy: hostFreqScalerURL, + HighToLowScaler: "powersave", + LowToHighScaler: "performance", + TimeBoundThrottleRetentionDuration: 5, + ThrottleRetention: true, + TimeBoundThrottleRetention: false, + ThermalBoundThrottleRetention: true, + ThermalBoundThrottleRetentionThreshold: 66, FreqScalPolicies: map[string]*pb.HostFreqScalingPolicy{ "powersave": { ScalingGovernor: "powersave", @@ -402,8 +402,8 @@ func (hfs *HFS) Entry() { go hfs.mutateCPUFreq(m) - if hfs.cfg.GetEnforceLowFreqScaler() == true { - if hfs.cfg.GetThermalBoundScaler() == true && hfs.psEnforced == true { + if hfs.cfg.GetThrottleRetention() == true { + if hfs.cfg.GetThermalBoundThrottleRetention() == true && hfs.psEnforced == true { go hfs.CheckThermalThreshold() } } @@ -443,7 +443,7 @@ func (hfs *HFS) mutateCPUFreq(m lib.Event) { } me := m.Data().(*core.MutationEvent) - enforceLowFreqScaler := hfs.cfg.GetEnforceLowFreqScaler() + enforceLowFreqScaler := hfs.cfg.ThrottleRetention() if enforceLowFreqScaler == true { switch me.Mutation[1] { @@ -455,9 +455,9 @@ func (hfs *HFS) mutateCPUFreq(m lib.Event) { highToLowScaler := hfs.cfg.GetHighToLowScaler() hfs.HostFrequencyScaling(me.NodeCfg, highToLowScaler) - if hfs.cfg.GetTimeBoundScaler() == true { + if hfs.cfg.GetTimeBoundThrottleRetention() == true { go hfs.EnforceTimeBoundScaler() - } else if hfs.cfg.GetThermalBoundScaler() == true { + } else if hfs.cfg.GetThermalBoundThrottleRetention() == true { hfs.mutex.Lock() hfs.psEnforced = true hfs.mutex.Unlock() @@ -506,7 +506,7 @@ func (hfs *HFS) mutateCPUFreq(m lib.Event) { // CheckThermalThreshold validates whether current thermal is less than preset threshold and if so set the PS enforcement to false func (hfs *HFS) CheckThermalThreshold() { currentThermal := hfs.ReadCPUTemp() - thresholdThermal := hfs.cfg.GetThermalThreshold() + thresholdThermal := hfs.cfg.GetThermalBoundThrottleRetentionThreshold() // if currentThermal >= thresholdThermal { // hfs.mutex.Lock() @@ -539,7 +539,7 @@ func (hfs *HFS) EnforceTimeBoundScaler() { hfs.psEnforced = true hfs.mutex.Unlock() - timer := time.NewTimer(time.Minute * time.Duration(hfs.cfg.GetLowFreqScalerDur())) + timer := time.NewTimer(time.Minute * time.Duration(hfs.cfg.GetTimeBoundThrottleRetentionDuration())) defer timer.Stop() for { diff --git a/modules/hostfrequencyscaling/proto/hostfrequencyscaling.pb.go b/modules/hostfrequencyscaling/proto/hostfrequencyscaling.pb.go index cfe89b84d..6011bdbc3 100644 --- a/modules/hostfrequencyscaling/proto/hostfrequencyscaling.pb.go +++ b/modules/hostfrequencyscaling/proto/hostfrequencyscaling.pb.go @@ -19,27 +19,27 @@ var _ = math.Inf const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package type HostFreqScalingConfig struct { - FreqScalPolicies map[string]*HostFreqScalingPolicy `protobuf:"bytes,1,rep,name=freq_scal_policies,json=freqScalPolicies,proto3" json:"freq_scal_policies,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` - FreqSensorUrl string `protobuf:"bytes,2,opt,name=freq_sensor_url,json=freqSensorUrl,proto3" json:"freq_sensor_url,omitempty"` - ScalingFreqPolicy string `protobuf:"bytes,3,opt,name=scaling_freq_policy,json=scalingFreqPolicy,proto3" json:"scaling_freq_policy,omitempty"` - LowToHighScaler string `protobuf:"bytes,4,opt,name=low_to_high_scaler,json=lowToHighScaler,proto3" json:"low_to_high_scaler,omitempty"` - HighToLowScaler string `protobuf:"bytes,5,opt,name=high_to_low_scaler,json=highToLowScaler,proto3" json:"high_to_low_scaler,omitempty"` - LowFreqScalerDur int32 `protobuf:"varint,6,opt,name=low_freq_scaler_dur,json=lowFreqScalerDur,proto3" json:"low_freq_scaler_dur,omitempty"` - EnforceLowFreqScaler bool `protobuf:"varint,7,opt,name=enforce_low_freq_scaler,json=enforceLowFreqScaler,proto3" json:"enforce_low_freq_scaler,omitempty"` - ThermalSensorUrl string `protobuf:"bytes,8,opt,name=thermal_sensor_url,json=thermalSensorUrl,proto3" json:"thermal_sensor_url,omitempty"` - TimeBoundScaler bool `protobuf:"varint,9,opt,name=time_bound_scaler,json=timeBoundScaler,proto3" json:"time_bound_scaler,omitempty"` - ThermalBoundScaler bool `protobuf:"varint,10,opt,name=thermal_bound_scaler,json=thermalBoundScaler,proto3" json:"thermal_bound_scaler,omitempty"` - ThermalThreshold int32 `protobuf:"varint,11,opt,name=thermal_threshold,json=thermalThreshold,proto3" json:"thermal_threshold,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` + FreqScalPolicies map[string]*HostFreqScalingPolicy `protobuf:"bytes,1,rep,name=freq_scal_policies,json=freqScalPolicies,proto3" json:"freq_scal_policies,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` + FreqSensorUrl string `protobuf:"bytes,2,opt,name=freq_sensor_url,json=freqSensorUrl,proto3" json:"freq_sensor_url,omitempty"` + ScalingFreqPolicy string `protobuf:"bytes,3,opt,name=scaling_freq_policy,json=scalingFreqPolicy,proto3" json:"scaling_freq_policy,omitempty"` + LowToHighScaler string `protobuf:"bytes,4,opt,name=low_to_high_scaler,json=lowToHighScaler,proto3" json:"low_to_high_scaler,omitempty"` + HighToLowScaler string `protobuf:"bytes,5,opt,name=high_to_low_scaler,json=highToLowScaler,proto3" json:"high_to_low_scaler,omitempty"` + TimeBoundThrottleRetentionDuration int32 `protobuf:"varint,6,opt,name=time_bound_throttle_retention_duration,json=timeBoundThrottleRetentionDuration,proto3" json:"time_bound_throttle_retention_duration,omitempty"` + ThrottleRetention bool `protobuf:"varint,7,opt,name=throttle_retention,json=throttleRetention,proto3" json:"throttle_retention,omitempty"` + ThermalSensorUrl string `protobuf:"bytes,8,opt,name=thermal_sensor_url,json=thermalSensorUrl,proto3" json:"thermal_sensor_url,omitempty"` + TimeBoundThrottleRetention bool `protobuf:"varint,9,opt,name=time_bound_throttle_retention,json=timeBoundThrottleRetention,proto3" json:"time_bound_throttle_retention,omitempty"` + ThermalBoundThrottleRetention bool `protobuf:"varint,10,opt,name=thermal_bound_throttle_retention,json=thermalBoundThrottleRetention,proto3" json:"thermal_bound_throttle_retention,omitempty"` + ThermalBoundThrottleRetentionThreshold int32 `protobuf:"varint,11,opt,name=thermal_bound_throttle_retention_threshold,json=thermalBoundThrottleRetentionThreshold,proto3" json:"thermal_bound_throttle_retention_threshold,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` } func (m *HostFreqScalingConfig) Reset() { *m = HostFreqScalingConfig{} } func (m *HostFreqScalingConfig) String() string { return proto.CompactTextString(m) } func (*HostFreqScalingConfig) ProtoMessage() {} func (*HostFreqScalingConfig) Descriptor() ([]byte, []int) { - return fileDescriptor_hostfrequencyscaling_98d6dac51b8eb441, []int{0} + return fileDescriptor_hostfrequencyscaling_c41765decf96698a, []int{0} } func (m *HostFreqScalingConfig) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_HostFreqScalingConfig.Unmarshal(m, b) @@ -94,16 +94,16 @@ func (m *HostFreqScalingConfig) GetHighToLowScaler() string { return "" } -func (m *HostFreqScalingConfig) GetLowFreqScalerDur() int32 { +func (m *HostFreqScalingConfig) GetTimeBoundThrottleRetentionDuration() int32 { if m != nil { - return m.LowFreqScalerDur + return m.TimeBoundThrottleRetentionDuration } return 0 } -func (m *HostFreqScalingConfig) GetEnforceLowFreqScaler() bool { +func (m *HostFreqScalingConfig) GetThrottleRetention() bool { if m != nil { - return m.EnforceLowFreqScaler + return m.ThrottleRetention } return false } @@ -115,23 +115,23 @@ func (m *HostFreqScalingConfig) GetThermalSensorUrl() string { return "" } -func (m *HostFreqScalingConfig) GetTimeBoundScaler() bool { +func (m *HostFreqScalingConfig) GetTimeBoundThrottleRetention() bool { if m != nil { - return m.TimeBoundScaler + return m.TimeBoundThrottleRetention } return false } -func (m *HostFreqScalingConfig) GetThermalBoundScaler() bool { +func (m *HostFreqScalingConfig) GetThermalBoundThrottleRetention() bool { if m != nil { - return m.ThermalBoundScaler + return m.ThermalBoundThrottleRetention } return false } -func (m *HostFreqScalingConfig) GetThermalThreshold() int32 { +func (m *HostFreqScalingConfig) GetThermalBoundThrottleRetentionThreshold() int32 { if m != nil { - return m.ThermalThreshold + return m.ThermalBoundThrottleRetentionThreshold } return 0 } @@ -151,7 +151,7 @@ func (m *HostFreqScalingPolicy) Reset() { *m = HostFreqScalingPolicy{} } func (m *HostFreqScalingPolicy) String() string { return proto.CompactTextString(m) } func (*HostFreqScalingPolicy) ProtoMessage() {} func (*HostFreqScalingPolicy) Descriptor() ([]byte, []int) { - return fileDescriptor_hostfrequencyscaling_98d6dac51b8eb441, []int{1} + return fileDescriptor_hostfrequencyscaling_c41765decf96698a, []int{1} } func (m *HostFreqScalingPolicy) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_HostFreqScalingPolicy.Unmarshal(m, b) @@ -213,40 +213,41 @@ func init() { } func init() { - proto.RegisterFile("hostfrequencyscaling.proto", fileDescriptor_hostfrequencyscaling_98d6dac51b8eb441) -} - -var fileDescriptor_hostfrequencyscaling_98d6dac51b8eb441 = []byte{ - // 491 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x92, 0xdb, 0x6e, 0xd3, 0x40, - 0x10, 0x86, 0xe5, 0x86, 0x94, 0x64, 0x43, 0x89, 0xb3, 0x6d, 0x85, 0x55, 0xb8, 0x88, 0x8a, 0x84, - 0x0c, 0x85, 0x08, 0x05, 0x21, 0x21, 0xee, 0x38, 0xf7, 0xa2, 0x48, 0x95, 0x1b, 0xae, 0x17, 0xd7, - 0x59, 0x1f, 0xc4, 0x66, 0x27, 0x1d, 0xaf, 0x9b, 0xfa, 0xa1, 0x78, 0x1f, 0x1e, 0x07, 0xed, 0x78, - 0x4d, 0x93, 0x92, 0x2b, 0x5b, 0xff, 0x7c, 0xff, 0xcc, 0xce, 0x81, 0x1d, 0xe5, 0x50, 0x9a, 0x14, - 0xe5, 0x55, 0x25, 0x75, 0x52, 0x97, 0x49, 0xac, 0x0a, 0x9d, 0x4d, 0x96, 0x08, 0x06, 0x78, 0x97, - 0x3e, 0xc7, 0xbf, 0xbb, 0xec, 0xf0, 0x14, 0x4a, 0xf3, 0x15, 0xe5, 0xd5, 0x45, 0x03, 0x7c, 0x02, - 0x9d, 0x16, 0x19, 0xff, 0xc9, 0xb8, 0xb5, 0x0a, 0x6b, 0x13, 0x4b, 0x50, 0x45, 0x52, 0xc8, 0x32, - 0xf0, 0xc6, 0x9d, 0x70, 0x30, 0x9d, 0x36, 0x49, 0x26, 0x5b, 0x9d, 0x93, 0x56, 0x39, 0x77, 0xa6, - 0x2f, 0xda, 0x60, 0x1d, 0xf9, 0xe9, 0x1d, 0x99, 0x3f, 0x63, 0xc3, 0xa6, 0x82, 0xd4, 0x25, 0xa0, - 0xa8, 0x50, 0x05, 0x3b, 0x63, 0x2f, 0xec, 0x47, 0x7b, 0x84, 0x92, 0xfa, 0x03, 0x15, 0x9f, 0xb0, - 0x7d, 0xf7, 0x76, 0x41, 0x3c, 0x3d, 0xa6, 0x0e, 0x3a, 0xc4, 0x8e, 0x5c, 0xc8, 0x16, 0xa5, 0xcc, - 0x35, 0x3f, 0x61, 0x5c, 0xc1, 0x4a, 0x18, 0x10, 0x79, 0x91, 0xe5, 0xd4, 0x80, 0xc4, 0xe0, 0x1e, - 0xe1, 0x43, 0x05, 0xab, 0x19, 0x9c, 0x16, 0x59, 0x7e, 0x41, 0xb2, 0x85, 0x89, 0x32, 0x20, 0xac, - 0xc9, 0xc1, 0xdd, 0x06, 0xb6, 0x91, 0x19, 0x9c, 0xc1, 0xca, 0xc1, 0xaf, 0xd8, 0xbe, 0x85, 0xfe, - 0xcd, 0x45, 0xa2, 0x98, 0x57, 0x18, 0xec, 0x8e, 0xbd, 0xb0, 0x1b, 0xf9, 0x0a, 0x56, 0x6d, 0xeb, - 0x12, 0x3f, 0x57, 0xc8, 0xdf, 0xb2, 0x47, 0x52, 0xa7, 0x80, 0x89, 0x14, 0x77, 0x6c, 0xc1, 0xfd, - 0xb1, 0x17, 0xf6, 0xa2, 0x03, 0x17, 0x3e, 0x5b, 0x77, 0xf2, 0x97, 0x8c, 0x9b, 0x5c, 0xe2, 0x22, - 0x56, 0xeb, 0xa3, 0xe9, 0xd1, 0x93, 0x7c, 0x17, 0xb9, 0x9d, 0xce, 0x0b, 0x36, 0x32, 0xc5, 0x42, - 0x8a, 0x4b, 0xa8, 0xf4, 0xbc, 0x4d, 0xdf, 0xa7, 0xf4, 0x43, 0x1b, 0xf8, 0x68, 0x75, 0x97, 0xf9, - 0x35, 0x3b, 0x68, 0x33, 0x6f, 0xe0, 0x8c, 0xf0, 0xb6, 0xea, 0xba, 0xe3, 0x84, 0x8d, 0x5a, 0x87, - 0xc9, 0x51, 0x96, 0x39, 0xa8, 0x79, 0x30, 0x68, 0xfa, 0x75, 0x81, 0x59, 0xab, 0x1f, 0xc5, 0xec, - 0x70, 0xeb, 0xee, 0xb9, 0xcf, 0x3a, 0xbf, 0x64, 0x1d, 0x78, 0xd4, 0x82, 0xfd, 0xe5, 0x53, 0xd6, - 0xbd, 0x8e, 0x55, 0x25, 0x69, 0xe3, 0x83, 0xe9, 0x93, 0xed, 0x07, 0xd5, 0x2c, 0x34, 0x6a, 0xd0, - 0xf7, 0x3b, 0xef, 0xbc, 0xe3, 0x3f, 0xde, 0x7f, 0xf7, 0xea, 0xb6, 0xfe, 0x9c, 0xf9, 0xed, 0x95, - 0x64, 0x70, 0x2d, 0x51, 0x03, 0xba, 0x82, 0x43, 0xa7, 0x7f, 0x73, 0x32, 0x0f, 0x6f, 0xd1, 0x45, - 0xa1, 0x69, 0x2f, 0xee, 0xf2, 0x1e, 0x3a, 0xfd, 0x7b, 0xa1, 0x6d, 0x85, 0x0d, 0x32, 0xbe, 0x69, - 0xc8, 0xce, 0x26, 0x19, 0xdf, 0x10, 0xf9, 0x98, 0xf5, 0x35, 0xcc, 0xa5, 0x88, 0x31, 0xc9, 0xdd, - 0xad, 0xf5, 0xac, 0xf0, 0x01, 0x93, 0x9c, 0x3f, 0x65, 0x7b, 0x14, 0x5c, 0xaa, 0xd8, 0xa4, 0x80, - 0x0b, 0x77, 0x5f, 0x0f, 0xac, 0x78, 0xee, 0xb4, 0xcb, 0x5d, 0x1a, 0xc1, 0x9b, 0xbf, 0x01, 0x00, - 0x00, 0xff, 0xff, 0xba, 0x11, 0x0a, 0xdc, 0xb6, 0x03, 0x00, 0x00, + proto.RegisterFile("hostfrequencyscaling.proto", fileDescriptor_hostfrequencyscaling_c41765decf96698a) +} + +var fileDescriptor_hostfrequencyscaling_c41765decf96698a = []byte{ + // 501 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x93, 0xcf, 0x6e, 0xd3, 0x40, + 0x10, 0xc6, 0xe5, 0x86, 0x94, 0x64, 0x43, 0x49, 0xba, 0xa8, 0x92, 0x15, 0xa8, 0x64, 0x05, 0x29, + 0x32, 0xff, 0x72, 0x08, 0x17, 0xc4, 0xad, 0xfc, 0x6b, 0x0f, 0x20, 0x55, 0x6e, 0xb8, 0x70, 0x59, + 0xb6, 0xce, 0xc6, 0x5e, 0xb1, 0xd9, 0x49, 0xd7, 0xeb, 0xa6, 0x7e, 0x22, 0x5e, 0x89, 0xc7, 0x41, + 0x3b, 0x5e, 0xab, 0xb4, 0x4d, 0xca, 0x29, 0xab, 0x6f, 0x7e, 0xf3, 0xcd, 0x64, 0xf4, 0x99, 0x0c, + 0x73, 0x28, 0xec, 0xc2, 0x88, 0x8b, 0x52, 0xe8, 0xb4, 0x2a, 0x52, 0xae, 0xa4, 0xce, 0x26, 0x2b, + 0x03, 0x16, 0x68, 0x1b, 0x7f, 0x46, 0xbf, 0x77, 0xc9, 0xc1, 0x09, 0x14, 0xf6, 0x8b, 0x11, 0x17, + 0x67, 0x35, 0xf0, 0x11, 0xf4, 0x42, 0x66, 0xf4, 0x27, 0xa1, 0xae, 0x95, 0xb9, 0x36, 0xb6, 0x02, + 0x25, 0x53, 0x29, 0x8a, 0x30, 0x88, 0x5a, 0x71, 0x6f, 0x3a, 0xad, 0x4d, 0x26, 0x1b, 0x3b, 0x27, + 0x8d, 0x72, 0xea, 0x9b, 0x3e, 0x6b, 0x6b, 0xaa, 0x64, 0xb0, 0xb8, 0x25, 0xd3, 0x31, 0xe9, 0xd7, + 0x13, 0x84, 0x2e, 0xc0, 0xb0, 0xd2, 0xa8, 0x70, 0x27, 0x0a, 0xe2, 0x6e, 0xb2, 0x87, 0x28, 0xaa, + 0xdf, 0x8d, 0xa2, 0x13, 0xf2, 0xc4, 0xef, 0xce, 0x90, 0xc7, 0x65, 0xaa, 0xb0, 0x85, 0xec, 0xbe, + 0x2f, 0xb9, 0xa1, 0xe8, 0x5c, 0xd1, 0x57, 0x84, 0x2a, 0x58, 0x33, 0x0b, 0x2c, 0x97, 0x59, 0x8e, + 0x7f, 0x40, 0x98, 0xf0, 0x01, 0xe2, 0x7d, 0x05, 0xeb, 0x19, 0x9c, 0xc8, 0x2c, 0x3f, 0x43, 0xd9, + 0xc1, 0x48, 0x59, 0x60, 0xae, 0xc9, 0xc3, 0xed, 0x1a, 0x76, 0x95, 0x19, 0x7c, 0x85, 0xb5, 0x87, + 0x13, 0x32, 0xb6, 0x72, 0x29, 0xd8, 0x39, 0x94, 0x7a, 0xce, 0x6c, 0x6e, 0xc0, 0x5a, 0x25, 0x98, + 0x11, 0x56, 0x68, 0x2b, 0x41, 0xb3, 0x79, 0x69, 0xb8, 0x7b, 0x84, 0xbb, 0x51, 0x10, 0xb7, 0x93, + 0x91, 0xa3, 0x3f, 0x38, 0x78, 0xe6, 0xd9, 0xa4, 0x41, 0x3f, 0x79, 0x92, 0xbe, 0x21, 0xf4, 0xae, + 0x51, 0xf8, 0x30, 0x0a, 0xe2, 0x4e, 0xb2, 0x6f, 0x6f, 0xb7, 0xd1, 0xd7, 0x0e, 0x17, 0x66, 0xc9, + 0xd5, 0xbf, 0x77, 0xeb, 0xe0, 0xbe, 0x03, 0x5f, 0xb9, 0x3e, 0xdd, 0x11, 0x39, 0xbc, 0x77, 0xe1, + 0xb0, 0x8b, 0x73, 0x86, 0xdb, 0xf7, 0xa4, 0xc7, 0x24, 0x6a, 0x06, 0x6e, 0x75, 0x21, 0xe8, 0x72, + 0xe8, 0xb9, 0x2d, 0x46, 0x3f, 0xc8, 0xcb, 0xff, 0x19, 0x39, 0x49, 0x14, 0x39, 0xa8, 0x79, 0xd8, + 0xc3, 0x03, 0x8e, 0xef, 0xb5, 0x9c, 0x35, 0xf4, 0x90, 0x93, 0x83, 0x8d, 0xa9, 0xa3, 0x03, 0xd2, + 0xfa, 0x25, 0xaa, 0x30, 0xc0, 0xfb, 0xb8, 0x27, 0x9d, 0x92, 0xf6, 0x25, 0x57, 0xa5, 0xc0, 0xac, + 0xf5, 0xa6, 0xcf, 0x36, 0x47, 0xb9, 0x8e, 0x52, 0x52, 0xa3, 0xef, 0x77, 0xde, 0x05, 0xa3, 0x3f, + 0xc1, 0x9d, 0x2f, 0xc5, 0xe7, 0xed, 0x05, 0x19, 0x34, 0xf9, 0xcc, 0xe0, 0x52, 0x18, 0x0d, 0xc6, + 0x0f, 0xec, 0x7b, 0xfd, 0xd8, 0xcb, 0x34, 0xbe, 0x46, 0x97, 0x52, 0x63, 0x9c, 0x7d, 0xe6, 0x1f, + 0x7b, 0xfd, 0x9b, 0xd4, 0x6e, 0xc2, 0x0d, 0x92, 0x5f, 0xd5, 0x64, 0xeb, 0x26, 0xc9, 0xaf, 0x90, + 0x7c, 0x4a, 0xba, 0x1a, 0xe6, 0x82, 0x71, 0x93, 0xe6, 0x3e, 0xe5, 0x1d, 0x27, 0x1c, 0x99, 0x34, + 0xa7, 0xcf, 0xc9, 0x1e, 0x16, 0x57, 0x8a, 0xdb, 0x05, 0x98, 0xa5, 0x4f, 0xf6, 0x23, 0x27, 0x9e, + 0x7a, 0xed, 0x7c, 0x17, 0x4f, 0xf0, 0xf6, 0x6f, 0x00, 0x00, 0x00, 0xff, 0xff, 0xdb, 0xf3, 0x89, + 0x18, 0x30, 0x04, 0x00, 0x00, } diff --git a/modules/hostfrequencyscaling/proto/hostfrequencyscaling.proto b/modules/hostfrequencyscaling/proto/hostfrequencyscaling.proto index 6305fc802..04830860e 100644 --- a/modules/hostfrequencyscaling/proto/hostfrequencyscaling.proto +++ b/modules/hostfrequencyscaling/proto/hostfrequencyscaling.proto @@ -16,12 +16,12 @@ string scaling_freq_policy = 3; string low_to_high_scaler = 4; string high_to_low_scaler = 5; - int32 low_freq_scaler_dur = 6; - bool enforce_low_freq_scaler = 7; + int32 time_bound_throttle_retention_duration = 6; + bool throttle_retention = 7; string thermal_sensor_url = 8; - bool time_bound_scaler = 9; - bool thermal_bound_scaler = 10; - int32 thermal_threshold = 11; + bool time_bound_throttle_retention = 9; + bool thermal_bound_throttle_retention = 10; + int32 thermal_bound_throttle_retention_threshold = 11; } From 94427bc2af48cd170eaded5e8a866272fddfead7 Mon Sep 17 00:00:00 2001 From: Ghazanfar Ali Date: Wed, 1 Jan 2020 10:30:25 -0700 Subject: [PATCH 81/87] bug fix --- modules/hostfrequencyscaling/hostfrequencyscaling.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/hostfrequencyscaling/hostfrequencyscaling.go b/modules/hostfrequencyscaling/hostfrequencyscaling.go index 1400de290..bbd3979a6 100644 --- a/modules/hostfrequencyscaling/hostfrequencyscaling.go +++ b/modules/hostfrequencyscaling/hostfrequencyscaling.go @@ -443,7 +443,7 @@ func (hfs *HFS) mutateCPUFreq(m lib.Event) { } me := m.Data().(*core.MutationEvent) - enforceLowFreqScaler := hfs.cfg.ThrottleRetention() + enforceLowFreqScaler := hfs.cfg.GetThrottleRetention() if enforceLowFreqScaler == true { switch me.Mutation[1] { From b29c555316ab1a04062edf9ed787040bbe06c0d9 Mon Sep 17 00:00:00 2001 From: Kevin Pelzel Date: Tue, 7 Jan 2020 13:08:34 -0700 Subject: [PATCH 82/87] fixing errors from rebase --- core/Node.go | 5 - core/StateMutationEngine.go | 103 +++--------------- core/StateSyncEngine.go | 2 +- .../HostFrequencyScaler.go | 4 +- 4 files changed, 19 insertions(+), 95 deletions(-) diff --git a/core/Node.go b/core/Node.go index e20d32081..05f9c214a 100644 --- a/core/Node.go +++ b/core/Node.go @@ -14,7 +14,6 @@ package core import ( "fmt" - "log" "reflect" "sync" @@ -387,8 +386,6 @@ func (n *Node) Diff(node lib.Node, prefix string) (r []string, e error) { r, e = lib.MessageDiff(n.pb, m.pb, prefix) - log.Printf("node: %s r: %v eright: %v eleft: %v", node.ID().String(), r, eright, eleft) - // handle extensions for _, u := range eright { nodeExt, ok := m.exts[u] @@ -409,8 +406,6 @@ func (n *Node) Diff(node lib.Node, prefix string) (r []string, e error) { r = append(r, fmt.Sprintf("%s%s", prefix, u)) } - log.Printf("node: %s r after extensions: %v", node.ID().String(), r) - // handle services prefix = lib.URLPush(prefix, "Services") for _, u := range sright { diff --git a/core/StateMutationEngine.go b/core/StateMutationEngine.go index b05a7fe28..f42c58931 100644 --- a/core/StateMutationEngine.go +++ b/core/StateMutationEngine.go @@ -210,26 +210,26 @@ func (sme *StateMutationEngine) DumpGraph() { fmt.Printf("\n=== START: Node list ===\n") for _, m := range sme.nodes { fmt.Printf(` - Node: %p - Spec: %p - req: %s - exc: %s - In: %v - Out: %v - `, m, m.spec, sme.dumpMapOfValues(m.spec.Requires()), sme.dumpMapOfValues(m.spec.Excludes()), m.in, m.out) + Node: %p + Spec: %p + req: %s + exc: %s + In: %v + Out: %v + `, m, m.spec, sme.dumpMapOfValues(m.spec.Requires()), sme.dumpMapOfValues(m.spec.Excludes()), m.in, m.out) } fmt.Printf("\n=== END: Node list ===\n") fmt.Printf("\n=== START: Edge list ===\n") for _, m := range sme.edges { fmt.Printf(` - Edge: %p - Mutation: %p - mut: %s - req: %s - exc: %s - From: %p - To: %p - `, m, m.mut, sme.dumpMutMap(m.mut.Mutates()), sme.dumpMapOfValues(m.mut.Requires()), sme.dumpMapOfValues(m.mut.Excludes()), m.from, m.to) + Edge: %p + Mutation: %p + mut: %s + req: %s + exc: %s + From: %p + To: %p + `, m, m.mut, sme.dumpMutMap(m.mut.Mutates()), sme.dumpMapOfValues(m.mut.Requires()), sme.dumpMapOfValues(m.mut.Excludes()), m.from, m.to) } fmt.Printf("\n=== END: Edge list ===\n") sme.graphMutex.RUnlock() @@ -697,32 +697,6 @@ func nodeMerge(list []int, nodes []*mutationNode) (*mutationNode, []*mutationEdg return node, node.out } -func nodeMerge(list []int, nodes []*mutationNode) (*mutationNode, []*mutationEdge) { - // build a new node from a merge of multiple nodes - // use least-common specification - // note: this will choke on a zero length list, but that shouldn't happen - node := nodes[list[0]] // build off of the first node - for i := 1; i < len(list); i++ { - // remap edges - inode := nodes[list[i]] - for _, e := range inode.in { - if !edgeInEdges(e, node.in) { // don't add if we already have this - e.to = node - node.in = append(node.in, e) - } - } - for _, e := range inode.out { - if !edgeInEdges(e, node.out) { - e.from = node - node.out = append(node.out, e) - } - } - // prune spec - node.spec.LeastCommon(inode.spec) - } - return node, node.out -} - // buildGraphStage1 builds a fully expanded set of paths branching from a starting root // this will build a very verbose, probably unusable graph // it is expected that later graph stages will clean it up and make it more sane @@ -951,24 +925,6 @@ func (sme *StateMutationEngine) nodeViolatesDeps(deps map[string]lib.StateSpec, } } } - // Can this form an in arrow? - if m.SpecCompatIn(root.spec, sme.mutators) { - nme := &mutationEdge{ - cost: 1, - mut: m, - to: root, - } - newNode := &mutationNode{ - spec: root.spec.SpecMergeMust(m.Before()), - in: []*mutationEdge{}, - out: []*mutationEdge{newEdge}, - } - newEdge.from = newNode - root.in = append(root.in, newEdge) - ns, es := sme.buildGraphStage1(newNode, newEdge, seenNodes) - nodes = append(nodes, ns...) - edges = append(edges, es...) - } } return } @@ -1051,33 +1007,6 @@ func (sme *StateMutationEngine) buildGraphStripState(nodes []*mutationNode, edge } return edges } - fmt.Println("=== BEGIN: Graph sanity check ===") - // sanity checks - // 1. Equal number of nodeEdges as edges? - if len(nodeEdges) != len(edges) { - fmt.Printf("len(nodeEdges) != len(edges) : %d != %d\n", len(nodeEdges), len(edges)) - ret = false - } - // 2. Equal number of edgeNodes as nodes? - if len(edgeNodes) != len(nodes) { - fmt.Printf("len(edgeNodes) != len(nodes) : %d != %d\n", len(edgeNodes), len(nodes)) - ret = false - } - // 2. nodeEdges should have ref count 2 - bad := 0 - for _, c := range nodeEdges { - if c != 2 { - bad++ - } - } - if bad > 0 { - fmt.Printf("%d edges have ref count != 2\n", bad) - ret = false - } - - fmt.Println("=== END: Graph sanity check ===") - return ret -} // 1. iterate through the nodes // - remove dependecy violating info @@ -1388,6 +1317,7 @@ func (sme *StateMutationEngine) startNewMutation(node string) { // we need to hold the path mutex for the rest of this function p.mutex.Lock() defer p.mutex.Unlock() + sme.activeMutex.Lock() sme.active[node] = p sme.activeMutex.Unlock() @@ -1675,7 +1605,6 @@ func (sme *StateMutationEngine) updateMutation(node string, url string, val refl sme.Log(ERROR, e.Error()) return } - sme.log.Logf(lib.LLDEBUG, "(node: %v) sme got value from url: %v", node, val) // this is a discovery on a completed chain if m.cur >= len(m.chain) { diff --git a/core/StateSyncEngine.go b/core/StateSyncEngine.go index bdba52ed9..72a648dea 100644 --- a/core/StateSyncEngine.go +++ b/core/StateSyncEngine.go @@ -691,7 +691,7 @@ func (sse *StateSyncEngine) sync(n *stateSyncNeighbor) { } } if n.due() { - sse.Logf(DEBUG, "sending hello to: %s", n.getID().String()) + sse.Logf(DEBUG, "sending hello: %s", n.getID().String()) sse.send(n) sse.sortQueue() } diff --git a/extensions/HostFrequencyScaler/HostFrequencyScaler.go b/extensions/HostFrequencyScaler/HostFrequencyScaler.go index 810de2f02..8b4e7a910 100644 --- a/extensions/HostFrequencyScaler/HostFrequencyScaler.go +++ b/extensions/HostFrequencyScaler/HostFrequencyScaler.go @@ -8,10 +8,10 @@ import ( "github.com/hpc/kraken/lib" ) -//go:generate protoc -I ../../core/proto/include -I proto --go_out=plugins=grpc:proto proto/RFAggregatorServer.proto +//go:generate protoc -I ../../core/proto/include -I proto --go_out=plugins=grpc:proto proto/HostFrequencyScaler.proto ///////////////// -// RFAggregatorServer Object / +// HostFrequencyScaler Object / /////////////// var _ lib.Extension = HostFrequencyScaler{} From 2a8501d690f84347c8870182d0db6e80473d884f Mon Sep 17 00:00:00 2001 From: Kevin Pelzel Date: Tue, 7 Jan 2020 13:12:15 -0700 Subject: [PATCH 83/87] fixing weird whitespace issue --- core/StateMutationEngine.go | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/core/StateMutationEngine.go b/core/StateMutationEngine.go index f42c58931..d0562c793 100644 --- a/core/StateMutationEngine.go +++ b/core/StateMutationEngine.go @@ -210,26 +210,26 @@ func (sme *StateMutationEngine) DumpGraph() { fmt.Printf("\n=== START: Node list ===\n") for _, m := range sme.nodes { fmt.Printf(` - Node: %p - Spec: %p - req: %s - exc: %s - In: %v - Out: %v - `, m, m.spec, sme.dumpMapOfValues(m.spec.Requires()), sme.dumpMapOfValues(m.spec.Excludes()), m.in, m.out) + Node: %p + Spec: %p + req: %s + exc: %s + In: %v + Out: %v + `, m, m.spec, sme.dumpMapOfValues(m.spec.Requires()), sme.dumpMapOfValues(m.spec.Excludes()), m.in, m.out) } fmt.Printf("\n=== END: Node list ===\n") fmt.Printf("\n=== START: Edge list ===\n") for _, m := range sme.edges { fmt.Printf(` - Edge: %p - Mutation: %p - mut: %s - req: %s - exc: %s - From: %p - To: %p - `, m, m.mut, sme.dumpMutMap(m.mut.Mutates()), sme.dumpMapOfValues(m.mut.Requires()), sme.dumpMapOfValues(m.mut.Excludes()), m.from, m.to) + Edge: %p + Mutation: %p + mut: %s + req: %s + exc: %s + From: %p + To: %p + `, m, m.mut, sme.dumpMutMap(m.mut.Mutates()), sme.dumpMapOfValues(m.mut.Requires()), sme.dumpMapOfValues(m.mut.Excludes()), m.from, m.to) } fmt.Printf("\n=== END: Edge list ===\n") sme.graphMutex.RUnlock() From 3a44beb476e0ba61ee088bffc4c6ae1a6c37f36a Mon Sep 17 00:00:00 2001 From: ghazanfarttu Date: Tue, 7 Jan 2020 14:44:20 -0600 Subject: [PATCH 84/87] general cleanup --- .../hostfrequencyscaling.go | 52 +------------------ 1 file changed, 2 insertions(+), 50 deletions(-) diff --git a/modules/hostfrequencyscaling/hostfrequencyscaling.go b/modules/hostfrequencyscaling/hostfrequencyscaling.go index bbd3979a6..ff0a754ee 100644 --- a/modules/hostfrequencyscaling/hostfrequencyscaling.go +++ b/modules/hostfrequencyscaling/hostfrequencyscaling.go @@ -84,7 +84,7 @@ const ( freqSensorPath string = "/sys/devices/system/cpu/cpufreq/policy0/" // thermalSensorUrl holds thermal sensor path on pi node - thermalSensorUrl string = "/sys/devices/virtual/thermal/thermal_zone0/temp" + thermalSensorURL string = "/sys/devices/virtual/thermal/thermal_zone0/temp" ) var profileMap = map[string]string{ @@ -225,7 +225,7 @@ func (*HFS) Name() string { return "github.com/hpc/kraken/modules/hostfrequencys func (*HFS) NewConfig() proto.Message { r := &pb.HostFreqScalingConfig{ FreqSensorUrl: freqSensorPath, - ThermalSensorUrl: thermalSensorUrl, + ThermalSensorUrl: thermalSensorURL, ScalingFreqPolicy: hostFreqScalerURL, HighToLowScaler: "powersave", LowToHighScaler: "performance", @@ -413,25 +413,6 @@ func (hfs *HFS) Entry() { } } - // // setup a ticker for checking whether PS is enforced in Thermal bound scenario - // if hfs.cfg.GetThermalBoundScaler() == true { - - // dur, _ := time.ParseDuration("1s") - // thermalCheckTick := time.NewTicker(dur) - - // // thermal ticker - // for { - // select { - // case <-thermalCheckTick.C: - // if hfs.psEnforced == true { - // go hfs.CheckThermalThreshold() - // } - - // break - // } - // } - - // } } // aggregateHandler makes calls to aggregator for the given nodes with related mutation and frequecy scaling policy @@ -508,28 +489,12 @@ func (hfs *HFS) CheckThermalThreshold() { currentThermal := hfs.ReadCPUTemp() thresholdThermal := hfs.cfg.GetThermalBoundThrottleRetentionThreshold() - // if currentThermal >= thresholdThermal { - // hfs.mutex.Lock() - // hfs.psEnforced = true - // hfs.mutex.Unlock() - // } else if (currentThermal / 1000) < thresholdThermal { hfs.mutex.Lock() hfs.psEnforced = false hfs.mutex.Unlock() - // url := lib.NodeURLJoin(node.ID().String(), hostFreqScalerURL) - // ev := core.NewEvent( - // lib.Event_DISCOVERY, - // url, - // &core.DiscoveryEvent{ - // URL: url, - // ValueID: profileMap["performance"], - // }, - // ) - // hfs.dchan <- ev } - //hfs.api.Logf(lib.LLERROR, "*** T E M P ***: %v", currentThermal/1000) } @@ -629,7 +594,6 @@ func (hfs *HFS) HostFrequencyScaling(node lib.Node, freqScalPolicy string) { CPUMaxFreq: cpuMaxFreqq, } - //if bBoot == true { url := lib.NodeURLJoin(node.ID().String(), hostFreqScalerURL) ev := core.NewEvent( lib.Event_DISCOVERY, @@ -640,18 +604,6 @@ func (hfs *HFS) HostFrequencyScaling(node lib.Node, freqScalPolicy string) { }, ) hfs.dchan <- ev - // } else { - // url := lib.NodeURLJoin(node.ID().String(), hostHightoLowFreqScalerURL) - // ev := core.NewEvent( - // lib.Event_DISCOVERY, - // url, - // &core.DiscoveryEvent{ - // URL: url, - // ValueID: currentScalingConfig.CurScalingGovernor, - // }, - // ) - // hfs.dchan <- ev - // } } From 5889818e346de5bcd4bbe4c65db4655928ecc3fb Mon Sep 17 00:00:00 2001 From: ghazanfarttu Date: Tue, 7 Jan 2020 14:58:41 -0600 Subject: [PATCH 85/87] removing pipxe-child and some other changes --- config/pipxe-child.yaml | 28 ------------------- .../hostthermaldiscovery.go | 19 ++----------- 2 files changed, 2 insertions(+), 45 deletions(-) delete mode 100644 config/pipxe-child.yaml diff --git a/config/pipxe-child.yaml b/config/pipxe-child.yaml deleted file mode 100644 index 6e36ec61c..000000000 --- a/config/pipxe-child.yaml +++ /dev/null @@ -1,28 +0,0 @@ -# kraken-build.go: describes a build for a BitScope Raspberry Pi cluster -targets: - 'linux-arm64': # this identifies the build, will be appended to the binary name - os: 'linux' # os must match a supported GOOS - arch: 'arm64' # arch must match a supported GOARCH - 'linux-amd64': - os: 'linux' - arch: 'amd64' - 'darwin-amd64': - os: 'darwin' - arch: 'amd64' - -# included extensions -extensions: - - github.com/hpc/kraken/extensions/IPv4 - - github.com/hpc/kraken/extensions/RPi3 - - github.com/hpc/kraken/extensions/HostThermal - - github.com/hpc/kraken/extensions/HostFrequencyScaler -# included modules -modules: - - github.com/hpc/kraken/modules/restapi - - github.com/hpc/kraken/modules/rfpipower - - github.com/hpc/kraken/modules/pipxe - - github.com/hpc/kraken/modules/hostthermaldiscovery - - github.com/hpc/kraken/modules/hostfrequencyscaling - - github.com/hpc/kraken/modules/cpuburn - - github.com/hpc/kraken/modules/websocket - diff --git a/modules/hostthermaldiscovery/hostthermaldiscovery.go b/modules/hostthermaldiscovery/hostthermaldiscovery.go index 475faa7bd..90e513f5a 100644 --- a/modules/hostthermaldiscovery/hostthermaldiscovery.go +++ b/modules/hostthermaldiscovery/hostthermaldiscovery.go @@ -213,16 +213,11 @@ func (hostDisc *HostDisc) CapturingStatData() { func (hostDisc *HostDisc) DiscFreqScaler() { hostFreqScaler := hostDisc.ReadFreqScaler() - // if hostFreqScaler == hostDisc.preFreqScaler { - // // no change in frequency scaler so no need to generate discovery event - // return - // } + hostDisc.preFreqScaler = hostFreqScaler vid := profileMap[hostFreqScaler] - //hostDisc.api.Logf(lib., "PRINTSCALER: %s", vid) - url := lib.NodeURLJoin(hostDisc.api.Self().String(), hostFreqScalerURL) // Generating discovery event for CPU Thermal state @@ -248,7 +243,7 @@ func (hostDisc *HostDisc) ReadFreqScaler() string { hostDisc.api.Logf(lib.LLERROR, "Reading CPU thermal sensor failed: %v", err) return "" } - //fscalingGovernor := strings.TrimSuffix(string(bscalingGovernor), "\n") + return strings.TrimSuffix(string(bscalingGovernor), "\n") } @@ -350,16 +345,6 @@ func (hostDisc *HostDisc) lambdaStateDiscovery(v CPUTempObj) (string, int32) { lowerCritical := hostDisc.cfg.GetLowerCritical() upperCritical := hostDisc.cfg.GetUpperCritical() - // cpuThermalThresholds := hostDisc.cfg.GetThermalThresholds() - // lowerNormal := cpuThermalThresholds["CPUThermalThresholds"].GetLowerNormal() - // upperNormal := cpuThermalThresholds["CPUThermalThresholds"].GetUpperNormal() - - // lowerHigh := cpuThermalThresholds["CPUThermalThresholds"].GetLowerHigh() - // upperHigh := cpuThermalThresholds["CPUThermalThresholds"].GetUpperHigh() - - // lowerCritical := cpuThermalThresholds["CPUThermalThresholds"].GetLowerCritical() - // upperCritical := cpuThermalThresholds["CPUThermalThresholds"].GetUpperCritical() - if cpuTemp <= lowerCritical || cpuTemp >= upperCritical { cpuTempState = thpb.HostThermal_CPU_TEMP_CRITICAL } else if cpuTemp >= lowerHigh && cpuTemp < upperHigh { From 14dd1307fea9e5af9770245c97977b9fc94149a6 Mon Sep 17 00:00:00 2001 From: Kevin Pelzel Date: Wed, 8 Jan 2020 16:49:48 -0700 Subject: [PATCH 86/87] fixing whitespacing --- kraken/main.go.tpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kraken/main.go.tpl b/kraken/main.go.tpl index 29f9a62e0..575af6cfe 100644 --- a/kraken/main.go.tpl +++ b/kraken/main.go.tpl @@ -145,7 +145,7 @@ func main() { lib.Event_DISCOVERY, url, &core.DiscoveryEvent{ - ID: k.ID(), + ID: k.ID(), URL: url, ValueID: stateToVID[ds[d]], }, From 0502246caaefd2549a309c49aea7d8da5475522b Mon Sep 17 00:00:00 2001 From: Kevin Pelzel Date: Wed, 8 Jan 2020 16:49:58 -0700 Subject: [PATCH 87/87] setting child log level back to 7 --- utils/layer0/uinit/uinit.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/layer0/uinit/uinit.go b/utils/layer0/uinit/uinit.go index 3dc074cdc..9e8f92093 100644 --- a/utils/layer0/uinit/uinit.go +++ b/utils/layer0/uinit/uinit.go @@ -28,7 +28,7 @@ const ioDir = "/tmp/io" const ioMode = 0700 // log level of child node -const logLevel = "10" +const logLevel = "7" type command struct { Cmd string