ANDROID: cma: Change restrict_cma_redirect to be set by default

When restrict_cma_redirect boot parameter was introduced, its default
was set to follow the upstream behavior, which does not restrict any
movable allocation from using CMA. However this poses an issue when
partners upgrade from previous Android kernels and expect the same
behavior, which is to restrict CMA usage to movable allocations with
__GFP_CMA.
Change the default value of restrict_cma_redirect boot parameter to
keep backward compatibility with earlier ACK versions. Partners who
need upstream behavior will need to set restrict_cma_redirect=false
explicitly.

Bug: 399727765
Change-Id: Ia88008578557e38da54a455bc4ce3dc6f86fe52e
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
This commit is contained in:
Suren Baghdasaryan
2025-02-28 20:37:01 +00:00
parent 9b41e79f48
commit 3dbfe78ade
+10 -8
View File
@@ -181,27 +181,29 @@ EXPORT_PER_CPU_SYMBOL(numa_node);
DEFINE_STATIC_KEY_TRUE(vm_numa_stat_key);
/*
* By default, when restrict_cma_redirect is false, all movable allocations
* By default, restrict_cma_redirect is set to true, so only MOVABLE allocations
* marked __GFP_CMA are eligible to be redirected to CMA region. These allocations
* are redirected if *any* free space is available in the CMA region.
* When restrict_cma_redirect is false, all movable allocations
* are eligible for redirection to CMA region (i.e movable allocations are
* not restricted from CMA region), when there is sufficient space there.
* (see __rmqueue()).
*
* If restrict_cma_redirect is set to true, only MOVABLE allocations marked
* __GFP_CMA are eligible to be redirected to CMA region. These allocations
* are redirected if *any* free space is available in the CMA region.
*/
DEFINE_STATIC_KEY_FALSE(restrict_cma_redirect);
DEFINE_STATIC_KEY_TRUE(restrict_cma_redirect);
static int __init restrict_cma_redirect_setup(char *str)
{
#ifdef CONFIG_CMA
static_branch_enable(&restrict_cma_redirect);
bool res;
if (!kstrtobool(str, &res) && !res)
static_branch_disable(&restrict_cma_redirect);
#else
pr_warn("CONFIG_CMA not set. Ignoring restrict_cma_redirect option\n");
#endif
return 1;
}
__setup("restrict_cma_redirect", restrict_cma_redirect_setup);
__setup("restrict_cma_redirect=", restrict_cma_redirect_setup);
static inline bool cma_redirect_restricted(void)
{