162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
262306a36Sopenharmony_ci#ifndef _MM_PAGE_REPORTING_H
362306a36Sopenharmony_ci#define _MM_PAGE_REPORTING_H
462306a36Sopenharmony_ci
562306a36Sopenharmony_ci#include <linux/mmzone.h>
662306a36Sopenharmony_ci#include <linux/pageblock-flags.h>
762306a36Sopenharmony_ci#include <linux/page-isolation.h>
862306a36Sopenharmony_ci#include <linux/jump_label.h>
962306a36Sopenharmony_ci#include <linux/slab.h>
1062306a36Sopenharmony_ci#include <linux/pgtable.h>
1162306a36Sopenharmony_ci#include <linux/scatterlist.h>
1262306a36Sopenharmony_ci
1362306a36Sopenharmony_ci#ifdef CONFIG_PAGE_REPORTING
1462306a36Sopenharmony_ciDECLARE_STATIC_KEY_FALSE(page_reporting_enabled);
1562306a36Sopenharmony_ciextern unsigned int page_reporting_order;
1662306a36Sopenharmony_civoid __page_reporting_notify(void);
1762306a36Sopenharmony_ci
1862306a36Sopenharmony_cistatic inline bool page_reported(struct page *page)
1962306a36Sopenharmony_ci{
2062306a36Sopenharmony_ci	return static_branch_unlikely(&page_reporting_enabled) &&
2162306a36Sopenharmony_ci	       PageReported(page);
2262306a36Sopenharmony_ci}
2362306a36Sopenharmony_ci
2462306a36Sopenharmony_ci/**
2562306a36Sopenharmony_ci * page_reporting_notify_free - Free page notification to start page processing
2662306a36Sopenharmony_ci *
2762306a36Sopenharmony_ci * This function is meant to act as a screener for __page_reporting_notify
2862306a36Sopenharmony_ci * which will determine if a give zone has crossed over the high-water mark
2962306a36Sopenharmony_ci * that will justify us beginning page treatment. If we have crossed that
3062306a36Sopenharmony_ci * threshold then it will start the process of pulling some pages and
3162306a36Sopenharmony_ci * placing them in the batch list for treatment.
3262306a36Sopenharmony_ci */
3362306a36Sopenharmony_cistatic inline void page_reporting_notify_free(unsigned int order)
3462306a36Sopenharmony_ci{
3562306a36Sopenharmony_ci	/* Called from hot path in __free_one_page() */
3662306a36Sopenharmony_ci	if (!static_branch_unlikely(&page_reporting_enabled))
3762306a36Sopenharmony_ci		return;
3862306a36Sopenharmony_ci
3962306a36Sopenharmony_ci	/* Determine if we have crossed reporting threshold */
4062306a36Sopenharmony_ci	if (order < page_reporting_order)
4162306a36Sopenharmony_ci		return;
4262306a36Sopenharmony_ci
4362306a36Sopenharmony_ci	/* This will add a few cycles, but should be called infrequently */
4462306a36Sopenharmony_ci	__page_reporting_notify();
4562306a36Sopenharmony_ci}
4662306a36Sopenharmony_ci#else /* CONFIG_PAGE_REPORTING */
4762306a36Sopenharmony_ci#define page_reported(_page)	false
4862306a36Sopenharmony_ci
4962306a36Sopenharmony_cistatic inline void page_reporting_notify_free(unsigned int order)
5062306a36Sopenharmony_ci{
5162306a36Sopenharmony_ci}
5262306a36Sopenharmony_ci#endif /* CONFIG_PAGE_REPORTING */
5362306a36Sopenharmony_ci#endif /*_MM_PAGE_REPORTING_H */
54