Conservative SmartOS global-zone memory pressure guard with dry-run-first policy and SMF integration.
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
 
 
 
 

61 lignes
3.5 KiB

  1. # GNU make / gmake. Native target requires an illumos 64-bit compiler + headers.
  2. CC = gcc
  3. CPPFLAGS = -D__EXTENSIONS__ -D_POSIX_C_SOURCE=200809L -Isrc
  4. CFLAGS = -std=c99 -m64 -O2 -Wall -Wextra -Werror -Wformat=2
  5. LDLIBS = -lkstat -lrt -lpthread
  6. SOURCES = src/main.c src/core.c src/config.c src/support.c src/illumos.c src/validation.c src/result.c src/signal.c
  7. TESTFLAGS = -std=c99 -O1 -g -D_POSIX_C_SOURCE=200809L -D_XOPEN_SOURCE=700 -Isrc -Wall -Wextra -Werror -Wformat=2 -pedantic -pthread
  8. .PHONY: all native-check test test-distribution test-sanitize portability clean
  9. all: o6h-memory-guard
  10. native-check:
  11. @test "`uname -s`" = SunOS || { echo "Native build requires SmartOS/illumos; use make test and make portability here."; exit 1; }
  12. o6h-memory-guard: $(SOURCES) src/guard.h | native-check
  13. $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ $(SOURCES) $(LDLIBS)
  14. test-guard: tests/test_guard.c tests/fixtures/pageout_deadman_real_incident_2026_09.csv tests/fixtures/successful_pageout_deadman_avoidance_2026_09_21.csv src/core.c src/config.c src/guard.h
  15. $(CC) $(TESTFLAGS) -o $@ tests/test_guard.c src/core.c src/config.c
  16. test-runtime: tests/test_runtime.c tests/fixtures/global_victim_ranking_smartos_2026_09.csv tests/fixtures/panic32_daemon_stall_2026_09_22.csv tests/fixtures/floor_free_pages_486_2026_09_23.csv src/main.c src/core.c src/config.c src/result.c src/guard.h
  17. $(CC) $(TESTFLAGS) -o $@ tests/test_runtime.c src/core.c src/config.c src/result.c
  18. test-runtime: tests/fixtures/pckill_latency_2026_09_28.csv tests/fixtures/refresh_recovery_and_failure.csv
  19. test-runtime: tests/fixtures/panic33_persistent_floor_budget_exhaustion_2026_10_08.csv
  20. test-distribution: tests/test_distribution.sh smf/o6h-memory-guard.xml etc/o6h-memory-guard.conf src/main.c
  21. sh tests/test_distribution.sh
  22. test-validation: tests/test_validation.c src/validation.c src/signal.c src/guard.h
  23. $(CC) $(TESTFLAGS) -Itests/api-sketch -o $@ tests/test_validation.c
  24. test-prepare: tests/test_prepare.c src/illumos.c src/core.c src/config.c src/guard.h
  25. $(CC) $(TESTFLAGS) -Itests/api-sketch -o $@ tests/test_prepare.c src/core.c src/config.c
  26. test: test-guard test-runtime test-validation test-prepare test-distribution
  27. ./test-guard
  28. ./test-runtime
  29. ./test-validation
  30. ./test-prepare
  31. test-sanitize:
  32. $(CC) $(TESTFLAGS) -fsanitize=address,undefined -fno-omit-frame-pointer -o test-sanitize-guard tests/test_guard.c src/core.c src/config.c
  33. ./test-sanitize-guard
  34. $(CC) $(TESTFLAGS) -fsanitize=address,undefined -fno-omit-frame-pointer -o test-sanitize-runtime tests/test_runtime.c src/core.c src/config.c src/result.c
  35. ./test-sanitize-runtime
  36. $(CC) $(TESTFLAGS) -Itests/api-sketch -fsanitize=address,undefined -fno-omit-frame-pointer -o test-sanitize-validation tests/test_validation.c
  37. ./test-sanitize-validation
  38. $(CC) $(TESTFLAGS) -Itests/api-sketch -fsanitize=address,undefined -fno-omit-frame-pointer -o test-sanitize-prepare tests/test_prepare.c src/core.c src/config.c
  39. ./test-sanitize-prepare
  40. # Local API sketches only: NOT real illumos headers, ABI, linking or runtime validation.
  41. portability:
  42. $(CC) $(TESTFLAGS) -Itests/api-sketch -fsyntax-only $(SOURCES)
  43. @for source in $(SOURCES); do $(CC) $(TESTFLAGS) -Itests/api-sketch -fanalyzer -c $$source -o /dev/null || exit 1; done
  44. sh -n install.sh tests/test_distribution.sh
  45. xmllint --nonet --noout smf/o6h-memory-guard.xml
  46. clean:
  47. rm -f o6h-memory-guard test-guard test-runtime test-validation test-prepare test-sanitize-guard test-sanitize-runtime test-sanitize-validation test-sanitize-prepare