From 95a39f602bcafef8faa15711ee0f28f6808ad672 Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Nov 23 2022 01:42:18 +0000 Subject: Reduce kdump memory consumption by not letting NetworkManager manage unneeded network interfaces Resolves: bz2076416 Upstream: Fedora Conflict: None commit 586fe410aa1b0093fb208c869b70ffeb7f085a55 Author: Coiby Xu Date: Thu Sep 9 11:50:00 2021 +0800 Reduce kdump memory consumption by not letting NetworkManager manage unneeded network interfaces By default, NetworkManger will manage all the network interfaces and try to set interface IFF_UP to get carrier state. Regardless of whether the network interface is connected to a cable or not, the NIC driver will allocate memory resources for e.g. ring buffers when setting IFF_UP. This could be a waste of memory. For example it's found i40e consumes ~15GB on a power machine. On this machine, i40e manages four interfaces but only one interface is valid. This patch use "managed=false" to tell NetworkManager to not manage network interfaces that are not needed by kdump by putting 10-kdump-netif_allowlist.conf in the initramfs. Signed-off-by: Coiby Xu Reviewed-by: Thomas Haller Reviewed-by: Philipp Rudo Signed-off-by: Coiby Xu --- diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 8397841..ef11d92 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -364,6 +364,29 @@ kdump_install_nmconnections() { echo > "${initdir}/usr/libexec/nm-initrd-generator" } +kdump_install_nm_netif_allowlist() { + local _netif _except_netif _netif_allowlist _netif_allowlist_nm_conf + + for _netif in $1; do + _per_mac=$(kdump_get_perm_addr "$_netif") + if [[ "$_per_mac" != 'not set' ]]; then + _except_netif="mac:$_per_mac" + else + _except_netif="interface-name:$_netif" + fi + _netif_allowlist="${_netif_allowlist}except:${_except_netif};" + done + + _netif_allowlist_nm_conf=$_DRACUT_KDUMP_NM_TMP_DIR/netif_allowlist_nm_conf + cat << EOF > "$_netif_allowlist_nm_conf" +[device-others] +match-device=${_netif_allowlist} +managed=false +EOF + + inst "$_netif_allowlist_nm_conf" "/etc/NetworkManager/conf.d/10-kdump-netif_allowlist.conf" +} + kdump_setup_bridge() { local _netdev=$1 local _dev @@ -558,6 +581,7 @@ kdump_install_net() { if [[ -n "$_netifs" ]]; then kdump_install_nmconnections apply_nm_initrd_generator_timeouts + kdump_install_nm_netif_allowlist "$_netifs" fi }