diff --git a/include/linux/gfp.h b/include/linux/gfp.h index e652b9bbb262..9ec3b227e8f2 100644 --- a/include/linux/gfp.h +++ b/include/linux/gfp.h @@ -351,6 +351,9 @@ static inline bool pm_suspended_storage(void) } #endif /* CONFIG_PM_SLEEP */ +int set_reclaim_params(int wmark_scale_factor, int swappiness); +void get_reclaim_params(int *wmark_scale_factor, int *swappiness); + #ifdef CONFIG_CONTIG_ALLOC /* The below functions must be run on a range from a single zone. */ extern int alloc_contig_range(unsigned long start, unsigned long end, diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 55e1b0d71b79..0c32100ecf9a 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -536,6 +536,30 @@ static inline int pfn_to_bitidx(const struct page *page, unsigned long pfn) return (pfn >> pageblock_order) * NR_PAGEBLOCK_BITS; } +int set_reclaim_params(int wmark_scale_factor, int swappiness) +{ + if (wmark_scale_factor > 3000 || wmark_scale_factor < 1) + return -EINVAL; + + if (swappiness > 200 || swappiness < 0) + return -EINVAL; + + WRITE_ONCE(vm_swappiness, swappiness); + WRITE_ONCE(watermark_scale_factor, wmark_scale_factor); + + setup_per_zone_wmarks(); + + return 0; +} +EXPORT_SYMBOL_GPL(set_reclaim_params); + +void get_reclaim_params(int *wmark_scale_factor, int *swappiness) +{ + *wmark_scale_factor = watermark_scale_factor; + *swappiness = vm_swappiness; +} +EXPORT_SYMBOL_GPL(get_reclaim_params); + static __always_inline unsigned long __get_pfnblock_flags_mask(const struct page *page, unsigned long pfn,