{"id":13575799,"url":"https://github.com/amd/amd_energy","last_synced_at":"2025-04-04T23:30:40.601Z","repository":{"id":70008532,"uuid":"361995597","full_name":"amd/amd_energy","owner":"amd","description":null,"archived":false,"fork":false,"pushed_at":"2024-07-18T07:04:04.000Z","size":14,"stargazers_count":36,"open_issues_count":4,"forks_count":15,"subscribers_count":6,"default_branch":"master","last_synced_at":"2024-11-05T11:44:05.215Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/amd.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-04-27T05:49:32.000Z","updated_at":"2024-10-10T14:03:37.000Z","dependencies_parsed_at":"2024-07-18T08:50:35.461Z","dependency_job_id":null,"html_url":"https://github.com/amd/amd_energy","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amd%2Famd_energy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amd%2Famd_energy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amd%2Famd_energy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amd%2Famd_energy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/amd","download_url":"https://codeload.github.com/amd/amd_energy/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247266474,"owners_count":20910831,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-01T15:01:04.302Z","updated_at":"2025-04-04T23:30:40.307Z","avatar_url":"https://github.com/amd.png","language":"C","funding_links":[],"categories":["C"],"sub_categories":[],"readme":".. SPDX-License-Identifier: GPL-2.0\n\nKernel driver amd_energy\n==========================\n\nSupported chips:\n\n* AMD Family 17h Processors: Model 30h\n\n* AMD Family 19h Processors: Model 01h and 30h\n\n* AMD Family 19h Processors: Model 01h and 10h\n\n* AMD Family 19h Processors: Model 00h, 11h, A0h, 90h\n\n* AMD Family 1Ah Processors: Model 00h, 02h, 11h, 10h\n\n  Prefix: 'amd_energy'\n\n  Addresses used:  RAPL MSRs\n\n  Datasheets:\n\n  - Processor Programming Reference (PPR) for AMD Family 17h Model 01h, Revision B1 Processors\n\n\thttps://developer.amd.com/wp-content/resources/55570-B1_PUB.zip\n\n  - Preliminary Processor Programming Reference (PPR) for AMD Family 17h Model 31h, Revision B0 Processors\n\n\thttps://developer.amd.com/wp-content/resources/56176_ppr_Family_17h_Model_71h_B0_pub_Rev_3.06.zip\n\n  - Preliminary Processor Programming Reference (PPR) for AMD Family 19h Model 1h, Revision B1 Processors\n\n\thttps://www.amd.com/system/files/TechDocs/55898_pub.zip\n\nAuthor: Naveen Krishna Chatradhi \u003cnchatrad@amd.com\u003e\n\nSecurity: CVE-2020-12912\n------------------------------\n\nRefer 2020 tab in https://www.amd.com/en/corporate/product-security#paragraph-313561 for details\n\nDescription\n-----------\n\nThe Energy driver exposes the energy counters that are\nreported via the Running Average Power Limit (RAPL)\nModel-specific Registers (MSRs) via the hardware monitor\n(HWMON) sysfs interface.\n\n1. Power, Energy and Time Units\n   MSR_RAPL_POWER_UNIT/ C001_0299:\n   shared with all cores in the socket\n\n2. Energy consumed by each Core\n   MSR_CORE_ENERGY_STATUS/ C001_029A:\n   32-bitRO, Accumulator, core-level power reporting\n\n3. Energy consumed by Socket\n   MSR_PACKAGE_ENERGY_STATUS/ C001_029B:\n   32-bitRO, Accumulator, socket-level power reporting,\n   shared with all cores in socket\n\nThese registers are updated every 1ms and cleared on\nreset of the system.\n\nNote: If SMT is enabled, Linux enumerates all threads as cpus.\nSince, the energy status registers are accessed at core level,\nreading those registers from the sibling threads would result\nin duplicate values. Hence, energy counter entries are not\npopulated for the siblings.\n\nEnergy Calculation\n------------------\n\nEnergy information (in Joules) is based on the multiplier,\n1/2^ESU; where ESU is an unsigned integer read from\nMSR_RAPL_POWER_UNIT register. Default value is 10000b,\nindicating energy status unit is 15.3 micro-Joules increment.\n\nReported values are scaled as per the formula\n\nscaled value = ((1/2^ESU) * (Raw value) * 1000000UL) in uJoules\n\nUsers calculate power for a given domain by calculating\n\tdEnergy/dTime for that domain.\n\nEnergy accumulation\n--------------------------\n\nCurrent, Socket energy status register is 32bit, assuming a 240W\n2P system, the register would wrap around in\n\n\t2^32*15.3 e-6/240 * 2 = 547.60833024 secs to wrap(~9 mins)\n\nThe Core energy register may wrap around after several days.\n\nTo improve the wrap around time, a kernel thread is implemented\nto accumulate the socket energy counters and one core energy counter\nper run to a respective 64-bit counter. The kernel thread starts\nrunning during probe, wakes up every 100 secs and stops running\nwhen driver is removed.\n\nFrequency of the accumulator thread is set during the probe\nbased on the chosen energy unit resolution. For example\nA. fine grain (1.625 micro J)\nB. course grain (0.125 milli J)\n\nA socket and core energy read would return the current register\nvalue added to the respective energy accumulator.\n\nOn newer EPYC CPUs with 64bit RAPL energy MSRs, software accumulation\nof energy counters is not required. Hence, accumulation is enabled\nonly on select EPYC CPUs with 32bit RAPL MSRs.\n\nSysfs attributes\n----------------\n\n=============== ========  =====================================\nAttribute\tLabel\t  Description\n===============\t========  =====================================\n\n* For index N between [1] and [nr_cpus]\n\n===============\t========  ======================================\nenergy[N]_input EcoreX\t  Core Energy   X = [0] to [nr_cpus - 1]\n\t\t\t  Measured input core energy\n===============\t========  ======================================\n\n* For N between [nr_cpus] and [nr_cpus + nr_socks]\n\n===============\t========  ======================================\nenergy[N]_input EsocketX  Socket Energy X = [0] to [nr_socks -1]\n\t\t\t  Measured input socket energy\n=============== ========  ======================================\n\nNote: To address CVE-2020-12912, the visibility of the energy[N]_input\nattributes is restricted to owner and groups only.\n\nBuild and Install\n-----------------\n\nKernel development packages for the running kernel need to be installed\nprior to building the Energy module. A Makefile is provided which should\nwork with most kernel source trees.\n\nTo build the kernel module:\n\n#\u003e make\n\nTo install the kernel module:\n\n#\u003e sudo make modules_install\n\nTo clean the kernel module build directory:\n\n#\u003e make clean\n\n\nLoading\n-------\n\nIf the Energy module was installed you should use the modprobe command to\nload the module.\n\n#\u003e sudo modprobe amd_energy\n\nThe Energy module can also be loaded using insmod if the module was not\ninstalled:\n\nThe Energy module can also be loaded using insmod if the module was not\ninstalled:\n\n#\u003e sudo insmod ./amd_energy.ko\n\n\nDKMS support\n------------\n\nBuilding Module with running version of kernel\n\nAdd the module to DKMS tree:\n#\u003e sudo dkms add ../amd_energy\n\nBuild the module using DKMS:\n#\u003e sudo dkms build -m amd_energy/1.0\n\nInstall the module using DKMS:\n#\u003e sudo dkms install --force amd_energy/1.0\n\nLoad the module:\n#\u003e sudo modprobe amd_energy\n\nBuilding Module with specific version of kernel\n\nAdd the module to DKMS tree:\n#\u003e sudo dkms add ../amd_energy\n\nBuild the module using DKMS:\n#\u003e sudo dkms build amd_energy/1.0 -k linux_version\n\nInstall the module using DKMS:\n#\u003e sudo dkms install --force amd_energy/1.0 -k linux_version\nModule is built: /lib/modules/linux_version/updates/dkms/\n\nNotes: It is required to have specific linux version header in /usr/src\n\nTo remove module from dkms tree\n#\u003e sudo dkms remove -m amd_energy/1.0 --all\n#\u003e sudo rm -rf /usr/src/amd_energy-1.0/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Famd%2Famd_energy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Famd%2Famd_energy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Famd%2Famd_energy/lists"}