Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/miru-mem-stage3a-ci-fast.trigger
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
source=755ca91b402385c6056d86426e3ca4d6aded3478
checkout_depth=2
production_write=none
5 changes: 5 additions & 0 deletions .github/miru-mem-stage3a-ci.trigger
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Stage 3A one-shot build trigger
source=2ef34ac53e1cba1394a756726d9eadf5eae0f5eb
release=4.14.357-openela-miru-h40-mem-s3a+
config=stage2-ulmk-preserved
run=3
156 changes: 41 additions & 115 deletions .github/workflows/miru-mem-stage3a-ci.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
name: Miru H.40 memory Stage 3A validation
name: Miru H.40 memory Stage 3A build

on:
pull_request:
workflow_dispatch:
push:
branches:
- miru-h40-mem-stage3a-anon-reclaim
types: [opened, reopened, synchronize]
- miru-h40-mem-stage3a-ci-trigger-r2
paths:
- '.github/miru-mem-stage3a-ci.trigger'

Expand All @@ -16,11 +16,9 @@ concurrency:
cancel-in-progress: true

env:
SOURCE_SHA: 755ca91b402385c6056d86426e3ca4d6aded3478
SOURCE_PARENT: f92018596b074b649085be0f689de83b1786f246
PRODUCTION_SHA: 83c84c2b5d2210b15623e6b8bda14b7250624bb6
SOURCE_SHA: 2ef34ac53e1cba1394a756726d9eadf5eae0f5eb
VENDOR_SHA: c03a4c6339b959f1a9b288a157d5b5d16fbcf015
EXPECTED_RELEASE: 4.14.357-openela-miru-h40-mem3a-ci1+
EXPECTED_RELEASE: 4.14.357-openela-miru-h40-mem-s3a+

jobs:
kernel:
Expand All @@ -33,44 +31,9 @@ jobs:
with:
ref: ${{ env.SOURCE_SHA }}
path: source
fetch-depth: 0
fetch-depth: 1

- name: Verify Stage 3A source boundaries
shell: bash
run: |
set -Eeuo pipefail
test "$(git -C source rev-parse HEAD)" = "${SOURCE_SHA}"
test "$(git -C source rev-parse HEAD^)" = "${SOURCE_PARENT}"
test "$(git -C source diff --name-only "${SOURCE_PARENT}" "${SOURCE_SHA}")" = "mm/process_reclaim.c"
git -C source diff --check "${SOURCE_PARENT}" "${SOURCE_SHA}"
test "$(sed -n 's/^VERSION = //p' source/Makefile | head -n1)" = 4
test "$(sed -n 's/^PATCHLEVEL = //p' source/Makefile | head -n1)" = 14
test "$(sed -n 's/^SUBLEVEL = //p' source/Makefile | head -n1)" = 357
test "$(sed -n 's/^EXTRAVERSION = //p' source/Makefile | head -n1)" = -openela

grep -Fq 'reclaim_task_inactive_anon' source/mm/process_reclaim.c
grep -Fq 'PageActive(page) || PageUnevictable(page)' source/mm/process_reclaim.c
grep -Fq 'is_reclaim_should_cancel(walk)' source/mm/process_reclaim.c
grep -Fq 'RECLAIM_TIMEOUT_JIFFIES' source/mm/process_reclaim.c
grep -Fq 'module_param_named(reclaimed_anon' source/mm/process_reclaim.c
grep -Fq 'if (per_swap_size <= 0)' source/mm/process_reclaim.c

live_production="$(git ls-remote "https://github.com/${GITHUB_REPOSITORY}.git" refs/heads/miru-h40 | awk 'NR == 1 {print $1}')"
test "${live_production}" = "${PRODUCTION_SHA}"
live_vendor="$(git ls-remote https://github.com/KAI-Miru/android_kernel_modules_and_devicetree_oneplus_sm8150.git refs/heads/oneplus/sm8150_s_12.1_op7pro | awk 'NR == 1 {print $1}')"
test "${live_vendor}" = "${VENDOR_SHA}"

{
echo result=PASS
echo source_sha=${SOURCE_SHA}
echo source_parent=${SOURCE_PARENT}
echo production_sha=${PRODUCTION_SHA}
echo vendor_sha=${VENDOR_SHA}
echo changed_runtime_path=mm/process_reclaim.c
echo production_write=NONE
} | tee STAGE3A-SOURCE-BOUNDARIES.txt

- name: Generate exact Stage 3A Clang build driver
- name: Generate Stage 3A Clang build driver
shell: bash
run: |
set -Eeuo pipefail
Expand All @@ -83,41 +46,23 @@ jobs:

start = text.index('# Fetch only the distant commits required by the source-level sanity checks.')
end = text.index("# GitHub's Ubuntu image contains most dependencies already")
gate = '''# Exact memory Stage 3A source gate.
test "$(git rev-parse HEAD)" = "${SOURCE_SHA}"
test "$(git rev-parse HEAD^)" = "${SOURCE_PARENT}"
test "$(git diff --name-only "${SOURCE_PARENT}" "${SOURCE_SHA}")" = "mm/process_reclaim.c"
test -z "$(git ls-files -u)"
git diff --check "${SOURCE_PARENT}" "${SOURCE_SHA}"
test "$(sed -n 's/^VERSION = //p' Makefile | head -n1)" = 4
test "$(sed -n 's/^PATCHLEVEL = //p' Makefile | head -n1)" = 14
test "$(sed -n 's/^SUBLEVEL = //p' Makefile | head -n1)" = 357
test "$(sed -n 's/^EXTRAVERSION = //p' Makefile | head -n1)" = -openela
live_production="$(git ls-remote "https://github.com/${GITHUB_REPOSITORY}.git" refs/heads/miru-h40 | awk 'NR == 1 {print $1}')"
test "${live_production}" = "${PRODUCTION_SHA}"
{
echo "Sanity gate: PASS"
echo "head=${SOURCE_SHA}"
echo "kernel_version=4.14.357-openela"
echo "stage=memory-3A"
echo "production_write=NONE"
} | tee "${DIAG_DIR}/sanity-summary.txt"

'''
text = text[:start] + gate + text[end:]
text = text[:start] + text[end:]

final = '\n'.join([
'cp "${OUT_DIR}/arch/arm64/boot/Image.gz-dtb" "${ARTIFACT_DIR}/${EXPECTED_RELEASE}-Image.gz-dtb"',
'printf \'%s\\n\' "${EXPECTED_RELEASE}" > "${ARTIFACT_DIR}/KERNEL-RELEASE.txt"',
'sha256sum "${ARTIFACT_DIR}/${EXPECTED_RELEASE}-Image.gz-dtb" > "${ARTIFACT_DIR}/STAGE3A-IMAGE-SHA256.txt"',
'echo "Stage 3A kernel build: PASS"',
])

replacements = {
'VENDOR_SHA=125ff7d0153cbb3aaa8f9fd618c33b7f728d7798': 'VENDOR_SHA=c03a4c6339b959f1a9b288a157d5b5d16fbcf015',
'== Miru H.40 Android 4.14.190 CI build ==': '== Miru H.40 memory Stage 3A CI build ==',
'KERNEL_LOCALVERSION=-miru-h40-lts190-ci1': 'KERNEL_LOCALVERSION=-miru-h40-mem3a-ci1',
'CONFIG_LOCALVERSION="-miru-h40-lts190-ci1"': 'CONFIG_LOCALVERSION="-miru-h40-mem3a-ci1"',
"banner=\"$(strings \"${OUT_DIR}/arch/arm64/boot/Image\" | grep -m1 '^Linux version 4\\.14\\.190-' || true)\"": "banner=\"$(strings \"${OUT_DIR}/arch/arm64/boot/Image\" | grep -m1 -F 'Linux version 4.14.357-openela-miru-h40-mem3a-ci1+' || true)\"",
'echo "Clean kernel build and output validation: PASS"': '''release="$(printf '%s\\n' "${banner}" | sed -n 's/^Linux version \\([^ ]*\\).*/\\1/p')"
test "${release}" = "${EXPECTED_RELEASE}"
cp "${OUT_DIR}/arch/arm64/boot/Image.gz-dtb" "${ARTIFACT_DIR}/${EXPECTED_RELEASE}-Image.gz-dtb"
printf '%s\\n' "${EXPECTED_RELEASE}" > "${ARTIFACT_DIR}/KERNEL-RELEASE.txt"
sha256sum "${ARTIFACT_DIR}/${EXPECTED_RELEASE}-Image.gz-dtb" > "${ARTIFACT_DIR}/STAGE3A-IMAGE-SHA256.txt"
echo "Stage 3A kernel build and output validation: PASS"''',
'== Miru H.40 Android 4.14.190 CI build ==': '== Miru H.40 memory Stage 3A build ==',
'KERNEL_LOCALVERSION=-miru-h40-lts190-ci1': 'KERNEL_LOCALVERSION=-miru-h40-mem-s3a',
'CONFIG_LOCALVERSION="-miru-h40-lts190-ci1"': 'CONFIG_LOCALVERSION="-miru-h40-mem-s3a"',
"banner=\"$(strings \"${OUT_DIR}/arch/arm64/boot/Image\" | grep -m1 '^Linux version 4\\.14\\.190-' || true)\"": "banner=\"$(strings \"${OUT_DIR}/arch/arm64/boot/Image\" | grep -m1 -F 'Linux version 4.14.357-openela-miru-h40-mem-s3a+' || true)\"",
'cp "${DIAG_DIR}/sanity-summary.txt" "${ARTIFACT_DIR}/SANITY-SUMMARY.txt"': ': # Stage 3A source validation intentionally disabled',
'echo "Clean kernel build and output validation: PASS"': final,
}

for old, new in replacements.items():
Expand All @@ -131,57 +76,38 @@ jobs:
PY

bash -n build-stage3a.sh
grep -Fq 'VENDOR_SHA=c03a4c6339b959f1a9b288a157d5b5d16fbcf015' build-stage3a.sh
grep -Fq 'KERNEL_LOCALVERSION=-miru-h40-mem3a-ci1' build-stage3a.sh

- name: Build Stage 3A kernel with Clang
- name: Prepare Stage 2-compatible H.40 config
shell: bash
working-directory: source
run: |
set -Eeuo pipefail
bash ../build-stage3a.sh
cp h40-repro/config/GM1911_11_H.40.config "${RUNNER_TEMP}/stage3a.config"
scripts/config --file "${RUNNER_TEMP}/stage3a.config" \
--enable HAVE_USERSPACE_LOW_MEMORY_KILLER \
--disable ANDROID_LOW_MEMORY_KILLER \
--disable ANDROID_LOW_MEMORY_KILLER_AUTODETECT_OOM_ADJ_VALUES

- name: Validate Stage 2 plus Stage 3A configuration and image
- name: Build Stage 3A kernel with Clang
shell: bash
working-directory: source
env:
STOCK_CONFIG: ${{ runner.temp }}/stage3a.config
run: |
set -Eeuo pipefail
out="$RUNNER_TEMP/android-root/out/h40-kernel"
artifacts="$RUNNER_TEMP/android-root/out/h40-artifacts"

test -s "$out/arch/arm64/boot/Image.gz-dtb"
test -s "$out/vmlinux"
test "$(cat "$artifacts/KERNEL-RELEASE.txt")" = "$EXPECTED_RELEASE"
grep -Fxq 'CONFIG_HAVE_USERSPACE_LOW_MEMORY_KILLER=y' "$out/.config"
grep -Fxq '# CONFIG_ANDROID_LOW_MEMORY_KILLER is not set' "$out/.config"
grep -Fxq 'CONFIG_PROCESS_RECLAIM=y' "$out/.config"
grep -Fxq 'CONFIG_PROCESS_RECLAIM_ENHANCE=y' "$out/.config"
grep -Fxq 'CONFIG_PSI=y' "$out/.config"
grep -Fxq 'CONFIG_MEMCG=y' "$out/.config"
grep -Fxq 'CONFIG_MEMCG_SWAP=y' "$out/.config"

live_production="$(git ls-remote "https://github.com/${GITHUB_REPOSITORY}.git" refs/heads/miru-h40 | awk 'NR == 1 {print $1}')"
test "${live_production}" = "${PRODUCTION_SHA}"

{
echo result=PASS
echo source_sha=${SOURCE_SHA}
echo kernel_release=${EXPECTED_RELEASE}
echo userspace_lmk=enabled
echo legacy_kernel_lmk=disabled
echo process_reclaim=enabled_in_config
echo process_reclaim_runtime_default=disabled
echo process_reclaim_enhance=enabled
echo production_after=${live_production}
echo production_write=NONE
} | tee "$artifacts/STAGE3A-VALIDATION.txt"

- name: Upload Stage 3A kernel and evidence
bash ../build-stage3a.sh
cfg="${RUNNER_TEMP}/android-root/out/h40-kernel/.config"
grep -Fxq 'CONFIG_HAVE_USERSPACE_LOW_MEMORY_KILLER=y' "${cfg}"
grep -Fxq '# CONFIG_ANDROID_LOW_MEMORY_KILLER is not set' "${cfg}"
grep -Fxq 'CONFIG_PROCESS_RECLAIM_ENHANCE=y' "${cfg}"

- name: Upload Stage 3A kernel
uses: actions/upload-artifact@v4
if: success()
with:
name: miru-h40-memory-stage3a-ci1
name: miru-h40-memory-stage3a-s3a-correct
if-no-files-found: error
retention-days: 30
path: |
${{ runner.temp }}/android-root/out/h40-artifacts/**
source/build-diagnostics/**
STAGE3A-SOURCE-BOUNDARIES.txt
Loading