action.yml 4.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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 avoid_extra_s2idle_wake_attempts.patch"
  40. FILE="drivers/base/power/wakeup.c"
  41. # Check if the function exists
  42. if grep -q "^void pm_system_wakeup(void)" "$FILE"; then
  43. # Check if the line exists inside the function
  44. if sed -n '/^void pm_system_wakeup(void)/,/^}/p' "$FILE" | grep -q 'suspend_abort_fs_sync();'; then
  45. # Remove the line
  46. sed -i '/^void pm_system_wakeup(void)/,/^}/{
  47. /suspend_abort_fs_sync();/d
  48. }' "$FILE"
  49. fi
  50. fi
  51. patch -p1 -F3 --forward < "${{ github.workspace }}/kernel_patches/common/avoid_extra_s2idle_wake_attempts.patch"
  52. echo "Patching disable_cache_hot_buddy.patch"
  53. patch -p1 -F3 --forward < "${{ github.workspace }}/kernel_patches/common/disable_cache_hot_buddy.patch"
  54. echo "Patching f2fs_enlarge_min_fsync_blocks.patch"
  55. patch -p1 -F3 --forward < "${{ github.workspace }}/kernel_patches/common/f2fs_enlarge_min_fsync_blocks.patch"
  56. echo "Patching increase_ext4_default_commit_age.patch"
  57. patch -p1 -F3 --forward < "${{ github.workspace }}/kernel_patches/common/increase_ext4_default_commit_age.patch"
  58. echo "Patching increase_sk_mem_packets.patch"
  59. patch -p1 -F3 --forward < "${{ github.workspace }}/kernel_patches/common/increase_sk_mem_packets.patch"
  60. echo "Patching reduce_pci_pme_wakeups.patch"
  61. patch -p1 -F3 --forward < "${{ github.workspace }}/kernel_patches/common/reduce_pci_pme_wakeups.patch"
  62. echo "Patching silence_irq_cpu_logspam.patch"
  63. patch -p1 -F3 --forward < "${{ github.workspace }}/kernel_patches/common/silence_irq_cpu_logspam.patch"
  64. echo "Patching silence_system_logspam.patch"
  65. patch -p1 -F3 --forward < "${{ github.workspace }}/kernel_patches/common/silence_system_logspam.patch"
  66. echo "[+] Other patches applied"