Skip to content

Commit

Permalink
mm: add sysfs entry for pmadv_ksm syscall number
Browse files Browse the repository at this point in the history
As `pmadv_ksm()` syscall is out-of-tree, maintain a separate
`/sys/kernel/pmadv/ksm` file with a syscall number so that userspace
tools can always know what to use in runtime even if the syscall number
shifts after adding another in-tree syscall.

The idea is borrowed from futex2 submission.

Signed-off-by: Oleksandr Natalenko <oleksandr@natalenko.name>
  • Loading branch information
pfactum committed Apr 23, 2023
1 parent c74b82c commit 6857193
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions mm/madvise.c
Expand Up @@ -1614,3 +1614,28 @@ SYSCALL_DEFINE3(pmadv_ksm, int, pidfd, int, behaviour, unsigned int, flags)
return -ENOSYS;
#endif /* CONFIG_KSM */
}

#ifdef CONFIG_KSM
static ssize_t ksm_show(struct kobject *kobj, struct kobj_attribute *attr,
char *buf)
{
return sprintf(buf, "%u\n", __NR_pmadv_ksm);
}
static struct kobj_attribute pmadv_ksm_attr = __ATTR_RO(ksm);

static struct attribute *pmadv_sysfs_attrs[] = {
&pmadv_ksm_attr.attr,
NULL,
};

static const struct attribute_group pmadv_sysfs_attr_group = {
.attrs = pmadv_sysfs_attrs,
.name = "pmadv",
};

static int __init pmadv_sysfs_init(void)
{
return sysfs_create_group(kernel_kobj, &pmadv_sysfs_attr_group);
}
subsys_initcall(pmadv_sysfs_init);
#endif /* CONFIG_KSM */

0 comments on commit 6857193

Please sign in to comment.