Freeing up some of the reserved memory

Hi!

I’m working on a project that involves a model that barely does not fit into the memory even if I disable things like desktop and a few services to free up the memory. htop shows only 15GB of the memory is available and:

daniel@orinnx:~$ cat /var/log/dmesg | grep Memory
[ 0.000000] kernel: Memory: 15483820K/16420928K available (18432K kernel code, 3168K rwdata, 7164K rodata, 3968K init, 1110K bss, 674964K reserved, 262144K cma-reserved)

so 256 MB is cma-reserved and ~660MB is reserved. How can I reclaim part of this memory? I understand something could stop working if I do so, but my goal is to run a model and I need the most of the memory available and I’m close to have just enough to run the model. A few more 100s of MB is what I need.

There are some reserved memory for some coprocessor suppose it’s necessary reserved.

Do we know what coprocessor and how to eventually disable it if it’s not necessary for the task that I am working on? I read a thread about the Xavier NX with JP 5.x where the user was able to free up a few hundred megabytes by disabling a feature they did not need (however the same thing was not applicable here).

try disabling vpr region from the device tree node.
vpr-carveout {
status = “disabled”;
};

Hi Bibek,
Thank you for your reply.
I tried to extract the device tree and with:

dtc -I fs -O dts -o extracted.dts /proc/device-tree

there’s no vpr-carveout, so I verified with:

dtc -I dtb -O dts -o kernel_tegra234-p3767-0000-p3768-0000-a0.dts /boot/dtb/kernel_tegra234-p3767-0000-p3768-0000-a0.dtb

I can already see:

 		vpr-carveout {
 			compatible = "nvidia,vpr-carveout";
 			status = "disabled";
 			phandle = <0x45>;
 		};

The rest of the reserved memory (from /device/tree) if it can be helpful:

	reserved-memory {
		#address-cells = <0x02>;
		#size-cells = <0x02>;
		ranges;

		linux,cma {
			linux,cma-default;
			alignment = <0x00 0x10000>;
			compatible = "shared-dma-pool";
			size = <0x00 0x10000000>;
			status = "okay";
			reusable;
		};

		generic_carveout {
			alignment = <0x00 0x100000>;
			alloc-ranges = <0x01 0x00 0x01 0x00>;
			compatible = "nvidia,generic_carveout";
			size = <0x00 0x00>;
			status = "disabled";
			phandle = <0x2d7>;
			no-map;
		};

		camdbg_carveout {
			alignment = <0x00 0x100000>;
			alloc-ranges = <0x01 0x00 0x01 0x00>;
			compatible = "nvidia,camdbg_carveout";
			size = <0x00 0x6400000>;
			status = "disabled";
			phandle = <0x2db>;
		};

		ramoops_carveout {
			alignment = <0x00 0x10000>;
			record-size = <0x10000>;
			alloc-ranges = <0x00 0x00 0x01 0x00>;
			compatible = "ramoops";
			size = <0x00 0x200000>;
			console-size = <0x80000>;
			status = "okay";
			reg = <0x04 0x68000000 0x00 0x200000>;
			phandle = <0x2d9>;
			no-map;
		};
	};

Thank you! :)

- Daniel

you can disable the cma region also

I tried that and blindly disabled a few other carveouts (left only grid-of-semaphores and the result is:

daniel@orinnx3:~$ cat /var/log/dmesg | grep Memory
[ 0.000000] kernel: Memory: 15679168K/16420928K available (18496K kernel code, 3168K rwdata, 7172K rodata, 3968K init, 1418K bss, 676224K reserved, 65536K cma-reserved)

but htop and tegrastats still show 15GB of the available memory:

06-28-2023 17:30:09 RAM 511/15388MB (lfb 3556x4MB) SWAP 0/7694MB (cached 0MB) …

- Daniel

yes, you can not get that 676224K reclaimed because that’s used for UEFI and OPTEE

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.