a01e106f08
This catches the android14-6.1-lts branch up with the latest changes and abi updates. Included in here are the following commits:07775f9683
ANDROID: GKI: Add symbols for rockchip sataf44d373b32
ANDROID: sched: Add trace_android_rvh_setschedulerefa8f34b5a
ANDROID: Update the ABI symbol listcee8ebf7c5
ANDROID: GKI: build damon for monitoring virtual address spaces31c59d59c7
UPSTREAM: mm/damon/sysfs-schemes: handle tried region directory allocation failure1cedfc05e9
UPSTREAM: mm/damon/sysfs-schemes: handle tried regions sysfs directory allocation failure7fbeab3c65
UPSTREAM: mm/damon/sysfs: check error from damon_sysfs_update_target()606444fd06
UPSTREAM: mm/damon/sysfs: eliminate potential uninitialized variable warningc132d077eb
UPSTREAM: mm/damon/sysfs: update monitoring target regions for online input commit6b7c4cc262
UPSTREAM: mm/damon/sysfs: remove requested targets when online-commit inputs1e19db10e7
UPSTREAM: mm/damon/sysfs: avoid empty scheme tried regions for large apply intervalc194e597cb
UPSTREAM: mm/damon/sysfs-schemes: do not update tried regions more than one DAMON snapshotf5a0a8bc43
UPSTREAM: mm/damon/sysfs: check DAMOS regions update progress from before_terminate()b46391e092
UPSTREAM: mm/damon/sysfs: implement a command for updating only schemes tried total bytes7d48e19f74
UPSTREAM: mm/damon/sysfs-schemes: implement DAMOS tried total bytes filea548d90994
UPSTREAM: mm/damon/ops-common: refactor to use {pte|pmd}p_clear_young_notify()ea215c9a10
UPSTREAM: mm/damon/core: skip apply schemes if empty3ca21ef5fa
UPSTREAM: mm/damon: use kstrtobool() instead of strtobool()5bf7b56860
UPSTREAM: mm/damon/sysfs-schemes: implement DAMOS-tried regions clear command80ccab9b0e
UPSTREAM: mm/damon/sysfs: implement DAMOS tried regions update command3421250b35
UPSTREAM: mm/damon/sysfs-schemes: implement scheme region directoryb4c34cc168
UPSTREAM: mm/damon/sysfs-schemes: implement schemes/tried_regions directoryb5d1f3576b
UPSTREAM: mm/damon/core: add a callback for scheme target regions check6547a97f32
UPSTREAM: mm/damon/lru_sort: enable and disable synchronously540e9b850d
UPSTREAM: mm/damon/reclaim: enable and disable synchronously4e2d3f8e31
UPSTREAM: mm/damon/{reclaim,lru_sort}: remove unnecessarily included headers3c0bc73f6e
UPSTREAM: mm/damon/modules: deduplicate init steps for DAMON context setup67ef7b0f42
UPSTREAM: mm/damon/sysfs: split out schemes directory implementation to separate file0b17df8a4f
UPSTREAM: mm/damon/sysfs: split out kdamond-independent schemes stats update logic into a new functiona45dff567c
UPSTREAM: mm/damon/sysfs: move unsigned long range directory to common modulec5038d80ce
UPSTREAM: mm/damon/sysfs: move sysfs_lock to common moduleb7fc8d59a5
UPSTREAM: mm/damon/sysfs: remove parameters of damon_sysfs_region_alloc()19364f11a4
UPSTREAM: mm/damon/sysfs: use damon_addr_range for region's start and end valuesb6e6b1dbf8
UPSTREAM: mm/damon/core: split out scheme quota adjustment logic into a new function43475d9708
UPSTREAM: mm/damon/core: split out scheme stat update logic into a new function0b0a43029e
UPSTREAM: mm/damon/core: split damos application logic into a new function6c7495f04a
UPSTREAM: mm/damon/core: split out DAMOS-charged region skip logic into a new functionac1031618a
ANDROID: Snapshot Mainline's version of checkpatch.pl4fa87d4d8f
ANDROID: KVM: arm64: Skip prefaulting ptes which will be modified laterfbc707442c
ANDROID: KVM: arm64: Introduce module_change_host_prot_rangefd720ebc6a
ANDROID: KVM: arm64: Relax checks in module_change_host_page_protf082d22541
ANDROID: KVM: arm64: Optimise module_change_host_page_prot01dd8c280b
ANDROID: KVM: arm64: Prefault entries when splitting a block mappingcc653d701f
ANDROID: virt: gunyah: Zero state_data after vcpu_runcc294d9503
ANDROID: Update the ABI symbol list956a0d3998
ANDROID: fs: Add vendor hooks for ep_create_wakeup_source & timerfd_created8d2b95fd0
ANDROID: ABI: update symbol list for galaxybcc758eed7
Reapply "binder: fix UAF caused by faulty buffer cleanup"b2b3a1e6d1
UPSTREAM: x86/sev: Check for user-space IOIO pointing to kernel space62b97630d4
UPSTREAM: x86/sev: Check IOBM for IOIO exceptions from user-space071c14698c
FROMGIT: usb: typec: tcpm: skip checking port->send_discover in PD3.0a9567a35d0
ANDROID: arm64: Disable workaround for CPU errata 2441007 and 2441009 Change-Id: Icbda2fae389ea4c2e7230821c59ac0380a35d756 Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
118 lines
2.8 KiB
C
118 lines
2.8 KiB
C
// SPDX-License-Identifier: GPL-2.0
|
|
/*
|
|
* Common Primitives for Data Access Monitoring
|
|
*
|
|
* Author: SeongJae Park <sj@kernel.org>
|
|
*/
|
|
|
|
#include <linux/mmu_notifier.h>
|
|
#include <linux/page_idle.h>
|
|
#include <linux/pagemap.h>
|
|
#include <linux/rmap.h>
|
|
|
|
#include "ops-common.h"
|
|
|
|
/*
|
|
* Get an online page for a pfn if it's in the LRU list. Otherwise, returns
|
|
* NULL.
|
|
*
|
|
* The body of this function is stolen from the 'page_idle_get_page()'. We
|
|
* steal rather than reuse it because the code is quite simple.
|
|
*/
|
|
struct page *damon_get_page(unsigned long pfn)
|
|
{
|
|
struct page *page = pfn_to_online_page(pfn);
|
|
|
|
if (!page || !PageLRU(page) || !get_page_unless_zero(page))
|
|
return NULL;
|
|
|
|
if (unlikely(!PageLRU(page))) {
|
|
put_page(page);
|
|
page = NULL;
|
|
}
|
|
return page;
|
|
}
|
|
|
|
void damon_ptep_mkold(pte_t *pte, struct vm_area_struct *vma, unsigned long addr)
|
|
{
|
|
struct page *page = damon_get_page(pte_pfn(*pte));
|
|
|
|
if (!page)
|
|
return;
|
|
|
|
if (ptep_clear_young_notify(vma, addr, pte))
|
|
set_page_young(page);
|
|
|
|
set_page_idle(page);
|
|
put_page(page);
|
|
}
|
|
|
|
void damon_pmdp_mkold(pmd_t *pmd, struct vm_area_struct *vma, unsigned long addr)
|
|
{
|
|
#ifdef CONFIG_TRANSPARENT_HUGEPAGE
|
|
struct page *page = damon_get_page(pmd_pfn(*pmd));
|
|
|
|
if (!page)
|
|
return;
|
|
|
|
if (pmdp_clear_young_notify(vma, addr, pmd))
|
|
set_page_young(page);
|
|
|
|
set_page_idle(page);
|
|
put_page(page);
|
|
#endif /* CONFIG_TRANSPARENT_HUGEPAGE */
|
|
}
|
|
|
|
#define DAMON_MAX_SUBSCORE (100)
|
|
#define DAMON_MAX_AGE_IN_LOG (32)
|
|
|
|
int damon_hot_score(struct damon_ctx *c, struct damon_region *r,
|
|
struct damos *s)
|
|
{
|
|
int freq_subscore;
|
|
unsigned int age_in_sec;
|
|
int age_in_log, age_subscore;
|
|
unsigned int freq_weight = s->quota.weight_nr_accesses;
|
|
unsigned int age_weight = s->quota.weight_age;
|
|
int hotness;
|
|
|
|
freq_subscore = r->nr_accesses * DAMON_MAX_SUBSCORE /
|
|
damon_max_nr_accesses(&c->attrs);
|
|
|
|
age_in_sec = (unsigned long)r->age * c->attrs.aggr_interval / 1000000;
|
|
for (age_in_log = 0; age_in_log < DAMON_MAX_AGE_IN_LOG && age_in_sec;
|
|
age_in_log++, age_in_sec >>= 1)
|
|
;
|
|
|
|
/* If frequency is 0, higher age means it's colder */
|
|
if (freq_subscore == 0)
|
|
age_in_log *= -1;
|
|
|
|
/*
|
|
* Now age_in_log is in [-DAMON_MAX_AGE_IN_LOG, DAMON_MAX_AGE_IN_LOG].
|
|
* Scale it to be in [0, 100] and set it as age subscore.
|
|
*/
|
|
age_in_log += DAMON_MAX_AGE_IN_LOG;
|
|
age_subscore = age_in_log * DAMON_MAX_SUBSCORE /
|
|
DAMON_MAX_AGE_IN_LOG / 2;
|
|
|
|
hotness = (freq_weight * freq_subscore + age_weight * age_subscore);
|
|
if (freq_weight + age_weight)
|
|
hotness /= freq_weight + age_weight;
|
|
/*
|
|
* Transform it to fit in [0, DAMOS_MAX_SCORE]
|
|
*/
|
|
hotness = hotness * DAMOS_MAX_SCORE / DAMON_MAX_SUBSCORE;
|
|
|
|
return hotness;
|
|
}
|
|
|
|
int damon_cold_score(struct damon_ctx *c, struct damon_region *r,
|
|
struct damos *s)
|
|
{
|
|
int hotness = damon_hot_score(c, r, s);
|
|
|
|
/* Return coldness of the region */
|
|
return DAMOS_MAX_SCORE - hotness;
|
|
}
|