action.yml 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. name: 'Apply Performance Patches'
  2. description: 'Apply experimental kernel patches with version-specific logic'
  3. inputs:
  4. kernel_version:
  5. description: 'Kernel version (e.g., 6.1)'
  6. required: true
  7. runs:
  8. using: 'composite'
  9. steps:
  10. - name: Apply Experimental Patches
  11. shell: bash
  12. working-directory: ${{ github.workspace }}/kernel/common
  13. run: |
  14. set -euo pipefail
  15. KERNEL_VERSION="${{ inputs.kernel_version }}"
  16. MIN_VERSION="5.16"
  17. patch -p1 --forward < "${{ github.workspace }}/kernel_patches/common/optimized_mem_operations.patch"
  18. patch -p1 --forward < "${{ github.workspace }}/kernel_patches/common/file_struct_8bytes_align.patch"
  19. patch -p1 --forward < "${{ github.workspace }}/kernel_patches/common/reduce_cache_pressure.patch"
  20. patch -p1 --forward < "${{ github.workspace }}/kernel_patches/common/mem_opt_prefetch.patch"
  21. if [ "$(printf '%s\n' "$KERNEL_VERSION" "$MIN_VERSION" | sort -V | tail -n1)" = "$KERNEL_VERSION" ]; then
  22. patch -p1 --forward < "${{ github.workspace }}/kernel_patches/common/optimise_memcmp.patch"
  23. elif [ "$(printf '%s\n' "$KERNEL_VERSION" "5.11" | sort -V | tail -n1)" = "$KERNEL_VERSION" ]; then
  24. sed -e 's/SYM_FUNC_START(__pi_memcmp)/SYM_FUNC_START_WEAK_PI(memcmp)/' -e 's/SYM_FUNC_END(__pi_memcmp)/SYM_FUNC_END_PI(memcmp)/' -e 's/SYM_FUNC_ALIAS_WEAK(memcmp, __pi_memcmp)/EXPORT_SYMBOL_NOKASAN(memcmp)/' "${{ github.workspace }}/kernel_patches/common/optimise_memcmp.patch" | patch -p1 --forward
  25. else
  26. echo "Optimised memcmp patch not found!"
  27. fi
  28. patch -p1 --forward < "${{ github.workspace }}/kernel_patches/common/minimise_wakeup_time.patch"
  29. patch -p1 --forward < "${{ github.workspace }}/kernel_patches/common/int_sqrt.patch"
  30. patch -p1 --forward < "${{ github.workspace }}/kernel_patches/common/reduce_gc_thread_sleep_time.patch"
  31. patch -p1 --forward < "${{ github.workspace }}/kernel_patches/common/add_timeout_wakelocks_globally.patch"
  32. patch -p1 --forward < "${{ github.workspace }}/kernel_patches/common/f2fs_reduce_congestion.patch"
  33. patch -p1 --forward < "${{ github.workspace }}/kernel_patches/common/reduce_freeze_timeout.patch"
  34. if [ "$(printf '%s\n' "$KERNEL_VERSION" "$MIN_VERSION" | sort -V | head -n1)" = "$KERNEL_VERSION" ]; then
  35. patch -p1 --forward < "${{ github.workspace }}/kernel_patches/common/clear_page_16bytes_align.patch"
  36. else
  37. cat "${{ github.workspace }}/kernel_patches/common/clear_page_16bytes_align.patch" | sed -e 's/SYM_FUNC_START_PI(clear_page)/SYM_FUNC_START_PI(__pi_clear_page)/' | patch -p1 -F3 --forward
  38. fi
  39. echo "Patching add_limitation_scaling_min_freq.patch"
  40. patch -p1 -F3 --forward < "${{ github.workspace }}/kernel_patches/common/add_limitation_scaling_min_freq.patch"
  41. echo "Patching re_write_limitation_scaling_min_freq.patch"
  42. patch -p1 -F3 --forward < "${{ github.workspace }}/kernel_patches/common/re_write_limitation_scaling_min_freq.patch"
  43. echo "Patching adjust_cpu_scan_order.patch"
  44. patch -p1 -F3 --forward < "${{ github.workspace }}/kernel_patches/common/adjust_cpu_scan_order.patch"
  45. echo "Patching avoid_extra_s2idle_wake_attempts.patch"
  46. FILE="drivers/base/power/wakeup.c"
  47. # Check if the function exists
  48. if grep -q "^void pm_system_wakeup(void)" "$FILE"; then
  49. # Check if the line exists inside the function
  50. if sed -n '/^void pm_system_wakeup(void)/,/^}/p' "$FILE" | grep -q 'suspend_abort_fs_sync();'; then
  51. # Remove the line
  52. sed -i '/^void pm_system_wakeup(void)/,/^}/{
  53. /suspend_abort_fs_sync();/d
  54. }' "$FILE"
  55. fi
  56. fi
  57. patch -p1 -F3 --forward < "${{ github.workspace }}/kernel_patches/common/avoid_extra_s2idle_wake_attempts.patch"
  58. echo "Patching disable_cache_hot_buddy.patch"
  59. patch -p1 -F3 --forward < "${{ github.workspace }}/kernel_patches/common/disable_cache_hot_buddy.patch"
  60. echo "Patching f2fs_enlarge_min_fsync_blocks.patch"
  61. patch -p1 -F3 --forward < "${{ github.workspace }}/kernel_patches/common/f2fs_enlarge_min_fsync_blocks.patch"
  62. echo "Patching increase_ext4_default_commit_age.patch"
  63. patch -p1 -F3 --forward < "${{ github.workspace }}/kernel_patches/common/increase_ext4_default_commit_age.patch"
  64. echo "Patching increase_sk_mem_packets.patch"
  65. patch -p1 -F3 --forward < "${{ github.workspace }}/kernel_patches/common/increase_sk_mem_packets.patch"
  66. echo "Patching reduce_pci_pme_wakeups.patch"
  67. patch -p1 -F3 --forward < "${{ github.workspace }}/kernel_patches/common/reduce_pci_pme_wakeups.patch"
  68. echo "Patching silence_irq_cpu_logspam.patch"
  69. patch -p1 -F3 --forward < "${{ github.workspace }}/kernel_patches/common/silence_irq_cpu_logspam.patch"
  70. echo "Patching silence_system_logspam.patch"
  71. patch -p1 -F3 --forward < "${{ github.workspace }}/kernel_patches/common/silence_system_logspam.patch"
  72. echo "Patching use_unlikely_wrap_cpufreq.patch"
  73. patch -p1 -F3 --forward < "${{ github.workspace }}/kernel_patches/common/use_unlikely_wrap_cpufreq.patch"
  74. echo "[+] Other patches applied"