目录

目录

源代码目录

名字解释

CPU 电源管理

RAPL接口

CPU Freq

sys系统接口

trace事件

调度

CPU idle

sys文件系统接口

外设电源管理



源代码目录

├── calibrate   (测试之前的校准)

│   ├── calibrate.cpp

│   └── calibrate.h

├── cpu      (CPU 、内存接口

│   ├── abstract_cpu.cpp

│   ├── cpu_core.cpp

│   ├── cpu.cpp

│   ├── cpudevice.cpp

│   ├── cpudevice.h

│   ├── cpu.h

│   ├── cpu_linux.cpp

│   ├── cpu_package.cpp

│   ├── cpu_rapl_device.cpp

│   ├── cpu_rapl_device.h

│   ├── dram_rapl_device.cpp

│   ├── dram_rapl_device.h

│   ├── intel_cpus.cpp

│   ├── intel_cpus.h

│   ├── intel_gpu.cpp

│   └── rapl

│       ├── rapl_interface.cpp

│       └── rapl_interface.h

├── csstoh.sh

├── devices   (SCSI、音频、背光、设备频率控制、intel GPU、网卡、wifi蓝牙、usb、

|   |             thinkpad风扇、设备runtime控制)

│   ├── ahci.cpp

│   ├── ahci.h

│   ├── alsa.cpp

│   ├── alsa.h

│   ├── backlight.cpp

│   ├── backlight.h

│   ├── devfreq.cpp

│   ├── devfreq.h

│   ├── device.cpp

│   ├── device.h

│   ├── gpu_rapl_device.cpp

│   ├── gpu_rapl_device.h

│   ├── i915-gpu.cpp

│   ├── i915-gpu.h

│   ├── network.cpp

│   ├── network.h

│   ├── rfkill.cpp

│   ├── rfkill.h

│   ├── runtime_pm.cpp

│   ├── runtime_pm.h

│   ├── thinkpad-fan.cpp

│   ├── thinkpad-fan.h

│   ├── thinkpad-light.cpp

│   ├── thinkpad-light.h

│   ├── usb.cpp

│   └── usb.h

├── devlist.cpp

├── devlist.h

├── display.cpp

├── display.h

├── lib.cpp

├── lib.h

├── main.cpp

├── Makefile

├── Makefile.am

├── Makefile.in

├── measurement

│   ├── acpi.cpp

│   ├── acpi.h

│   ├── extech.cpp

│   ├── extech.h

│   ├── measurement.cpp

│   ├── measurement.h

│   ├── opal-sensors.cpp

│   ├── opal-sensors.h

│   ├── sysfs.cpp

│   └── sysfs.h

├── parameters  (这里还具有学习优化的机制?)

│   ├── learn.cpp

│   ├── parameters.cpp

│   ├── parameters.h

│   └── persistent.cpp

├── perf   (采用linux内核event跟踪机制监控,主要关注哪些事件用来衡量哪些事情)

│   ├── perf_bundle.cpp

│   ├── perf_bundle.h

│   ├── perf.cpp

│   ├── perf_event.h

│   └── perf.h

├── powertop.css

├── process (进程、中断的占用CPU时间

│   ├── do_process.cpp

│   ├── interrupt.cpp

│   ├── interrupt.h

│   ├── powerconsumer.cpp

│   ├── powerconsumer.h

│   ├── process.cpp

│   ├── processdevice.cpp

│   ├── processdevice.h

│   ├── process.h

│   ├── timer.cpp

│   ├── timer.h

│   ├── work.cpp

│   └── work.h

├── report

│   ├── report.cpp

│   ├── report-data-html.cpp

│   ├── report-data-html.h

│   ├── report-formatter-base.cpp

│   ├── report-formatter-base.h

│   ├── report-formatter-csv.cpp

│   ├── report-formatter-csv.h

│   ├── report-formatter.h

│   ├── report-formatter-html.cpp

│   ├── report-formatter-html.h

│   ├── report.h

│   ├── report-maker.cpp

│   └── report-maker.h

├── tuning    (调整电源管理的接口汇总)

│   ├── bluetooth.cpp

│   ├── bluetooth.h

│   ├── ethernet.cpp

│   ├── ethernet.h

│   ├── iw.c

│   ├── iw.h

│   ├── nl80211.h

│   ├── runtime.cpp

│   ├── runtime.h

│   ├── tunable.cpp

│   ├── tunable.h

│   ├── tuning.cpp

│   ├── tuning.h

│   ├── tuningi2c.cpp

│   ├── tuningi2c.h

│   ├── tuningsysfs.cpp

│   ├── tuningsysfs.h

│   ├── tuningusb.cpp

│   ├── tuningusb.h

│   ├── wifi.cpp

│   └── wifi.h

└── wakeup

├── waketab.cpp

├── wakeup.cpp

├── wakeup_ethernet.cpp

├── wakeup_ethernet.h

├── wakeup.h

├── wakeup_usb.cpp

└── wakeup_usb.h

名字解释

Since Intel Sandy Bridge CPUs, the Intel Running Average Power Limit (RAPL) interface allows monitoring and controlling the power consumption of the CPU and DRAM in software. Hence, the CPU basically comes with its own power meter. With the current implementation of the Linux driver, every unprivileged user has access to its measurements.

main.cpp

main->powertop_init

1) mount -t debugfs debugfs /sys/kernel/debug  挂载debugfs

2) 在 /data/local/powertop  或者 /var/cache/powertop 创建调配参数保存

CPU 电源管理

3)  enumerate_cpus  函数解析 "/proc/cpuinfo" 中cpu信息,包括 厂家、型号、model等

同时针对/sys/class/drm/card0/power/rc6_residency_ms  的存在情况,进行handle_i965_gpu GPU 的处理。

 perf_events 对象,主要作用是什么

RAPL接口

msr接口获取及设置CPU 内存的功耗配置

/dev/cpu/0/msr

/sys/class/powercap/intel-rapl/

虽然 接口 set_dram_power_limit 实现了,但实际没有使用。

这一块儿还要记录研究!!

CPU Freq

为了节省CPU的功耗和减少发热,根据当前CPU的负载状态,动态地提供刚好足够的主频给CPU,即在系统正常运行时的节能策略。;有一点需要关注的,这个根据负载调频,并不是tlp或者powertop这种工具做的,而是在内核实现的。内核仅仅通过governor对外面暴露策略。

sys系统接口

/sys/devices/system/cpu/cpu6/cpufreq

字段 取值 含义
affected_cpus     
cpuinfo_min_freq     
energy_performance_available_preferences    
related_cpus        
  scaling_cur_freq    
scaling_governor powersave  
scaling_min_freq    
cpuinfo_max_freq     
cpuinfo_transition_latency     
energy_performance_preference      
scaling_available_governors  s

performance powersave

 
scaling_driver   intel_pstate  

trace事件

power:power_frequency 事件涉及到的内核代码为:

/x86-kernel/drivers/cpufreq/cpufreq.c  :cpufreq_notify_transition - Notify frequency transition and adjust_jiffies

/x86-kernel/drivers/cpufreq/intel_pstate.c

x86-kernel/kernel/sched/cpufreq_schedutil.c  :CPUFreq governor based on scheduler-provided CPU utilization data

if (!perf_events->add_event("power:cpu_frequency"))

perf_events->add_event("power:power_frequency")

governor

调度

CPU idle

为在空闲时,CPU依次关闭某些逻辑期间的程序。

sys文件系统接口

/sys/devices/system/cpu/cpu0/cpuidle/state0

字段 取值 含义
desc     
disable 0 启用此状态
latency    
name

POLL

intel cpu状态的名字
power    
residency    
time    
usage    

对这些字段的使用是在 /powertop-2.14/src/cpu/cpu_linux.cpp 中,主要使用 time usage 和name 字段,即统计各个cpu 状态的百分比

trace 事件

power:cpu_idle

!perf_events->add_event("power:cpu_idle")){

perf_events->add_event("power:power_start");

perf_events->add_event("power:power_end");

}

这个事件在内核里面没有搜到??

外设电源管理

4) create_all_devices  依次调用如下接口,对各种外设的电源管理进行检测:

create_all_backlights();  :对此目录下的文件进行处理 "/sys/class/backlight/

create_all_usb_devices();  :对此目录下的文件进行处理 "("/sys/bus/usb/devices/"

create_all_ahcis();  : /sys/class/scsi_host/"

create_all_alsa();  : "/sys/class/sound/"

create_all_rfkills();   /sys/class/rfkill/"    "/sys/class/rfkill/%s/name

create_i915_gpu();   /sys/kernel/debug/tracing/events/i915/i915_gem_ring_dispatch/format   (跟踪GPU的事务,已衡量GPU的功耗??)

create_thinkpad_fan();  :/sys/devices/platform/thinkpad_hwmon/fan1_input   特定品牌风扇信息的处理?

create_thinkpad_light();  :/sys/devices/platform/thinkpad_acpi/leds/tpacpi::thinklight/brightness

create_all_nics();   :"/sys/class/net/

create_all_runtime_pm_devices();  又包含支持 runtime的各种总线设备:

do_bus("pci");    /sys/bus/pci/devices/0000\:00\:1f.0/power/runtime_suspended_time 某个设备

do_bus("spi");

do_bus("platform");

do_bus("i2c");

}

powertop代码走读记录相关推荐

  1. keras Mask Rcnn代码走读(九)-detect方法介绍

    keras Mask Rcnn代码走读(八)-detect方法介绍,主要用于图片实体分割的推断时调用的. 一,首先对图像进行处理,调用self.mold_inputs()函数,把原图等比例resize ...

  2. webrtc代码走读四(rtp包格式)

    一.rtp包头格式 V:版本号,必须为2 P:填充位 X:扩展位,标志是否存在扩展 CC:CSRC个数 M:Mark标志位,标志是否是一帧的结束,音频帧几乎每个包都是一个完整的帧,所以M一般情况都等于 ...

  3. Appendix:附录文件内容记录脚本代码转换过程记录

    Appendix:附录文件内容记录脚本代码转换过程记录 附录文件内容记录脚本代码转换过程记录 Microsoft Windows [版本 10.0.14393] (c) 2016 Microsoft ...

  4. RAISR-master:google图像新压缩技术RAISR的测试代码调试记录(Python实现,没接触过python的小白,内含pip install解决方案)

    RAISR-master:google图像新压缩技术RAISR的测试代码调试记录(Python实现,没接触过python的小白,内含pip install解决方案) 参考文章: (1)RAISR-ma ...

  5. WordPress纯PHP代码实现记录搜索引擎蜘蛛爬行记录

    在新站或网站收录有问题时,可能需要持续关注搜索引擎蜘蛛的抓取情况.每次打开服务器端访问日志查看非常麻烦,特别是当日志文件比较大时更是不便.最好的办法就是在线直接打开看蜘蛛爬行记录.为此,我们可以免插件 ...

  6. AM5728-Uboot SPL 代码走读

    1 执行流程 am5728的cpu上电后,执行流程:ROM->MLO(SPL)->u-boot.img 第一级bootloader:引导加载程序,板子上电后会自动执行这些代码,如启动方式( ...

  7. rtsp流媒体播放器----ffmpeg相关代码走读(一)

    rtsp流媒体播放器--ffmpeg相关代码走读(一) 本文介绍avformat_open_input和init_input两个函数 直接贴代码如下 avformat_open_input 函数 in ...

  8. TI单芯片毫米波雷达代码走读(二十五)—— 角度维(3D)处理流程

    专栏目录链接: TI单芯片毫米波雷达1642代码走读(〇)--总纲 我们从今天开始进入近的篇章--3D处理 毫米波雷达信号处理的3个维度: 第一维度:距离 第二维度:多普勒 第三维度:角度 第二维度知 ...

  9. TI单芯片毫米波雷达1642代码走读(〇)——总纲

    前言 近年来,自动驾驶行业发展如火如荼,雷达技术也逐渐从军工封闭圈走向了开放的市场. 毫米波雷达具有全天候探测能力,特别是在雨雪雾天气以及夜间都能可靠工作,并且探测距离相对其他车载传感器非常远,对运动 ...

最新文章

  1. android 半透明pop,Android实现AppCompatActivity全屏半透明
  2. Android L 新特性
  3. 行家来信 | 我在国际AI开源组织LFAI当董事的200天
  4. python中get和set使用_Python中的__get__与__set__
  5. 论文|记忆网络之Memory Networks
  6. 【顾连科普】健康生活的10个小常识,请收下
  7. vc获取n卡编号_电脑入门知识:通过显卡型号中字母和数字判断显卡性能
  8. 一维数组,二维数组,三维数组,数组与指针,结构体数组,通过改变指针类型改变访问数组的方式
  9. ALGO-22 数的划分(DFS,经典剪枝)
  10. 2016年10月20日 .NET Core 1.0.2 更新
  11. 2018 蓝桥杯省赛 B 组模拟赛(一)H.封印之门 最短路
  12. 第二章 Qt Widgets项目的创建、运行和发布的过程
  13. tcpdump/editcap等工具保存文件时名称中自定义添加日期/时间
  14. python分类时特征选择_推荐 :使用Python实现机器学习特征选择的4种方法(附代码)...
  15. matlab画直方图
  16. java抽象和接口的理解_Java学习笔记16---抽象类与接口的浅显理解
  17. 2016——大数据版图
  18. java springboot智慧农业分销平台商用
  19. Android 软件平台架构设计
  20. http常见状态返回码

热门文章

  1. 听说你立志要做数据分析,不如先听听老司机的建议?
  2. HBase安装及使用
  3. 设置mysql root密码
  4. Windows中缺少mfc140.dll文件解决方法
  5. 用jupyter notebook卸载Python第三方库
  6. 记录一个阿里云OSS图片上传错误
  7. 时间复杂度和空间复杂度的计算方法
  8. 微信小程序学习笔记--测颜值
  9. Going to Redmond (keep moving)
  10. 武汉市洪山区高新技术企业认定奖励标准及申请材料、条件、要求