From 1f17430bf0e9a8234da22e7f28714b16cc81d9d7 Mon Sep 17 00:00:00 2001 From: Swetha Chikkaboraiah Date: Wed, 29 Jul 2020 22:47:07 +0530 Subject: [PATCH] AndroidKernel: Disable debugfs for user builds Debugfs is not needed on user builds, so disabling same at compile time for ARM 64. Change-Id: If6708c9de060584ebcba4cac9bad8e85d6a5ab7f Signed-off-by: Swetha Chikkaboraiah --- AndroidKernel.mk | 20 +++++++++++++++++--- disable_dbgfs.sh | 29 +++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+), 3 deletions(-) create mode 100755 disable_dbgfs.sh diff --git a/AndroidKernel.mk b/AndroidKernel.mk index f7e26617f635..73a2232be4a2 100644 --- a/AndroidKernel.mk +++ b/AndroidKernel.mk @@ -10,6 +10,8 @@ ifneq ($(TARGET_KERNEL_APPEND_DTB), true) $(info Using DTB Image) INSTALLED_DTBIMAGE_TARGET := $(PRODUCT_OUT)/dtb.img endif +MAKE_ARGS := $(strip $(TARGET_KERNEL_MAKE_ARGS)) +KERNEL_DISABLE_DEBUGFS := $(TARGET_KERNEL_DISABLE_DEBUGFS) TARGET_KERNEL_MAKE_ENV := $(strip $(TARGET_KERNEL_MAKE_ENV)) ifeq ($(TARGET_KERNEL_MAKE_ENV),) @@ -138,6 +140,7 @@ $(info Using appended DTB) TARGET_PREBUILT_INT_KERNEL := $(TARGET_PREBUILT_INT_KERNEL)-dtb endif +KERNEL_DEBUGFS := $(KERNEL_OUT)/tmp KERNEL_HEADERS_INSTALL := $(KERNEL_OUT)/usr KERNEL_MODULES_INSTALL ?= system KERNEL_MODULES_OUT ?= $(PRODUCT_OUT)/$(KERNEL_MODULES_INSTALL)/lib/modules @@ -162,6 +165,9 @@ mpath=`dirname $$mdpath`; rm -rf $$mpath;\ fi endef +$(KERNEL_OUT): $(KERNEL_DEBUGFS) + mkdir -p $(KERNEL_OUT) + ifneq ($(KERNEL_LEGACY_DIR),true) $(KERNEL_USR): $(KERNEL_HEADERS_INSTALL) rm -rf $(KERNEL_SYMLINK) @@ -170,9 +176,6 @@ $(KERNEL_USR): $(KERNEL_HEADERS_INSTALL) $(TARGET_PREBUILT_INT_KERNEL): $(KERNEL_USR) endif -$(KERNEL_OUT): - mkdir -p $(KERNEL_OUT) - $(KERNEL_CONFIG): $(KERNEL_OUT) $(MAKE) -C $(TARGET_KERNEL_SOURCE) O=$(BUILD_ROOT_LOC)$(KERNEL_OUT) $(KERNEL_MAKE_ENV) ARCH=$(KERNEL_ARCH) CROSS_COMPILE=$(KERNEL_CROSS_COMPILE) $(real_cc) $(KERNEL_DEFCONFIG) $(hide) if [ ! -z "$(KERNEL_CONFIG_OVERRIDE)" ]; then \ @@ -206,6 +209,17 @@ $(TARGET_PREBUILT_INT_KERNEL): $(KERNEL_OUT) $(KERNEL_HEADERS_INSTALL) $(clean-module-folder) endif +$(KERNEL_DEBUGFS): + KERNEL_DIR=$(TARGET_KERNEL_SOURCE) \ + DEFCONFIG=$(KERNEL_DEFCONFIG) \ + OUT_DIR=$(KERNEL_OUT) \ + ARCH=$(KERNEL_ARCH) \ + CROSS_COMPILE=$(KERNEL_CROSS_COMPILE) \ + DISABLE_DEBUGFS=$(KERNEL_DISABLE_DEBUGFS) \ + $(TARGET_KERNEL_SOURCE)/disable_dbgfs.sh \ + $(real_cc) \ + $(TARGET_KERNEL_MAKE_ARGS) + $(KERNEL_HEADERS_INSTALL): $(KERNEL_OUT) $(hide) if [ ! -z "$(KERNEL_HEADER_DEFCONFIG)" ]; then \ rm -f $(BUILD_ROOT_LOC)$(KERNEL_CONFIG) && \ diff --git a/disable_dbgfs.sh b/disable_dbgfs.sh new file mode 100755 index 000000000000..fe23680972a5 --- /dev/null +++ b/disable_dbgfs.sh @@ -0,0 +1,29 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0 + +# disable debugfs for user builds +export MAKE_ARGS=$@ + +if [ ${DISABLE_DEBUGFS} == "true" ]; then + echo "build variant ${TARGET_BUILD_VARIANT}" + if [ ${TARGET_BUILD_VARIANT} == "user" ] && \ + [ ${ARCH} == "arm64" ]; then + echo "combining fragments for user build" + (cd $KERNEL_DIR && \ + ARCH=${ARCH} CROSS_COMPILE=${CROSS_COMPILE}\ + ./scripts/kconfig/merge_config.sh \ + ./arch/${ARCH}/configs/$DEFCONFIG \ + ./arch/${ARCH}/configs/vendor/debugfs.config + make ${MAKE_ARGS} ARCH=${ARCH} \ + CROSS_COMPILE=${CROSS_COMPILE} savedefconfig + mv defconfig ./arch/${ARCH}/configs/$DEFCONFIG + rm .config) + else + if [[ ${DEFCONFIG} == *"perf_defconfig" ]] && \ + [ ${ARCH} == "arm64" ]; then + echo "resetting perf defconfig" + (cd ${KERNEL_DIR} && \ + git checkout arch/$ARCH/configs/$DEFCONFIG) + fi + fi +fi