Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

mm/damon/sysfs-schemes: implement quotas->goal_tuner file

Add a new DAMON sysfs interface file, namely 'goal_tuner' under the DAMOS
quotas directory. It is connected to the damos_quota->goal_tuner field.
Users can therefore select their favorite goal-based quotas tuning
algorithm by writing the name of the tuner to the file. Reading the file
returns the name of the currently selected tuner.

Link: https://lkml.kernel.org/r/20260310010529.91162-5-sj@kernel.org
Signed-off-by: SeongJae Park <sj@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

SeongJae Park and committed by
Andrew Morton
e9a19cc8 af738a6a

+58
+58
mm/damon/sysfs-schemes.c
··· 1488 1488 unsigned long sz; 1489 1489 unsigned long reset_interval_ms; 1490 1490 unsigned long effective_sz; /* Effective size quota in bytes */ 1491 + enum damos_quota_goal_tuner goal_tuner; 1491 1492 }; 1492 1493 1493 1494 static struct damon_sysfs_quotas *damon_sysfs_quotas_alloc(void) ··· 1611 1610 return sysfs_emit(buf, "%lu\n", quotas->effective_sz); 1612 1611 } 1613 1612 1613 + struct damos_sysfs_qgoal_tuner_name { 1614 + enum damos_quota_goal_tuner tuner; 1615 + char *name; 1616 + }; 1617 + 1618 + static struct damos_sysfs_qgoal_tuner_name damos_sysfs_qgoal_tuner_names[] = { 1619 + { 1620 + .tuner = DAMOS_QUOTA_GOAL_TUNER_CONSIST, 1621 + .name = "consist", 1622 + }, 1623 + { 1624 + .tuner = DAMOS_QUOTA_GOAL_TUNER_TEMPORAL, 1625 + .name = "temporal", 1626 + }, 1627 + }; 1628 + 1629 + static ssize_t goal_tuner_show(struct kobject *kobj, 1630 + struct kobj_attribute *attr, char *buf) 1631 + { 1632 + struct damon_sysfs_quotas *quotas = container_of(kobj, 1633 + struct damon_sysfs_quotas, kobj); 1634 + int i; 1635 + 1636 + for (i = 0; i < ARRAY_SIZE(damos_sysfs_qgoal_tuner_names); i++) { 1637 + struct damos_sysfs_qgoal_tuner_name *tuner_name; 1638 + 1639 + tuner_name = &damos_sysfs_qgoal_tuner_names[i]; 1640 + if (tuner_name->tuner == quotas->goal_tuner) 1641 + return sysfs_emit(buf, "%s\n", tuner_name->name); 1642 + } 1643 + return -EINVAL; 1644 + } 1645 + 1646 + static ssize_t goal_tuner_store(struct kobject *kobj, 1647 + struct kobj_attribute *attr, const char *buf, size_t count) 1648 + { 1649 + struct damon_sysfs_quotas *quotas = container_of(kobj, 1650 + struct damon_sysfs_quotas, kobj); 1651 + int i; 1652 + 1653 + for (i = 0; i < ARRAY_SIZE(damos_sysfs_qgoal_tuner_names); i++) { 1654 + struct damos_sysfs_qgoal_tuner_name *tuner_name; 1655 + 1656 + tuner_name = &damos_sysfs_qgoal_tuner_names[i]; 1657 + if (sysfs_streq(buf, tuner_name->name)) { 1658 + quotas->goal_tuner = tuner_name->tuner; 1659 + return count; 1660 + } 1661 + } 1662 + return -EINVAL; 1663 + } 1664 + 1614 1665 static void damon_sysfs_quotas_release(struct kobject *kobj) 1615 1666 { 1616 1667 kfree(container_of(kobj, struct damon_sysfs_quotas, kobj)); ··· 1680 1627 static struct kobj_attribute damon_sysfs_quotas_effective_bytes_attr = 1681 1628 __ATTR_RO_MODE(effective_bytes, 0400); 1682 1629 1630 + static struct kobj_attribute damon_sysfs_quotas_goal_tuner_attr = 1631 + __ATTR_RW_MODE(goal_tuner, 0600); 1632 + 1683 1633 static struct attribute *damon_sysfs_quotas_attrs[] = { 1684 1634 &damon_sysfs_quotas_ms_attr.attr, 1685 1635 &damon_sysfs_quotas_sz_attr.attr, 1686 1636 &damon_sysfs_quotas_reset_interval_ms_attr.attr, 1687 1637 &damon_sysfs_quotas_effective_bytes_attr.attr, 1638 + &damon_sysfs_quotas_goal_tuner_attr.attr, 1688 1639 NULL, 1689 1640 }; 1690 1641 ATTRIBUTE_GROUPS(damon_sysfs_quotas); ··· 2775 2718 .weight_sz = sysfs_weights->sz, 2776 2719 .weight_nr_accesses = sysfs_weights->nr_accesses, 2777 2720 .weight_age = sysfs_weights->age, 2721 + .goal_tuner = sysfs_quotas->goal_tuner, 2778 2722 }; 2779 2723 struct damos_watermarks wmarks = { 2780 2724 .metric = sysfs_wmarks->metric,