- Complete installation and uninstallation scripts - Optimized TLP configuration for maximum battery life - PowerTOP analysis and auto-tune functionality - Real-time battery monitoring with detailed stats - ThinkPad-specific optimizations and battery thresholds - Comprehensive documentation and usage guides - Tested on ThinkPad T14 Gen 1 with 13% power reduction
7.1 KiB
PowerTOP Usage Guide
Overview
PowerTOP is a Linux tool to diagnose issues with power consumption and power management. It provides detailed information about power usage by various system components and suggests optimizations.
Installation Verification
After running the installation script, verify PowerTOP is installed:
# Check PowerTOP version
powertop --version
# Quick test (requires sudo)
sudo powertop --time=5
Basic Usage
Interactive Mode
# Launch PowerTOP in interactive mode
sudo powertop
Navigation:
Tab: Switch between tabsEnter: Toggle tunablesq: Quit- Arrow keys: Navigate lists
Tabs Overview
- Overview: General system power consumption
- Idle stats: CPU idle state statistics
- Frequency stats: CPU frequency usage
- Device stats: Individual device power usage
- Tunables: Available power optimizations
Command Line Usage
Generate Reports
# Generate HTML report (60 seconds)
sudo powertop --html=report.html --time=60
# Generate CSV report
sudo powertop --csv=report.csv --time=60
# Custom duration
sudo powertop --html=report.html --time=120
Auto-tune Mode
# Apply all available optimizations
sudo powertop --auto-tune
# View what would be changed (dry-run)
sudo powertop --auto-tune --debug
Note: Auto-tune changes are temporary and reset on reboot.
Using the PowerTOP Analysis Script
Our custom script (scripts/powertop-analyze.sh) provides enhanced functionality:
Basic Report Generation
# Generate 60-second HTML report
./scripts/powertop-analyze.sh
# Custom duration and format
./scripts/powertop-analyze.sh --duration 120 --format csv
# Different output directory
./scripts/powertop-analyze.sh --output /tmp/reports
Apply Optimizations
# Apply PowerTOP auto-tune
./scripts/powertop-analyze.sh --auto-tune
# Quick system summary
./scripts/powertop-analyze.sh --quick
View Reports
# Open latest report in browser
./scripts/powertop-analyze.sh --show-report
# List all generated reports
ls -la ~/.battery-optimizer/reports/
Understanding Reports
HTML Report Sections
-
System Information
- Hardware details
- Kernel version
- System uptime
-
Power Consumption Overview
- Total system power draw
- Battery discharge rate
- Power source information
-
Top Power Consumers
- Applications using most power
- Hardware devices consuming power
- System services impact
-
Processor Information
- CPU frequency usage
- Idle state statistics
- Core utilization
-
Device Power Management
- ASPM status
- Runtime PM status
- USB autosuspend status
-
Tunables
- Available optimizations
- Current status (Good/Bad)
- Recommended changes
Key Metrics to Monitor
-
Power Consumption (Watts)
- Lower is better
- Typical laptop: 8-15W idle, 25-45W under load
-
Wakeups per Second
- Lower is better for battery life
- Target: <100 wakeups/second
-
CPU Usage
- Identify power-hungry applications
- Background processes impact
Optimization Categories
CPU Optimizations
# CPU governor (applied by TLP)
echo 'powersave' | sudo tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
# CPU idle states
# Managed automatically by kernel
Device Power Management
# Enable ASPM (PCIe power saving)
echo 'powersave' | sudo tee /sys/module/pcie_aspm/parameters/policy
# Runtime PM for devices
echo 'auto' | sudo tee /sys/bus/pci/devices/*/power/control
USB Power Management
# Enable USB autosuspend
echo '1' | sudo tee /sys/module/usbcore/parameters/autosuspend
# Per-device control
echo 'auto' | sudo tee /sys/bus/usb/devices/*/power/control
Audio Power Saving
# Enable audio power saving
echo '1' | sudo tee /sys/module/snd_hda_intel/parameters/power_save
Making Optimizations Permanent
Method 1: Systemd Service (Recommended)
Our installation script creates a PowerTOP service:
# Check service status
systemctl status powertop.service
# Enable auto-tune on boot
sudo systemctl enable powertop.service
# Manually run auto-tune
sudo systemctl start powertop.service
Method 2: Custom Scripts
Create startup scripts in /etc/rc.local or systemd services:
# Example optimization script
#!/bin/bash
echo 'auto' > /sys/bus/pci/devices/*/power/control
echo 'min_power' > /sys/class/scsi_host/*/link_power_management_policy
Method 3: TLP Integration
Most PowerTOP optimizations are already included in our TLP configuration.
Troubleshooting
Common Issues
-
PowerTOP requires root privileges
- This is normal for hardware access
- Always use
sudo powertop
-
No power consumption data
- Check if running on battery
- Ensure ACPI support in kernel
- Some virtual machines don't report power data
-
Optimizations not persisting
- Use systemd service for permanent changes
- Check for conflicting power managers
Debug Commands
# Check kernel power management support
ls /sys/class/power_supply/
# Verify ACPI tables
sudo acpidump | head -20
# Check for power management conflicts
systemctl list-units | grep power
Best Practices
Regular Monitoring
- Weekly Reports: Generate PowerTOP reports to track trends
- Before/After Testing: Measure impact of configuration changes
- Application Profiling: Identify power-hungry applications
Analysis Workflow
- Baseline Measurement: Record power consumption before changes
- Apply Optimizations: Use systematic approach
- Measure Impact: Generate new reports
- Document Changes: Keep track of what works
Report Interpretation
- Focus on Top Consumers: Address highest impact items first
- Check Tunables: Apply "Bad" recommendations carefully
- Monitor Trends: Look for patterns over time
- Validate Changes: Ensure functionality isn't compromised
Integration with Other Tools
With TLP
PowerTOP and TLP complement each other:
- TLP: Provides systematic, persistent power management
- PowerTOP: Offers detailed analysis and additional optimizations
With System Monitoring
# Combine with system monitoring
./scripts/powertop-analyze.sh &
./scripts/battery-monitor.sh --watch
With Performance Tools
# Monitor performance impact
htop &
sudo powertop --auto-tune
# Check if system remains responsive
Advanced Usage
Automated Analysis
#!/bin/bash
# Daily power analysis script
DATE=$(date +%Y%m%d)
sudo powertop --html=/var/log/powertop_${DATE}.html --time=3600
# Email report or upload to monitoring system
Custom Reporting
# Extract specific data from CSV reports
awk -F',' 'NR>1 {print $1,$3}' report.csv | sort -k2 -nr | head -10
Integration with Monitoring Systems
PowerTOP data can be integrated with:
- Grafana dashboards
- Nagios monitoring
- Custom logging systems
This guide should be used alongside the PowerTOP analysis script provided in this repository for optimal power management.