Carveout Customization and Profiling#

NvMap provides a few carveouts to be used for different use cases.

Modify these carveouts according to your system’s needs and for your usescases. Additionally, to ensure efficient and adequate use of the carveouts, profile carveout usage throughout development.

Carveout Customization#

This section describes how to customize memory carveouts, which allows you to set aside memory for device isolation and security.

Generic Carveout#

  • This carveout is a reserved memory carveout inside Linux GuestOS.

  • It is used by display to obtain IPA contiguous buffers to satisfy their use cases.

  • The memory for generic carveout is reserved during boot time and is not available to OS memory allocations. The size of the carveout depends on the use-cases or applications for which the platform is targeted and their cumulative memory usage over the application lifecycle.

  • To update the generic carveout size, the device tree (DT) needs to be modified as follows:

    • In the relevant platform-specific DT file, update the size in the generic_carveout DT node that is present under reserved-memory DT node. For example, the following DT node updates the size of generic carveout to 0x80000000 bytes:

reserved-memory {
    generic_carveout {
        compatible = "nvidia,generic_carveout";
        size = <0 0x80000000>;
        status = "okay";
    };
};

Carveout Profiling#

The size of the carveout depends on the use cases or applications for which the platform is targeted, and their memory usage needs cumulatively over the application lifecycle. Set the carveout size based on the total outstanding buffers and sizes that is used at any point in the system.

It is recommended to profile carveout usage throughout development. Repeated profiling:

  • Ensures that carveout usage has not changed as development progresses.

  • Considers carveout usage for applications.

The carveouts can be profiled as follows:

Generic Carveout#

Certain debugfs nodes are provided to find out the size, free size of the carveout, allocations from the carveout, etc.

  • /sys/kernel/debug/nvmap/generic-0/free_size debugfs node shows the free size in the generic carveout at the time of query (in bytes) while

  • /sys/kernel/debug/nvmap/generic-0/size debugfs node shows the total size of the generic carveout at the time of query (in bytes).

Example 1 : You can use the following command to get the free size present in generic carveout. The following output shows that the free size at the time of running this command was 0x1000000 bytes.

cat /sys/kernel/debug/nvmap/generic-0/free_size
0x0000000001000000

Example 2 : You can use the following command to get the total size of the generic carveout. The following output shows that the size of the generic carveout at the time of running this command was 0x2000000 bytes.

cat /sys/kernel/debug/nvmap/generic-0/size
0x0000000002000000

With the help of running the application and querying free_size and size debugfs nodes at necessary points in time, the generic carveout memory usage can be understood and the size of the generic carveout can be decided.