Determine whether to enable userfaultfd GC at build time.
This is determined by: - a product config flag - the vendor API level It is then passed to the device as a system property "ro.dalvik.vm.enable_uffd_gc". This change is a no-op change. It doesn't enable userfaultfd GC by default. OVERRIDE_ENABLE_UFFD_GC=default can be passed to the build system to enable userfaultfd GC for testing purposes. Bug: 242553398 Test: - 1. lunch aosp_redfin-userdebug 2. OVERRIDE_ENABLE_UFFD_GC=default build/soong/soong_ui.bash --dumpvars-mode --vars=ENABLE_UFFD_GC 3. See "false" in the output Test: - 1. lunch aosp_oriole-userdebug 2. OVERRIDE_ENABLE_UFFD_GC=default build/soong/soong_ui.bash --dumpvars-mode --vars=ENABLE_UFFD_GC 3. See "true" in the output Test: - 1. lunch aosp_redfin-userdebug 2. OVERRIDE_ENABLE_UFFD_GC=true build/soong/soong_ui.bash --dumpvars-mode --vars=ENABLE_UFFD_GC 3. See "true" in the output Test: - 1. lunch aosp_oriole-userdebug 2. OVERRIDE_ENABLE_UFFD_GC=false build/soong/soong_ui.bash --dumpvars-mode --vars=ENABLE_UFFD_GC 3. See "false" in the output Change-Id: Ifd6e6cddb502315912ff949619a5b526ae0d73ff
This commit is contained in:
parent
05cc591fff
commit
d6c6e3a9f3
7 changed files with 66 additions and 1 deletions
|
@ -1,4 +1,5 @@
|
|||
per-file *dex_preopt*.* = ngeoffray@google.com,skvadrik@google.com
|
||||
per-file *dex_preopt*.* = jiakaiz@google.com,ngeoffray@google.com,skvadrik@google.com
|
||||
per-file art_*.* = jiakaiz@google.com,ngeoffray@google.com,skvadrik@google.com
|
||||
per-file verify_uses_libraries.sh = ngeoffray@google.com,skvadrik@google.com
|
||||
|
||||
# For global Proguard rules
|
||||
|
|
46
core/art_config.mk
Normal file
46
core/art_config.mk
Normal file
|
@ -0,0 +1,46 @@
|
|||
# ART configuration that has to be determined after product config is resolved.
|
||||
#
|
||||
# Inputs:
|
||||
# PRODUCT_ENABLE_UFFD_GC: See comments in build/make/core/product.mk.
|
||||
# OVERRIDE_ENABLE_UFFD_GC: Overrides PRODUCT_ENABLE_UFFD_GC. Can be passed from the commandline for
|
||||
# debugging purposes.
|
||||
# BOARD_API_LEVEL: See comments in build/make/core/main.mk.
|
||||
# BOARD_SHIPPING_API_LEVEL: See comments in build/make/core/main.mk.
|
||||
# PRODUCT_SHIPPING_API_LEVEL: See comments in build/make/core/product.mk.
|
||||
#
|
||||
# Outputs:
|
||||
# ENABLE_UFFD_GC: Whether to use userfaultfd GC.
|
||||
|
||||
config_enable_uffd_gc := \
|
||||
$(firstword $(OVERRIDE_ENABLE_UFFD_GC) $(PRODUCT_ENABLE_UFFD_GC))
|
||||
|
||||
ifeq (,$(filter-out default,$(config_enable_uffd_gc)))
|
||||
ENABLE_UFFD_GC := true
|
||||
|
||||
# Disable userfaultfd GC if the device doesn't support it (i.e., if
|
||||
# `min(ro.board.api_level ?? ro.board.first_api_level ?? MAX_VALUE,
|
||||
# ro.product.first_api_level ?? ro.build.version.sdk ?? MAX_VALUE) < 31`)
|
||||
# This logic aligns with how `ro.vendor.api_level` is calculated in
|
||||
# `system/core/init/property_service.cpp`.
|
||||
# We omit the check on `ro.build.version.sdk` here because we are on the latest build system.
|
||||
board_api_level := $(firstword $(BOARD_API_LEVEL) $(BOARD_SHIPPING_API_LEVEL))
|
||||
ifneq (,$(board_api_level))
|
||||
ifeq (true,$(call math_lt,$(board_api_level),31))
|
||||
ENABLE_UFFD_GC := false
|
||||
endif
|
||||
endif
|
||||
|
||||
ifneq (,$(PRODUCT_SHIPPING_API_LEVEL))
|
||||
ifeq (true,$(call math_lt,$(PRODUCT_SHIPPING_API_LEVEL),31))
|
||||
ENABLE_UFFD_GC := false
|
||||
endif
|
||||
endif
|
||||
else ifeq (true,$(config_enable_uffd_gc))
|
||||
ENABLE_UFFD_GC := true
|
||||
else ifeq (false,$(config_enable_uffd_gc))
|
||||
ENABLE_UFFD_GC := false
|
||||
else
|
||||
$(error Unknown PRODUCT_ENABLE_UFFD_GC value: $(config_enable_uffd_gc))
|
||||
endif
|
||||
|
||||
ADDITIONAL_PRODUCT_PROPERTIES += ro.dalvik.vm.enable_uffd_gc=$(ENABLE_UFFD_GC)
|
|
@ -130,6 +130,7 @@ ifeq ($(WRITE_SOONG_VARIABLES),true)
|
|||
$(call add_json_str, Dex2oatXmx, $(DEX2OAT_XMX))
|
||||
$(call add_json_str, Dex2oatXms, $(DEX2OAT_XMS))
|
||||
$(call add_json_str, EmptyDirectory, $(OUT_DIR)/empty)
|
||||
$(call add_json_bool, EnableUffdGc, $(ENABLE_UFFD_GC))
|
||||
|
||||
ifdef TARGET_ARCH
|
||||
$(call add_json_map, CpuVariant)
|
||||
|
|
|
@ -493,6 +493,8 @@ endif
|
|||
# Typical build; include any Android.mk files we can find.
|
||||
#
|
||||
|
||||
include $(BUILD_SYSTEM)/art_config.mk
|
||||
|
||||
# Bring in dex_preopt.mk
|
||||
# This creates some modules so it needs to be included after
|
||||
# should-install-to-system is defined (in order for base_rules.mk to function
|
||||
|
|
|
@ -370,6 +370,18 @@ _product_single_value_vars += PRODUCT_MODULE_BUILD_FROM_SOURCE
|
|||
# If true, installs a full version of com.android.virt APEX.
|
||||
_product_single_value_vars += PRODUCT_AVF_ENABLED
|
||||
|
||||
# Whether to use userfaultfd GC.
|
||||
# Possible values are:
|
||||
# - "default" or empty: both the build system and the runtime determine whether to use userfaultfd
|
||||
# GC based on the vendor API level
|
||||
# - "true": forces the build system to use userfaultfd GC regardless of the vendor API level; the
|
||||
# runtime determines whether to use userfaultfd GC based on the kernel support. Note that the
|
||||
# device may have to re-compile everything on the first boot if the kernel doesn't support
|
||||
# userfaultfd
|
||||
# - "false": disallows the build system and the runtime to use userfaultfd GC even if the device
|
||||
# supports it
|
||||
_product_single_value_vars += PRODUCT_ENABLE_UFFD_GC
|
||||
|
||||
.KATI_READONLY := _product_single_value_vars _product_list_vars
|
||||
_product_var_list :=$= $(_product_single_value_vars) $(_product_list_vars)
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@ BINDER32BIT := true
|
|||
endif
|
||||
endif
|
||||
|
||||
include $(BUILD_SYSTEM)/art_config.mk
|
||||
include $(BUILD_SYSTEM)/dex_preopt_config.mk
|
||||
|
||||
ifeq ($(WRITE_SOONG_VARIABLES),true)
|
||||
|
|
|
@ -113,3 +113,5 @@ PRODUCT_SYSTEM_PROPERTIES += \
|
|||
dalvik.vm.image-dex2oat-Xmx=64m \
|
||||
dalvik.vm.dex2oat-Xms=64m \
|
||||
dalvik.vm.dex2oat-Xmx=512m \
|
||||
|
||||
PRODUCT_ENABLE_UFFD_GC := false # TODO(jiakaiz): Change this to "default".
|
||||
|
|
Loading…
Reference in a new issue