├── .github ├── dependabot.yml └── workflows │ ├── common-codeql.yaml │ ├── common-trivy.yaml │ ├── release.yaml │ ├── scan-periodic.yaml │ ├── trivy-csv.tpl │ └── verify.yaml ├── LICENSE ├── Makefile ├── README.md ├── cmd ├── blockio │ ├── main.go │ └── sample.cfg ├── rdt │ ├── main.go │ └── sample-conf.yaml └── sst-ctl │ └── main.go ├── doc ├── blockio.md ├── rdt.md └── sst.md ├── go.mod ├── go.sum ├── pkg ├── blockio │ ├── blockio.go │ ├── blockio_test.go │ ├── cgroups.go │ ├── config.go │ ├── kubernetes.go │ ├── oci.go │ └── oci_test.go ├── kubernetes │ ├── annotations.go │ └── annotations_test.go ├── log │ └── log.go ├── path │ ├── path.go │ └── path_test.go ├── rdt │ ├── bitmask.go │ ├── config.go │ ├── info.go │ ├── kubernetes.go │ ├── kubernetes_test.go │ ├── prometheus.go │ ├── rdt.go │ └── rdt_test.go ├── sst │ ├── _sst_types_amd64.go │ ├── _sst_types_priv.go │ ├── fuzz_test.go │ ├── gen_sst_types.sh │ ├── sst.go │ ├── sst_if.go │ ├── sst_types_amd64.go │ ├── sst_types_priv.go │ └── sysfs.go ├── testutils │ ├── file.go │ └── verify.go └── utils │ ├── idset.go │ ├── json.go │ ├── msr.go │ ├── sort.go │ └── sysfs.go ├── security.md └── test └── data ├── rdt.go ├── resctrl.full ├── Guaranteed │ ├── cpus │ ├── cpus_list │ ├── mode │ ├── mon_data │ │ ├── mon_L3_00 │ │ │ ├── llc_occupancy │ │ │ ├── mbm_local_bytes │ │ │ └── mbm_total_bytes │ │ ├── mon_L3_01 │ │ │ ├── llc_occupancy │ │ │ ├── mbm_local_bytes │ │ │ └── mbm_total_bytes │ │ ├── mon_L3_02 │ │ │ ├── llc_occupancy │ │ │ ├── mbm_local_bytes │ │ │ └── mbm_total_bytes │ │ └── mon_L3_03 │ │ │ ├── llc_occupancy │ │ │ ├── mbm_local_bytes │ │ │ └── mbm_total_bytes │ ├── mon_groups │ │ └── non_goresctrl.group │ │ │ ├── cpus │ │ │ ├── cpus_list │ │ │ ├── mon_data │ │ │ ├── mon_L3_00 │ │ │ │ ├── llc_occupancy │ │ │ │ ├── mbm_local_bytes │ │ │ │ └── mbm_total_bytes │ │ │ ├── mon_L3_01 │ │ │ │ ├── llc_occupancy │ │ │ │ ├── mbm_local_bytes │ │ │ │ └── mbm_total_bytes │ │ │ ├── mon_L3_02 │ │ │ │ ├── llc_occupancy │ │ │ │ ├── mbm_local_bytes │ │ │ │ └── mbm_total_bytes │ │ │ └── mon_L3_03 │ │ │ │ ├── llc_occupancy │ │ │ │ ├── mbm_local_bytes │ │ │ │ └── mbm_total_bytes │ │ │ └── tasks │ ├── schemata │ ├── size │ └── tasks ├── cpus ├── cpus_list ├── goresctrl.Guaranteed │ ├── cpus │ ├── cpus_list │ ├── mode │ ├── mon_data │ │ ├── mon_L3_00 │ │ │ ├── llc_occupancy │ │ │ ├── mbm_local_bytes │ │ │ └── mbm_total_bytes │ │ ├── mon_L3_01 │ │ │ ├── llc_occupancy │ │ │ ├── mbm_local_bytes │ │ │ └── mbm_total_bytes │ │ ├── mon_L3_02 │ │ │ ├── llc_occupancy │ │ │ ├── mbm_local_bytes │ │ │ └── mbm_total_bytes │ │ └── mon_L3_03 │ │ │ ├── llc_occupancy │ │ │ ├── mbm_local_bytes │ │ │ └── mbm_total_bytes │ ├── mon_groups │ │ ├── goresctrl.predefined_group_empty │ │ │ ├── cpus │ │ │ ├── cpus_list │ │ │ ├── mon_data │ │ │ │ ├── mon_L3_00 │ │ │ │ │ ├── llc_occupancy │ │ │ │ │ ├── mbm_local_bytes │ │ │ │ │ └── mbm_total_bytes │ │ │ │ ├── mon_L3_01 │ │ │ │ │ ├── llc_occupancy │ │ │ │ │ ├── mbm_local_bytes │ │ │ │ │ └── mbm_total_bytes │ │ │ │ ├── mon_L3_02 │ │ │ │ │ ├── llc_occupancy │ │ │ │ │ ├── mbm_local_bytes │ │ │ │ │ └── mbm_total_bytes │ │ │ │ └── mon_L3_03 │ │ │ │ │ ├── llc_occupancy │ │ │ │ │ ├── mbm_local_bytes │ │ │ │ │ └── mbm_total_bytes │ │ │ └── tasks │ │ ├── goresctrl.predefined_group_live │ │ │ ├── cpus │ │ │ ├── cpus_list │ │ │ ├── mon_data │ │ │ │ ├── mon_L3_00 │ │ │ │ │ ├── llc_occupancy │ │ │ │ │ ├── mbm_local_bytes │ │ │ │ │ └── mbm_total_bytes │ │ │ │ ├── mon_L3_01 │ │ │ │ │ ├── llc_occupancy │ │ │ │ │ ├── mbm_local_bytes │ │ │ │ │ └── mbm_total_bytes │ │ │ │ ├── mon_L3_02 │ │ │ │ │ ├── llc_occupancy │ │ │ │ │ ├── mbm_local_bytes │ │ │ │ │ └── mbm_total_bytes │ │ │ │ └── mon_L3_03 │ │ │ │ │ ├── llc_occupancy │ │ │ │ │ ├── mbm_local_bytes │ │ │ │ │ └── mbm_total_bytes │ │ │ └── tasks │ │ └── non_goresctrl.group │ │ │ ├── cpus │ │ │ ├── cpus_list │ │ │ ├── mon_data │ │ │ ├── mon_L3_00 │ │ │ │ ├── llc_occupancy │ │ │ │ ├── mbm_local_bytes │ │ │ │ └── mbm_total_bytes │ │ │ ├── mon_L3_01 │ │ │ │ ├── llc_occupancy │ │ │ │ ├── mbm_local_bytes │ │ │ │ └── mbm_total_bytes │ │ │ ├── mon_L3_02 │ │ │ │ ├── llc_occupancy │ │ │ │ ├── mbm_local_bytes │ │ │ │ └── mbm_total_bytes │ │ │ └── mon_L3_03 │ │ │ │ ├── llc_occupancy │ │ │ │ ├── mbm_local_bytes │ │ │ │ └── mbm_total_bytes │ │ │ └── tasks │ ├── schemata │ ├── size │ └── tasks ├── goresctrl.Stale │ ├── cpus │ ├── cpus_list │ ├── mode │ ├── mon_data │ │ ├── mon_L3_00 │ │ │ ├── llc_occupancy │ │ │ ├── mbm_local_bytes │ │ │ └── mbm_total_bytes │ │ ├── mon_L3_01 │ │ │ ├── llc_occupancy │ │ │ ├── mbm_local_bytes │ │ │ └── mbm_total_bytes │ │ ├── mon_L3_02 │ │ │ ├── llc_occupancy │ │ │ ├── mbm_local_bytes │ │ │ └── mbm_total_bytes │ │ └── mon_L3_03 │ │ │ ├── llc_occupancy │ │ │ ├── mbm_local_bytes │ │ │ └── mbm_total_bytes │ ├── mon_groups │ │ └── non_goresctrl.group │ │ │ ├── cpus │ │ │ ├── cpus_list │ │ │ ├── mon_data │ │ │ ├── mon_L3_00 │ │ │ │ ├── llc_occupancy │ │ │ │ ├── mbm_local_bytes │ │ │ │ └── mbm_total_bytes │ │ │ ├── mon_L3_01 │ │ │ │ ├── llc_occupancy │ │ │ │ ├── mbm_local_bytes │ │ │ │ └── mbm_total_bytes │ │ │ ├── mon_L3_02 │ │ │ │ ├── llc_occupancy │ │ │ │ ├── mbm_local_bytes │ │ │ │ └── mbm_total_bytes │ │ │ └── mon_L3_03 │ │ │ │ ├── llc_occupancy │ │ │ │ ├── mbm_local_bytes │ │ │ │ └── mbm_total_bytes │ │ │ └── tasks │ ├── schemata │ ├── size │ └── tasks ├── info │ ├── L3 │ │ ├── bit_usage │ │ ├── cbm_mask │ │ ├── min_cbm_bits │ │ ├── num_closids │ │ └── shareable_bits │ ├── L3_MON │ │ ├── max_threshold_occupancy │ │ ├── mon_features │ │ └── num_rmids │ ├── MB │ │ ├── bandwidth_gran │ │ ├── delay_linear │ │ ├── min_bandwidth │ │ └── num_closids │ └── last_cmd_status ├── mode ├── mon_data │ ├── mon_L3_00 │ │ ├── llc_occupancy │ │ ├── mbm_local_bytes │ │ └── mbm_total_bytes │ ├── mon_L3_01 │ │ ├── llc_occupancy │ │ ├── mbm_local_bytes │ │ └── mbm_total_bytes │ ├── mon_L3_02 │ │ ├── llc_occupancy │ │ ├── mbm_local_bytes │ │ └── mbm_total_bytes │ └── mon_L3_03 │ │ ├── llc_occupancy │ │ ├── mbm_local_bytes │ │ └── mbm_total_bytes ├── mon_groups │ ├── example │ │ ├── cpus │ │ ├── cpus_list │ │ ├── mon_data │ │ │ ├── mon_L3_00 │ │ │ │ ├── llc_occupancy │ │ │ │ ├── mbm_local_bytes │ │ │ │ └── mbm_total_bytes │ │ │ ├── mon_L3_01 │ │ │ │ ├── llc_occupancy │ │ │ │ ├── mbm_local_bytes │ │ │ │ └── mbm_total_bytes │ │ │ ├── mon_L3_02 │ │ │ │ ├── llc_occupancy │ │ │ │ ├── mbm_local_bytes │ │ │ │ └── mbm_total_bytes │ │ │ └── mon_L3_03 │ │ │ │ ├── llc_occupancy │ │ │ │ ├── mbm_local_bytes │ │ │ │ └── mbm_total_bytes │ │ └── tasks │ └── non_goresctrl.group │ │ ├── cpus │ │ ├── cpus_list │ │ ├── mon_data │ │ ├── mon_L3_00 │ │ │ ├── llc_occupancy │ │ │ ├── mbm_local_bytes │ │ │ └── mbm_total_bytes │ │ ├── mon_L3_01 │ │ │ ├── llc_occupancy │ │ │ ├── mbm_local_bytes │ │ │ └── mbm_total_bytes │ │ ├── mon_L3_02 │ │ │ ├── llc_occupancy │ │ │ ├── mbm_local_bytes │ │ │ └── mbm_total_bytes │ │ └── mon_L3_03 │ │ │ ├── llc_occupancy │ │ │ ├── mbm_local_bytes │ │ │ └── mbm_total_bytes │ │ └── tasks ├── non_goresctrl.Group │ ├── cpus │ ├── cpus_list │ ├── mode │ ├── mon_data │ │ ├── mon_L3_00 │ │ │ ├── llc_occupancy │ │ │ ├── mbm_local_bytes │ │ │ └── mbm_total_bytes │ │ ├── mon_L3_01 │ │ │ ├── llc_occupancy │ │ │ ├── mbm_local_bytes │ │ │ └── mbm_total_bytes │ │ ├── mon_L3_02 │ │ │ ├── llc_occupancy │ │ │ ├── mbm_local_bytes │ │ │ └── mbm_total_bytes │ │ └── mon_L3_03 │ │ │ ├── llc_occupancy │ │ │ ├── mbm_local_bytes │ │ │ └── mbm_total_bytes │ ├── schemata │ ├── size │ └── tasks ├── schemata ├── size └── tasks ├── resctrl.l2 ├── cpus ├── cpus_list ├── info │ ├── L2 │ │ ├── bit_usage │ │ ├── cbm_mask │ │ ├── min_cbm_bits │ │ ├── num_closids │ │ └── shareable_bits │ └── last_cmd_status ├── mode ├── schemata ├── size └── tasks ├── resctrl.l2cdp ├── cpus ├── cpus_list ├── info │ ├── L2CODE │ │ ├── bit_usage │ │ ├── cbm_mask │ │ ├── min_cbm_bits │ │ ├── num_closids │ │ └── shareable_bits │ ├── L2DATA │ │ ├── bit_usage │ │ ├── cbm_mask │ │ ├── min_cbm_bits │ │ ├── num_closids │ │ └── shareable_bits │ ├── L3 │ │ ├── bit_usage │ │ ├── cbm_mask │ │ ├── min_cbm_bits │ │ ├── num_closids │ │ └── shareable_bits │ └── last_cmd_status ├── mode ├── schemata ├── size └── tasks ├── resctrl.nol3.mbps ├── cpus ├── cpus_list ├── info │ ├── L3_MON │ │ ├── max_threshold_occupancy │ │ ├── mon_features │ │ └── num_rmids │ ├── MB │ │ ├── bandwidth_gran │ │ ├── delay_linear │ │ ├── min_bandwidth │ │ └── num_closids │ └── last_cmd_status ├── mode ├── mon_data │ ├── mon_L3_00 │ │ ├── llc_occupancy │ │ ├── mbm_local_bytes │ │ └── mbm_total_bytes │ ├── mon_L3_01 │ │ ├── llc_occupancy │ │ ├── mbm_local_bytes │ │ └── mbm_total_bytes │ ├── mon_L3_02 │ │ ├── llc_occupancy │ │ ├── mbm_local_bytes │ │ └── mbm_total_bytes │ └── mon_L3_03 │ │ ├── llc_occupancy │ │ ├── mbm_local_bytes │ │ └── mbm_total_bytes ├── schemata ├── size └── tasks ├── resctrl.nol3 ├── cpus ├── cpus_list ├── info │ ├── L3_MON │ │ ├── max_threshold_occupancy │ │ ├── mon_features │ │ └── num_rmids │ ├── MB │ │ ├── bandwidth_gran │ │ ├── delay_linear │ │ ├── min_bandwidth │ │ └── num_closids │ └── last_cmd_status ├── mode ├── mon_data │ ├── mon_L3_00 │ │ ├── llc_occupancy │ │ ├── mbm_local_bytes │ │ └── mbm_total_bytes │ ├── mon_L3_01 │ │ ├── llc_occupancy │ │ ├── mbm_local_bytes │ │ └── mbm_total_bytes │ ├── mon_L3_02 │ │ ├── llc_occupancy │ │ ├── mbm_local_bytes │ │ └── mbm_total_bytes │ └── mon_L3_03 │ │ ├── llc_occupancy │ │ ├── mbm_local_bytes │ │ └── mbm_total_bytes ├── schemata ├── size └── tasks ├── resctrl.nomb.cdp ├── cpus ├── cpus_list ├── info │ ├── L3CODE │ │ ├── bit_usage │ │ ├── cbm_mask │ │ ├── min_cbm_bits │ │ ├── num_closids │ │ └── shareable_bits │ ├── L3DATA │ │ ├── bit_usage │ │ ├── cbm_mask │ │ ├── min_cbm_bits │ │ ├── num_closids │ │ └── shareable_bits │ ├── L3_MON │ │ ├── max_threshold_occupancy │ │ ├── mon_features │ │ └── num_rmids │ └── last_cmd_status ├── mode ├── mon_data │ ├── mon_L3_00 │ │ ├── llc_occupancy │ │ ├── mbm_local_bytes │ │ └── mbm_total_bytes │ ├── mon_L3_01 │ │ ├── llc_occupancy │ │ ├── mbm_local_bytes │ │ └── mbm_total_bytes │ ├── mon_L3_02 │ │ ├── llc_occupancy │ │ ├── mbm_local_bytes │ │ └── mbm_total_bytes │ └── mon_L3_03 │ │ ├── llc_occupancy │ │ ├── mbm_local_bytes │ │ └── mbm_total_bytes ├── schemata ├── size └── tasks └── resctrl.nomb ├── cpus ├── cpus_list ├── info ├── L3 │ ├── bit_usage │ ├── cbm_mask │ ├── min_cbm_bits │ ├── num_closids │ └── shareable_bits ├── L3_MON │ ├── max_threshold_occupancy │ ├── mon_features │ └── num_rmids └── last_cmd_status ├── mode ├── mon_data ├── mon_L3_00 │ ├── llc_occupancy │ ├── mbm_local_bytes │ └── mbm_total_bytes ├── mon_L3_01 │ ├── llc_occupancy │ ├── mbm_local_bytes │ └── mbm_total_bytes ├── mon_L3_02 │ ├── llc_occupancy │ ├── mbm_local_bytes │ └── mbm_total_bytes └── mon_L3_03 │ ├── llc_occupancy │ ├── mbm_local_bytes │ └── mbm_total_bytes ├── schemata ├── size └── tasks /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: "gomod" 4 | target-branch: main 5 | directory: "/" 6 | schedule: 7 | interval: "weekly" 8 | # Disable version updates (we're a library) 9 | open-pull-requests-limit: 0 10 | 11 | - package-ecosystem: "github-actions" 12 | target-branch: main 13 | directory: "/" 14 | schedule: 15 | interval: "daily" 16 | -------------------------------------------------------------------------------- /.github/workflows/common-codeql.yaml: -------------------------------------------------------------------------------- 1 | name: CodeQL 2 | on: 3 | workflow_call: 4 | inputs: 5 | export-report: 6 | default: false 7 | required: false 8 | type: boolean 9 | 10 | permissions: 11 | contents: read 12 | 13 | jobs: 14 | codeql-scan: 15 | runs-on: ubuntu-22.04 16 | permissions: 17 | security-events: write 18 | steps: 19 | - name: Checkout 20 | uses: actions/checkout@v4 21 | 22 | - name: Initialize CodeQL 23 | uses: github/codeql-action/init@v3 24 | with: 25 | languages: go 26 | 27 | - name: Perform CodeQL Analysis 28 | uses: github/codeql-action/analyze@v3 29 | 30 | - name: Generate CodeQL Security Report 31 | if: ${{ inputs.export-report }} 32 | uses: rsdmike/github-security-report-action@v3.0.4 33 | with: 34 | template: report 35 | token: ${{ secrets.GITHUB_TOKEN }} 36 | 37 | - name: Upload PDF report as an artifact 38 | if: ${{ inputs.export-report }} 39 | uses: actions/upload-artifact@v4 40 | with: 41 | name: codeql-report 42 | path: report.pdf 43 | -------------------------------------------------------------------------------- /.github/workflows/common-trivy.yaml: -------------------------------------------------------------------------------- 1 | name: Trivy 2 | on: 3 | workflow_call: 4 | inputs: 5 | upload-to-github-security-tab: 6 | default: false 7 | required: false 8 | type: boolean 9 | export-csv: 10 | default: false 11 | required: false 12 | type: boolean 13 | 14 | permissions: 15 | contents: read 16 | 17 | jobs: 18 | trivy-scan-licenses: 19 | runs-on: ubuntu-22.04 20 | steps: 21 | - name: Checkout 22 | uses: actions/checkout@v4 23 | 24 | - name: Run Trivy in fs mode 25 | uses: aquasecurity/trivy-action@master 26 | with: 27 | scan-type: fs 28 | scan-ref: . 29 | exit-code: 1 30 | scanners: license 31 | severity: "UNKNOWN,MEDIUM,HIGH,CRITICAL" 32 | 33 | trivy-scan-vulns: 34 | runs-on: ubuntu-22.04 35 | permissions: 36 | security-events: write 37 | steps: 38 | - name: Checkout 39 | uses: actions/checkout@v4 40 | 41 | - name: Run Trivy in fs mode 42 | continue-on-error: true 43 | uses: aquasecurity/trivy-action@master 44 | with: 45 | scan-type: fs 46 | scan-ref: . 47 | exit-code: 1 48 | list-all-pkgs: true 49 | format: json 50 | output: trivy-report.json 51 | 52 | - name: Show report in human-readable format 53 | uses: aquasecurity/trivy-action@master 54 | with: 55 | scan-type: convert 56 | vuln-type: '' 57 | severity: '' 58 | image-ref: trivy-report.json 59 | format: table 60 | 61 | - name: Convert report to sarif format 62 | if: ${{ inputs.upload-to-github-security-tab }} 63 | uses: aquasecurity/trivy-action@master 64 | with: 65 | scan-type: convert 66 | vuln-type: '' 67 | severity: '' 68 | image-ref: trivy-report.json 69 | format: sarif 70 | output: trivy-report.sarif 71 | 72 | - name: Upload sarif report to GitHub Security tab 73 | if: ${{ inputs.upload-to-github-security-tab }} 74 | uses: github/codeql-action/upload-sarif@v3 75 | with: 76 | sarif_file: trivy-report.sarif 77 | 78 | - name: Convert report to csv 79 | if: ${{ inputs.export-csv }} 80 | uses: aquasecurity/trivy-action@master 81 | with: 82 | scan-type: convert 83 | vuln-type: '' 84 | severity: '' 85 | image-ref: trivy-report.json 86 | format: template 87 | template: "@.github/workflows/trivy-csv.tpl" 88 | output: trivy-report.csv 89 | 90 | - name: Upload CSV report as an artifact 91 | if: ${{ inputs.export-csv }} 92 | uses: actions/upload-artifact@v4 93 | with: 94 | name: trivy-report 95 | path: trivy-report.csv 96 | -------------------------------------------------------------------------------- /.github/workflows/release.yaml: -------------------------------------------------------------------------------- 1 | name: Release 2 | 3 | on: 4 | push: 5 | tags: [ 'v*' ] 6 | 7 | permissions: 8 | contents: read 9 | 10 | concurrency: 11 | group: ${{ github.workflow }}-${{ github.ref_name }} 12 | cancel-in-progress: true 13 | 14 | jobs: 15 | trivy: 16 | permissions: 17 | contents: read 18 | security-events: write 19 | uses: "./.github/workflows/common-trivy.yaml" 20 | with: 21 | export-csv: true 22 | 23 | codeql: 24 | permissions: 25 | contents: read 26 | security-events: write 27 | uses: "./.github/workflows/common-codeql.yaml" 28 | with: 29 | export-report: true 30 | -------------------------------------------------------------------------------- /.github/workflows/scan-periodic.yaml: -------------------------------------------------------------------------------- 1 | name: Scan periodic 2 | on: 3 | schedule: 4 | - cron: '15 3 * * *' 5 | 6 | permissions: 7 | contents: read 8 | 9 | jobs: 10 | trivy: 11 | permissions: 12 | contents: read 13 | security-events: write 14 | uses: "./.github/workflows/common-trivy.yaml" 15 | with: 16 | upload-to-github-security-tab: true 17 | -------------------------------------------------------------------------------- /.github/workflows/trivy-csv.tpl: -------------------------------------------------------------------------------- 1 | {{ range . }} 2 | Trivy Vulnerability Scan Results ({{- .Target -}}) 3 | VulnerabilityID,Severity,CVSS Score,Title,Library,Vulnerable Version,Fixed Version,Information URL,Triage Information 4 | {{ range .Vulnerabilities }} 5 | {{- .VulnerabilityID }}, 6 | {{- .Severity }}, 7 | {{- range $key, $value := .CVSS }} 8 | {{- if (eq $key "nvd") }} 9 | {{- .V3Score -}} 10 | {{- end }} 11 | {{- end }}, 12 | {{- quote .Title }}, 13 | {{- quote .PkgName }}, 14 | {{- quote .InstalledVersion }}, 15 | {{- quote .FixedVersion }}, 16 | {{- .PrimaryURL }} 17 | {{ else -}} 18 | No vulnerabilities found at this time. 19 | {{ end }} 20 | Trivy Dependency Scan Results ({{ .Target }}) 21 | ID,Name,Version,Notes 22 | {{ range .Packages -}} 23 | {{- quote .ID }}, 24 | {{- quote .Name }}, 25 | {{- quote .Version }} 26 | {{ else -}} 27 | No dependencies found at this time. 28 | {{ end }} 29 | {{ end }} 30 | -------------------------------------------------------------------------------- /.github/workflows/verify.yaml: -------------------------------------------------------------------------------- 1 | name: Verify 2 | on: 3 | push: 4 | pull_request: 5 | paths-ignore: 6 | - "**.md" 7 | 8 | permissions: 9 | contents: read 10 | 11 | concurrency: 12 | group: ${{ github.workflow }}-${{ github.ref }} 13 | cancel-in-progress: true 14 | 15 | jobs: 16 | test-and-lint: 17 | runs-on: ubuntu-22.04 18 | steps: 19 | - uses: actions/checkout@v4 20 | 21 | - uses: actions/setup-go@v5 22 | with: 23 | go-version-file: go.mod 24 | 25 | - name: Install golangci-lint 26 | run: | 27 | curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.54.0 28 | 29 | - name: Verify 30 | run: make verify 31 | 32 | - name: Test 33 | run: make test 34 | 35 | - name: Codecov report 36 | run: bash <(curl -s https://codecov.io/bash) 37 | 38 | trivy: 39 | permissions: 40 | contents: read 41 | security-events: write 42 | uses: "./.github/workflows/common-trivy.yaml" 43 | with: 44 | upload-to-github-security-tab: true 45 | 46 | codeql: 47 | permissions: 48 | contents: read 49 | security-events: write 50 | uses: "./.github/workflows/common-codeql.yaml" 51 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | GO_CMD := go 2 | 3 | Q := @ 4 | 5 | .PHONY: all ci-lint gofmt-verify test verify 6 | 7 | all: test 8 | 9 | verify: gofmt-verify ci-lint 10 | 11 | gofmt-verify: 12 | @out=`gofmt -w -l -d $$(find . -name '*.go')`; \ 13 | if [ -n "$$out" ]; then \ 14 | echo "$$out"; \ 15 | exit 1; \ 16 | fi 17 | 18 | ci-lint: 19 | golangci-lint run 20 | 21 | test: 22 | $(Q)$(GO_CMD) test -v -coverprofile=coverage.txt ./pkg/... 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Go Resource Control 2 | 3 | The goresctrl library provides Go interface to manage following resources. 4 | 5 | - CPU cache allocation and memory bandwidth, see the [rdt](doc/rdt.md) 6 | (Intel Resource Director Technology) package. 7 | 8 | - CPU frequency in core granularity, see the [sst](doc/sst.md) (Intel 9 | Speed Select Technology) package. 10 | 11 | - Storage I/O scheduler priority and bandwidth, see the 12 | [blockio](doc/blockio.md) package. 13 | -------------------------------------------------------------------------------- /cmd/blockio/main.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 Intel Corporation 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // This application demonstrates using the blockio API. 18 | 19 | package main 20 | 21 | import ( 22 | "encoding/json" 23 | "flag" 24 | "fmt" 25 | "os" 26 | 27 | "github.com/intel/goresctrl/pkg/blockio" 28 | goresctrlpath "github.com/intel/goresctrl/pkg/path" 29 | ) 30 | 31 | var examples string = `Examples: 32 | # Inspect OCI blockio structure 33 | $ blockio -config sample.cfg -class slowread | jq 34 | 35 | # Apply read throttling to a cgroup 36 | $ blockio -config sample.cfg -class slowread -cgroup user.slice/mygroup 37 | $ cat /sys/fs/cgroup/blkio/user.slice/mygroup/blkio.throttle.read_bps_device 38 | 39 | # Remove throttling from a cgroup 40 | $ blockio -config sample.cfg -class nolimit -cgroup user.slice/mygroup 41 | ` 42 | 43 | func usage() { 44 | flag.CommandLine.SetOutput(os.Stdout) 45 | fmt.Fprintln(flag.CommandLine.Output(), "blockio - demo application for goresctrl/pkg/blockio API") 46 | fmt.Fprintln(flag.CommandLine.Output(), "Usage: blockio -config=FILE -class=NAME [-cgroup=CGROUP]") 47 | flag.PrintDefaults() 48 | fmt.Fprint(flag.CommandLine.Output(), examples) 49 | } 50 | 51 | func errorExit(format string, args ...interface{}) { 52 | fmt.Fprintln(os.Stderr, fmt.Sprintf(format, args...)) 53 | os.Exit(1) 54 | } 55 | 56 | func main() { 57 | // Parse commandline arguments 58 | flag.Usage = usage 59 | flag.Func("prefix", "set mount prefix for system directories", func(s string) error { 60 | goresctrlpath.SetPrefix(s) 61 | return nil 62 | }) 63 | optConfig := flag.String("config", "", "load class configuration from FILE") 64 | optClass := flag.String("class", "", "use configuration of the blockio class NAME") 65 | flag.Parse() 66 | 67 | if optConfig == nil || *optConfig == "" { 68 | errorExit("missing -config=FILE") 69 | } 70 | 71 | if optClass == nil || *optClass == "" { 72 | errorExit("missing -class=NAME") 73 | } 74 | 75 | // Read blockio class configuration. 76 | if err := blockio.SetConfigFromFile(*optConfig, true); err != nil { 77 | errorExit("%v", err) 78 | } 79 | 80 | // Print OCI spec. 81 | oci, err := blockio.OciLinuxBlockIO(*optClass) 82 | if err != nil { 83 | errorExit("%v", err) 84 | } 85 | ociBytes, err := json.Marshal(oci) 86 | if err != nil { 87 | errorExit("%v", err) 88 | } 89 | fmt.Printf("%s\n", ociBytes) 90 | } 91 | -------------------------------------------------------------------------------- /cmd/blockio/sample.cfg: -------------------------------------------------------------------------------- 1 | classes: 2 | slowread: 3 | - devices: 4 | - /dev/[hsv]d[a-z] 5 | throttlereadbps: 5M 6 | highprio: 7 | - weight: 400 8 | nolimit: 9 | -------------------------------------------------------------------------------- /cmd/rdt/main.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 Intel Corporation 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // This application demonstrates using the blockio API. 18 | 19 | package main 20 | 21 | import ( 22 | "flag" 23 | "fmt" 24 | "os" 25 | "sort" 26 | "strings" 27 | 28 | "github.com/intel/goresctrl/pkg/rdt" 29 | ) 30 | 31 | var ( 32 | // Global command line flags 33 | groupPrefix string 34 | ) 35 | 36 | type subCmd func([]string) error 37 | 38 | var subCmds = map[string]subCmd{ 39 | "info": subCmdInfo, 40 | "configure": subCmdConfigure, 41 | } 42 | 43 | func main() { 44 | cmds := make([]string, 0, len(subCmds)) 45 | for c := range subCmds { 46 | cmds = append(cmds, c) 47 | } 48 | sort.Strings(cmds) 49 | allCmds := strings.Join(cmds, ", ") 50 | 51 | if len(os.Args) < 2 { 52 | exitError("missing sub-command, must be one of: %s\n", allCmds) 53 | } 54 | 55 | // Run sub-command 56 | cmd, ok := subCmds[os.Args[1]] 57 | if !ok { 58 | exitError("unknown sub-command %q, must be of: %s\n", os.Args[1], allCmds) 59 | } 60 | 61 | if err := cmd(os.Args[2:]); err != nil { 62 | exitError("sub-command %q failed: %v\n", os.Args[1], err) 63 | } 64 | } 65 | 66 | func addGlobalFlags(flagset *flag.FlagSet) { 67 | flagset.StringVar(&groupPrefix, "group-prefix", "", "prefix to use for resctrl groups") 68 | } 69 | 70 | func subCmdInfo(args []string) error { 71 | // Parse command line args 72 | flags := flag.NewFlagSet("info", flag.ExitOnError) 73 | addGlobalFlags(flags) 74 | if err := flags.Parse(args); err != nil { 75 | return err 76 | } 77 | 78 | // Run sub-command 79 | if err := rdt.Initialize(groupPrefix); err != nil { 80 | fmt.Printf("RDT is not enabled: %v\n", err) 81 | return nil 82 | } 83 | 84 | fmt.Printf("Monitoring supported: %v\n", rdt.MonSupported()) 85 | if rdt.MonSupported() { 86 | mon := rdt.GetMonFeatures() 87 | 88 | fmt.Println("Monitoring features:") 89 | for r, f := range mon { 90 | fmt.Printf(" - %s: %v\n", r, strings.Join(f, ", ")) 91 | } 92 | } 93 | fmt.Println("Classes:") 94 | for _, cls := range rdt.GetClasses() { 95 | fmt.Printf(" - %s\n", cls.Name()) 96 | 97 | mon := cls.GetMonGroups() 98 | if len(mon) > 0 { 99 | fmt.Println(" Monitoring groups:") 100 | for _, grp := range mon { 101 | fmt.Printf(" - %s\n", grp.Name()) 102 | } 103 | } 104 | } 105 | 106 | return nil 107 | } 108 | 109 | func subCmdConfigure(args []string) error { 110 | // Parse command line args 111 | flags := flag.NewFlagSet("configure", flag.ExitOnError) 112 | addGlobalFlags(flags) 113 | 114 | configFile := flags.String("config-file", "", "path to rdt configuration file") 115 | force := flags.Bool("force", false, "force configuration, delete non-empty resctrl groups") 116 | 117 | if err := flags.Parse(args); err != nil { 118 | return err 119 | } 120 | 121 | if *configFile == "" { 122 | return fmt.Errorf("-config-file must be specified") 123 | } 124 | 125 | // Run sub-command 126 | if err := rdt.Initialize(groupPrefix); err != nil { 127 | return fmt.Errorf("RDT is not enabled: %v", err) 128 | } 129 | 130 | fmt.Println("Configuring resctrl filesystem...") 131 | if err := rdt.SetConfigFromFile(*configFile, *force); err != nil { 132 | return err 133 | } 134 | 135 | fmt.Println("Done!") 136 | 137 | return nil 138 | } 139 | 140 | func exitError(format string, args ...interface{}) { 141 | fmt.Printf("ERROR: "+format+"\n", args...) 142 | os.Exit(1) 143 | } 144 | -------------------------------------------------------------------------------- /cmd/rdt/sample-conf.yaml: -------------------------------------------------------------------------------- 1 | options: 2 | l2: 3 | optional: true 4 | l3: 5 | optional: true 6 | mb: 7 | optional: true 8 | partitions: 9 | default: 10 | l2Allocation: "100%" 11 | l3Allocation: "100%" 12 | mbAllocation: ["100%", "4000000000MBps"] 13 | classes: 14 | Guaranteed: 15 | l3Allocation: "100%" 16 | l2Allocation: "100%" 17 | mbAllocation: ["100%", "4000000000MBps"] 18 | Burstable: 19 | l3Allocation: "60%" 20 | l2Allocation: "60%" 21 | mbAllocation: ["60%", "10000MBps"] 22 | Besteffort: 23 | l3Allocation: "30%" 24 | l2Allocation: "30%" 25 | mbAllocation: ["30%", "4000MBps"] 26 | -------------------------------------------------------------------------------- /cmd/sst-ctl/main.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 Intel Corporation 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package main 18 | 19 | import ( 20 | "flag" 21 | "fmt" 22 | "os" 23 | "sort" 24 | "strconv" 25 | "strings" 26 | 27 | goresctrlpath "github.com/intel/goresctrl/pkg/path" 28 | "github.com/intel/goresctrl/pkg/sst" 29 | "github.com/intel/goresctrl/pkg/utils" 30 | ) 31 | 32 | var ( 33 | // Global command line flags 34 | packageIds string 35 | ) 36 | 37 | type subCmd func([]string) error 38 | 39 | var subCmds = map[string]subCmd{ 40 | "info": subCmdInfo, 41 | "bf": subCmdBF, 42 | "cp": subCmdCP, 43 | } 44 | 45 | func main() { 46 | cmds := make([]string, 0, len(subCmds)) 47 | for c := range subCmds { 48 | cmds = append(cmds, c) 49 | } 50 | sort.Strings(cmds) 51 | allCmds := strings.Join(cmds, ", ") 52 | 53 | if len(os.Args) < 2 { 54 | fmt.Printf("missing sub-command, must be one of: %s\n", allCmds) 55 | os.Exit(1) 56 | } 57 | 58 | // Run sub-command 59 | cmd, ok := subCmds[os.Args[1]] 60 | if !ok { 61 | fmt.Printf("unknown sub-command %q, must be of: %s\n", os.Args[1], allCmds) 62 | os.Exit(1) 63 | } 64 | 65 | if err := cmd(os.Args[2:]); err != nil { 66 | fmt.Printf("ERROR: sub-command %q failed: %v\n", os.Args[1], err) 67 | os.Exit(1) 68 | } 69 | } 70 | 71 | func addGlobalFlags(flagset *flag.FlagSet) { 72 | flagset.StringVar(&packageIds, "package", "", "One or more physical package id") 73 | flagset.Func("prefix", "set mount prefix for system directories", func(s string) error { 74 | goresctrlpath.SetPrefix(s) 75 | return nil 76 | }) 77 | } 78 | 79 | func printPackageInfo(pkgId ...int) error { 80 | info, err := sst.GetPackageInfo(pkgId...) 81 | if err != nil { 82 | return err 83 | } 84 | 85 | fmt.Println(utils.DumpJSON(info)) 86 | 87 | return nil 88 | } 89 | 90 | // TODO: Move this functionality into utils.NewIdSetFromString() 91 | func str2slice(str string) []int { 92 | var s []int 93 | 94 | for _, str := range strings.Split(str, ",") { 95 | if str == "" { 96 | continue 97 | } 98 | 99 | id, err := strconv.ParseInt(str, 10, 0) 100 | if err != nil { 101 | fmt.Printf("invalid value '%s': %v", str, err) 102 | continue 103 | } 104 | 105 | s = append(s, int(id)) 106 | } 107 | 108 | return s 109 | } 110 | 111 | func subCmdInfo(args []string) error { 112 | // Parse command line args 113 | flags := flag.NewFlagSet("info", flag.ExitOnError) 114 | addGlobalFlags(flags) 115 | if err := flags.Parse(args); err != nil { 116 | return err 117 | } 118 | 119 | return printPackageInfo(str2slice(packageIds)...) 120 | } 121 | 122 | func enableBF(pkgId ...int) error { 123 | if len(pkgId) == 0 { 124 | fmt.Printf("Enabling BF for all packages\n") 125 | } else { 126 | fmt.Printf("Enabling BF for package(s) %v\n", pkgId) 127 | } 128 | 129 | err := sst.EnableBF(pkgId...) 130 | if err != nil { 131 | return err 132 | } 133 | 134 | return printPackageInfo(pkgId...) 135 | } 136 | 137 | func disableBF(pkgId ...int) error { 138 | if len(pkgId) == 0 { 139 | fmt.Printf("Disabling BF for all packages\n") 140 | } else { 141 | fmt.Printf("Disabling BF for package(s) %v\n", pkgId) 142 | } 143 | 144 | err := sst.DisableBF(pkgId...) 145 | if err != nil { 146 | return err 147 | } 148 | 149 | return printPackageInfo(pkgId...) 150 | } 151 | 152 | func subCmdBF(args []string) error { 153 | var enable, disable bool 154 | 155 | flags := flag.NewFlagSet("bf", flag.ExitOnError) 156 | flags.BoolVar(&enable, "enable", false, "enable feature") 157 | flags.BoolVar(&disable, "disable", false, "disable feature") 158 | addGlobalFlags(flags) 159 | 160 | if err := flags.Parse(args); err != nil { 161 | return err 162 | } 163 | 164 | if (!enable && !disable) || (enable && disable) { 165 | fmt.Printf("Please provide either -enable or -disable flag\n") 166 | return nil 167 | } 168 | 169 | var err error 170 | 171 | pkgs := str2slice(packageIds) 172 | 173 | if enable { 174 | err = enableBF(pkgs...) 175 | } else { 176 | err = disableBF(pkgs...) 177 | } 178 | 179 | return err 180 | } 181 | 182 | func getPackage(packageStr string, cpus utils.IDSet) (map[int]*sst.SstPackageInfo, *sst.SstPackageInfo, []int, error) { 183 | var infomap map[int]*sst.SstPackageInfo 184 | var info *sst.SstPackageInfo 185 | var packageId int 186 | var err error 187 | 188 | // If user has specified a package, then all the CPUs must belong to it. 189 | pkgs := str2slice(packageStr) 190 | if len(pkgs) > 1 { 191 | fmt.Printf("Only one package can be configured at a time (you have %d)\n", len(pkgs)) 192 | return nil, nil, nil, fmt.Errorf("Provide one package value only") 193 | } 194 | 195 | if len(pkgs) == 0 { 196 | // User has not specified a package, figure it out from the 197 | // first CPU in the list. 198 | infomap, err = sst.GetPackageInfo() 199 | if err != nil { 200 | return nil, nil, nil, err 201 | } 202 | 203 | for packageId, info = range infomap { 204 | if sst.CheckPackageCpus(info, cpus) { 205 | pkgs = append(pkgs, packageId) 206 | break 207 | } 208 | } 209 | } else { 210 | // User has specified one package, make sure all the CPUs belong to it. 211 | infomap, err = sst.GetPackageInfo(pkgs...) 212 | if err != nil { 213 | return nil, nil, nil, err 214 | } 215 | 216 | for packageId, info = range infomap { 217 | if !sst.CheckPackageCpus(info, cpus) { 218 | fmt.Printf("All the CPUs %v must belong to one specific package\n", cpus) 219 | return nil, nil, nil, fmt.Errorf("Not all CPUs belong to package %d", packageId) 220 | } 221 | 222 | pkgs = append(pkgs, packageId) 223 | break 224 | } 225 | } 226 | 227 | return infomap, info, pkgs, nil 228 | } 229 | 230 | // TODO: Instead of all CP parameters groupped together, separate them like this. 231 | // sst-ctl cp enable 232 | // sst-ctl cp disable 233 | // sst-ctl cp configure -clos=CLOS... 234 | // sst-ctl cp assign... 235 | 236 | func subCmdCP(args []string) error { 237 | var enable, disable, reset bool 238 | 239 | // Clos setup variables 240 | var epp, minFreq, maxFreq, desiredFreq, proportionalPriority, clos int 241 | 242 | // CPU to Clos mapping variables 243 | var cpuStr string 244 | var cpus utils.IDSet 245 | 246 | var packageId int 247 | var pkgs []int 248 | var info *sst.SstPackageInfo 249 | var infomap map[int]*sst.SstPackageInfo 250 | var err error 251 | var priority int 252 | 253 | defaultMaxFreq := 0xff 254 | 255 | flags := flag.NewFlagSet("cp", flag.ExitOnError) 256 | flags.BoolVar(&enable, "enable", false, "Enable feature") 257 | flags.BoolVar(&disable, "disable", false, "Disable feature") 258 | flags.BoolVar(&reset, "reset", false, "Reset CP to a known state") 259 | flags.IntVar(&clos, "clos", -1, "Class of service (0 - 3)") 260 | flags.IntVar(&epp, "epp", 0, "Energy Performance Preference value, Lower value favors performance, and higher value favors power. The value can be between 0 and 15. The default value is 0.") 261 | flags.IntVar(&minFreq, "min", 0, "Clos minimum frequency MHz") 262 | flags.IntVar(&maxFreq, "max", defaultMaxFreq, "Clos maximum frequency MHz") 263 | flags.IntVar(&desiredFreq, "desired", 0, "Clos desired frequency MHz") 264 | flags.IntVar(&proportionalPriority, "proportional", 0, "Clos proportional priority weight. Used if CP priority mode is 0 (Proportional)") 265 | flags.IntVar(&priority, "priority", 1, "CP priority mode. 0 is Proportional, 1 is Ordered.") 266 | flags.StringVar(&cpuStr, "cpus", "", "List of CPUs assigned to the Clos.") 267 | 268 | addGlobalFlags(flags) 269 | 270 | flags.Usage = func() { 271 | flags.PrintDefaults() 272 | 273 | fmt.Fprintf(os.Stderr, "\nExample usage:\n\n") 274 | fmt.Fprintf(os.Stderr, "First reset CP to default:\n\t%s cp -reset\n\n", os.Args[0]) 275 | fmt.Fprintf(os.Stderr, "Then set the CLOS values:\n\t%s cp -clos 1 -desired 280 -epp 1 -max 30 -min 21 -priority 1 -package 0\n\n", os.Args[0]) 276 | fmt.Fprintf(os.Stderr, "Then bind CPUs to a CLOS:\n\t%s cp -clos 1 -cpus 1,3,5,6\n\n", os.Args[0]) 277 | fmt.Fprintf(os.Stderr, "Finally enable CP:\n\t%s cp -enable -package 0\n\n", os.Args[0]) 278 | } 279 | 280 | if err := flags.Parse(args); err != nil { 281 | return err 282 | } 283 | 284 | if reset { 285 | err := sst.ResetCPConfig() 286 | _ = printPackageInfo() 287 | return err 288 | } 289 | 290 | if enable && disable { 291 | return fmt.Errorf("Please provide either -enable or -disable flag") 292 | } 293 | 294 | // If user specifies a list of CPUs, then he/she wants to assign those 295 | // CPUs to a specific CLOS. If the -cpus option is not set, then user 296 | // wants to configure the actual CLOS values. Both operations cannot be 297 | // done at the same time. 298 | 299 | // If user specifies a list of CPUs, then the package option is ignored. 300 | // Verify that all the CPUs belong to one specific package. 301 | if cpuStr != "" { 302 | cpus = utils.NewIDSet(str2slice(cpuStr)...) 303 | 304 | infomap, info, pkgs, err = getPackage(packageIds, cpus) 305 | if err != nil { 306 | return fmt.Errorf("Cannot get CPUs %v package: %w", cpus, err) 307 | } 308 | 309 | if len(pkgs) == 0 { 310 | return fmt.Errorf("All the CPUs %v must belong to one specific package", cpus) 311 | } 312 | 313 | if clos < 0 { 314 | return fmt.Errorf("Clos not set, use -clos option") 315 | } 316 | 317 | cpu2Clos := make(sst.ClosCPUSet, 1) 318 | cpu2Clos[clos] = cpus 319 | 320 | if err := sst.ConfigureCP(info, priority, &cpu2Clos); err != nil { 321 | return err 322 | } 323 | 324 | } else if clos >= 0 { 325 | pkgs = str2slice(packageIds) 326 | if len(pkgs) == 0 { 327 | return fmt.Errorf("No packages set, invalid value %q", packageIds) 328 | } 329 | 330 | closinfo := sst.SstClosInfo{ 331 | EPP: epp, 332 | ProportionalPriority: proportionalPriority, 333 | MinFreq: minFreq, 334 | MaxFreq: maxFreq, 335 | DesiredFreq: desiredFreq, 336 | } 337 | 338 | infomap, err = sst.GetPackageInfo(pkgs...) 339 | if err != nil { 340 | return fmt.Errorf("Cannot get package info: %w", err) 341 | } 342 | 343 | for _, info = range infomap { 344 | if err := sst.ClosSetup(info, clos, &closinfo); err != nil { 345 | return fmt.Errorf("Cannot set Clos: %w", err) 346 | } 347 | } 348 | } else { 349 | if (!enable && !disable) && clos < 0 { 350 | return fmt.Errorf("Clos not set, use -clos option") 351 | } 352 | 353 | // Print information if user just wants to enable / disable CP 354 | infomap, _ = sst.GetPackageInfo(pkgs...) 355 | } 356 | 357 | if enable || disable { 358 | for packageId, info = range infomap { 359 | if enable { 360 | fmt.Printf("Enabling CP for package %d\n", packageId) 361 | 362 | err = sst.EnableCP(info) 363 | if err != nil { 364 | return err 365 | } 366 | } else if disable { 367 | fmt.Printf("Disabling CP for package %d\n", packageId) 368 | 369 | err = sst.DisableCP(info) 370 | if err != nil { 371 | return err 372 | } 373 | } 374 | } 375 | } 376 | 377 | for packageId = range infomap { 378 | // If we add a CPU to Clos, punit might add another CPU to same Clos. 379 | // Make sure we have re-read the package info before printing it 380 | _ = printPackageInfo(packageId) 381 | } 382 | 383 | return nil 384 | } 385 | -------------------------------------------------------------------------------- /doc/blockio.md: -------------------------------------------------------------------------------- 1 | # Block I/O 2 | 3 | ## Background 4 | 5 | The cgroup block I/O controller, 6 | [blkio](https://www.kernel.org/doc/html/latest/admin-guide/cgroup-v1/blkio-controller.html) 7 | in cgroup v1, 8 | [io](https://www.kernel.org/doc/html/latest/admin-guide/cgroup-v2.html#io) 9 | in cgroup v2, in Linux kernel controls I/O scheduler weights and I/O 10 | bandwidth per block device. 11 | 12 | The blockio package in goresctrl is configured with class-based block 13 | I/O controller parameters, where different parameters can be 14 | configured for each class. The package provides two separate output 15 | options: parameters of a class can be applied directly to cgroup v1 16 | directory structure, or they can be exported as 17 | [Linux BlockIO OCI spec](https://github.com/opencontainers/runtime-spec/blob/master/config-linux.md#block-io). 18 | 19 | ## API 20 | 21 | The API is described in 22 | [pkg.go.dev](https://pkg.go.dev/github.com/intel/goresctrl/pkg/blockio). 23 | 24 | ## Configuration 25 | 26 | Block I/O classes can be configured with a yaml file. Example: 27 | 28 | ``` 29 | Classes: 30 | 31 | # Define a blockio class "LowPrioThrottled". 32 | # Containers in this class will be throttled and handled as 33 | # low priority in the I/O scheduler. 34 | 35 | LowPrioThrottled: 36 | 37 | # Weight without a Devices list specifies the default 38 | # I/O scheduler weight for all devices 39 | # that are not explicitly mentioned in following items. 40 | # This will be written to cgroups(.bfq).weight. 41 | # Weights range from 10 to 1000, the default is 100. 42 | 43 | - Weight: 80 44 | 45 | # Set all parameters for all /dev/sd* and /dev/vd* block 46 | # devices. 47 | 48 | - Devices: 49 | - /dev/sd[a-z] 50 | - /dev/vd[a-z] 51 | ThrottleReadBps: 50M # max read bytes per second 52 | ThrottleWriteBps: 10M # max write bytes per second 53 | ThrottleReadIOPS: 10k # max read io operations per second 54 | ThrottleWriteIOPS: 5k # max write io operations per second 55 | Weight: 50 # I/O scheduler (cfq/bfq) weight for 56 | # these devices will be written to 57 | # cgroups(.bfq).weight_device 58 | 59 | # Set parameters particularly for SSD devices. 60 | # This configuration overrides above configurations for those 61 | # /dev/sd* and /dev/vd* devices whose disk id contains "SSD". 62 | 63 | - Devices: 64 | - /dev/disk/by-id/*SSD* 65 | ThrottleReadBps: 100M 66 | ThrottleWriteBps: 40M 67 | # Not mentioning Throttle*IOPS means no I/O operations 68 | # throttling on matching devices. 69 | Weight: 50 70 | 71 | # Define a blockio class "HighPrioFullSpeed". 72 | # There is no throttling on these containers, and 73 | # they will be prioritized by the I/O scheduler. 74 | 75 | HighPrioFullSpeed: 76 | - Weight: 400 77 | ``` 78 | -------------------------------------------------------------------------------- /doc/sst.md: -------------------------------------------------------------------------------- 1 | # Intel SST (Speed Select Technology) 2 | 3 | ## Background 4 | 5 | Intel® SST provides capabilities for managing CPU core frequency. 6 | 7 | ## API 8 | 9 | The API is described in 10 | [pkg.go.dev](https://pkg.go.dev/github.com/intel/goresctrl/pkg/sst). 11 | -------------------------------------------------------------------------------- /go.mod: -------------------------------------------------------------------------------- 1 | module github.com/intel/goresctrl 2 | 3 | go 1.20 4 | 5 | require ( 6 | github.com/google/go-cmp v0.5.9 7 | github.com/opencontainers/runtime-spec v1.0.2 8 | github.com/prometheus/client_golang v1.16.0 9 | golang.org/x/exp v0.0.0-20231214170342-aacd6d4b4611 10 | golang.org/x/sys v0.11.0 11 | k8s.io/apimachinery v0.27.4 12 | sigs.k8s.io/yaml v1.3.0 13 | ) 14 | 15 | require ( 16 | github.com/beorn7/perks v1.0.1 // indirect 17 | github.com/cespare/xxhash/v2 v2.2.0 // indirect 18 | github.com/gogo/protobuf v1.3.2 // indirect 19 | github.com/golang/protobuf v1.5.3 // indirect 20 | github.com/google/gofuzz v1.2.0 // indirect 21 | github.com/kr/text v0.2.0 // indirect 22 | github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect 23 | github.com/prometheus/client_model v0.3.0 // indirect 24 | github.com/prometheus/common v0.42.0 // indirect 25 | github.com/prometheus/procfs v0.10.1 // indirect 26 | github.com/rogpeppe/go-internal v1.9.0 // indirect 27 | google.golang.org/protobuf v1.33.0 // indirect 28 | gopkg.in/inf.v0 v0.9.1 // indirect 29 | gopkg.in/yaml.v2 v2.4.0 // indirect 30 | ) 31 | -------------------------------------------------------------------------------- /go.sum: -------------------------------------------------------------------------------- 1 | github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= 2 | github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= 3 | github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44= 4 | github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= 5 | github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= 6 | github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= 7 | github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= 8 | github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= 9 | github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= 10 | github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= 11 | github.com/golang/protobuf v1.3.5/go.mod h1:6O5/vntMXwX2lRkT1hjjk0nAC1IDOTvTlVgjlRvqsdk= 12 | github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= 13 | github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= 14 | github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= 15 | github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= 16 | github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= 17 | github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= 18 | github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0= 19 | github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= 20 | github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= 21 | github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= 22 | github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= 23 | github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= 24 | github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= 25 | github.com/matttproud/golang_protobuf_extensions v1.0.4 h1:mmDVorXM7PCGKw94cs5zkfA9PSy5pEvNWRP0ET0TIVo= 26 | github.com/matttproud/golang_protobuf_extensions v1.0.4/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4= 27 | github.com/opencontainers/runtime-spec v1.0.2 h1:UfAcuLBJB9Coz72x1hgl8O5RVzTdNiaglX6v2DM6FI0= 28 | github.com/opencontainers/runtime-spec v1.0.2/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0= 29 | github.com/prometheus/client_golang v1.16.0 h1:yk/hx9hDbrGHovbci4BY+pRMfSuuat626eFsHb7tmT8= 30 | github.com/prometheus/client_golang v1.16.0/go.mod h1:Zsulrv/L9oM40tJ7T815tM89lFEugiJ9HzIqaAx4LKc= 31 | github.com/prometheus/client_model v0.3.0 h1:UBgGFHqYdG/TPFD1B1ogZywDqEkwp3fBMvqdiQ7Xew4= 32 | github.com/prometheus/client_model v0.3.0/go.mod h1:LDGWKZIo7rky3hgvBe+caln+Dr3dPggB5dvjtD7w9+w= 33 | github.com/prometheus/common v0.42.0 h1:EKsfXEYo4JpWMHH5cg+KOUWeuJSov1Id8zGR8eeI1YM= 34 | github.com/prometheus/common v0.42.0/go.mod h1:xBwqVerjNdUDjgODMpudtOMwlOwf2SaTr1yjz4b7Zbc= 35 | github.com/prometheus/procfs v0.10.1 h1:kYK1Va/YMlutzCGazswoHKo//tZVlFpKYh+PymziUAg= 36 | github.com/prometheus/procfs v0.10.1/go.mod h1:nwNm2aOCAYw8uTR/9bWRREkZFxAUcWzPHWJq+XBB/FM= 37 | github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8= 38 | github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= 39 | github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= 40 | github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= 41 | github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= 42 | golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= 43 | golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= 44 | golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= 45 | golang.org/x/exp v0.0.0-20231214170342-aacd6d4b4611 h1:qCEDpW1G+vcj3Y7Fy52pEM1AWm3abj8WimGYejI3SC4= 46 | golang.org/x/exp v0.0.0-20231214170342-aacd6d4b4611/go.mod h1:iRJReGqOEeBhDZGkGbynYwcHlctCvnjTYIamk7uXpHI= 47 | golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= 48 | golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= 49 | golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= 50 | golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= 51 | golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= 52 | golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= 53 | golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 54 | golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 55 | golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 56 | golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 57 | golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 58 | golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 59 | golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 60 | golang.org/x/sys v0.11.0 h1:eG7RXZHdqOJ1i+0lgLgCpSXAp6M3LYlAo6osgSi0xOM= 61 | golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 62 | golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= 63 | golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= 64 | golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= 65 | golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= 66 | golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= 67 | golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= 68 | golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= 69 | golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= 70 | golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= 71 | golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= 72 | google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= 73 | google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= 74 | google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI= 75 | google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= 76 | gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= 77 | gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= 78 | gopkg.in/inf.v0 v0.9.1 h1:73M5CoZyi3ZLMOyDlQh031Cx6N9NDJ2Vvfl76EDAgDc= 79 | gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw= 80 | gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= 81 | gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= 82 | k8s.io/apimachinery v0.27.4 h1:CdxflD4AF61yewuid0fLl6bM4a3q04jWel0IlP+aYjs= 83 | k8s.io/apimachinery v0.27.4/go.mod h1:XNfZ6xklnMCOGGFNqXG7bUrQCoR04dh/E7FprV6pb+E= 84 | sigs.k8s.io/yaml v1.3.0 h1:a2VclLzOGrwOHDiV8EfBGhvjHvP46CtW5j6POvhYGGo= 85 | sigs.k8s.io/yaml v1.3.0/go.mod h1:GeOyir5tyXNByN85N/dRIT9es5UQNerPYEKK56eTBm8= 86 | -------------------------------------------------------------------------------- /pkg/blockio/cgroups.go: -------------------------------------------------------------------------------- 1 | // Copyright 2020-2021 Intel Corporation. All Rights Reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package blockio 16 | 17 | // BlockIOParameters contains cgroups blockio controller parameters. 18 | // 19 | // Effects of Weight and Rate values in SetBlkioParameters(): 20 | // Value | Effect 21 | // -------+------------------------------------------------------------------- 22 | // 23 | // -1 | Do not write to cgroups, value is missing. 24 | // 0 | Write to cgroups, will clear the setting as specified in cgroups blkio interface. 25 | // other | Write to cgroups, sets the value. 26 | type BlockIOParameters struct { 27 | Weight int64 28 | WeightDevice DeviceWeights 29 | ThrottleReadBpsDevice DeviceRates 30 | ThrottleWriteBpsDevice DeviceRates 31 | ThrottleReadIOPSDevice DeviceRates 32 | ThrottleWriteIOPSDevice DeviceRates 33 | } 34 | 35 | // DeviceWeight contains values for 36 | // - blkio.[io-scheduler].weight 37 | type DeviceWeight struct { 38 | Major int64 39 | Minor int64 40 | Weight int64 41 | } 42 | 43 | // DeviceRate contains values for 44 | // - blkio.throttle.read_bps_device 45 | // - blkio.throttle.write_bps_device 46 | // - blkio.throttle.read_iops_device 47 | // - blkio.throttle.write_iops_device 48 | type DeviceRate struct { 49 | Major int64 50 | Minor int64 51 | Rate int64 52 | } 53 | 54 | // DeviceWeights contains weights for devices. 55 | type DeviceWeights []DeviceWeight 56 | 57 | // DeviceRates contains throttling rates for devices. 58 | type DeviceRates []DeviceRate 59 | 60 | // NewBlockIOParameters creates new BlockIOParameters instance. 61 | func NewBlockIOParameters() BlockIOParameters { 62 | return BlockIOParameters{ 63 | Weight: -1, 64 | } 65 | } 66 | 67 | // DeviceParameters interface provides functions common to DeviceWeights and DeviceRates. 68 | type DeviceParameters interface { 69 | Append(maj, min, val int64) 70 | Update(maj, min, val int64) 71 | } 72 | 73 | // Append appends (major, minor, value) to DeviceWeights slice. 74 | func (w *DeviceWeights) Append(maj, min, val int64) { 75 | *w = append(*w, DeviceWeight{Major: maj, Minor: min, Weight: val}) 76 | } 77 | 78 | // Append appends (major, minor, value) to DeviceRates slice. 79 | func (r *DeviceRates) Append(maj, min, val int64) { 80 | *r = append(*r, DeviceRate{Major: maj, Minor: min, Rate: val}) 81 | } 82 | 83 | // Update updates device weight in DeviceWeights slice, or appends it if not found. 84 | func (w *DeviceWeights) Update(maj, min, val int64) { 85 | for index, devWeight := range *w { 86 | if devWeight.Major == maj && devWeight.Minor == min { 87 | (*w)[index].Weight = val 88 | return 89 | } 90 | } 91 | w.Append(maj, min, val) 92 | } 93 | 94 | // Update updates device rate in DeviceRates slice, or appends it if not found. 95 | func (r *DeviceRates) Update(maj, min, val int64) { 96 | for index, devRate := range *r { 97 | if devRate.Major == maj && devRate.Minor == min { 98 | (*r)[index].Rate = val 99 | return 100 | } 101 | } 102 | r.Append(maj, min, val) 103 | } 104 | -------------------------------------------------------------------------------- /pkg/blockio/config.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019-2021 Intel Corporation 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package blockio 18 | 19 | // Config contains a blockio configuration. 20 | type Config struct { 21 | // Classes define weights and throttling parameters for sets of devices. 22 | Classes map[string][]DevicesParameters `json:",omitempty"` 23 | } 24 | 25 | // DevicesParameters defines Block IO parameters for a set of devices. 26 | type DevicesParameters struct { 27 | Devices []string `json:",omitempty"` 28 | ThrottleReadBps string `json:",omitempty"` 29 | ThrottleWriteBps string `json:",omitempty"` 30 | ThrottleReadIOPS string `json:",omitempty"` 31 | ThrottleWriteIOPS string `json:",omitempty"` 32 | Weight string `json:",omitempty"` 33 | } 34 | -------------------------------------------------------------------------------- /pkg/blockio/kubernetes.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 Intel Corporation 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package blockio 18 | 19 | import ( 20 | "github.com/intel/goresctrl/pkg/kubernetes" 21 | ) 22 | 23 | const ( 24 | // BlockioContainerAnnotation is the CRI level container annotation for setting 25 | // the blockio class of a container 26 | BlockioContainerAnnotation = "io.kubernetes.cri.blockio-class" 27 | 28 | // BlockioPodAnnotation is a Pod annotation for setting the blockio class of 29 | // all containers of the pod 30 | BlockioPodAnnotation = "blockio.resources.beta.kubernetes.io/pod" 31 | 32 | // BlockioPodAnnotationContainerPrefix is prefix for per-container Pod annotation 33 | // for setting the blockio class of one container of the pod 34 | BlockioPodAnnotationContainerPrefix = "blockio.resources.beta.kubernetes.io/container." 35 | ) 36 | 37 | // ContainerClassFromAnnotations determines the effective blockio 38 | // class of a container from the Pod annotations and CRI level 39 | // container annotations of a container. If the class is not specified 40 | // by any annotation, returns empty class name. Returned error is 41 | // reserved (nil). 42 | func ContainerClassFromAnnotations(containerName string, containerAnnotations, podAnnotations map[string]string) (string, error) { 43 | clsName, _ := kubernetes.ContainerClassFromAnnotations( 44 | BlockioContainerAnnotation, BlockioPodAnnotation, BlockioPodAnnotationContainerPrefix, 45 | containerName, containerAnnotations, podAnnotations) 46 | return clsName, nil 47 | } 48 | -------------------------------------------------------------------------------- /pkg/blockio/oci.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019-2021 Intel Corporation 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package blockio 18 | 19 | import ( 20 | "fmt" 21 | 22 | oci "github.com/opencontainers/runtime-spec/specs-go" 23 | ) 24 | 25 | // OciLinuxBlockIO returns OCI LinuxBlockIO structure corresponding to the class. 26 | func OciLinuxBlockIO(class string) (*oci.LinuxBlockIO, error) { 27 | blockio, ok := classBlockIO[class] 28 | if !ok { 29 | return nil, fmt.Errorf("no OCI BlockIO parameters for class %#v", class) 30 | } 31 | ociBlockio := oci.LinuxBlockIO{} 32 | if blockio.Weight != -1 { 33 | w := uint16(blockio.Weight) 34 | ociBlockio.Weight = &w 35 | } 36 | ociBlockio.WeightDevice = ociLinuxWeightDevices(blockio.WeightDevice) 37 | ociBlockio.ThrottleReadBpsDevice = ociLinuxThrottleDevices(blockio.ThrottleReadBpsDevice) 38 | ociBlockio.ThrottleWriteBpsDevice = ociLinuxThrottleDevices(blockio.ThrottleWriteBpsDevice) 39 | ociBlockio.ThrottleReadIOPSDevice = ociLinuxThrottleDevices(blockio.ThrottleReadIOPSDevice) 40 | ociBlockio.ThrottleWriteIOPSDevice = ociLinuxThrottleDevices(blockio.ThrottleWriteIOPSDevice) 41 | return &ociBlockio, nil 42 | } 43 | 44 | func ociLinuxWeightDevices(dws DeviceWeights) []oci.LinuxWeightDevice { 45 | if len(dws) == 0 { 46 | return nil 47 | } 48 | olwds := make([]oci.LinuxWeightDevice, len(dws)) 49 | for i, wd := range dws { 50 | w := uint16(wd.Weight) 51 | olwds[i].Major = wd.Major 52 | olwds[i].Minor = wd.Minor 53 | olwds[i].Weight = &w 54 | } 55 | return olwds 56 | } 57 | 58 | func ociLinuxThrottleDevices(drs DeviceRates) []oci.LinuxThrottleDevice { 59 | if len(drs) == 0 { 60 | return nil 61 | } 62 | oltds := make([]oci.LinuxThrottleDevice, len(drs)) 63 | for i, dr := range drs { 64 | oltds[i].Major = dr.Major 65 | oltds[i].Minor = dr.Minor 66 | oltds[i].Rate = uint64(dr.Rate) 67 | } 68 | return oltds 69 | } 70 | -------------------------------------------------------------------------------- /pkg/blockio/oci_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019-2021 Intel Corporation. All Rights Reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package blockio 16 | 17 | import ( 18 | "testing" 19 | 20 | oci "github.com/opencontainers/runtime-spec/specs-go" 21 | 22 | "github.com/intel/goresctrl/pkg/testutils" 23 | ) 24 | 25 | // TestOciLinuxBlockIO: unit tests for OciLinuxBlockIO(). 26 | func TestOciLinuxBlockIO(t *testing.T) { 27 | tcases := []struct { 28 | name string 29 | class string 30 | blockIOClasses map[string]BlockIOParameters 31 | expectedBlockIO *oci.LinuxBlockIO 32 | // It would be great to define expected 33 | // oci.LinuxBlockIO with a single literal. But that 34 | // is impossible because Major and Minor fields are 35 | // inside non-exported oci.linuxBlockIODevice 36 | // struct. Therefore here are expected triplets of 37 | // major/minor/(weight|rate). 38 | expectedWeight uint16 39 | expectedWeightDevices [][3]uint16 40 | expectedThrottleReadBpsDevices [][3]uint64 41 | expectedThrottleWriteBpsDevices [][3]uint64 42 | expectedThrottleReadIOPSDevices [][3]uint64 43 | expectedThrottleWriteIOPSDevices [][3]uint64 44 | expectedErrorSubstrings []string 45 | }{ 46 | { 47 | name: "unknown class", 48 | class: "foobar", 49 | blockIOClasses: nil, 50 | expectedErrorSubstrings: []string{"foobar"}, 51 | }, 52 | { 53 | name: "all fields", 54 | class: "allfields", 55 | blockIOClasses: map[string]BlockIOParameters{ 56 | "allfields": BlockIOParameters{ 57 | Weight: 10, 58 | WeightDevice: DeviceWeights{ 59 | {Major: 20, Minor: 21, Weight: 22}, 60 | {Major: 23, Minor: 24, Weight: 25}, 61 | }, 62 | ThrottleReadBpsDevice: DeviceRates{ 63 | {Major: 30, Minor: 31, Rate: 32}, 64 | {Major: 33, Minor: 34, Rate: 35}, 65 | }, 66 | ThrottleWriteBpsDevice: DeviceRates{ 67 | {Major: 40, Minor: 41, Rate: 42}, 68 | {Major: 43, Minor: 44, Rate: 45}, 69 | }, 70 | ThrottleReadIOPSDevice: DeviceRates{ 71 | {Major: 50, Minor: 51, Rate: 52}, 72 | {Major: 53, Minor: 54, Rate: 55}, 73 | }, 74 | ThrottleWriteIOPSDevice: DeviceRates{ 75 | {Major: 60, Minor: 61, Rate: 62}, 76 | {Major: 63, Minor: 64, Rate: 65}, 77 | }, 78 | }, 79 | }, 80 | expectedWeight: 10, 81 | expectedWeightDevices: [][3]uint16{{20, 21, 22}, {23, 24, 25}}, 82 | expectedThrottleReadBpsDevices: [][3]uint64{{30, 31, 32}, {33, 34, 35}}, 83 | expectedThrottleWriteBpsDevices: [][3]uint64{{40, 41, 42}, {43, 44, 45}}, 84 | expectedThrottleReadIOPSDevices: [][3]uint64{{50, 51, 52}, {53, 54, 55}}, 85 | expectedThrottleWriteIOPSDevices: [][3]uint64{{60, 61, 62}, {63, 64, 65}}, 86 | expectedBlockIO: &oci.LinuxBlockIO{}, 87 | }, 88 | } 89 | for _, tc := range tcases { 90 | t.Run(tc.name, func(t *testing.T) { 91 | classBlockIO = tc.blockIOClasses 92 | gotBlockIO, gotError := OciLinuxBlockIO(tc.class) 93 | expectedErrorCount := 0 94 | if len(tc.expectedErrorSubstrings) > 0 { 95 | expectedErrorCount = 1 96 | } 97 | testutils.VerifyError(t, gotError, expectedErrorCount, tc.expectedErrorSubstrings) 98 | if tc.expectedBlockIO != nil { 99 | tc.expectedBlockIO.Weight = &tc.expectedWeight 100 | for _, wd := range tc.expectedWeightDevices { 101 | tc.expectedBlockIO.WeightDevice = append(tc.expectedBlockIO.WeightDevice, linuxWeightDevice(wd)) 102 | } 103 | for _, rd := range tc.expectedThrottleReadBpsDevices { 104 | tc.expectedBlockIO.ThrottleReadBpsDevice = append(tc.expectedBlockIO.ThrottleReadBpsDevice, linuxThrottleDevice(rd)) 105 | } 106 | for _, rd := range tc.expectedThrottleWriteBpsDevices { 107 | tc.expectedBlockIO.ThrottleWriteBpsDevice = append(tc.expectedBlockIO.ThrottleWriteBpsDevice, linuxThrottleDevice(rd)) 108 | } 109 | for _, rd := range tc.expectedThrottleReadIOPSDevices { 110 | tc.expectedBlockIO.ThrottleReadIOPSDevice = append(tc.expectedBlockIO.ThrottleReadIOPSDevice, linuxThrottleDevice(rd)) 111 | } 112 | for _, rd := range tc.expectedThrottleWriteIOPSDevices { 113 | tc.expectedBlockIO.ThrottleWriteIOPSDevice = append(tc.expectedBlockIO.ThrottleWriteIOPSDevice, linuxThrottleDevice(rd)) 114 | } 115 | } 116 | testutils.VerifyDeepEqual(t, "OCI BlockIO", tc.expectedBlockIO, gotBlockIO) 117 | }) 118 | } 119 | } 120 | 121 | func linuxWeightDevice(triplet [3]uint16) oci.LinuxWeightDevice { 122 | wd := oci.LinuxWeightDevice{} 123 | wd.Major = int64(triplet[0]) 124 | wd.Minor = int64(triplet[1]) 125 | wd.Weight = &triplet[2] 126 | return wd 127 | } 128 | 129 | func linuxThrottleDevice(triplet [3]uint64) oci.LinuxThrottleDevice { 130 | rd := oci.LinuxThrottleDevice{} 131 | rd.Major = int64(triplet[0]) 132 | rd.Minor = int64(triplet[1]) 133 | rd.Rate = triplet[2] 134 | return rd 135 | } 136 | -------------------------------------------------------------------------------- /pkg/kubernetes/annotations.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 Intel Corporation 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package kubernetes 18 | 19 | // ClassOrigin type indicates the source of container's class 20 | // information: whether it is found from CRI level container 21 | // annotations, Kubernetes' pod annotations, or it has not been found 22 | // at all. 23 | type ClassOrigin int 24 | 25 | const ( 26 | ClassOriginNotFound ClassOrigin = iota 27 | ClassOriginContainerAnnotation 28 | ClassOriginPodAnnotation 29 | ) 30 | 31 | func (c ClassOrigin) String() string { 32 | switch c { 33 | case ClassOriginNotFound: 34 | return "" 35 | case ClassOriginContainerAnnotation: 36 | return "container annotations" 37 | case ClassOriginPodAnnotation: 38 | return "pod annotations" 39 | default: 40 | return "" 41 | } 42 | } 43 | 44 | // ContainerClassFromAnnotations determines the effective class of a 45 | // container from the Pod annotations and CRI level container 46 | // annotations of a container. 47 | func ContainerClassFromAnnotations(containerAnnotation, podAnnotation, podAnnotationContainerPrefix string, containerName string, containerAnnotations, podAnnotations map[string]string) (string, ClassOrigin) { 48 | if clsName, ok := containerAnnotations[containerAnnotation]; ok { 49 | return clsName, ClassOriginContainerAnnotation 50 | } 51 | if clsName, ok := podAnnotations[podAnnotationContainerPrefix+containerName]; ok { 52 | return clsName, ClassOriginPodAnnotation 53 | } 54 | if clsName, ok := podAnnotations[podAnnotation]; ok { 55 | return clsName, ClassOriginPodAnnotation 56 | } 57 | return "", ClassOriginNotFound 58 | } 59 | -------------------------------------------------------------------------------- /pkg/kubernetes/annotations_test.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 Intel Corporation 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package kubernetes 18 | 19 | import ( 20 | "testing" 21 | ) 22 | 23 | // TestContainerClassFromAnnotations: unit test for ContainerClassFromAnnotations. 24 | func TestContainerClassFromAnnotations(t *testing.T) { 25 | aContainerAnnotation := "io.kubernetes.cri.a-class" 26 | aPodAnnotation := "a.resources.beta.kubernetes.io/pod" 27 | aPodAnnotationContainerPrefix := "a.resources.beta.kubernetes.io/container." 28 | bContainerAnnotation := "io.kubernetes.cri.b-class" 29 | bPodAnnotation := "b.resources.beta.kubernetes.io/pod" 30 | bPodAnnotationContainerPrefix := "b.resources.beta.kubernetes.io/container." 31 | allContainerAnnotations := map[string]string{ 32 | aContainerAnnotation: "a-container-class", 33 | bContainerAnnotation: "b-container-class", 34 | } 35 | allPodAnnotations := map[string]string{ 36 | aPodAnnotation: "a-pod-class", 37 | aPodAnnotationContainerPrefix + "special-container": "a-pod-container-class", 38 | bPodAnnotation: "b-pod-class", 39 | bPodAnnotationContainerPrefix + "special-container": "b-pod-container-class", 40 | } 41 | tcases := []struct { 42 | name string // the name of the test case 43 | // inputs 44 | lookForCA string // container annotation to look for 45 | lookForPA string // pod annotation to look for 46 | lookForPAC string // pod annotation container prefix to look for 47 | cName string // container name 48 | cAnns map[string]string // container annotations 49 | pAnns map[string]string // pod annotations 50 | // outputs 51 | expectedClass string 52 | expectedOrigin ClassOrigin 53 | }{ 54 | { 55 | name: "all empty", 56 | expectedOrigin: ClassOriginNotFound, 57 | }, 58 | { 59 | name: "container annotation overrides all pod annotations", 60 | lookForCA: aContainerAnnotation, 61 | lookForPA: aPodAnnotation, 62 | lookForPAC: aPodAnnotationContainerPrefix, 63 | cName: "special-container", 64 | cAnns: allContainerAnnotations, 65 | pAnns: allPodAnnotations, 66 | expectedClass: "a-container-class", 67 | expectedOrigin: ClassOriginContainerAnnotation, 68 | }, 69 | { 70 | name: "container prefix overrides default pod annotation", 71 | lookForCA: "not.existing.container.annotation", 72 | lookForPA: bPodAnnotation, 73 | lookForPAC: bPodAnnotationContainerPrefix, 74 | cName: "special-container", 75 | cAnns: allContainerAnnotations, 76 | pAnns: allPodAnnotations, 77 | expectedClass: "b-pod-container-class", 78 | expectedOrigin: ClassOriginPodAnnotation, 79 | }, 80 | { 81 | name: "default pod annotation", 82 | lookForCA: "not.existing.container.annotation", 83 | lookForPA: bPodAnnotation, 84 | lookForPAC: bPodAnnotationContainerPrefix, 85 | cName: "ordinary-container", 86 | cAnns: allContainerAnnotations, 87 | pAnns: allPodAnnotations, 88 | expectedClass: "b-pod-class", 89 | expectedOrigin: ClassOriginPodAnnotation, 90 | }, 91 | } 92 | for _, tc := range tcases { 93 | t.Run(tc.name, func(t *testing.T) { 94 | observedClass, observedOrigin := ContainerClassFromAnnotations( 95 | tc.lookForCA, tc.lookForPA, tc.lookForPAC, 96 | tc.cName, tc.cAnns, tc.pAnns) 97 | if observedClass != tc.expectedClass { 98 | t.Errorf("expected class %q, observed %q", tc.expectedClass, observedClass) 99 | } 100 | if observedOrigin != tc.expectedOrigin { 101 | t.Errorf("expected origin %q, observed %q", tc.expectedOrigin, observedOrigin) 102 | } 103 | }) 104 | } 105 | 106 | } 107 | -------------------------------------------------------------------------------- /pkg/log/log.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019-2021 Intel Corporation 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package log 18 | 19 | import ( 20 | "fmt" 21 | stdlog "log" 22 | "strings" 23 | ) 24 | 25 | // Logger is the logging interface for goresctl 26 | type Logger interface { 27 | Debugf(format string, v ...interface{}) 28 | Infof(format string, v ...interface{}) 29 | Warnf(format string, v ...interface{}) 30 | Errorf(format string, v ...interface{}) 31 | Panicf(format string, v ...interface{}) 32 | Fatalf(format string, v ...interface{}) 33 | } 34 | 35 | type logger struct { 36 | *stdlog.Logger 37 | } 38 | 39 | // NewLoggerWrapper wraps an implementation of the golang standard intreface 40 | // into a goresctl specific compatible logger interface 41 | func NewLoggerWrapper(l *stdlog.Logger) Logger { 42 | return &logger{Logger: l} 43 | } 44 | 45 | func (l *logger) Debugf(format string, v ...interface{}) { 46 | l.Logger.Printf("DEBUG: "+format, v...) 47 | } 48 | 49 | func (l *logger) Infof(format string, v ...interface{}) { 50 | l.Logger.Printf("INFO: "+format, v...) 51 | } 52 | 53 | func (l *logger) Warnf(format string, v ...interface{}) { 54 | l.Logger.Printf("WARN: "+format, v...) 55 | } 56 | 57 | func (l *logger) Errorf(format string, v ...interface{}) { 58 | l.Logger.Printf("ERROR: "+format, v...) 59 | } 60 | 61 | func (l *logger) Panicf(format string, v ...interface{}) { 62 | l.Logger.Panicf(format, v...) 63 | } 64 | 65 | func (l *logger) Fatalf(format string, v ...interface{}) { 66 | l.Logger.Fatalf(format, v...) 67 | } 68 | 69 | func InfoBlock(l Logger, heading, linePrefix, format string, v ...interface{}) { 70 | l.Infof("%s", heading) 71 | 72 | lines := strings.Split(fmt.Sprintf(format, v...), "\n") 73 | for _, line := range lines { 74 | l.Infof("%s%s", linePrefix, line) 75 | } 76 | } 77 | 78 | func DebugBlock(l Logger, heading, linePrefix, format string, v ...interface{}) { 79 | l.Debugf("%s", heading) 80 | 81 | lines := strings.Split(fmt.Sprintf(format, v...), "\n") 82 | for _, line := range lines { 83 | l.Debugf("%s%s", linePrefix, line) 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /pkg/path/path.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2023 Intel Corporation 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package path 18 | 19 | import "path/filepath" 20 | 21 | // RootDir is a helper for handling system directory paths 22 | type RootDir string 23 | 24 | var prefix RootDir = "/" 25 | 26 | // Path returns a full path to a file under RootDir 27 | func (d RootDir) Path(elems ...string) string { 28 | return filepath.Join(append([]string{string(d)}, elems...)...) 29 | } 30 | 31 | // SetPrefix sets the global path prefix to use for all system files. 32 | func SetPrefix(p string) { prefix = RootDir(p) } 33 | 34 | // Path returns a path to a file, prefixed with the global prefix. 35 | func Path(elems ...string) string { return prefix.Path(elems...) } 36 | -------------------------------------------------------------------------------- /pkg/path/path_test.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2023 Intel Corporation 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package path 18 | 19 | import ( 20 | "testing" 21 | ) 22 | 23 | func TestPath(t *testing.T) { 24 | // Helper function for checking test cases 25 | TC := func(path []string, expected string) { 26 | if result := Path(path...); result != expected { 27 | t.Errorf("unexpected path: %v -> %q, expected %q", path, result, expected) 28 | } 29 | } 30 | 31 | // Run test cases 32 | TC([]string{}, "/") 33 | TC([]string{"foo"}, "/foo") 34 | 35 | SetPrefix("/prefix/mnt/") 36 | TC([]string{}, "/prefix/mnt") 37 | TC([]string{"/foo", "bar"}, "/prefix/mnt/foo/bar") 38 | } 39 | -------------------------------------------------------------------------------- /pkg/rdt/bitmask.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 Intel Corporation 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package rdt 18 | 19 | import ( 20 | "fmt" 21 | "math/bits" 22 | "strconv" 23 | "strings" 24 | ) 25 | 26 | // bitmask represents a generic 64 bit wide bitmask 27 | type bitmask uint64 28 | 29 | // MarshalJSON implements the Marshaler interface of "encoding/json" 30 | func (b bitmask) MarshalJSON() ([]byte, error) { 31 | return []byte(fmt.Sprintf("\"%#x\"", b)), nil 32 | } 33 | 34 | // listStr prints the bitmask in human-readable format, similar to e.g. the 35 | // cpuset format of the Linux kernel 36 | func (b bitmask) listStr() string { 37 | str := "" 38 | sep := "" 39 | 40 | shift := int(0) 41 | lsbOne := b.lsbOne() 42 | 43 | // Process "ranges of ones" 44 | for lsbOne != -1 { 45 | b >>= uint(lsbOne) 46 | 47 | // Get range lenght from the position of the first zero 48 | numOnes := b.lsbZero() 49 | 50 | if numOnes == 1 { 51 | str += sep + strconv.Itoa(lsbOne+shift) 52 | } else { 53 | str += sep + strconv.Itoa(lsbOne+shift) + "-" + strconv.Itoa(lsbOne+numOnes-1+shift) 54 | } 55 | 56 | // Shift away the bits that have been processed 57 | b >>= uint(numOnes) 58 | shift += lsbOne + numOnes 59 | 60 | // Get next bit that is set (if any) 61 | lsbOne = b.lsbOne() 62 | 63 | sep = "," 64 | } 65 | 66 | return str 67 | } 68 | 69 | // listStrToBitmask parses a string containing a human-readable list of bit 70 | // numbers into a bitmask 71 | func listStrToBitmask(str string) (bitmask, error) { 72 | b := bitmask(0) 73 | 74 | // Empty bitmask 75 | if len(str) == 0 { 76 | return b, nil 77 | } 78 | 79 | ranges := strings.Split(str, ",") 80 | for _, ran := range ranges { 81 | split := strings.SplitN(ran, "-", 2) 82 | 83 | bitNum, err := strconv.ParseUint(split[0], 10, 6) 84 | if err != nil { 85 | return b, fmt.Errorf("invalid bitmask %q: %v", str, err) 86 | } 87 | 88 | if len(split) == 1 { 89 | b |= 1 << bitNum 90 | } else { 91 | endNum, err := strconv.ParseUint(split[1], 10, 6) 92 | if err != nil { 93 | return b, fmt.Errorf("invalid bitmask %q: %v", str, err) 94 | } 95 | if endNum <= bitNum { 96 | return b, fmt.Errorf("invalid range %q in bitmask %q", ran, str) 97 | } 98 | b |= (1<<(endNum-bitNum+1) - 1) << bitNum 99 | } 100 | } 101 | return b, nil 102 | } 103 | 104 | func (b bitmask) lsbOne() int { 105 | if b == 0 { 106 | return -1 107 | } 108 | return bits.TrailingZeros64(uint64(b)) 109 | } 110 | 111 | func (b bitmask) msbOne() int { 112 | // Returns -1 for b == 0 113 | return 63 - bits.LeadingZeros64(uint64(b)) 114 | } 115 | 116 | func (b bitmask) lsbZero() int { 117 | return bits.TrailingZeros64(^uint64(b)) 118 | } 119 | -------------------------------------------------------------------------------- /pkg/rdt/info.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019-2021 Intel Corporation 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package rdt 18 | 19 | import ( 20 | "bufio" 21 | "fmt" 22 | "os" 23 | "path/filepath" 24 | "sort" 25 | "strconv" 26 | "strings" 27 | ) 28 | 29 | // resctrlInfo contains information about the RDT support in the system 30 | type resctrlInfo struct { 31 | resctrlPath string 32 | resctrlMountOpts map[string]struct{} 33 | numClosids uint64 34 | cat map[cacheLevel]catInfoAll 35 | l3mon l3MonInfo 36 | mb mbInfo 37 | } 38 | 39 | type cacheLevel string 40 | 41 | const ( 42 | L2 cacheLevel = "L2" 43 | L3 cacheLevel = "L3" 44 | ) 45 | 46 | type catInfoAll struct { 47 | cacheIds []uint64 48 | unified catInfo 49 | code catInfo 50 | data catInfo 51 | } 52 | 53 | type catInfo struct { 54 | cbmMask bitmask 55 | minCbmBits uint64 56 | shareableBits bitmask 57 | } 58 | 59 | type l3MonInfo struct { 60 | numRmids uint64 61 | monFeatures []string 62 | } 63 | 64 | type mbInfo struct { 65 | cacheIds []uint64 66 | bandwidthGran uint64 67 | delayLinear uint64 68 | minBandwidth uint64 69 | mbpsEnabled bool // true if MBA_MBps is enabled 70 | } 71 | 72 | var mountInfoPath string = "/proc/mounts" 73 | 74 | // getInfo is a helper method for a "unified API" for getting L3 information 75 | func (i catInfoAll) getInfo() catInfo { 76 | switch { 77 | case i.code.Supported(): 78 | return i.code 79 | case i.data.Supported(): 80 | return i.data 81 | } 82 | return i.unified 83 | } 84 | 85 | func (i catInfoAll) cbmMask() bitmask { 86 | mask := i.getInfo().cbmMask 87 | if mask != 0 { 88 | return mask 89 | } 90 | return bitmask(^uint64(0)) 91 | } 92 | 93 | func (i catInfoAll) minCbmBits() uint64 { 94 | return i.getInfo().minCbmBits 95 | } 96 | 97 | func getRdtInfo() (*resctrlInfo, error) { 98 | var err error 99 | info := &resctrlInfo{cat: make(map[cacheLevel]catInfoAll)} 100 | 101 | info.resctrlPath, info.resctrlMountOpts, err = getResctrlMountInfo() 102 | if err != nil { 103 | return info, fmt.Errorf("failed to detect resctrl mount point: %v", err) 104 | } 105 | log.Infof("detected resctrl filesystem at %q", info.resctrlPath) 106 | 107 | // Check that RDT is available 108 | infopath := filepath.Join(info.resctrlPath, "info") 109 | if _, err := os.Stat(infopath); err != nil { 110 | return info, fmt.Errorf("failed to read RDT info from %q: %v", infopath, err) 111 | } 112 | 113 | // Check CAT feature available 114 | for _, cl := range []cacheLevel{L2, L3} { 115 | cat := catInfoAll{} 116 | catFeatures := map[string]*catInfo{ 117 | "": &cat.unified, 118 | "CODE": &cat.code, 119 | "DATA": &cat.data, 120 | } 121 | for suffix, i := range catFeatures { 122 | dir := string(cl) + suffix 123 | subpath := filepath.Join(infopath, dir) 124 | if _, err = os.Stat(subpath); err == nil { 125 | *i, info.numClosids, err = getCatInfo(subpath) 126 | if err != nil { 127 | return info, fmt.Errorf("failed to get %s info from %q: %v", dir, subpath, err) 128 | } 129 | } 130 | } 131 | if cat.getInfo().Supported() { 132 | cat.cacheIds, err = getCacheIds(info.resctrlPath, string(cl)) 133 | if err != nil { 134 | return info, fmt.Errorf("failed to get %s CAT cache IDs: %v", cl, err) 135 | } 136 | } 137 | info.cat[cl] = cat 138 | } 139 | 140 | // Check MON features available 141 | subpath := filepath.Join(infopath, "L3_MON") 142 | if _, err = os.Stat(subpath); err == nil { 143 | info.l3mon, err = getL3MonInfo(subpath) 144 | if err != nil { 145 | return info, fmt.Errorf("failed to get L3_MON info from %q: %v", subpath, err) 146 | } 147 | } 148 | 149 | // Check MBA feature available 150 | subpath = filepath.Join(infopath, "MB") 151 | if _, err = os.Stat(subpath); err == nil { 152 | info.mb, info.numClosids, err = getMBInfo(subpath) 153 | if err != nil { 154 | return info, fmt.Errorf("failed to get MBA info from %q: %v", subpath, err) 155 | } 156 | 157 | info.mb.cacheIds, err = getCacheIds(info.resctrlPath, "MB") 158 | if err != nil { 159 | return info, fmt.Errorf("failed to get MBA cache IDs: %v", err) 160 | } 161 | } 162 | 163 | return info, nil 164 | } 165 | 166 | func getCatInfo(basepath string) (catInfo, uint64, error) { 167 | var err error 168 | var numClosids uint64 169 | info := catInfo{} 170 | 171 | info.cbmMask, err = readFileBitmask(filepath.Join(basepath, "cbm_mask")) 172 | if err != nil { 173 | return info, numClosids, err 174 | } 175 | info.minCbmBits, err = readFileUint64(filepath.Join(basepath, "min_cbm_bits")) 176 | if err != nil { 177 | return info, numClosids, err 178 | } 179 | info.shareableBits, err = readFileBitmask(filepath.Join(basepath, "shareable_bits")) 180 | if err != nil { 181 | return info, numClosids, err 182 | } 183 | numClosids, err = readFileUint64(filepath.Join(basepath, "num_closids")) 184 | if err != nil { 185 | return info, numClosids, err 186 | } 187 | 188 | return info, numClosids, nil 189 | } 190 | 191 | // Supported returns true if L3 cache allocation has is supported and enabled in the system 192 | func (i catInfo) Supported() bool { 193 | return i.cbmMask != 0 194 | } 195 | 196 | func getL3MonInfo(basepath string) (l3MonInfo, error) { 197 | var err error 198 | info := l3MonInfo{} 199 | 200 | info.numRmids, err = readFileUint64(filepath.Join(basepath, "num_rmids")) 201 | if err != nil { 202 | return info, err 203 | } 204 | 205 | lines, err := readFileString(filepath.Join(basepath, "mon_features")) 206 | if err != nil { 207 | return info, err 208 | } 209 | info.monFeatures = strings.Split(lines, "\n") 210 | sort.Strings(info.monFeatures) 211 | 212 | return info, nil 213 | } 214 | 215 | // Supported returns true if L3 monitoring is supported and enabled in the system 216 | func (i l3MonInfo) Supported() bool { 217 | return i.numRmids != 0 && len(i.monFeatures) > 0 218 | } 219 | 220 | func getMBInfo(basepath string) (mbInfo, uint64, error) { 221 | var err error 222 | var numClosids uint64 223 | info := mbInfo{} 224 | 225 | info.bandwidthGran, err = readFileUint64(filepath.Join(basepath, "bandwidth_gran")) 226 | if err != nil { 227 | return info, numClosids, err 228 | } 229 | info.delayLinear, err = readFileUint64(filepath.Join(basepath, "delay_linear")) 230 | if err != nil { 231 | return info, numClosids, err 232 | } 233 | info.minBandwidth, err = readFileUint64(filepath.Join(basepath, "min_bandwidth")) 234 | if err != nil { 235 | return info, numClosids, err 236 | } 237 | numClosids, err = readFileUint64(filepath.Join(basepath, "num_closids")) 238 | if err != nil { 239 | return info, numClosids, err 240 | } 241 | 242 | // Detect MBps mode directly from mount options as it's not visible in MB 243 | // info directory 244 | _, mountOpts, err := getResctrlMountInfo() 245 | if err != nil { 246 | return info, numClosids, fmt.Errorf("failed to get resctrl mount options: %v", err) 247 | } 248 | if _, ok := mountOpts["mba_MBps"]; ok { 249 | info.mbpsEnabled = true 250 | } 251 | 252 | return info, numClosids, nil 253 | } 254 | 255 | // Supported returns true if memory bandwidth allocation has is supported and enabled in the system 256 | func (i mbInfo) Supported() bool { 257 | return i.minBandwidth != 0 258 | } 259 | 260 | func getCacheIds(basepath string, prefix string) ([]uint64, error) { 261 | var ids []uint64 262 | 263 | // Parse cache IDs from the root schemata 264 | data, err := readFileString(filepath.Join(basepath, "schemata")) 265 | if err != nil { 266 | return ids, fmt.Errorf("failed to read root schemata: %v", err) 267 | } 268 | 269 | for _, line := range strings.Split(data, "\n") { 270 | trimmed := strings.TrimSpace(line) 271 | lineSplit := strings.SplitN(trimmed, ":", 2) 272 | 273 | // Find line with given resource prefix 274 | if len(lineSplit) == 2 && strings.HasPrefix(lineSplit[0], prefix) { 275 | schema := strings.Split(lineSplit[1], ";") 276 | ids = make([]uint64, len(schema)) 277 | 278 | // Get individual cache configurations from the schema 279 | for idx, definition := range schema { 280 | split := strings.Split(definition, "=") 281 | if len(split) != 2 { 282 | return ids, fmt.Errorf("looks like an invalid schema %q", trimmed) 283 | } 284 | ids[idx], err = strconv.ParseUint(split[0], 10, 64) 285 | if err != nil { 286 | return ids, fmt.Errorf("failed to parse cache id in %q: %v", trimmed, err) 287 | } 288 | } 289 | return ids, nil 290 | } 291 | } 292 | return ids, fmt.Errorf("no %s resources in root schemata", prefix) 293 | } 294 | 295 | func getResctrlMountInfo() (string, map[string]struct{}, error) { 296 | mountOptions := map[string]struct{}{} 297 | 298 | f, err := os.Open(mountInfoPath) 299 | if err != nil { 300 | return "", mountOptions, err 301 | } 302 | defer f.Close() 303 | 304 | s := bufio.NewScanner(f) 305 | for s.Scan() { 306 | split := strings.Split(s.Text(), " ") 307 | if len(split) > 3 && split[2] == "resctrl" { 308 | opts := strings.Split(split[3], ",") 309 | for _, opt := range opts { 310 | mountOptions[opt] = struct{}{} 311 | } 312 | return split[1], mountOptions, nil 313 | } 314 | } 315 | return "", mountOptions, fmt.Errorf("resctrl not found in " + mountInfoPath) 316 | } 317 | 318 | func readFileUint64(path string) (uint64, error) { 319 | data, err := readFileString(path) 320 | if err != nil { 321 | return 0, err 322 | } 323 | 324 | return strconv.ParseUint(data, 10, 64) 325 | } 326 | 327 | func readFileBitmask(path string) (bitmask, error) { 328 | data, err := readFileString(path) 329 | if err != nil { 330 | return 0, err 331 | } 332 | 333 | value, err := strconv.ParseUint(data, 16, 64) 334 | return bitmask(value), err 335 | } 336 | 337 | func readFileString(path string) (string, error) { 338 | data, err := os.ReadFile(path) 339 | return strings.TrimSpace(string(data)), err 340 | } 341 | -------------------------------------------------------------------------------- /pkg/rdt/kubernetes.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 Intel Corporation 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package rdt 18 | 19 | import ( 20 | "fmt" 21 | "github.com/intel/goresctrl/pkg/kubernetes" 22 | ) 23 | 24 | const ( 25 | // RdtContainerAnnotation is the CRI level container annotation for setting 26 | // the RDT class (CLOS) of a container 27 | RdtContainerAnnotation = "io.kubernetes.cri.rdt-class" 28 | 29 | // RdtPodAnnotation is a Pod annotation for setting the RDT class (CLOS) of 30 | // all containers of the pod 31 | RdtPodAnnotation = "rdt.resources.beta.kubernetes.io/pod" 32 | 33 | // RdtPodAnnotationContainerPrefix is prefix for per-container Pod annotation 34 | // for setting the RDT class (CLOS) of one container of the pod 35 | RdtPodAnnotationContainerPrefix = "rdt.resources.beta.kubernetes.io/container." 36 | ) 37 | 38 | // ContainerClassFromAnnotations determines the effective RDT class of a 39 | // container from the Pod annotations and CRI level container annotations of a 40 | // container. Verifies that the class exists in goresctrl configuration and that 41 | // it is allowed to be used. 42 | func ContainerClassFromAnnotations(containerName string, containerAnnotations, podAnnotations map[string]string) (string, error) { 43 | clsName, clsOrigin := kubernetes.ContainerClassFromAnnotations( 44 | RdtContainerAnnotation, RdtPodAnnotation, RdtPodAnnotationContainerPrefix, 45 | containerName, containerAnnotations, podAnnotations) 46 | 47 | if clsOrigin != kubernetes.ClassOriginNotFound { 48 | if rdt == nil { 49 | return "", fmt.Errorf("RDT not initialized, class %q not available", clsName) 50 | } 51 | 52 | // Verify validity of class name 53 | if !IsQualifiedClassName(clsName) { 54 | return "", fmt.Errorf("unqualified RDT class name %q", clsName) 55 | } 56 | 57 | // If RDT has been initialized we check that the class exists 58 | if _, ok := rdt.getClass(clsName); !ok { 59 | return "", fmt.Errorf("RDT class %q does not exist in configuration", clsName) 60 | } 61 | 62 | // If classes have been configured by goresctrl 63 | if clsConf, ok := rdt.conf.Classes[unaliasClassName(clsName)]; ok { 64 | // Check that the class is allowed 65 | if clsOrigin == kubernetes.ClassOriginPodAnnotation && clsConf.Kubernetes.DenyPodAnnotation { 66 | return "", fmt.Errorf("RDT class %q not allowed from Pod annotations", clsName) 67 | } else if clsOrigin == kubernetes.ClassOriginContainerAnnotation && clsConf.Kubernetes.DenyContainerAnnotation { 68 | return "", fmt.Errorf("RDT class %q not allowed from Container annotation", clsName) 69 | } 70 | } 71 | } 72 | 73 | return clsName, nil 74 | } 75 | -------------------------------------------------------------------------------- /pkg/rdt/kubernetes_test.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 Intel Corporation 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package rdt 18 | 19 | import ( 20 | "testing" 21 | ) 22 | 23 | func TestContainerClassFromAnnotations(t *testing.T) { 24 | mockRdt := &control{ 25 | classes: make(map[string]*ctrlGroup), 26 | } 27 | 28 | containerName := "test-container" 29 | containerAnnotations := map[string]string{} 30 | podAnnotations := map[string]string{} 31 | 32 | // Helper function for checking test cases 33 | tc := func(expectError bool, expectedClsName string) { 34 | cls, err := ContainerClassFromAnnotations(containerName, containerAnnotations, podAnnotations) 35 | if !expectError && err != nil { 36 | t.Errorf("unexpected error: %v", err) 37 | } else if expectError && err == nil { 38 | t.Errorf("unexpected success setting RDT class to %q", cls) 39 | } else if cls != expectedClsName { 40 | t.Errorf("invalid rdt class, expecting %q, got %q", expectedClsName, cls) 41 | } 42 | } 43 | 44 | // 45 | // 1. Test container annotation 46 | // 47 | 48 | // Should succeed when rdt is uninitialized but annotations are empty 49 | rdt = nil 50 | tc(false, "") 51 | 52 | // Should fail when rdt is uninitialized but annotations point to a class 53 | containerAnnotations = map[string]string{RdtContainerAnnotation: "class-1"} 54 | podAnnotations = map[string]string{ 55 | RdtPodAnnotationContainerPrefix + containerName: "class-2", 56 | RdtPodAnnotation: "class-3"} 57 | tc(true, "") 58 | 59 | // Mock configured rdt which enables the functionality 60 | rdt = mockRdt 61 | 62 | // Should fail with an empty set of classes 63 | tc(true, "") 64 | 65 | // Should succeed when the class exists but no configuration has been set ("discovery mode") 66 | mockRdt.classes = map[string]*ctrlGroup{"": nil, "class-1": nil, "class-2": nil, "class-3": nil} 67 | tc(false, "class-1") 68 | 69 | // Should succeed with default class config 70 | mockRdt.conf.Classes = classSet{"class-1": &classConfig{}, "class-2": &classConfig{}, "class-3": &classConfig{}} 71 | tc(false, "class-1") 72 | 73 | // Should fail when container annotation has been denied in class ocnfig 74 | mockRdt.conf.Classes["class-1"].Kubernetes.DenyContainerAnnotation = true 75 | tc(true, "") 76 | 77 | // Test invalid class name 78 | containerAnnotations[RdtContainerAnnotation] = "foo/bar" 79 | tc(true, "") 80 | 81 | // 82 | // 2. Test per-container Pod annotation 83 | // 84 | delete(containerAnnotations, RdtContainerAnnotation) 85 | tc(false, "class-2") 86 | 87 | // Should fail when pod annotations for the class are denied 88 | mockRdt.conf.Classes["class-2"].Kubernetes.DenyPodAnnotation = true 89 | tc(true, "") 90 | 91 | // 92 | // 3. Test pod-wide Pod annotation 93 | // 94 | delete(podAnnotations, RdtPodAnnotationContainerPrefix+containerName) 95 | tc(false, "class-3") 96 | 97 | // Should fail when pod annotations for the class are denied 98 | mockRdt.conf.Classes["class-3"].Kubernetes.DenyPodAnnotation = true 99 | tc(true, "") 100 | 101 | // 102 | // Test empty annotations 103 | // 104 | delete(podAnnotations, RdtPodAnnotation) 105 | tc(false, "") 106 | } 107 | -------------------------------------------------------------------------------- /pkg/rdt/prometheus.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020 Intel Corporation 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package rdt 18 | 19 | import ( 20 | "fmt" 21 | "sync" 22 | 23 | "github.com/prometheus/client_golang/prometheus" 24 | ) 25 | 26 | var customLabels []string = []string{} 27 | 28 | // collector implements prometheus.Collector interface 29 | type collector struct { 30 | descriptors map[string]*prometheus.Desc 31 | } 32 | 33 | // NewCollector creates new Prometheus collector of RDT metrics 34 | func NewCollector() (prometheus.Collector, error) { 35 | c := &collector{descriptors: make(map[string]*prometheus.Desc)} 36 | return c, nil 37 | } 38 | 39 | // RegisterCustomPrometheusLabels registers monitor group annotations to be 40 | // exported as Prometheus metrics labels 41 | func RegisterCustomPrometheusLabels(names ...string) { 42 | Names: 43 | for _, n := range names { 44 | for _, c := range customLabels { 45 | if n == c { 46 | break Names 47 | } 48 | } 49 | customLabels = append(customLabels, n) 50 | } 51 | } 52 | 53 | // Describe method of the prometheus.Collector interface 54 | func (c *collector) Describe(ch chan<- *prometheus.Desc) { 55 | for resource, features := range GetMonFeatures() { 56 | switch resource { 57 | case MonResourceL3: 58 | for _, f := range features { 59 | ch <- c.describeL3(f) 60 | } 61 | } 62 | } 63 | } 64 | 65 | // Collect method of the prometheus.Collector interface 66 | func (c collector) Collect(ch chan<- prometheus.Metric) { 67 | var wg sync.WaitGroup 68 | 69 | for _, cls := range GetClasses() { 70 | for _, monGrp := range cls.GetMonGroups() { 71 | wg.Add(1) 72 | g := monGrp 73 | go func() { 74 | defer wg.Done() 75 | c.collectGroupMetrics(ch, g) 76 | }() 77 | } 78 | } 79 | wg.Wait() 80 | } 81 | 82 | func (c *collector) describeL3(feature string) *prometheus.Desc { 83 | d, ok := c.descriptors[feature] 84 | if !ok { 85 | name := "l3_" + feature 86 | help := "L3 " + feature 87 | 88 | switch feature { 89 | case "llc_occupancy": 90 | help = "L3 (LLC) occupancy" 91 | case "mbm_local_bytes": 92 | help = "bytes transferred to/from local memory through LLC" 93 | case "mbm_total_bytes": 94 | help = "total bytes transferred to/from memory through LLC" 95 | } 96 | labels := append([]string{"rdt_class", "rdt_mon_group", "cache_id"}, customLabels...) 97 | d = prometheus.NewDesc(name, help, labels, nil) 98 | c.descriptors[feature] = d 99 | } 100 | return d 101 | } 102 | 103 | func (c *collector) collectGroupMetrics(ch chan<- prometheus.Metric, mg MonGroup) { 104 | allData := mg.GetMonData() 105 | 106 | annotations := mg.GetAnnotations() 107 | customLabelValues := make([]string, len(customLabels)) 108 | for i, name := range customLabels { 109 | customLabelValues[i] = annotations[name] 110 | } 111 | 112 | for cacheID, data := range allData.L3 { 113 | for feature, value := range data { 114 | labels := append([]string{mg.Parent().Name(), mg.Name(), fmt.Sprint(cacheID)}, customLabelValues...) 115 | 116 | ch <- prometheus.MustNewConstMetric( 117 | c.describeL3(feature), 118 | prometheus.CounterValue, 119 | float64(value), 120 | labels..., 121 | ) 122 | } 123 | } 124 | } 125 | -------------------------------------------------------------------------------- /pkg/sst/_sst_types_amd64.go: -------------------------------------------------------------------------------- 1 | //go:build amd64 2 | // +build amd64 3 | 4 | /* 5 | Copyright 2021 Intel Corporation 6 | 7 | Licensed under the Apache License, Version 2.0 (the "License"); 8 | you may not use this file except in compliance with the License. 9 | You may obtain a copy of the License at 10 | 11 | http://www.apache.org/licenses/LICENSE-2.0 12 | 13 | Unless required by applicable law or agreed to in writing, software 14 | distributed under the License is distributed on an "AS IS" BASIS, 15 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | See the License for the specific language governing permissions and 17 | limitations under the License. 18 | */ 19 | 20 | // This file is used for auto-generation of sst_types_amd64.go 21 | package sst 22 | 23 | // #include 24 | // #include 25 | // 26 | import "C" 27 | 28 | const ( 29 | ISST_IF_GET_PHY_ID = C.ISST_IF_GET_PHY_ID 30 | ISST_IF_IO_CMD = C.ISST_IF_IO_CMD 31 | ISST_IF_MBOX_COMMAND = C.ISST_IF_MBOX_COMMAND 32 | ) 33 | 34 | type isstIfCPUMaps C.struct_isst_if_cpu_maps 35 | type isstIfCPUMap C.struct_isst_if_cpu_map 36 | 37 | type isstIfIoReg C.struct_isst_if_io_reg 38 | type isstIfIoRegs C.struct_isst_if_io_regs 39 | 40 | type isstIfMboxCmd C.struct_isst_if_mbox_cmd 41 | type isstIfMboxCmds C.struct_isst_if_mbox_cmds 42 | -------------------------------------------------------------------------------- /pkg/sst/_sst_types_priv.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 Intel Corporation 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // This file is used for auto-generation of sst_types_priv.go 18 | package sst 19 | 20 | // #include "tools/power/x86/intel-speed-select/isst.h" 21 | // #include "tools/arch/x86/include/asm/msr-index.h" 22 | // 23 | import "C" 24 | 25 | const ( 26 | // TDP (perf profile) related commands 27 | CONFIG_TDP = C.CONFIG_TDP 28 | CONFIG_TDP_GET_LEVELS_INFO = C.CONFIG_TDP_GET_LEVELS_INFO 29 | CONFIG_TDP_GET_TDP_CONTROL = C.CONFIG_TDP_GET_TDP_CONTROL 30 | CONFIG_TDP_SET_TDP_CONTROL = C.CONFIG_TDP_SET_TDP_CONTROL 31 | CONFIG_TDP_GET_TDP_INFO = C.CONFIG_TDP_GET_TDP_INFO 32 | CONFIG_TDP_GET_PWR_INFO = C.CONFIG_TDP_GET_PWR_INFO 33 | CONFIG_TDP_GET_TJMAX_INFO = C.CONFIG_TDP_GET_TJMAX_INFO 34 | CONFIG_TDP_GET_CORE_MASK = C.CONFIG_TDP_GET_CORE_MASK 35 | CONFIG_TDP_GET_TURBO_LIMIT_RATIOS = C.CONFIG_TDP_GET_TURBO_LIMIT_RATIOS 36 | CONFIG_TDP_SET_LEVEL = C.CONFIG_TDP_SET_LEVEL 37 | CONFIG_TDP_GET_UNCORE_P0_P1_INFO = C.CONFIG_TDP_GET_UNCORE_P0_P1_INFO 38 | CONFIG_TDP_GET_P1_INFO = C.CONFIG_TDP_GET_P1_INFO 39 | CONFIG_TDP_GET_MEM_FREQ = C.CONFIG_TDP_GET_MEM_FREQ 40 | 41 | CONFIG_TDP_GET_FACT_HP_TURBO_LIMIT_NUMCORES = C.CONFIG_TDP_GET_FACT_HP_TURBO_LIMIT_NUMCORES 42 | CONFIG_TDP_GET_FACT_HP_TURBO_LIMIT_RATIOS = C.CONFIG_TDP_GET_FACT_HP_TURBO_LIMIT_RATIOS 43 | CONFIG_TDP_GET_FACT_LP_CLIPPING_RATIO = C.CONFIG_TDP_GET_FACT_LP_CLIPPING_RATIO 44 | 45 | CONFIG_TDP_PBF_GET_CORE_MASK_INFO = C.CONFIG_TDP_PBF_GET_CORE_MASK_INFO 46 | CONFIG_TDP_PBF_GET_P1HI_P1LO_INFO = C.CONFIG_TDP_PBF_GET_P1HI_P1LO_INFO 47 | CONFIG_TDP_PBF_GET_TJ_MAX_INFO = C.CONFIG_TDP_PBF_GET_TJ_MAX_INFO 48 | CONFIG_TDP_PBF_GET_TDP_INFO = C.CONFIG_TDP_PBF_GET_TDP_INFO 49 | 50 | // CLOS related commands 51 | CONFIG_CLOS = C.CONFIG_CLOS 52 | CLOS_PM_QOS_CONFIG = C.CLOS_PM_QOS_CONFIG 53 | CLOS_PQR_ASSOC = C.CLOS_PQR_ASSOC 54 | CLOS_PM_CLOS = C.CLOS_PM_CLOS 55 | CLOS_STATUS = C.CLOS_STATUS 56 | 57 | MBOX_CMD_WRITE_BIT = C.MBOX_CMD_WRITE_BIT 58 | 59 | // PM commands 60 | READ_PM_CONFIG = C.READ_PM_CONFIG 61 | WRITE_PM_CONFIG = C.WRITE_PM_CONFIG 62 | PM_FEATURE = C.PM_FEATURE 63 | 64 | PM_QOS_INFO_OFFSET = C.PM_QOS_INFO_OFFSET 65 | PM_QOS_CONFIG_OFFSET = C.PM_QOS_CONFIG_OFFSET 66 | PM_CLOS_OFFSET = C.PM_CLOS_OFFSET 67 | PQR_ASSOC_OFFSET = C.PQR_ASSOC_OFFSET 68 | 69 | // Hardware P state interface 70 | MSR_PM_ENABLE = C.MSR_PM_ENABLE 71 | ) 72 | -------------------------------------------------------------------------------- /pkg/sst/fuzz_test.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2023 Intel Corporation 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package sst 18 | 19 | import ( 20 | "flag" 21 | "testing" 22 | "time" 23 | 24 | "github.com/google/go-cmp/cmp" 25 | "golang.org/x/exp/maps" 26 | ) 27 | 28 | var enable = flag.Bool("sst.system-fuzz", false, "Enable SST fuzz tests that manipulate the system state (caution: requires root, manipulates configuration of the target system)") 29 | 30 | // FuzzClosSetup is a fuzz test for the ClosSetup function. Caution needs to be 31 | // taken when this test is run. The test needs to be run as root on an 32 | // SST-enabled system. Moreover the test manipulates the actual SST 33 | // configuration of the target system so a dedicated non-production system 34 | // should be used. Test cannot be parallelized (as it depends on the system 35 | // state). Because of these precautions the test needs to be explicitly 36 | // enabled with "-sst.system-fuzz" flag. 37 | // 38 | // An example how to run the test: 39 | // 40 | // # go test -parallel=1 -fuzz=FuzzClosSetup ./pkg/sst/... -sst.system-fuzz 41 | func FuzzClosSetup(f *testing.F) { 42 | if !*enable { 43 | f.Skipf("skipping as sst.fuzz is not enabled") 44 | } 45 | 46 | pkgs, err := GetPackageInfo() 47 | if err != nil { 48 | f.Errorf("unable to get SST package info: %v", err) 49 | } 50 | pkgIDs := maps.Keys(pkgs) 51 | 52 | f.Add(pkgIDs[0], 0, 53 | 0, 0, 0, 0, 0) 54 | f.Add(pkgIDs[len(pkgIDs)-1], 1, 55 | 2, 5, 100, 200, 150) 56 | f.Add(pkgIDs[len(pkgIDs)-1], 3, 57 | 15, 15, 255, 255, 255) 58 | // Failure test cases 59 | f.Add(pkgIDs[len(pkgIDs)-1], 4, 60 | 2, 5, 100, 200, 150) 61 | f.Add(pkgIDs[len(pkgIDs)-1], 1, 62 | 20, 5, 100, 200, 150) 63 | f.Add(pkgIDs[len(pkgIDs)-1], 1, 64 | 2, 20, 100, 200, 150) 65 | f.Add(pkgIDs[len(pkgIDs)-1], 1, 66 | 2, 10, 200, 100, 150) 67 | f.Add(pkgIDs[len(pkgIDs)-1], 1, 68 | 2, 10, 100, 300, 150) 69 | f.Add(pkgIDs[len(pkgIDs)-1], 1, 70 | -1, -1, -1, -1, -1) 71 | f.Add(pkgIDs[len(pkgIDs)-1], 1, 72 | 16, 16, 256, 256, 256) 73 | f.Fuzz(func(t *testing.T, pkg, clos, epp, pp, minf, maxf, desiredf int) { 74 | expectedInfo := &SstClosInfo{ 75 | EPP: epp, 76 | ProportionalPriority: pp, 77 | MinFreq: minf, 78 | MaxFreq: maxf, 79 | DesiredFreq: desiredf, 80 | } 81 | err := ClosSetup(pkgs[pkg], clos, expectedInfo) 82 | if err != nil { 83 | return 84 | } 85 | time.Sleep(100 * time.Millisecond) 86 | info, err := getSinglePackageInfo(pkgs[pkg].pkg) 87 | if err != nil { 88 | t.Errorf("failed to get package info: %v", err) 89 | } 90 | if !cmp.Equal(info.ClosInfo[clos], *expectedInfo) { 91 | t.Errorf("CLOS not configured correctly, expected %v, got %v", expectedInfo, info.ClosInfo[clos]) 92 | } 93 | }) 94 | } 95 | -------------------------------------------------------------------------------- /pkg/sst/gen_sst_types.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | set -o pipefail 4 | 5 | tmpfile="_sst_types_out.go" 6 | trap "rm -f $tmpfile" EXIT 7 | 8 | generate() { 9 | local target="$1" 10 | shift 11 | local copts=$@ 12 | 13 | echo "Generating $target..." 14 | 15 | go tool cgo -godefs -- $copts _"$target" | gofmt > "$tmpfile" 16 | mv "$tmpfile" "$target" 17 | } 18 | 19 | KERNEL_SRC_DIR="${KERNEL_SRC_DIR:-/usr/src/linux}" 20 | 21 | echo "INFO: using kernel sources at $KERNEL_SRC_DIR" 22 | 23 | # Generate types from Linux kernel (public) headers 24 | generate sst_types_amd64.go -I"$KERNEL_SRC_DIR/include/uapi" "-I$KERNEL_SRC_DIR/include" 25 | 26 | # Generate types from Linux kernel private headers 27 | generate sst_types_priv.go -I"$KERNEL_SRC_DIR" "-I$KERNEL_SRC_DIR/include -I$KERNEL_SRC_DIR/arch/x86/include/generated/" 28 | -------------------------------------------------------------------------------- /pkg/sst/sst_if.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 Intel Corporation 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package sst 18 | 19 | //go:generate ./gen_sst_types.sh 20 | 21 | import ( 22 | "fmt" 23 | "math" 24 | "os" 25 | "syscall" 26 | "unsafe" 27 | 28 | "github.com/intel/goresctrl/pkg/utils" 29 | ) 30 | 31 | // cpuMap holds the logical to punit cpu mapping table 32 | var cpuMap = make(map[utils.ID]utils.ID) 33 | 34 | // punitCPU returns the PUNIT CPU id corresponding a given Linux logical CPU 35 | func punitCPU(cpu utils.ID) (utils.ID, error) { 36 | if id, ok := cpuMap[cpu]; ok { 37 | return id, nil 38 | } 39 | 40 | id, err := getCPUMapping(cpu) 41 | if err == nil { 42 | cpuMap[cpu] = id 43 | } 44 | return id, err 45 | } 46 | 47 | // isstIoctl is a helper for executing ioctls on the linux isst_if device driver 48 | func isstIoctl(ioctl uintptr, req uintptr) error { 49 | devPath := isstDevPath() 50 | f, err := os.Open(devPath) 51 | if err != nil { 52 | return fmt.Errorf("failed to open isst device %q: %v", devPath, err) 53 | } 54 | defer f.Close() 55 | 56 | if _, _, errno := syscall.Syscall(syscall.SYS_IOCTL, uintptr(f.Fd()), ioctl, req); errno != 0 { 57 | return errno 58 | } 59 | 60 | return nil 61 | } 62 | 63 | // getCPUMapping gets mapping of Linux logical CPU numbers to (package-specific) 64 | // PUNIT CPU number for one cpu. This is needed because the PUNIT CPU/core 65 | // numbering differs from the Linux kernel numbering (exposed via sysfs) which 66 | // is based on APIC. 67 | func getCPUMapping(cpu utils.ID) (utils.ID, error) { 68 | if cpu < 0 || cpu > math.MaxUint32 { 69 | return utils.Unknown, fmt.Errorf("Invalid CPU number %d", cpu) 70 | } 71 | 72 | req := isstIfCPUMaps{ 73 | Cmd_count: 1, 74 | Cpu_map: [1]isstIfCPUMap{ 75 | {Logical_cpu: uint32(cpu)}, 76 | }, 77 | } 78 | 79 | if err := isstIoctl(ISST_IF_GET_PHY_ID, uintptr(unsafe.Pointer(&req))); err != nil { 80 | return -1, fmt.Errorf("failed to get CPU mapping for cpu %d: %v", cpu, err) 81 | } 82 | 83 | return utils.ID(req.Cpu_map[0].Physical_cpu), nil 84 | } 85 | 86 | // sendMboxCmd sends one mailbox command to PUNIT 87 | func sendMboxCmd(cpu utils.ID, cmd uint16, subCmd uint16, parameter uint32, reqData uint32) (uint32, error) { 88 | if cpu < 0 || cpu > math.MaxUint32 { 89 | return 0, fmt.Errorf("Invalid CPU number %d", cpu) 90 | } 91 | 92 | req := isstIfMboxCmds{ 93 | Cmd_count: 1, 94 | Mbox_cmd: [1]isstIfMboxCmd{ 95 | { 96 | Logical_cpu: uint32(cpu), 97 | Command: cmd, 98 | Sub_command: subCmd, 99 | Parameter: parameter, 100 | Req_data: reqData, 101 | }, 102 | }, 103 | } 104 | 105 | sstlog.Debugf("MBOX SEND cpu: %d cmd: %#02x sub: %#02x data: %#x", cpu, cmd, subCmd, reqData) 106 | if err := isstIoctl(ISST_IF_MBOX_COMMAND, uintptr(unsafe.Pointer(&req))); err != nil { 107 | return 0, fmt.Errorf("Mbox command failed with %v", err) 108 | } 109 | sstlog.Debugf("MBOX RECV data: %#x", req.Mbox_cmd[0].Resp_data) 110 | 111 | return req.Mbox_cmd[0].Resp_data, nil 112 | } 113 | 114 | // sendMMIOCmd sends one MMIO command to PUNIT 115 | func sendMMIOCmd(cpu utils.ID, reg uint32, value uint32, doWrite bool) (uint32, error) { 116 | if cpu < 0 || cpu > math.MaxUint32 { 117 | return 0, fmt.Errorf("Invalid CPU number %d", cpu) 118 | } 119 | 120 | var ReadWrite uint32 121 | 122 | if doWrite { 123 | ReadWrite = 1 124 | } 125 | 126 | req := isstIfIoRegs{ 127 | Req_count: 1, 128 | Io_reg: [1]isstIfIoReg{ 129 | { 130 | Logical_cpu: uint32(cpu), 131 | Reg: reg, 132 | Value: value, 133 | Read_write: ReadWrite, 134 | }, 135 | }, 136 | } 137 | sstlog.Debugf("MMIO SEND cpu: %d reg: %#x value: %#x write: %t", cpu, reg, value, doWrite) 138 | if err := isstIoctl(ISST_IF_IO_CMD, uintptr(unsafe.Pointer(&req))); err != nil { 139 | return 0, fmt.Errorf("MMIO command failed with %v", err) 140 | } 141 | sstlog.Debugf("MMIO RECV data: %#x", req.Io_reg[0].Value) 142 | 143 | return req.Io_reg[0].Value, nil 144 | } 145 | -------------------------------------------------------------------------------- /pkg/sst/sst_types_amd64.go: -------------------------------------------------------------------------------- 1 | // Code generated by cmd/cgo -godefs; DO NOT EDIT. 2 | // cgo -godefs -- -I/usr/src/linux/include/uapi -I/usr/src/linux/include _sst_types_amd64.go 3 | 4 | package sst 5 | 6 | const ( 7 | ISST_IF_GET_PHY_ID = 0xc008fe01 8 | ISST_IF_IO_CMD = 0x4008fe02 9 | ISST_IF_MBOX_COMMAND = 0xc008fe03 10 | ) 11 | 12 | type isstIfCPUMaps struct { 13 | Cmd_count uint32 14 | Cpu_map [1]isstIfCPUMap 15 | } 16 | type isstIfCPUMap struct { 17 | Logical_cpu uint32 18 | Physical_cpu uint32 19 | } 20 | 21 | type isstIfIoReg struct { 22 | Read_write uint32 23 | Logical_cpu uint32 24 | Reg uint32 25 | Value uint32 26 | } 27 | type isstIfIoRegs struct { 28 | Req_count uint32 29 | Io_reg [1]isstIfIoReg 30 | } 31 | 32 | type isstIfMboxCmd struct { 33 | Logical_cpu uint32 34 | Parameter uint32 35 | Req_data uint32 36 | Resp_data uint32 37 | Command uint16 38 | Sub_command uint16 39 | Reserved uint32 40 | } 41 | type isstIfMboxCmds struct { 42 | Cmd_count uint32 43 | Mbox_cmd [1]isstIfMboxCmd 44 | } 45 | -------------------------------------------------------------------------------- /pkg/sst/sst_types_priv.go: -------------------------------------------------------------------------------- 1 | // Code generated by cmd/cgo -godefs; DO NOT EDIT. 2 | // cgo -godefs -- -I/usr/src/linux -I/usr/src/linux/include -I/usr/src/linux/arch/x86/include/generated/ _sst_types_priv.go 3 | 4 | package sst 5 | 6 | const ( 7 | CONFIG_TDP = 0x7f 8 | CONFIG_TDP_GET_LEVELS_INFO = 0x0 9 | CONFIG_TDP_GET_TDP_CONTROL = 0x1 10 | CONFIG_TDP_SET_TDP_CONTROL = 0x2 11 | CONFIG_TDP_GET_TDP_INFO = 0x3 12 | CONFIG_TDP_GET_PWR_INFO = 0x4 13 | CONFIG_TDP_GET_TJMAX_INFO = 0x5 14 | CONFIG_TDP_GET_CORE_MASK = 0x6 15 | CONFIG_TDP_GET_TURBO_LIMIT_RATIOS = 0x7 16 | CONFIG_TDP_SET_LEVEL = 0x8 17 | CONFIG_TDP_GET_UNCORE_P0_P1_INFO = 0x9 18 | CONFIG_TDP_GET_P1_INFO = 0xa 19 | CONFIG_TDP_GET_MEM_FREQ = 0xb 20 | 21 | CONFIG_TDP_GET_FACT_HP_TURBO_LIMIT_NUMCORES = 0x10 22 | CONFIG_TDP_GET_FACT_HP_TURBO_LIMIT_RATIOS = 0x11 23 | CONFIG_TDP_GET_FACT_LP_CLIPPING_RATIO = 0x12 24 | 25 | CONFIG_TDP_PBF_GET_CORE_MASK_INFO = 0x20 26 | CONFIG_TDP_PBF_GET_P1HI_P1LO_INFO = 0x21 27 | CONFIG_TDP_PBF_GET_TJ_MAX_INFO = 0x22 28 | CONFIG_TDP_PBF_GET_TDP_INFO = 0x23 29 | 30 | CONFIG_CLOS = 0xd0 31 | CLOS_PM_QOS_CONFIG = 0x2 32 | CLOS_PQR_ASSOC = 0x0 33 | CLOS_PM_CLOS = 0x1 34 | CLOS_STATUS = 0x3 35 | 36 | MBOX_CMD_WRITE_BIT = 0x8 37 | 38 | READ_PM_CONFIG = 0x94 39 | WRITE_PM_CONFIG = 0x95 40 | PM_FEATURE = 0x3 41 | 42 | PM_QOS_INFO_OFFSET = 0x0 43 | PM_QOS_CONFIG_OFFSET = 0x4 44 | PM_CLOS_OFFSET = 0x8 45 | PQR_ASSOC_OFFSET = 0x20 46 | 47 | MSR_PM_ENABLE = 0x770 48 | ) 49 | -------------------------------------------------------------------------------- /pkg/sst/sysfs.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 Intel Corporation 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package sst 18 | 19 | import ( 20 | "os" 21 | "path/filepath" 22 | "strconv" 23 | "strings" 24 | 25 | goresctrlpath "github.com/intel/goresctrl/pkg/path" 26 | "github.com/intel/goresctrl/pkg/utils" 27 | ) 28 | 29 | type cpuPackageInfo struct { 30 | id int 31 | cpus []int 32 | } 33 | 34 | func (pkg *cpuPackageInfo) hasCpus(cpus utils.IDSet) bool { 35 | return utils.NewIDSetFromIntSlice(pkg.cpus...).Has(cpus.Members()...) 36 | } 37 | 38 | func getOnlineCpuPackages() (map[int]*cpuPackageInfo, error) { 39 | basePath := goresctrlpath.Path("sys/bus/cpu/devices") 40 | 41 | files, err := os.ReadDir(basePath) 42 | if err != nil { 43 | return nil, err 44 | } 45 | 46 | pkgs := make(map[int]*cpuPackageInfo) 47 | 48 | for _, file := range files { 49 | // Try to read siblings from topology 50 | raw, err := os.ReadFile(filepath.Join(basePath, file.Name(), "topology/physical_package_id")) 51 | if os.IsNotExist(err) { 52 | // Offline -> topology information does not exist 53 | continue 54 | } else if err != nil { 55 | return nil, err 56 | } 57 | 58 | cpuId, err := strconv.Atoi(file.Name()[3:]) 59 | if err != nil { 60 | return nil, err 61 | } 62 | 63 | pkgId, err := strconv.Atoi(strings.TrimSpace(string(raw))) 64 | if err != nil { 65 | return nil, err 66 | } 67 | 68 | if _, ok := pkgs[pkgId]; !ok { 69 | pkgs[pkgId] = &cpuPackageInfo{id: pkgId} 70 | } 71 | pkgs[pkgId].cpus = append(pkgs[pkgId].cpus, cpuId) 72 | } 73 | 74 | return pkgs, nil 75 | } 76 | 77 | func isHWPEnabled() (bool, error) { 78 | status, err := utils.ReadMSR(0, MSR_PM_ENABLE) 79 | if err != nil { 80 | return false, err 81 | } 82 | 83 | return (status & 0xff) != 0, nil 84 | } 85 | 86 | func setCPUScalingMin2CPUInfoMinFreq(cpu utils.ID) error { 87 | freq, err := utils.GetCPUFreqValue(cpu, "cpuinfo_min_freq") 88 | if err != nil { 89 | return err 90 | } 91 | 92 | return utils.SetCPUScalingMinFreq(cpu, freq) 93 | } 94 | 95 | func setCPUScalingMin2CPUInfoMaxFreq(cpu utils.ID) error { 96 | freq, err := utils.GetCPUFreqValue(cpu, "cpuinfo_max_freq") 97 | if err != nil { 98 | return err 99 | } 100 | 101 | return utils.SetCPUScalingMinFreq(cpu, freq) 102 | } 103 | -------------------------------------------------------------------------------- /pkg/testutils/file.go: -------------------------------------------------------------------------------- 1 | // Copyright 2020-2021 Intel Corporation. All Rights Reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package testutils 16 | 17 | import ( 18 | "os" 19 | "testing" 20 | ) 21 | 22 | func CreateTempFile(t *testing.T, data string) string { 23 | f, err := os.CreateTemp("", "goresctrl-testutils-") 24 | if err != nil { 25 | t.Fatal(err) 26 | } 27 | if _, err := f.WriteString(data); err != nil { 28 | t.Fatal(err) 29 | } 30 | if err := f.Close(); err != nil { 31 | t.Fatal(err) 32 | } 33 | return f.Name() 34 | } 35 | -------------------------------------------------------------------------------- /pkg/testutils/verify.go: -------------------------------------------------------------------------------- 1 | // Copyright 2020-2021 Intel Corporation. All Rights Reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package testutils 16 | 17 | import ( 18 | "reflect" 19 | "strings" 20 | "testing" 21 | ) 22 | 23 | // VerifyDeepEqual checks that two values (including structures) are equal, or else it fails the test. 24 | func VerifyDeepEqual(t *testing.T, valueName string, expectedValue interface{}, seenValue interface{}) bool { 25 | if reflect.DeepEqual(expectedValue, seenValue) { 26 | return true 27 | } 28 | t.Errorf("expected %s value %+v, got %+v", valueName, expectedValue, seenValue) 29 | return false 30 | } 31 | 32 | // VerifyError checks a (multi)error has expected properties, or else it fails the test. 33 | func VerifyError(t *testing.T, err error, expectedCount int, expectedSubstrings []string) bool { 34 | if expectedCount > 0 { 35 | if err == nil { 36 | t.Errorf("error expected, got nil") 37 | return false 38 | } 39 | if merr, ok := err.(interface{ Unwrap() []error }); !ok { 40 | if expectedCount > 1 { 41 | t.Errorf("expected %d errors, but got %#v instead of multierror", expectedCount, err) 42 | return false 43 | } 44 | // If exactly one error is expected, then err 45 | // is allowed to be any error, not just a 46 | // multierror. 47 | } else if errs := merr.Unwrap(); len(errs) != expectedCount { 48 | t.Errorf("expected %d errors, but got %d: %v", expectedCount, len(errs), merr) 49 | return false 50 | } 51 | } else if expectedCount == 0 { 52 | if err != nil { 53 | t.Errorf("expected 0 errors, but got: %v", err) 54 | return false 55 | } 56 | } 57 | for _, substring := range expectedSubstrings { 58 | if !strings.Contains(err.Error(), substring) { 59 | t.Errorf("expected error with substring %#v, got \"%v\"", substring, err) 60 | } 61 | } 62 | return true 63 | } 64 | 65 | func VerifyNoError(t *testing.T, err error) bool { 66 | if err != nil { 67 | t.Errorf("expected no error, got %v", err) 68 | return false 69 | } 70 | return true 71 | } 72 | 73 | func VerifyStrings(t *testing.T, expected string, got string) bool { 74 | if expected != got { 75 | t.Errorf("Strings differ: expected %q, got %q", expected, got) 76 | return false 77 | } 78 | return true 79 | } 80 | 81 | func VerifyStringSlices(t *testing.T, expected []string, got []string) bool { 82 | if len(expected) != len(got) { 83 | t.Errorf("Expected string slice of length %d, got %d", len(expected), len(got)) 84 | return false 85 | } 86 | for i, es := range expected { 87 | if es != got[i] { 88 | t.Errorf("Slices differ: expected[%d]=%q, got[%d]=%q", i, es, i, got[i]) 89 | return false 90 | } 91 | } 92 | return true 93 | } 94 | -------------------------------------------------------------------------------- /pkg/utils/idset.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019-2021 Intel Corporation 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package utils 18 | 19 | import ( 20 | "encoding/json" 21 | "fmt" 22 | "sort" 23 | "strconv" 24 | "strings" 25 | ) 26 | 27 | const ( 28 | // Unknown represents an unknown id. 29 | Unknown ID = -1 30 | ) 31 | 32 | // ID is nn integer id, used to identify packages, CPUs, nodes, etc. 33 | type ID = int 34 | 35 | // IDSet is an unordered set of integer ids. 36 | type IDSet map[ID]struct{} 37 | 38 | // NewIDSet creates a new unordered set of (integer) ids. 39 | func NewIDSet(ids ...ID) IDSet { 40 | s := make(map[ID]struct{}) 41 | 42 | for _, id := range ids { 43 | s[id] = struct{}{} 44 | } 45 | 46 | return s 47 | } 48 | 49 | // NewIDSetFromIntSlice creates a new unordered set from an integer slice. 50 | func NewIDSetFromIntSlice(ids ...int) IDSet { 51 | s := make(map[ID]struct{}) 52 | 53 | for _, id := range ids { 54 | s[ID(id)] = struct{}{} 55 | } 56 | 57 | return s 58 | } 59 | 60 | // Clone returns a copy of this IdSet. 61 | func (s IDSet) Clone() IDSet { 62 | return NewIDSet(s.Members()...) 63 | } 64 | 65 | // Add adds the given ids into the set. 66 | func (s IDSet) Add(ids ...ID) { 67 | for _, id := range ids { 68 | s[id] = struct{}{} 69 | } 70 | } 71 | 72 | // Del deletes the given ids from the set. 73 | func (s IDSet) Del(ids ...ID) { 74 | if s != nil { 75 | for _, id := range ids { 76 | delete(s, id) 77 | } 78 | } 79 | } 80 | 81 | // Size returns the number of ids in the set. 82 | func (s IDSet) Size() int { 83 | return len(s) 84 | } 85 | 86 | // Has tests if all the ids are present in the set. 87 | func (s IDSet) Has(ids ...ID) bool { 88 | if s == nil { 89 | return false 90 | } 91 | 92 | for _, id := range ids { 93 | _, ok := s[id] 94 | if !ok { 95 | return false 96 | } 97 | } 98 | 99 | return true 100 | } 101 | 102 | // Members returns all ids in the set as a randomly ordered slice. 103 | func (s IDSet) Members() []ID { 104 | if s == nil { 105 | return []ID{} 106 | } 107 | ids := make([]ID, len(s)) 108 | idx := 0 109 | for id := range s { 110 | ids[idx] = id 111 | idx++ 112 | } 113 | return ids 114 | } 115 | 116 | // SortedMembers returns all ids in the set as a sorted slice. 117 | func (s IDSet) SortedMembers() []ID { 118 | ids := s.Members() 119 | sort.Slice(ids, func(i, j int) bool { 120 | return ids[i] < ids[j] 121 | }) 122 | return ids 123 | } 124 | 125 | // String returns the set as a string. 126 | func (s IDSet) String() string { 127 | return s.StringWithSeparator(",") 128 | } 129 | 130 | // StringWithSeparator returns the set as a string, separated with the given separator. 131 | func (s IDSet) StringWithSeparator(args ...string) string { 132 | if len(s) == 0 { 133 | return "" 134 | } 135 | 136 | var sep string 137 | 138 | if len(args) == 1 { 139 | sep = args[0] 140 | } else { 141 | sep = "," 142 | } 143 | 144 | str := "" 145 | t := "" 146 | for _, id := range s.SortedMembers() { 147 | str = str + t + strconv.Itoa(int(id)) 148 | t = sep 149 | } 150 | 151 | return str 152 | } 153 | 154 | // MarshalJSON is the JSON marshaller for IDSet. 155 | func (s IDSet) MarshalJSON() ([]byte, error) { 156 | return json.Marshal(s.String()) 157 | } 158 | 159 | // UnmarshalJSON is the JSON unmarshaller for IDSet. 160 | func (s *IDSet) UnmarshalJSON(data []byte) error { 161 | str := "" 162 | if err := json.Unmarshal(data, &str); err != nil { 163 | return fmt.Errorf("invalid IDSet entry '%s': %v", string(data), err) 164 | } 165 | 166 | *s = NewIDSet() 167 | if str == "" { 168 | return nil 169 | } 170 | 171 | for _, idstr := range strings.Split(str, ",") { 172 | id, err := strconv.ParseInt(idstr, 10, 0) 173 | if err != nil { 174 | return fmt.Errorf("invalid IDSet entry '%s': %v", idstr, err) 175 | } 176 | s.Add(ID(id)) 177 | } 178 | 179 | return nil 180 | } 181 | -------------------------------------------------------------------------------- /pkg/utils/json.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 Intel Corporation 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package utils 18 | 19 | import ( 20 | "fmt" 21 | 22 | "sigs.k8s.io/yaml" 23 | ) 24 | 25 | // DumpJSON dumps a json-compatible struct in human-readable form 26 | func DumpJSON(r interface{}) string { 27 | out, err := yaml.Marshal(r) 28 | if err != nil { 29 | return fmt.Sprintf("!!!!!\nUnable to stringify %T: %v\n!!!!!", r, err) 30 | } 31 | return string(out) 32 | } 33 | -------------------------------------------------------------------------------- /pkg/utils/msr.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 Intel Corporation 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package utils 18 | 19 | import ( 20 | "encoding/binary" 21 | "fmt" 22 | "os" 23 | 24 | goresctrlpath "github.com/intel/goresctrl/pkg/path" 25 | ) 26 | 27 | func ReadMSR(cpu ID, msr int64) (uint64, error) { 28 | path := goresctrlpath.Path("dev/cpu", fmt.Sprintf("%d", cpu), "msr") 29 | file, err := os.Open(path) 30 | if err != nil { 31 | return 0, err 32 | } 33 | 34 | defer file.Close() 35 | 36 | // Whence is the point of reference for offset 37 | // 0 = Beginning of file 38 | // 1 = Current position 39 | // 2 = End of file 40 | var whence int = 0 41 | _, err = file.Seek(msr, whence) 42 | if err != nil { 43 | return 0, err 44 | } 45 | 46 | data := make([]byte, 8) 47 | 48 | _, err = file.Read(data) 49 | if err != nil { 50 | return 0, err 51 | } 52 | 53 | return binary.LittleEndian.Uint64(data), nil 54 | } 55 | -------------------------------------------------------------------------------- /pkg/utils/sort.go: -------------------------------------------------------------------------------- 1 | // Copyright 2020 Intel Corporation. All Rights Reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package utils 16 | 17 | import ( 18 | "sort" 19 | ) 20 | 21 | // SortUint64s sorts a slice of uint64 in increasing order. 22 | func SortUint64s(a []uint64) { 23 | sort.Sort(Uint64Slice(a)) 24 | } 25 | 26 | // Uint64Slice implmenents sort.Interface for a slice of uint64. 27 | type Uint64Slice []uint64 28 | 29 | // Len returns the length of an UintSlice 30 | func (s Uint64Slice) Len() int { return len(s) } 31 | 32 | // Less returns true if element at 'i' is less than the element at 'j' 33 | func (s Uint64Slice) Less(i, j int) bool { return s[i] < s[j] } 34 | 35 | // Swap swaps the values of two elements 36 | func (s Uint64Slice) Swap(i, j int) { s[i], s[j] = s[j], s[i] } 37 | -------------------------------------------------------------------------------- /pkg/utils/sysfs.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2022 Intel Corporation 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package utils 18 | 19 | import ( 20 | "fmt" 21 | "os" 22 | "strconv" 23 | "strings" 24 | 25 | goresctrlpath "github.com/intel/goresctrl/pkg/path" 26 | ) 27 | 28 | const ( 29 | SysfsUncoreBasepath = "sys/devices/system/cpu/intel_uncore_frequency" 30 | SysfsCpuBasepath = "sys/devices/system/cpu" 31 | ) 32 | 33 | func setCPUFreqValue(cpu ID, setting string, value int) error { 34 | return writeFileInt(cpuFreqPath(cpu, setting), value) 35 | } 36 | 37 | func SetCPUScalingGovernor(cpu ID, governor string) error { 38 | return writeFileStr(cpuFreqPath(cpu, "scaling_governor"), governor) 39 | } 40 | 41 | // GetCPUFreqValue returns information of the currently used CPU frequency 42 | func GetCPUFreqValue(cpu ID, setting string) (int, error) { 43 | raw, err := os.ReadFile(cpuFreqPath(cpu, setting)) 44 | if err != nil { 45 | return 0, err 46 | } 47 | 48 | value, err := strconv.Atoi(strings.TrimSpace(string(raw))) 49 | if err != nil { 50 | return 0, err 51 | } 52 | 53 | return value, nil 54 | } 55 | 56 | func cpuFreqPath(cpu ID, setting string) string { 57 | return goresctrlpath.Path(SysfsCpuBasepath, fmt.Sprintf("cpu%d", cpu), "cpufreq", setting) 58 | } 59 | 60 | // SetCPUScalingMinFreq sets the scaling_min_freq value of a given CPU 61 | func SetCPUScalingMinFreq(cpu ID, freq int) error { 62 | return setCPUFreqValue(cpu, "scaling_min_freq", freq) 63 | } 64 | 65 | // SetCPUScalingMaxFreq sets the scaling_max_freq value of a given CPU 66 | func SetCPUScalingMaxFreq(cpu ID, freq int) error { 67 | return setCPUFreqValue(cpu, "scaling_max_freq", freq) 68 | } 69 | 70 | // SetScalingGovernorForCPUs sets the scaling_governor of a given set of CPUs 71 | func SetScalingGovernorForCPUs(cpus []ID, governor string) error { 72 | for _, cpu := range cpus { 73 | if err := SetCPUScalingGovernor(cpu, governor); err != nil { 74 | return err 75 | } 76 | } 77 | 78 | return nil 79 | } 80 | 81 | // SetCPUsScalingMinFreq sets the scaling_min_freq value of a given set of CPUs 82 | func SetCPUsScalingMinFreq(cpus []ID, freq int) error { 83 | for _, cpu := range cpus { 84 | if err := SetCPUScalingMinFreq(cpu, freq); err != nil { 85 | return err 86 | } 87 | } 88 | 89 | return nil 90 | } 91 | 92 | // SetCPUsScalingMaxFreq sets the scaling_max_freq value of a given set of CPUs 93 | func SetCPUsScalingMaxFreq(cpus []ID, freq int) error { 94 | for _, cpu := range cpus { 95 | if err := SetCPUScalingMaxFreq(cpu, freq); err != nil { 96 | return err 97 | } 98 | } 99 | 100 | return nil 101 | } 102 | 103 | // UncoreFreqAvailable returns true if the uncore frequency control functions are available. 104 | func UncoreFreqAvailable() bool { 105 | _, err := os.Stat(goresctrlpath.Path(SysfsUncoreBasepath)) 106 | return err == nil 107 | } 108 | 109 | // SetUncoreMinFreq sets the minimum uncore frequency of a CPU die. Frequency is specified in kHz. 110 | func SetUncoreMinFreq(pkg, die ID, freqKhz int) error { 111 | return setUncoreFreqValue(pkg, die, "min_freq_khz", freqKhz) 112 | } 113 | 114 | // SetUncoreMaxFreq sets the maximum uncore frequency of a CPU die. Frequency is specified in kHz. 115 | func SetUncoreMaxFreq(pkg, die ID, freqKhz int) error { 116 | return setUncoreFreqValue(pkg, die, "max_freq_khz", freqKhz) 117 | } 118 | 119 | func uncoreFreqPath(pkg, die ID, attribute string) string { 120 | return goresctrlpath.Path(SysfsUncoreBasepath, fmt.Sprintf("package_%02d_die_%02d", pkg, die), attribute) 121 | } 122 | 123 | func getUncoreFreqValue(pkg, die ID, attribute string) (int, error) { 124 | return readFileInt(uncoreFreqPath(pkg, die, attribute)) 125 | } 126 | 127 | func setUncoreFreqValue(pkg, die ID, attribute string, value int) error { 128 | // Bounds checking 129 | if hwMinFreq, err := getUncoreFreqValue(pkg, die, "initial_min_freq_khz"); err != nil { 130 | return err 131 | } else if value < hwMinFreq { 132 | value = hwMinFreq 133 | } 134 | if hwMaxFreq, err := getUncoreFreqValue(pkg, die, "initial_max_freq_khz"); err != nil { 135 | return err 136 | } else if value > hwMaxFreq { 137 | value = hwMaxFreq 138 | } 139 | 140 | return writeFileInt(uncoreFreqPath(pkg, die, attribute), value) 141 | } 142 | 143 | func writeFileInt(path string, value int) error { 144 | return os.WriteFile(path, []byte(strconv.Itoa(value)), 0644) 145 | } 146 | 147 | func writeFileStr(path string, value string) error { 148 | return os.WriteFile(path, []byte(value), 0644) 149 | } 150 | 151 | func readFileInt(path string) (int, error) { 152 | data, err := os.ReadFile(path) 153 | if err != nil { 154 | return 0, err 155 | } 156 | i, err := strconv.ParseInt(strings.TrimSpace(string(data)), 10, 32) 157 | return int(i), err 158 | } 159 | -------------------------------------------------------------------------------- /security.md: -------------------------------------------------------------------------------- 1 | # Security Policy 2 | 3 | Intel is committed to rapidly addressing security vulnerabilities affecting our 4 | customers and providing clear guidance on the solution, impact, severity and 5 | mitigation. 6 | 7 | ## Reporting a Vulnerability 8 | 9 | Please report any security vulnerabilities in this project 10 | [utilizing the guidelines here](https://www.intel.com/content/www/us/en/security-center/vulnerability-handling-guidelines.html). 11 | -------------------------------------------------------------------------------- /test/data/rdt.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020 Intel Corporation 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package rdtdata 18 | 19 | import ( 20 | "path/filepath" 21 | "runtime" 22 | ) 23 | 24 | var thisDir []string 25 | 26 | func init() { 27 | _, this, _, _ := runtime.Caller(0) 28 | thisDir = []string{filepath.Dir(this)} 29 | } 30 | 31 | // Path returns an absolute path to test data 32 | func Path(elem ...string) string { 33 | return filepath.Join(append(thisDir, elem...)...) 34 | } 35 | -------------------------------------------------------------------------------- /test/data/resctrl.full/Guaranteed/cpus: -------------------------------------------------------------------------------- 1 | 00000000,00000000,00000000,00000000,00000000,00000000 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/Guaranteed/cpus_list: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/Guaranteed/mode: -------------------------------------------------------------------------------- 1 | shareable 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/Guaranteed/mon_data/mon_L3_00/llc_occupancy: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/Guaranteed/mon_data/mon_L3_00/mbm_local_bytes: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/Guaranteed/mon_data/mon_L3_00/mbm_total_bytes: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/Guaranteed/mon_data/mon_L3_01/llc_occupancy: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/Guaranteed/mon_data/mon_L3_01/mbm_local_bytes: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/Guaranteed/mon_data/mon_L3_01/mbm_total_bytes: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/Guaranteed/mon_data/mon_L3_02/llc_occupancy: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/Guaranteed/mon_data/mon_L3_02/mbm_local_bytes: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/Guaranteed/mon_data/mon_L3_02/mbm_total_bytes: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/Guaranteed/mon_data/mon_L3_03/llc_occupancy: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/Guaranteed/mon_data/mon_L3_03/mbm_local_bytes: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/Guaranteed/mon_data/mon_L3_03/mbm_total_bytes: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/Guaranteed/mon_groups/non_goresctrl.group/cpus: -------------------------------------------------------------------------------- 1 | 00000000,00000000,00000000,00000000,00000000,00000000 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/Guaranteed/mon_groups/non_goresctrl.group/cpus_list: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/Guaranteed/mon_groups/non_goresctrl.group/mon_data/mon_L3_00/llc_occupancy: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/Guaranteed/mon_groups/non_goresctrl.group/mon_data/mon_L3_00/mbm_local_bytes: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/Guaranteed/mon_groups/non_goresctrl.group/mon_data/mon_L3_00/mbm_total_bytes: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/Guaranteed/mon_groups/non_goresctrl.group/mon_data/mon_L3_01/llc_occupancy: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/Guaranteed/mon_groups/non_goresctrl.group/mon_data/mon_L3_01/mbm_local_bytes: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/Guaranteed/mon_groups/non_goresctrl.group/mon_data/mon_L3_01/mbm_total_bytes: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/Guaranteed/mon_groups/non_goresctrl.group/mon_data/mon_L3_02/llc_occupancy: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/Guaranteed/mon_groups/non_goresctrl.group/mon_data/mon_L3_02/mbm_local_bytes: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/Guaranteed/mon_groups/non_goresctrl.group/mon_data/mon_L3_02/mbm_total_bytes: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/Guaranteed/mon_groups/non_goresctrl.group/mon_data/mon_L3_03/llc_occupancy: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/Guaranteed/mon_groups/non_goresctrl.group/mon_data/mon_L3_03/mbm_local_bytes: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/Guaranteed/mon_groups/non_goresctrl.group/mon_data/mon_L3_03/mbm_total_bytes: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/Guaranteed/mon_groups/non_goresctrl.group/tasks: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/intel/goresctrl/f7cfa04536314eacecaa523f3b87d3978fbe28e3/test/data/resctrl.full/Guaranteed/mon_groups/non_goresctrl.group/tasks -------------------------------------------------------------------------------- /test/data/resctrl.full/Guaranteed/schemata: -------------------------------------------------------------------------------- 1 | L3:0=fffff;1=fffff;2=fffff;3=fffff 2 | MB:0=100;1=100;2=100;3=100 3 | -------------------------------------------------------------------------------- /test/data/resctrl.full/Guaranteed/size: -------------------------------------------------------------------------------- 1 | L3:0=57671680;1=57671680;2=57671680;3=57671680 2 | MB:0=100;1=100;2=100;3=100 3 | -------------------------------------------------------------------------------- /test/data/resctrl.full/Guaranteed/tasks: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/intel/goresctrl/f7cfa04536314eacecaa523f3b87d3978fbe28e3/test/data/resctrl.full/Guaranteed/tasks -------------------------------------------------------------------------------- /test/data/resctrl.full/cpus: -------------------------------------------------------------------------------- 1 | ffffffff,ffffffff,ffffffff,ffffffff,ffffffff,ffffffff 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/cpus_list: -------------------------------------------------------------------------------- 1 | 0-191 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/goresctrl.Guaranteed/cpus: -------------------------------------------------------------------------------- 1 | 00000000,00000000,00000000,00000000,00000000,00000000 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/goresctrl.Guaranteed/cpus_list: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/goresctrl.Guaranteed/mode: -------------------------------------------------------------------------------- 1 | shareable 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/goresctrl.Guaranteed/mon_data/mon_L3_00/llc_occupancy: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/goresctrl.Guaranteed/mon_data/mon_L3_00/mbm_local_bytes: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/goresctrl.Guaranteed/mon_data/mon_L3_00/mbm_total_bytes: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/goresctrl.Guaranteed/mon_data/mon_L3_01/llc_occupancy: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/goresctrl.Guaranteed/mon_data/mon_L3_01/mbm_local_bytes: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/goresctrl.Guaranteed/mon_data/mon_L3_01/mbm_total_bytes: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/goresctrl.Guaranteed/mon_data/mon_L3_02/llc_occupancy: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/goresctrl.Guaranteed/mon_data/mon_L3_02/mbm_local_bytes: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/goresctrl.Guaranteed/mon_data/mon_L3_02/mbm_total_bytes: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/goresctrl.Guaranteed/mon_data/mon_L3_03/llc_occupancy: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/goresctrl.Guaranteed/mon_data/mon_L3_03/mbm_local_bytes: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/goresctrl.Guaranteed/mon_data/mon_L3_03/mbm_total_bytes: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/goresctrl.Guaranteed/mon_groups/goresctrl.predefined_group_empty/cpus: -------------------------------------------------------------------------------- 1 | 00000000,00000000,00000000,00000000,00000000,00000000 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/goresctrl.Guaranteed/mon_groups/goresctrl.predefined_group_empty/cpus_list: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/goresctrl.Guaranteed/mon_groups/goresctrl.predefined_group_empty/mon_data/mon_L3_00/llc_occupancy: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/goresctrl.Guaranteed/mon_groups/goresctrl.predefined_group_empty/mon_data/mon_L3_00/mbm_local_bytes: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/goresctrl.Guaranteed/mon_groups/goresctrl.predefined_group_empty/mon_data/mon_L3_00/mbm_total_bytes: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/goresctrl.Guaranteed/mon_groups/goresctrl.predefined_group_empty/mon_data/mon_L3_01/llc_occupancy: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/goresctrl.Guaranteed/mon_groups/goresctrl.predefined_group_empty/mon_data/mon_L3_01/mbm_local_bytes: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/goresctrl.Guaranteed/mon_groups/goresctrl.predefined_group_empty/mon_data/mon_L3_01/mbm_total_bytes: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/goresctrl.Guaranteed/mon_groups/goresctrl.predefined_group_empty/mon_data/mon_L3_02/llc_occupancy: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/goresctrl.Guaranteed/mon_groups/goresctrl.predefined_group_empty/mon_data/mon_L3_02/mbm_local_bytes: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/goresctrl.Guaranteed/mon_groups/goresctrl.predefined_group_empty/mon_data/mon_L3_02/mbm_total_bytes: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/goresctrl.Guaranteed/mon_groups/goresctrl.predefined_group_empty/mon_data/mon_L3_03/llc_occupancy: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/goresctrl.Guaranteed/mon_groups/goresctrl.predefined_group_empty/mon_data/mon_L3_03/mbm_local_bytes: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/goresctrl.Guaranteed/mon_groups/goresctrl.predefined_group_empty/mon_data/mon_L3_03/mbm_total_bytes: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/goresctrl.Guaranteed/mon_groups/goresctrl.predefined_group_empty/tasks: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/intel/goresctrl/f7cfa04536314eacecaa523f3b87d3978fbe28e3/test/data/resctrl.full/goresctrl.Guaranteed/mon_groups/goresctrl.predefined_group_empty/tasks -------------------------------------------------------------------------------- /test/data/resctrl.full/goresctrl.Guaranteed/mon_groups/goresctrl.predefined_group_live/cpus: -------------------------------------------------------------------------------- 1 | 00000000,00000000,00000000,00000000,00000000,00000000 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/goresctrl.Guaranteed/mon_groups/goresctrl.predefined_group_live/cpus_list: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/goresctrl.Guaranteed/mon_groups/goresctrl.predefined_group_live/mon_data/mon_L3_00/llc_occupancy: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/goresctrl.Guaranteed/mon_groups/goresctrl.predefined_group_live/mon_data/mon_L3_00/mbm_local_bytes: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/goresctrl.Guaranteed/mon_groups/goresctrl.predefined_group_live/mon_data/mon_L3_00/mbm_total_bytes: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/goresctrl.Guaranteed/mon_groups/goresctrl.predefined_group_live/mon_data/mon_L3_01/llc_occupancy: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/goresctrl.Guaranteed/mon_groups/goresctrl.predefined_group_live/mon_data/mon_L3_01/mbm_local_bytes: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/goresctrl.Guaranteed/mon_groups/goresctrl.predefined_group_live/mon_data/mon_L3_01/mbm_total_bytes: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/goresctrl.Guaranteed/mon_groups/goresctrl.predefined_group_live/mon_data/mon_L3_02/llc_occupancy: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/goresctrl.Guaranteed/mon_groups/goresctrl.predefined_group_live/mon_data/mon_L3_02/mbm_local_bytes: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/goresctrl.Guaranteed/mon_groups/goresctrl.predefined_group_live/mon_data/mon_L3_02/mbm_total_bytes: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/goresctrl.Guaranteed/mon_groups/goresctrl.predefined_group_live/mon_data/mon_L3_03/llc_occupancy: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/goresctrl.Guaranteed/mon_groups/goresctrl.predefined_group_live/mon_data/mon_L3_03/mbm_local_bytes: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/goresctrl.Guaranteed/mon_groups/goresctrl.predefined_group_live/mon_data/mon_L3_03/mbm_total_bytes: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/goresctrl.Guaranteed/mon_groups/goresctrl.predefined_group_live/tasks: -------------------------------------------------------------------------------- 1 | 100 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/goresctrl.Guaranteed/mon_groups/non_goresctrl.group/cpus: -------------------------------------------------------------------------------- 1 | 00000000,00000000,00000000,00000000,00000000,00000000 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/goresctrl.Guaranteed/mon_groups/non_goresctrl.group/cpus_list: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/goresctrl.Guaranteed/mon_groups/non_goresctrl.group/mon_data/mon_L3_00/llc_occupancy: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/goresctrl.Guaranteed/mon_groups/non_goresctrl.group/mon_data/mon_L3_00/mbm_local_bytes: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/goresctrl.Guaranteed/mon_groups/non_goresctrl.group/mon_data/mon_L3_00/mbm_total_bytes: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/goresctrl.Guaranteed/mon_groups/non_goresctrl.group/mon_data/mon_L3_01/llc_occupancy: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/goresctrl.Guaranteed/mon_groups/non_goresctrl.group/mon_data/mon_L3_01/mbm_local_bytes: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/goresctrl.Guaranteed/mon_groups/non_goresctrl.group/mon_data/mon_L3_01/mbm_total_bytes: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/goresctrl.Guaranteed/mon_groups/non_goresctrl.group/mon_data/mon_L3_02/llc_occupancy: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/goresctrl.Guaranteed/mon_groups/non_goresctrl.group/mon_data/mon_L3_02/mbm_local_bytes: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/goresctrl.Guaranteed/mon_groups/non_goresctrl.group/mon_data/mon_L3_02/mbm_total_bytes: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/goresctrl.Guaranteed/mon_groups/non_goresctrl.group/mon_data/mon_L3_03/llc_occupancy: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/goresctrl.Guaranteed/mon_groups/non_goresctrl.group/mon_data/mon_L3_03/mbm_local_bytes: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/goresctrl.Guaranteed/mon_groups/non_goresctrl.group/mon_data/mon_L3_03/mbm_total_bytes: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/goresctrl.Guaranteed/mon_groups/non_goresctrl.group/tasks: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/intel/goresctrl/f7cfa04536314eacecaa523f3b87d3978fbe28e3/test/data/resctrl.full/goresctrl.Guaranteed/mon_groups/non_goresctrl.group/tasks -------------------------------------------------------------------------------- /test/data/resctrl.full/goresctrl.Guaranteed/schemata: -------------------------------------------------------------------------------- 1 | L3:0=fffff;1=fffff;2=fffff;3=fffff 2 | MB:0=100;1=100;2=100;3=100 3 | -------------------------------------------------------------------------------- /test/data/resctrl.full/goresctrl.Guaranteed/size: -------------------------------------------------------------------------------- 1 | L3:0=57671680;1=57671680;2=57671680;3=57671680 2 | MB:0=100;1=100;2=100;3=100 3 | -------------------------------------------------------------------------------- /test/data/resctrl.full/goresctrl.Guaranteed/tasks: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/intel/goresctrl/f7cfa04536314eacecaa523f3b87d3978fbe28e3/test/data/resctrl.full/goresctrl.Guaranteed/tasks -------------------------------------------------------------------------------- /test/data/resctrl.full/goresctrl.Stale/cpus: -------------------------------------------------------------------------------- 1 | 00000000,00000000,00000000,00000000,00000000,00000000 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/goresctrl.Stale/cpus_list: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/goresctrl.Stale/mode: -------------------------------------------------------------------------------- 1 | shareable 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/goresctrl.Stale/mon_data/mon_L3_00/llc_occupancy: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/goresctrl.Stale/mon_data/mon_L3_00/mbm_local_bytes: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/goresctrl.Stale/mon_data/mon_L3_00/mbm_total_bytes: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/goresctrl.Stale/mon_data/mon_L3_01/llc_occupancy: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/goresctrl.Stale/mon_data/mon_L3_01/mbm_local_bytes: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/goresctrl.Stale/mon_data/mon_L3_01/mbm_total_bytes: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/goresctrl.Stale/mon_data/mon_L3_02/llc_occupancy: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/goresctrl.Stale/mon_data/mon_L3_02/mbm_local_bytes: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/goresctrl.Stale/mon_data/mon_L3_02/mbm_total_bytes: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/goresctrl.Stale/mon_data/mon_L3_03/llc_occupancy: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/goresctrl.Stale/mon_data/mon_L3_03/mbm_local_bytes: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/goresctrl.Stale/mon_data/mon_L3_03/mbm_total_bytes: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/goresctrl.Stale/mon_groups/non_goresctrl.group/cpus: -------------------------------------------------------------------------------- 1 | 00000000,00000000,00000000,00000000,00000000,00000000 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/goresctrl.Stale/mon_groups/non_goresctrl.group/cpus_list: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/goresctrl.Stale/mon_groups/non_goresctrl.group/mon_data/mon_L3_00/llc_occupancy: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/goresctrl.Stale/mon_groups/non_goresctrl.group/mon_data/mon_L3_00/mbm_local_bytes: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/goresctrl.Stale/mon_groups/non_goresctrl.group/mon_data/mon_L3_00/mbm_total_bytes: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/goresctrl.Stale/mon_groups/non_goresctrl.group/mon_data/mon_L3_01/llc_occupancy: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/goresctrl.Stale/mon_groups/non_goresctrl.group/mon_data/mon_L3_01/mbm_local_bytes: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/goresctrl.Stale/mon_groups/non_goresctrl.group/mon_data/mon_L3_01/mbm_total_bytes: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/goresctrl.Stale/mon_groups/non_goresctrl.group/mon_data/mon_L3_02/llc_occupancy: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/goresctrl.Stale/mon_groups/non_goresctrl.group/mon_data/mon_L3_02/mbm_local_bytes: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/goresctrl.Stale/mon_groups/non_goresctrl.group/mon_data/mon_L3_02/mbm_total_bytes: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/goresctrl.Stale/mon_groups/non_goresctrl.group/mon_data/mon_L3_03/llc_occupancy: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/goresctrl.Stale/mon_groups/non_goresctrl.group/mon_data/mon_L3_03/mbm_local_bytes: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/goresctrl.Stale/mon_groups/non_goresctrl.group/mon_data/mon_L3_03/mbm_total_bytes: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/goresctrl.Stale/mon_groups/non_goresctrl.group/tasks: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/intel/goresctrl/f7cfa04536314eacecaa523f3b87d3978fbe28e3/test/data/resctrl.full/goresctrl.Stale/mon_groups/non_goresctrl.group/tasks -------------------------------------------------------------------------------- /test/data/resctrl.full/goresctrl.Stale/schemata: -------------------------------------------------------------------------------- 1 | L3:0=fffff;1=fffff;2=fffff;3=fffff 2 | MB:0=100;1=100;2=100;3=100 3 | -------------------------------------------------------------------------------- /test/data/resctrl.full/goresctrl.Stale/size: -------------------------------------------------------------------------------- 1 | L3:0=57671680;1=57671680;2=57671680;3=57671680 2 | MB:0=100;1=100;2=100;3=100 3 | -------------------------------------------------------------------------------- /test/data/resctrl.full/goresctrl.Stale/tasks: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/intel/goresctrl/f7cfa04536314eacecaa523f3b87d3978fbe28e3/test/data/resctrl.full/goresctrl.Stale/tasks -------------------------------------------------------------------------------- /test/data/resctrl.full/info/L3/bit_usage: -------------------------------------------------------------------------------- 1 | 0=XXSSSSSSSSSSSSSSSSSS;1=XXSSSSSSSSSSSSSSSSSS;2=XXSSSSSSSSSSSSSSSSSS;3=XXSSSSSSSSSSSSSSSSSS 2 | 3 | -------------------------------------------------------------------------------- /test/data/resctrl.full/info/L3/cbm_mask: -------------------------------------------------------------------------------- 1 | fffff 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/info/L3/min_cbm_bits: -------------------------------------------------------------------------------- 1 | 1 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/info/L3/num_closids: -------------------------------------------------------------------------------- 1 | 16 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/info/L3/shareable_bits: -------------------------------------------------------------------------------- 1 | c0000 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/info/L3_MON/max_threshold_occupancy: -------------------------------------------------------------------------------- 1 | 98304 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/info/L3_MON/mon_features: -------------------------------------------------------------------------------- 1 | llc_occupancy 2 | mbm_total_bytes 3 | mbm_local_bytes 4 | -------------------------------------------------------------------------------- /test/data/resctrl.full/info/L3_MON/num_rmids: -------------------------------------------------------------------------------- 1 | 192 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/info/MB/bandwidth_gran: -------------------------------------------------------------------------------- 1 | 10 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/info/MB/delay_linear: -------------------------------------------------------------------------------- 1 | 1 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/info/MB/min_bandwidth: -------------------------------------------------------------------------------- 1 | 10 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/info/MB/num_closids: -------------------------------------------------------------------------------- 1 | 8 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/info/last_cmd_status: -------------------------------------------------------------------------------- 1 | ok 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/mode: -------------------------------------------------------------------------------- 1 | shareable 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/mon_data/mon_L3_00/llc_occupancy: -------------------------------------------------------------------------------- 1 | 32440320 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/mon_data/mon_L3_00/mbm_local_bytes: -------------------------------------------------------------------------------- 1 | 48365568 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/mon_data/mon_L3_00/mbm_total_bytes: -------------------------------------------------------------------------------- 1 | 264830976 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/mon_data/mon_L3_01/llc_occupancy: -------------------------------------------------------------------------------- 1 | 28901376 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/mon_data/mon_L3_01/mbm_local_bytes: -------------------------------------------------------------------------------- 1 | 3342336 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/mon_data/mon_L3_01/mbm_total_bytes: -------------------------------------------------------------------------------- 1 | 208404480 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/mon_data/mon_L3_02/llc_occupancy: -------------------------------------------------------------------------------- 1 | 34406400 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/mon_data/mon_L3_02/mbm_local_bytes: -------------------------------------------------------------------------------- 1 | 603881472 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/mon_data/mon_L3_02/mbm_total_bytes: -------------------------------------------------------------------------------- 1 | 974782464 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/mon_data/mon_L3_03/llc_occupancy: -------------------------------------------------------------------------------- 1 | 31260672 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/mon_data/mon_L3_03/mbm_local_bytes: -------------------------------------------------------------------------------- 1 | 693239808 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/mon_data/mon_L3_03/mbm_total_bytes: -------------------------------------------------------------------------------- 1 | 760479744 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/mon_groups/example/cpus: -------------------------------------------------------------------------------- 1 | 00000000,00000000,00000000,00000000,00000000,00000000 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/mon_groups/example/cpus_list: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/mon_groups/example/mon_data/mon_L3_00/llc_occupancy: -------------------------------------------------------------------------------- 1 | 1 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/mon_groups/example/mon_data/mon_L3_00/mbm_local_bytes: -------------------------------------------------------------------------------- 1 | 2 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/mon_groups/example/mon_data/mon_L3_00/mbm_total_bytes: -------------------------------------------------------------------------------- 1 | 3 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/mon_groups/example/mon_data/mon_L3_01/llc_occupancy: -------------------------------------------------------------------------------- 1 | 11 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/mon_groups/example/mon_data/mon_L3_01/mbm_local_bytes: -------------------------------------------------------------------------------- 1 | 12 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/mon_groups/example/mon_data/mon_L3_01/mbm_total_bytes: -------------------------------------------------------------------------------- 1 | 13 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/mon_groups/example/mon_data/mon_L3_02/llc_occupancy: -------------------------------------------------------------------------------- 1 | 21 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/mon_groups/example/mon_data/mon_L3_02/mbm_local_bytes: -------------------------------------------------------------------------------- 1 | 22 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/mon_groups/example/mon_data/mon_L3_02/mbm_total_bytes: -------------------------------------------------------------------------------- 1 | 23 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/mon_groups/example/mon_data/mon_L3_03/llc_occupancy: -------------------------------------------------------------------------------- 1 | 31 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/mon_groups/example/mon_data/mon_L3_03/mbm_local_bytes: -------------------------------------------------------------------------------- 1 | 32 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/mon_groups/example/mon_data/mon_L3_03/mbm_total_bytes: -------------------------------------------------------------------------------- 1 | 33 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/mon_groups/example/tasks: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/mon_groups/non_goresctrl.group/cpus: -------------------------------------------------------------------------------- 1 | 00000000,00000000,00000000,00000000,00000000,00000000 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/mon_groups/non_goresctrl.group/cpus_list: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/mon_groups/non_goresctrl.group/mon_data/mon_L3_00/llc_occupancy: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/mon_groups/non_goresctrl.group/mon_data/mon_L3_00/mbm_local_bytes: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/mon_groups/non_goresctrl.group/mon_data/mon_L3_00/mbm_total_bytes: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/mon_groups/non_goresctrl.group/mon_data/mon_L3_01/llc_occupancy: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/mon_groups/non_goresctrl.group/mon_data/mon_L3_01/mbm_local_bytes: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/mon_groups/non_goresctrl.group/mon_data/mon_L3_01/mbm_total_bytes: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/mon_groups/non_goresctrl.group/mon_data/mon_L3_02/llc_occupancy: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/mon_groups/non_goresctrl.group/mon_data/mon_L3_02/mbm_local_bytes: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/mon_groups/non_goresctrl.group/mon_data/mon_L3_02/mbm_total_bytes: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/mon_groups/non_goresctrl.group/mon_data/mon_L3_03/llc_occupancy: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/mon_groups/non_goresctrl.group/mon_data/mon_L3_03/mbm_local_bytes: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/mon_groups/non_goresctrl.group/mon_data/mon_L3_03/mbm_total_bytes: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/mon_groups/non_goresctrl.group/tasks: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/intel/goresctrl/f7cfa04536314eacecaa523f3b87d3978fbe28e3/test/data/resctrl.full/mon_groups/non_goresctrl.group/tasks -------------------------------------------------------------------------------- /test/data/resctrl.full/non_goresctrl.Group/cpus: -------------------------------------------------------------------------------- 1 | 00000000,00000000,00000000,00000000,00000000,00000000 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/non_goresctrl.Group/cpus_list: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/non_goresctrl.Group/mode: -------------------------------------------------------------------------------- 1 | shareable 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/non_goresctrl.Group/mon_data/mon_L3_00/llc_occupancy: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/non_goresctrl.Group/mon_data/mon_L3_00/mbm_local_bytes: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/non_goresctrl.Group/mon_data/mon_L3_00/mbm_total_bytes: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/non_goresctrl.Group/mon_data/mon_L3_01/llc_occupancy: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/non_goresctrl.Group/mon_data/mon_L3_01/mbm_local_bytes: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/non_goresctrl.Group/mon_data/mon_L3_01/mbm_total_bytes: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/non_goresctrl.Group/mon_data/mon_L3_02/llc_occupancy: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/non_goresctrl.Group/mon_data/mon_L3_02/mbm_local_bytes: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/non_goresctrl.Group/mon_data/mon_L3_02/mbm_total_bytes: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/non_goresctrl.Group/mon_data/mon_L3_03/llc_occupancy: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/non_goresctrl.Group/mon_data/mon_L3_03/mbm_local_bytes: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/non_goresctrl.Group/mon_data/mon_L3_03/mbm_total_bytes: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /test/data/resctrl.full/non_goresctrl.Group/schemata: -------------------------------------------------------------------------------- 1 | L3:0=fffff;1=fffff;2=fffff;3=fffff 2 | MB:0=100;1=100;2=100;3=100 3 | -------------------------------------------------------------------------------- /test/data/resctrl.full/non_goresctrl.Group/size: -------------------------------------------------------------------------------- 1 | L3:0=57671680;1=57671680;2=57671680;3=57671680 2 | MB:0=100;1=100;2=100;3=100 3 | -------------------------------------------------------------------------------- /test/data/resctrl.full/non_goresctrl.Group/tasks: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/intel/goresctrl/f7cfa04536314eacecaa523f3b87d3978fbe28e3/test/data/resctrl.full/non_goresctrl.Group/tasks -------------------------------------------------------------------------------- /test/data/resctrl.full/schemata: -------------------------------------------------------------------------------- 1 | L3:0=fffff;1=fffff;2=fffff;3=fffff 2 | MB:0=100;1=100;2=100;3=100 3 | -------------------------------------------------------------------------------- /test/data/resctrl.full/size: -------------------------------------------------------------------------------- 1 | L3:0=57671680;1=57671680;2=57671680;3=57671680 2 | MB:0=100;1=100;2=100;3=100 3 | -------------------------------------------------------------------------------- /test/data/resctrl.full/tasks: -------------------------------------------------------------------------------- 1 | 1 2 | 2 3 | 3 4 | 4 5 | 6 6 | 8 7 | 10 8 | 11 9 | 12 10 | 13 11 | 14 12 | 15 13 | 16 14 | 17 15 | 19 16 | 20 17 | 21 18 | 22 19 | 23 20 | 24 21 | 25 22 | 26 23 | 27 24 | 28 25 | 29 26 | 30 27 | 31 28 | 32 29 | 33 30 | 34 31 | 35 32 | 36 33 | 37 34 | 38 35 | 39 36 | 40 37 | 41 38 | 42 39 | 43 40 | 44 41 | 45 42 | 46 43 | 47 44 | 49 45 | 50 46 | 51 47 | 52 48 | 53 49 | 54 50 | 55 51 | 56 52 | 57 53 | 58 54 | 59 55 | 60 56 | 61 57 | 62 58 | 64 59 | 65 60 | 66 61 | 67 62 | 68 63 | 69 64 | 70 65 | 71 66 | 72 67 | 73 68 | 74 69 | 75 70 | 76 71 | 77 72 | 78 73 | 79 74 | 80 75 | 81 76 | 82 77 | 83 78 | 84 79 | 85 80 | 86 81 | 87 82 | 88 83 | 89 84 | 90 85 | 91 86 | 92 87 | 93 88 | 94 89 | 95 90 | 96 91 | 97 92 | 99 93 | -------------------------------------------------------------------------------- /test/data/resctrl.l2/cpus: -------------------------------------------------------------------------------- 1 | f 2 | -------------------------------------------------------------------------------- /test/data/resctrl.l2/cpus_list: -------------------------------------------------------------------------------- 1 | 0-3 2 | -------------------------------------------------------------------------------- /test/data/resctrl.l2/info/L2/bit_usage: -------------------------------------------------------------------------------- 1 | 0=SSSSSSSS;1=SSSSSSSS 2 | -------------------------------------------------------------------------------- /test/data/resctrl.l2/info/L2/cbm_mask: -------------------------------------------------------------------------------- 1 | ff 2 | -------------------------------------------------------------------------------- /test/data/resctrl.l2/info/L2/min_cbm_bits: -------------------------------------------------------------------------------- 1 | 1 2 | -------------------------------------------------------------------------------- /test/data/resctrl.l2/info/L2/num_closids: -------------------------------------------------------------------------------- 1 | 4 2 | -------------------------------------------------------------------------------- /test/data/resctrl.l2/info/L2/shareable_bits: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /test/data/resctrl.l2/info/last_cmd_status: -------------------------------------------------------------------------------- 1 | ok 2 | -------------------------------------------------------------------------------- /test/data/resctrl.l2/mode: -------------------------------------------------------------------------------- 1 | shareable 2 | -------------------------------------------------------------------------------- /test/data/resctrl.l2/schemata: -------------------------------------------------------------------------------- 1 | L2:0=ff;1=ff 2 | -------------------------------------------------------------------------------- /test/data/resctrl.l2/size: -------------------------------------------------------------------------------- 1 | L2:0=1048576;1=1048576 2 | -------------------------------------------------------------------------------- /test/data/resctrl.l2/tasks: -------------------------------------------------------------------------------- 1 | 1 2 | 2 3 | 3 4 | 4 5 | 6 6 | 8 7 | 10 8 | 11 9 | 12 10 | 13 11 | 14 12 | 15 13 | 16 14 | 17 15 | 19 16 | 20 17 | 21 18 | 22 19 | 23 20 | 24 21 | 25 22 | 26 23 | 27 24 | 28 25 | 29 26 | 30 27 | 31 28 | 32 29 | 33 30 | 34 31 | 35 32 | 36 33 | 37 34 | 38 35 | 39 36 | 40 37 | 41 38 | 42 39 | 43 40 | 44 41 | 45 42 | 46 43 | 47 44 | 49 45 | 50 46 | 51 47 | 52 48 | 53 49 | 54 50 | 55 51 | 56 52 | 57 53 | 58 54 | 59 55 | 60 56 | 61 57 | 62 58 | 64 59 | 65 60 | 66 61 | 67 62 | 68 63 | 69 64 | 70 65 | 71 66 | 72 67 | 73 68 | 74 69 | 75 70 | 76 71 | 77 72 | 78 73 | 79 74 | 80 75 | 81 76 | 82 77 | 83 78 | 84 79 | 85 80 | 86 81 | 87 82 | 88 83 | 89 84 | 90 85 | 91 86 | 92 87 | 93 88 | 94 89 | 95 90 | 96 91 | 97 92 | 99 93 | -------------------------------------------------------------------------------- /test/data/resctrl.l2cdp/cpus: -------------------------------------------------------------------------------- 1 | ff 2 | -------------------------------------------------------------------------------- /test/data/resctrl.l2cdp/cpus_list: -------------------------------------------------------------------------------- 1 | 0-7 2 | -------------------------------------------------------------------------------- /test/data/resctrl.l2cdp/info/L2CODE/bit_usage: -------------------------------------------------------------------------------- 1 | 0=SSSSSSSSSSSSSSSSSSSS;1=SSSSSSSSSSSSSSSSSSSS;2=SSSSSSSSSSSSSSSSSSSS;3=SSSSSSSSSSSSSSSSSSSS 2 | -------------------------------------------------------------------------------- /test/data/resctrl.l2cdp/info/L2CODE/cbm_mask: -------------------------------------------------------------------------------- 1 | fffff 2 | -------------------------------------------------------------------------------- /test/data/resctrl.l2cdp/info/L2CODE/min_cbm_bits: -------------------------------------------------------------------------------- 1 | 1 2 | -------------------------------------------------------------------------------- /test/data/resctrl.l2cdp/info/L2CODE/num_closids: -------------------------------------------------------------------------------- 1 | 4 2 | -------------------------------------------------------------------------------- /test/data/resctrl.l2cdp/info/L2CODE/shareable_bits: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /test/data/resctrl.l2cdp/info/L2DATA/bit_usage: -------------------------------------------------------------------------------- 1 | 0=SSSSSSSSSSSSSSSSSSSS;1=SSSSSSSSSSSSSSSSSSSS;2=SSSSSSSSSSSSSSSSSSSS;3=SSSSSSSSSSSSSSSSSSSS 2 | -------------------------------------------------------------------------------- /test/data/resctrl.l2cdp/info/L2DATA/cbm_mask: -------------------------------------------------------------------------------- 1 | fffff 2 | -------------------------------------------------------------------------------- /test/data/resctrl.l2cdp/info/L2DATA/min_cbm_bits: -------------------------------------------------------------------------------- 1 | 1 2 | -------------------------------------------------------------------------------- /test/data/resctrl.l2cdp/info/L2DATA/num_closids: -------------------------------------------------------------------------------- 1 | 4 2 | -------------------------------------------------------------------------------- /test/data/resctrl.l2cdp/info/L2DATA/shareable_bits: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /test/data/resctrl.l2cdp/info/L3/bit_usage: -------------------------------------------------------------------------------- 1 | 0=SXSSSSSSSSSS 2 | -------------------------------------------------------------------------------- /test/data/resctrl.l2cdp/info/L3/cbm_mask: -------------------------------------------------------------------------------- 1 | fff 2 | -------------------------------------------------------------------------------- /test/data/resctrl.l2cdp/info/L3/min_cbm_bits: -------------------------------------------------------------------------------- 1 | 1 2 | -------------------------------------------------------------------------------- /test/data/resctrl.l2cdp/info/L3/num_closids: -------------------------------------------------------------------------------- 1 | 4 2 | -------------------------------------------------------------------------------- /test/data/resctrl.l2cdp/info/L3/shareable_bits: -------------------------------------------------------------------------------- 1 | 400 2 | -------------------------------------------------------------------------------- /test/data/resctrl.l2cdp/info/last_cmd_status: -------------------------------------------------------------------------------- 1 | ok 2 | -------------------------------------------------------------------------------- /test/data/resctrl.l2cdp/mode: -------------------------------------------------------------------------------- 1 | shareable 2 | -------------------------------------------------------------------------------- /test/data/resctrl.l2cdp/schemata: -------------------------------------------------------------------------------- 1 | L3:0=00fff 2 | L2DATA:0=fffff;1=fffff;2=fffff;3=fffff 3 | L2CODE:0=fffff;1=fffff;2=fffff;3=fffff 4 | -------------------------------------------------------------------------------- /test/data/resctrl.l2cdp/size: -------------------------------------------------------------------------------- 1 | L3:0=12582912 2 | L2DATA:0=1310720;1=1310720;2=1310720;3=1310720 3 | L2CODE:0=1310720;1=1310720;2=1310720;3=1310720 4 | -------------------------------------------------------------------------------- /test/data/resctrl.l2cdp/tasks: -------------------------------------------------------------------------------- 1 | 1 2 | 2 3 | 3 4 | 4 5 | 6 6 | 8 7 | 10 8 | 11 9 | 12 10 | 13 11 | 14 12 | 15 13 | 16 14 | 17 15 | 19 16 | 20 17 | 21 18 | 22 19 | 23 20 | 24 21 | 25 22 | 26 23 | 27 24 | 28 25 | 29 26 | 30 27 | 31 28 | 32 29 | 33 30 | 34 31 | 35 32 | 36 33 | 37 34 | 38 35 | 39 36 | 40 37 | 41 38 | 42 39 | 43 40 | 44 41 | 45 42 | 46 43 | 47 44 | 49 45 | 50 46 | 51 47 | 52 48 | 53 49 | 54 50 | 55 51 | 56 52 | 57 53 | 58 54 | 59 55 | 60 56 | 61 57 | 62 58 | 64 59 | 65 60 | 66 61 | 67 62 | 68 63 | 69 64 | 70 65 | 71 66 | 72 67 | 73 68 | 74 69 | 75 70 | 76 71 | 77 72 | 78 73 | 79 74 | 80 75 | 81 76 | 82 77 | 83 78 | 84 79 | 85 80 | 86 81 | 87 82 | 88 83 | 89 84 | 90 85 | 91 86 | 92 87 | 93 88 | 94 89 | 95 90 | 96 91 | 97 92 | 99 93 | -------------------------------------------------------------------------------- /test/data/resctrl.nol3.mbps/cpus: -------------------------------------------------------------------------------- 1 | ffffffff,ffffffff,ffffffff,ffffffff,ffffffff,ffffffff 2 | -------------------------------------------------------------------------------- /test/data/resctrl.nol3.mbps/cpus_list: -------------------------------------------------------------------------------- 1 | 0-191 2 | -------------------------------------------------------------------------------- /test/data/resctrl.nol3.mbps/info/L3_MON/max_threshold_occupancy: -------------------------------------------------------------------------------- 1 | 163840 2 | -------------------------------------------------------------------------------- /test/data/resctrl.nol3.mbps/info/L3_MON/mon_features: -------------------------------------------------------------------------------- 1 | llc_occupancy 2 | mbm_total_bytes 3 | mbm_local_bytes 4 | -------------------------------------------------------------------------------- /test/data/resctrl.nol3.mbps/info/L3_MON/num_rmids: -------------------------------------------------------------------------------- 1 | 160 2 | -------------------------------------------------------------------------------- /test/data/resctrl.nol3.mbps/info/MB/bandwidth_gran: -------------------------------------------------------------------------------- 1 | 10 2 | -------------------------------------------------------------------------------- /test/data/resctrl.nol3.mbps/info/MB/delay_linear: -------------------------------------------------------------------------------- 1 | 1 2 | -------------------------------------------------------------------------------- /test/data/resctrl.nol3.mbps/info/MB/min_bandwidth: -------------------------------------------------------------------------------- 1 | 10 2 | -------------------------------------------------------------------------------- /test/data/resctrl.nol3.mbps/info/MB/num_closids: -------------------------------------------------------------------------------- 1 | 8 2 | -------------------------------------------------------------------------------- /test/data/resctrl.nol3.mbps/info/last_cmd_status: -------------------------------------------------------------------------------- 1 | ok 2 | -------------------------------------------------------------------------------- /test/data/resctrl.nol3.mbps/mode: -------------------------------------------------------------------------------- 1 | shareable 2 | -------------------------------------------------------------------------------- /test/data/resctrl.nol3.mbps/mon_data/mon_L3_00/llc_occupancy: -------------------------------------------------------------------------------- 1 | 32440320 2 | -------------------------------------------------------------------------------- /test/data/resctrl.nol3.mbps/mon_data/mon_L3_00/mbm_local_bytes: -------------------------------------------------------------------------------- 1 | 48365568 2 | -------------------------------------------------------------------------------- /test/data/resctrl.nol3.mbps/mon_data/mon_L3_00/mbm_total_bytes: -------------------------------------------------------------------------------- 1 | 264830976 2 | -------------------------------------------------------------------------------- /test/data/resctrl.nol3.mbps/mon_data/mon_L3_01/llc_occupancy: -------------------------------------------------------------------------------- 1 | 28901376 2 | -------------------------------------------------------------------------------- /test/data/resctrl.nol3.mbps/mon_data/mon_L3_01/mbm_local_bytes: -------------------------------------------------------------------------------- 1 | 3342336 2 | -------------------------------------------------------------------------------- /test/data/resctrl.nol3.mbps/mon_data/mon_L3_01/mbm_total_bytes: -------------------------------------------------------------------------------- 1 | 208404480 2 | -------------------------------------------------------------------------------- /test/data/resctrl.nol3.mbps/mon_data/mon_L3_02/llc_occupancy: -------------------------------------------------------------------------------- 1 | 34406400 2 | -------------------------------------------------------------------------------- /test/data/resctrl.nol3.mbps/mon_data/mon_L3_02/mbm_local_bytes: -------------------------------------------------------------------------------- 1 | 603881472 2 | -------------------------------------------------------------------------------- /test/data/resctrl.nol3.mbps/mon_data/mon_L3_02/mbm_total_bytes: -------------------------------------------------------------------------------- 1 | 974782464 2 | -------------------------------------------------------------------------------- /test/data/resctrl.nol3.mbps/mon_data/mon_L3_03/llc_occupancy: -------------------------------------------------------------------------------- 1 | 31260672 2 | -------------------------------------------------------------------------------- /test/data/resctrl.nol3.mbps/mon_data/mon_L3_03/mbm_local_bytes: -------------------------------------------------------------------------------- 1 | 693239808 2 | -------------------------------------------------------------------------------- /test/data/resctrl.nol3.mbps/mon_data/mon_L3_03/mbm_total_bytes: -------------------------------------------------------------------------------- 1 | 760479744 2 | -------------------------------------------------------------------------------- /test/data/resctrl.nol3.mbps/schemata: -------------------------------------------------------------------------------- 1 | MB:0=4294967295;1=4294967295;2=4294967295;3=4294967295 2 | -------------------------------------------------------------------------------- /test/data/resctrl.nol3.mbps/size: -------------------------------------------------------------------------------- 1 | L3:0=28835840;1=28835840 2 | MB:0=4294967295;1=4294967295 3 | -------------------------------------------------------------------------------- /test/data/resctrl.nol3.mbps/tasks: -------------------------------------------------------------------------------- 1 | 1 2 | 2 3 | 3 4 | 4 5 | 6 6 | 8 7 | 10 8 | 11 9 | 12 10 | 13 11 | 14 12 | 15 13 | 16 14 | 17 15 | 19 16 | 20 17 | 21 18 | 22 19 | 23 20 | 24 21 | 25 22 | 26 23 | 27 24 | 28 25 | 29 26 | 30 27 | 31 28 | 32 29 | 33 30 | 34 31 | 35 32 | 36 33 | 37 34 | 38 35 | 39 36 | 40 37 | 41 38 | 42 39 | 43 40 | 44 41 | 45 42 | 46 43 | 47 44 | 49 45 | 50 46 | 51 47 | 52 48 | 53 49 | 54 50 | 55 51 | 56 52 | 57 53 | 58 54 | 59 55 | 60 56 | 61 57 | 62 58 | 64 59 | 65 60 | 66 61 | 67 62 | 68 63 | 69 64 | 70 65 | 71 66 | 72 67 | 73 68 | 74 69 | 75 70 | 76 71 | 77 72 | 78 73 | 79 74 | 80 75 | 81 76 | 82 77 | 83 78 | 84 79 | 85 80 | 86 81 | 87 82 | 88 83 | 89 84 | 90 85 | 91 86 | 92 87 | 93 88 | 94 89 | 95 90 | 96 91 | 97 92 | 99 93 | -------------------------------------------------------------------------------- /test/data/resctrl.nol3/cpus: -------------------------------------------------------------------------------- 1 | ffffffff,ffffffff,ffffffff,ffffffff,ffffffff,ffffffff 2 | -------------------------------------------------------------------------------- /test/data/resctrl.nol3/cpus_list: -------------------------------------------------------------------------------- 1 | 0-191 2 | -------------------------------------------------------------------------------- /test/data/resctrl.nol3/info/L3_MON/max_threshold_occupancy: -------------------------------------------------------------------------------- 1 | 98304 2 | -------------------------------------------------------------------------------- /test/data/resctrl.nol3/info/L3_MON/mon_features: -------------------------------------------------------------------------------- 1 | llc_occupancy 2 | mbm_total_bytes 3 | mbm_local_bytes 4 | -------------------------------------------------------------------------------- /test/data/resctrl.nol3/info/L3_MON/num_rmids: -------------------------------------------------------------------------------- 1 | 192 2 | -------------------------------------------------------------------------------- /test/data/resctrl.nol3/info/MB/bandwidth_gran: -------------------------------------------------------------------------------- 1 | 10 2 | -------------------------------------------------------------------------------- /test/data/resctrl.nol3/info/MB/delay_linear: -------------------------------------------------------------------------------- 1 | 1 2 | -------------------------------------------------------------------------------- /test/data/resctrl.nol3/info/MB/min_bandwidth: -------------------------------------------------------------------------------- 1 | 10 2 | -------------------------------------------------------------------------------- /test/data/resctrl.nol3/info/MB/num_closids: -------------------------------------------------------------------------------- 1 | 8 2 | -------------------------------------------------------------------------------- /test/data/resctrl.nol3/info/last_cmd_status: -------------------------------------------------------------------------------- 1 | ok 2 | -------------------------------------------------------------------------------- /test/data/resctrl.nol3/mode: -------------------------------------------------------------------------------- 1 | shareable 2 | -------------------------------------------------------------------------------- /test/data/resctrl.nol3/mon_data/mon_L3_00/llc_occupancy: -------------------------------------------------------------------------------- 1 | 32440320 2 | -------------------------------------------------------------------------------- /test/data/resctrl.nol3/mon_data/mon_L3_00/mbm_local_bytes: -------------------------------------------------------------------------------- 1 | 48365568 2 | -------------------------------------------------------------------------------- /test/data/resctrl.nol3/mon_data/mon_L3_00/mbm_total_bytes: -------------------------------------------------------------------------------- 1 | 264830976 2 | -------------------------------------------------------------------------------- /test/data/resctrl.nol3/mon_data/mon_L3_01/llc_occupancy: -------------------------------------------------------------------------------- 1 | 28901376 2 | -------------------------------------------------------------------------------- /test/data/resctrl.nol3/mon_data/mon_L3_01/mbm_local_bytes: -------------------------------------------------------------------------------- 1 | 3342336 2 | -------------------------------------------------------------------------------- /test/data/resctrl.nol3/mon_data/mon_L3_01/mbm_total_bytes: -------------------------------------------------------------------------------- 1 | 208404480 2 | -------------------------------------------------------------------------------- /test/data/resctrl.nol3/mon_data/mon_L3_02/llc_occupancy: -------------------------------------------------------------------------------- 1 | 34406400 2 | -------------------------------------------------------------------------------- /test/data/resctrl.nol3/mon_data/mon_L3_02/mbm_local_bytes: -------------------------------------------------------------------------------- 1 | 603881472 2 | -------------------------------------------------------------------------------- /test/data/resctrl.nol3/mon_data/mon_L3_02/mbm_total_bytes: -------------------------------------------------------------------------------- 1 | 974782464 2 | -------------------------------------------------------------------------------- /test/data/resctrl.nol3/mon_data/mon_L3_03/llc_occupancy: -------------------------------------------------------------------------------- 1 | 31260672 2 | -------------------------------------------------------------------------------- /test/data/resctrl.nol3/mon_data/mon_L3_03/mbm_local_bytes: -------------------------------------------------------------------------------- 1 | 693239808 2 | -------------------------------------------------------------------------------- /test/data/resctrl.nol3/mon_data/mon_L3_03/mbm_total_bytes: -------------------------------------------------------------------------------- 1 | 760479744 2 | -------------------------------------------------------------------------------- /test/data/resctrl.nol3/schemata: -------------------------------------------------------------------------------- 1 | MB:0=100;1=100;2=100;3=100 2 | -------------------------------------------------------------------------------- /test/data/resctrl.nol3/size: -------------------------------------------------------------------------------- 1 | MB:0=100;1=100;2=100;3=100 2 | -------------------------------------------------------------------------------- /test/data/resctrl.nol3/tasks: -------------------------------------------------------------------------------- 1 | 1 2 | 2 3 | 3 4 | 4 5 | 6 6 | 8 7 | 10 8 | 11 9 | 12 10 | 13 11 | 14 12 | 15 13 | 16 14 | 17 15 | 19 16 | 20 17 | 21 18 | 22 19 | 23 20 | 24 21 | 25 22 | 26 23 | 27 24 | 28 25 | 29 26 | 30 27 | 31 28 | 32 29 | 33 30 | 34 31 | 35 32 | 36 33 | 37 34 | 38 35 | 39 36 | 40 37 | 41 38 | 42 39 | 43 40 | 44 41 | 45 42 | 46 43 | 47 44 | 49 45 | 50 46 | 51 47 | 52 48 | 53 49 | 54 50 | 55 51 | 56 52 | 57 53 | 58 54 | 59 55 | 60 56 | 61 57 | 62 58 | 64 59 | 65 60 | 66 61 | 67 62 | 68 63 | 69 64 | 70 65 | 71 66 | 72 67 | 73 68 | 74 69 | 75 70 | 76 71 | 77 72 | 78 73 | 79 74 | 80 75 | 81 76 | 82 77 | 83 78 | 84 79 | 85 80 | 86 81 | 87 82 | 88 83 | 89 84 | 90 85 | 91 86 | 92 87 | 93 88 | 94 89 | 95 90 | 96 91 | 97 92 | 99 93 | -------------------------------------------------------------------------------- /test/data/resctrl.nomb.cdp/cpus: -------------------------------------------------------------------------------- 1 | ffffffff,ffffffff,ffffffff,ffffffff,ffffffff,ffffffff 2 | -------------------------------------------------------------------------------- /test/data/resctrl.nomb.cdp/cpus_list: -------------------------------------------------------------------------------- 1 | 0-191 2 | -------------------------------------------------------------------------------- /test/data/resctrl.nomb.cdp/info/L3CODE/bit_usage: -------------------------------------------------------------------------------- 1 | 0=HH000000000SSSSSSSSS;1=HH000000000SSSSSSSSS;2=HH000000000SSSSSSSSS;3=HH000000000SSSSSSSSS 2 | -------------------------------------------------------------------------------- /test/data/resctrl.nomb.cdp/info/L3CODE/cbm_mask: -------------------------------------------------------------------------------- 1 | fffff 2 | -------------------------------------------------------------------------------- /test/data/resctrl.nomb.cdp/info/L3CODE/min_cbm_bits: -------------------------------------------------------------------------------- 1 | 1 2 | -------------------------------------------------------------------------------- /test/data/resctrl.nomb.cdp/info/L3CODE/num_closids: -------------------------------------------------------------------------------- 1 | 8 2 | -------------------------------------------------------------------------------- /test/data/resctrl.nomb.cdp/info/L3CODE/shareable_bits: -------------------------------------------------------------------------------- 1 | c0000 2 | -------------------------------------------------------------------------------- /test/data/resctrl.nomb.cdp/info/L3DATA/bit_usage: -------------------------------------------------------------------------------- 1 | 0=HH000000000SSSSSSSSS;1=HH000000000SSSSSSSSS;2=HH000000000SSSSSSSSS;3=HH000000000SSSSSSSSS 2 | -------------------------------------------------------------------------------- /test/data/resctrl.nomb.cdp/info/L3DATA/cbm_mask: -------------------------------------------------------------------------------- 1 | fffff 2 | -------------------------------------------------------------------------------- /test/data/resctrl.nomb.cdp/info/L3DATA/min_cbm_bits: -------------------------------------------------------------------------------- 1 | 1 2 | -------------------------------------------------------------------------------- /test/data/resctrl.nomb.cdp/info/L3DATA/num_closids: -------------------------------------------------------------------------------- 1 | 8 2 | -------------------------------------------------------------------------------- /test/data/resctrl.nomb.cdp/info/L3DATA/shareable_bits: -------------------------------------------------------------------------------- 1 | c0000 2 | -------------------------------------------------------------------------------- /test/data/resctrl.nomb.cdp/info/L3_MON/max_threshold_occupancy: -------------------------------------------------------------------------------- 1 | 270336 2 | -------------------------------------------------------------------------------- /test/data/resctrl.nomb.cdp/info/L3_MON/mon_features: -------------------------------------------------------------------------------- 1 | llc_occupancy 2 | mbm_total_bytes 3 | mbm_local_bytes 4 | -------------------------------------------------------------------------------- /test/data/resctrl.nomb.cdp/info/L3_MON/num_rmids: -------------------------------------------------------------------------------- 1 | 176 2 | -------------------------------------------------------------------------------- /test/data/resctrl.nomb.cdp/info/last_cmd_status: -------------------------------------------------------------------------------- 1 | ok 2 | -------------------------------------------------------------------------------- /test/data/resctrl.nomb.cdp/mode: -------------------------------------------------------------------------------- 1 | shareable 2 | -------------------------------------------------------------------------------- /test/data/resctrl.nomb.cdp/mon_data/mon_L3_00/llc_occupancy: -------------------------------------------------------------------------------- 1 | 32440320 2 | -------------------------------------------------------------------------------- /test/data/resctrl.nomb.cdp/mon_data/mon_L3_00/mbm_local_bytes: -------------------------------------------------------------------------------- 1 | 48365568 2 | -------------------------------------------------------------------------------- /test/data/resctrl.nomb.cdp/mon_data/mon_L3_00/mbm_total_bytes: -------------------------------------------------------------------------------- 1 | 264830976 2 | -------------------------------------------------------------------------------- /test/data/resctrl.nomb.cdp/mon_data/mon_L3_01/llc_occupancy: -------------------------------------------------------------------------------- 1 | 28901376 2 | -------------------------------------------------------------------------------- /test/data/resctrl.nomb.cdp/mon_data/mon_L3_01/mbm_local_bytes: -------------------------------------------------------------------------------- 1 | 3342336 2 | -------------------------------------------------------------------------------- /test/data/resctrl.nomb.cdp/mon_data/mon_L3_01/mbm_total_bytes: -------------------------------------------------------------------------------- 1 | 208404480 2 | -------------------------------------------------------------------------------- /test/data/resctrl.nomb.cdp/mon_data/mon_L3_02/llc_occupancy: -------------------------------------------------------------------------------- 1 | 34406400 2 | -------------------------------------------------------------------------------- /test/data/resctrl.nomb.cdp/mon_data/mon_L3_02/mbm_local_bytes: -------------------------------------------------------------------------------- 1 | 603881472 2 | -------------------------------------------------------------------------------- /test/data/resctrl.nomb.cdp/mon_data/mon_L3_02/mbm_total_bytes: -------------------------------------------------------------------------------- 1 | 974782464 2 | -------------------------------------------------------------------------------- /test/data/resctrl.nomb.cdp/mon_data/mon_L3_03/llc_occupancy: -------------------------------------------------------------------------------- 1 | 31260672 2 | -------------------------------------------------------------------------------- /test/data/resctrl.nomb.cdp/mon_data/mon_L3_03/mbm_local_bytes: -------------------------------------------------------------------------------- 1 | 693239808 2 | -------------------------------------------------------------------------------- /test/data/resctrl.nomb.cdp/mon_data/mon_L3_03/mbm_total_bytes: -------------------------------------------------------------------------------- 1 | 760479744 2 | -------------------------------------------------------------------------------- /test/data/resctrl.nomb.cdp/schemata: -------------------------------------------------------------------------------- 1 | L3DATA:0=001ff;1=001ff;2=001ff;3=001ff 2 | L3CODE:0=001ff;1=001ff;2=001ff;3=001ff 3 | -------------------------------------------------------------------------------- /test/data/resctrl.nomb.cdp/size: -------------------------------------------------------------------------------- 1 | L3DATA:0=25952256 2 | L3CODE:0=25952256 3 | -------------------------------------------------------------------------------- /test/data/resctrl.nomb.cdp/tasks: -------------------------------------------------------------------------------- 1 | 1 2 | 2 3 | 3 4 | 4 5 | 6 6 | 8 7 | 10 8 | 11 9 | 12 10 | 13 11 | 14 12 | 15 13 | 16 14 | 17 15 | 19 16 | 20 17 | 21 18 | 22 19 | 23 20 | 24 21 | 25 22 | 26 23 | 27 24 | 28 25 | 29 26 | 30 27 | 31 28 | 32 29 | 33 30 | 34 31 | 35 32 | 36 33 | 37 34 | 38 35 | 39 36 | 40 37 | 41 38 | 42 39 | 43 40 | 44 41 | 45 42 | 46 43 | 47 44 | 49 45 | 50 46 | 51 47 | 52 48 | 53 49 | 54 50 | 55 51 | 56 52 | 57 53 | 58 54 | 59 55 | 60 56 | 61 57 | 62 58 | 64 59 | 65 60 | 66 61 | 67 62 | 68 63 | 69 64 | 70 65 | 71 66 | 72 67 | 73 68 | 74 69 | 75 70 | 76 71 | 77 72 | 78 73 | 79 74 | 80 75 | 81 76 | 82 77 | 83 78 | 84 79 | 85 80 | 86 81 | 87 82 | 88 83 | 89 84 | 90 85 | 91 86 | 92 87 | 93 88 | 94 89 | 95 90 | 96 91 | 97 92 | 99 93 | -------------------------------------------------------------------------------- /test/data/resctrl.nomb/cpus: -------------------------------------------------------------------------------- 1 | ffffffff,ffffffff,ffffffff,ffffffff,ffffffff,ffffffff 2 | -------------------------------------------------------------------------------- /test/data/resctrl.nomb/cpus_list: -------------------------------------------------------------------------------- 1 | 0-191 2 | -------------------------------------------------------------------------------- /test/data/resctrl.nomb/info/L3/bit_usage: -------------------------------------------------------------------------------- 1 | 0=XXSSSSSSSSSSSSSSSSSS;1=XXSSSSSSSSSSSSSSSSSS;2=XXSSSSSSSSSSSSSSSSSS;3=XXSSSSSSSSSSSSSSSSSS 2 | 3 | -------------------------------------------------------------------------------- /test/data/resctrl.nomb/info/L3/cbm_mask: -------------------------------------------------------------------------------- 1 | fffff 2 | -------------------------------------------------------------------------------- /test/data/resctrl.nomb/info/L3/min_cbm_bits: -------------------------------------------------------------------------------- 1 | 2 2 | -------------------------------------------------------------------------------- /test/data/resctrl.nomb/info/L3/num_closids: -------------------------------------------------------------------------------- 1 | 16 2 | -------------------------------------------------------------------------------- /test/data/resctrl.nomb/info/L3/shareable_bits: -------------------------------------------------------------------------------- 1 | c0000 2 | -------------------------------------------------------------------------------- /test/data/resctrl.nomb/info/L3_MON/max_threshold_occupancy: -------------------------------------------------------------------------------- 1 | 98304 2 | -------------------------------------------------------------------------------- /test/data/resctrl.nomb/info/L3_MON/mon_features: -------------------------------------------------------------------------------- 1 | llc_occupancy 2 | mbm_total_bytes 3 | mbm_local_bytes 4 | -------------------------------------------------------------------------------- /test/data/resctrl.nomb/info/L3_MON/num_rmids: -------------------------------------------------------------------------------- 1 | 192 2 | -------------------------------------------------------------------------------- /test/data/resctrl.nomb/info/last_cmd_status: -------------------------------------------------------------------------------- 1 | ok 2 | -------------------------------------------------------------------------------- /test/data/resctrl.nomb/mode: -------------------------------------------------------------------------------- 1 | shareable 2 | -------------------------------------------------------------------------------- /test/data/resctrl.nomb/mon_data/mon_L3_00/llc_occupancy: -------------------------------------------------------------------------------- 1 | 32440320 2 | -------------------------------------------------------------------------------- /test/data/resctrl.nomb/mon_data/mon_L3_00/mbm_local_bytes: -------------------------------------------------------------------------------- 1 | 48365568 2 | -------------------------------------------------------------------------------- /test/data/resctrl.nomb/mon_data/mon_L3_00/mbm_total_bytes: -------------------------------------------------------------------------------- 1 | 264830976 2 | -------------------------------------------------------------------------------- /test/data/resctrl.nomb/mon_data/mon_L3_01/llc_occupancy: -------------------------------------------------------------------------------- 1 | 28901376 2 | -------------------------------------------------------------------------------- /test/data/resctrl.nomb/mon_data/mon_L3_01/mbm_local_bytes: -------------------------------------------------------------------------------- 1 | 3342336 2 | -------------------------------------------------------------------------------- /test/data/resctrl.nomb/mon_data/mon_L3_01/mbm_total_bytes: -------------------------------------------------------------------------------- 1 | 208404480 2 | -------------------------------------------------------------------------------- /test/data/resctrl.nomb/mon_data/mon_L3_02/llc_occupancy: -------------------------------------------------------------------------------- 1 | 34406400 2 | -------------------------------------------------------------------------------- /test/data/resctrl.nomb/mon_data/mon_L3_02/mbm_local_bytes: -------------------------------------------------------------------------------- 1 | 603881472 2 | -------------------------------------------------------------------------------- /test/data/resctrl.nomb/mon_data/mon_L3_02/mbm_total_bytes: -------------------------------------------------------------------------------- 1 | 974782464 2 | -------------------------------------------------------------------------------- /test/data/resctrl.nomb/mon_data/mon_L3_03/llc_occupancy: -------------------------------------------------------------------------------- 1 | 31260672 2 | -------------------------------------------------------------------------------- /test/data/resctrl.nomb/mon_data/mon_L3_03/mbm_local_bytes: -------------------------------------------------------------------------------- 1 | 693239808 2 | -------------------------------------------------------------------------------- /test/data/resctrl.nomb/mon_data/mon_L3_03/mbm_total_bytes: -------------------------------------------------------------------------------- 1 | 760479744 2 | -------------------------------------------------------------------------------- /test/data/resctrl.nomb/schemata: -------------------------------------------------------------------------------- 1 | L3:0=fffff;1=fffff;2=fffff;3=fffff 2 | -------------------------------------------------------------------------------- /test/data/resctrl.nomb/size: -------------------------------------------------------------------------------- 1 | L3:0=57671680;1=57671680;2=57671680;3=57671680 2 | MB:0=100;1=100;2=100;3=100 3 | -------------------------------------------------------------------------------- /test/data/resctrl.nomb/tasks: -------------------------------------------------------------------------------- 1 | 1 2 | 2 3 | 3 4 | 4 5 | 6 6 | 8 7 | 10 8 | 11 9 | 12 10 | 13 11 | 14 12 | 15 13 | 16 14 | 17 15 | 19 16 | 20 17 | 21 18 | 22 19 | 23 20 | 24 21 | 25 22 | 26 23 | 27 24 | 28 25 | 29 26 | 30 27 | 31 28 | 32 29 | 33 30 | 34 31 | 35 32 | 36 33 | 37 34 | 38 35 | 39 36 | 40 37 | 41 38 | 42 39 | 43 40 | 44 41 | 45 42 | 46 43 | 47 44 | 49 45 | 50 46 | 51 47 | 52 48 | 53 49 | 54 50 | 55 51 | 56 52 | 57 53 | 58 54 | 59 55 | 60 56 | 61 57 | 62 58 | 64 59 | 65 60 | 66 61 | 67 62 | 68 63 | 69 64 | 70 65 | 71 66 | 72 67 | 73 68 | 74 69 | 75 70 | 76 71 | 77 72 | 78 73 | 79 74 | 80 75 | 81 76 | 82 77 | 83 78 | 84 79 | 85 80 | 86 81 | 87 82 | 88 83 | 89 84 | 90 85 | 91 86 | 92 87 | 93 88 | 94 89 | 95 90 | 96 91 | 97 92 | 99 93 | --------------------------------------------------------------------------------