mirror of
git://nv-tegra.nvidia.com/linux-nv-oot.git
synced 2025-12-22 09:11:26 +03:00
video: tegra: nvmap: Account NvMap memory for OOM Decisions
Account NvMap allocated memory into both RSS and CG tracking to make efficient OOM kill decisions during memory pressure. NvMap allocates memory via kernel APIs like alloc_pages, the kernel memory is not accounted on behalf of process who requests the allocation. Hence in case OOM, the OOM killer never kills the process who has allocated memory via NvMap even though this process might be holding most of the memory. Solve this issue using following approach: - Use __GFP_ACCOUNT and __GFP_NORETRY flag - __GFP_NORETRY will not let the current allocation flow to go into OOM path, so that it will never trigger OOM. - __GFP_ACCOUNT causes the allocation to be accounted to kmemcg. So any allocation done by NvMap will be definitely accounted to kmemcg and cgroups can be used to define memory limits. - Add RSS counting for the process which allocates by NvMap, so that OOM score for that process will get updated and OOM killer can pick this process based upon the OOM score. - Every process that has a reference to NvMap Handle would have the memory size accounted into its RSS. On releasing the reference to handle, the RSS would be reduced. Bug 5222690 Change-Id: I3fa9b76ec9fc8d7f805111cb96e11e2ab1db42ce Signed-off-by: Ketan Patil <ketanp@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3447072 GVS: buildbot_gerritrpt <buildbot_gerritrpt@nvidia.com> Reviewed-by: Krishna Reddy <vdumpa@nvidia.com> Reviewed-by: Jon Hunter <jonathanh@nvidia.com> Reviewed-by: Ajay Nandakumar Mannargudi <anandakumarm@nvidia.com>
This commit is contained in:
committed by
mobile promotions
parent
6b6d1e009a
commit
858d73775a
@@ -7933,6 +7933,23 @@ compile_test() {
|
||||
compile_check_conftest "$CODE" "NV_MII_BUS_STRUCT_HAS_WRITE_C45" "" "types"
|
||||
;;
|
||||
|
||||
mm_struct_struct_has_percpu_counter_rss_stat)
|
||||
#
|
||||
# Determine if the 'rss_stat' member of the 'mm_struct' structure is
|
||||
# defined with 'percpu_counter'.
|
||||
#
|
||||
# This change was made in Linux v6.2 by commit f1a7941243c1 ("mm:
|
||||
# convert mm's rss stats into percpu_counter2").
|
||||
#
|
||||
CODE="
|
||||
#include <linux/mm_types.h>
|
||||
void conftest_mm_struct_struct_has_percpu_counter_rss_stat(struct mm_struct *mm) {
|
||||
percpu_counter_add(&mm->rss_stat[0], 0);
|
||||
}"
|
||||
|
||||
compile_check_conftest "$CODE" "NV_MM_STRUCT_STRUCT_HAS_PERCPU_COUNTER_RSS_STAT" "" "types"
|
||||
;;
|
||||
|
||||
module_import_ns_calls_stringify)
|
||||
#
|
||||
# Determine if the MODULE_IMPORT_NS macro takes a string literal as
|
||||
|
||||
Reference in New Issue
Block a user