Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1695339 > unrolled thread

[PATCH -mm -v3 1/6] mm, swap: Add swap cache statistics sysfs interface

Started by"Huang, Ying" <ying.huang@intel.com>
First post2017-07-25 04:00 +0200
Last post2017-07-26 03:40 +0200
Articles 5 — 4 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH -mm -v3 1/6] mm, swap: Add swap cache statistics sysfs interface "Huang, Ying" <ying.huang@intel.com> - 2017-07-25 04:00 +0200
    Re: [PATCH -mm -v3 1/6] mm, swap: Add swap cache statistics sysfs  interface Andrew Morton <akpm@linux-foundation.org> - 2017-07-25 22:50 +0200
      Re: [PATCH -mm -v3 1/6] mm, swap: Add swap cache statistics sysfs interface "Huang\, Ying" <ying.huang@intel.com> - 2017-07-26 03:30 +0200
    Re: [PATCH -mm -v3 1/6] mm, swap: Add swap cache statistics sysfs  interface Rik van Riel <riel@redhat.com> - 2017-07-25 23:10 +0200
      Re: [PATCH -mm -v3 1/6] mm, swap: Add swap cache statistics sysfs interface "Huang\, Ying" <ying.huang@intel.com> - 2017-07-26 03:40 +0200

#1695339 — [PATCH -mm -v3 1/6] mm, swap: Add swap cache statistics sysfs interface

From"Huang, Ying" <ying.huang@intel.com>
Date2017-07-25 04:00 +0200
Subject[PATCH -mm -v3 1/6] mm, swap: Add swap cache statistics sysfs interface
Message-ID<u6XiG-4S8-5@gated-at.bofh.it>
From: Huang Ying <ying.huang@intel.com>

The swap cache stats could be gotten only via sysrq, which isn't
convenient in some situation.  So the sysfs interface of swap cache
stats is added for that.  The added sysfs directories/files are as
follow,

/sys/kernel/mm/swap
/sys/kernel/mm/swap/cache_find_total
/sys/kernel/mm/swap/cache_find_success
/sys/kernel/mm/swap/cache_add
/sys/kernel/mm/swap/cache_del
/sys/kernel/mm/swap/cache_pages

Signed-off-by: "Huang, Ying" <ying.huang@intel.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Minchan Kim <minchan@kernel.org>
Cc: Rik van Riel <riel@redhat.com>
Cc: Shaohua Li <shli@kernel.org>
Cc: Hugh Dickins <hughd@google.com>
Cc: Fengguang Wu <fengguang.wu@intel.com>
Cc: Tim Chen <tim.c.chen@intel.com>
Cc: Dave Hansen <dave.hansen@intel.com>
---
 mm/swap_state.c | 78 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 78 insertions(+)

diff --git a/mm/swap_state.c b/mm/swap_state.c
index b68c93014f50..a13bbf504e93 100644
--- a/mm/swap_state.c
+++ b/mm/swap_state.c
@@ -561,3 +561,81 @@ void exit_swap_address_space(unsigned int type)
 	synchronize_rcu();
 	kvfree(spaces);
 }
+
+#ifdef CONFIG_SYSFS
+static ssize_t swap_cache_pages_show(
+	struct kobject *kobj, struct kobj_attribute *attr, char *buf)
+{
+	return sprintf(buf, "%lu\n", total_swapcache_pages());
+}
+static struct kobj_attribute swap_cache_pages_attr =
+	__ATTR(cache_pages, 0444, swap_cache_pages_show, NULL);
+
+static ssize_t swap_cache_add_show(
+	struct kobject *kobj, struct kobj_attribute *attr, char *buf)
+{
+	return sprintf(buf, "%lu\n", swap_cache_info.add_total);
+}
+static struct kobj_attribute swap_cache_add_attr =
+	__ATTR(cache_add, 0444, swap_cache_add_show, NULL);
+
+static ssize_t swap_cache_del_show(
+	struct kobject *kobj, struct kobj_attribute *attr, char *buf)
+{
+	return sprintf(buf, "%lu\n", swap_cache_info.del_total);
+}
+static struct kobj_attribute swap_cache_del_attr =
+	__ATTR(cache_del, 0444, swap_cache_del_show, NULL);
+
+static ssize_t swap_cache_find_success_show(
+	struct kobject *kobj, struct kobj_attribute *attr, char *buf)
+{
+	return sprintf(buf, "%lu\n", swap_cache_info.find_success);
+}
+static struct kobj_attribute swap_cache_find_success_attr =
+	__ATTR(cache_find_success, 0444, swap_cache_find_success_show, NULL);
+
+static ssize_t swap_cache_find_total_show(
+	struct kobject *kobj, struct kobj_attribute *attr, char *buf)
+{
+	return sprintf(buf, "%lu\n", swap_cache_info.find_total);
+}
+static struct kobj_attribute swap_cache_find_total_attr =
+	__ATTR(cache_find_total, 0444, swap_cache_find_total_show, NULL);
+
+static struct attribute *swap_attrs[] = {
+	&swap_cache_pages_attr.attr,
+	&swap_cache_add_attr.attr,
+	&swap_cache_del_attr.attr,
+	&swap_cache_find_success_attr.attr,
+	&swap_cache_find_total_attr.attr,
+	NULL,
+};
+
+static struct attribute_group swap_attr_group = {
+	.attrs = swap_attrs,
+};
+
+static int __init swap_init_sysfs(void)
+{
+	int err;
+	struct kobject *swap_kobj;
+
+	swap_kobj = kobject_create_and_add("swap", mm_kobj);
+	if (!swap_kobj) {
+		pr_err("failed to create swap kobject\n");
+		return -ENOMEM;
+	}
+	err = sysfs_create_group(swap_kobj, &swap_attr_group);
+	if (err) {
+		pr_err("failed to register swap group\n");
+		goto delete_obj;
+	}
+	return 0;
+
+delete_obj:
+	kobject_put(swap_kobj);
+	return err;
+}
+subsys_initcall(swap_init_sysfs);
+#endif
-- 
2.13.2

[toc] | [next] | [standalone]


#1696419 — Re: [PATCH -mm -v3 1/6] mm, swap: Add swap cache statistics sysfs interface

FromAndrew Morton <akpm@linux-foundation.org>
Date2017-07-25 22:50 +0200
SubjectRe: [PATCH -mm -v3 1/6] mm, swap: Add swap cache statistics sysfs interface
Message-ID<u7eWh-7DI-85@gated-at.bofh.it>
In reply to#1695339
On Tue, 25 Jul 2017 09:51:46 +0800 "Huang, Ying" <ying.huang@intel.com> wrote:

> The swap cache stats could be gotten only via sysrq, which isn't
> convenient in some situation.  So the sysfs interface of swap cache
> stats is added for that.  The added sysfs directories/files are as
> follow,
> 
> /sys/kernel/mm/swap
> /sys/kernel/mm/swap/cache_find_total
> /sys/kernel/mm/swap/cache_find_success
> /sys/kernel/mm/swap/cache_add
> /sys/kernel/mm/swap/cache_del
> /sys/kernel/mm/swap/cache_pages

We should document this somewhere.  Documentation/ABI/ is the formal
place for sysfs files, but nobody will think to look there for VM
things, so perhaps place a pointer to the Documentation/ABI/ files
within Documentation/vm somewhere, only there isn't an appropriate
Documentation/vm file ;)

Or just put all these things in debugfs.  These are pretty specialized
things and appear to be developer-only files of short-term interest?

[toc] | [prev] | [next] | [standalone]


#1696710

From"Huang\, Ying" <ying.huang@intel.com>
Date2017-07-26 03:30 +0200
Message-ID<u7jjb-260-3@gated-at.bofh.it>
In reply to#1696419
Andrew Morton <akpm@linux-foundation.org> writes:

> On Tue, 25 Jul 2017 09:51:46 +0800 "Huang, Ying" <ying.huang@intel.com> wrote:
>
>> The swap cache stats could be gotten only via sysrq, which isn't
>> convenient in some situation.  So the sysfs interface of swap cache
>> stats is added for that.  The added sysfs directories/files are as
>> follow,
>> 
>> /sys/kernel/mm/swap
>> /sys/kernel/mm/swap/cache_find_total
>> /sys/kernel/mm/swap/cache_find_success
>> /sys/kernel/mm/swap/cache_add
>> /sys/kernel/mm/swap/cache_del
>> /sys/kernel/mm/swap/cache_pages
>
> We should document this somewhere.  Documentation/ABI/ is the formal
> place for sysfs files, but nobody will think to look there for VM
> things, so perhaps place a pointer to the Documentation/ABI/ files
> within Documentation/vm somewhere, only there isn't an appropriate
> Documentation/vm file ;)
>
> Or just put all these things in debugfs.  These are pretty specialized
> things and appear to be developer-only files of short-term interest?

Yes.  Debugfs should be better place for these.  Will update it in the
next version.

And I also introduced sysfs interface in [2/6] and [5/6]

/sys/kernel/mm/swap/ra_hits
/sys/kernel/mm/swap/ra_total

/sys/kernel/mm/swap/vma_ra_enabled
/sys/kernel/mm/swap/vma_ra_max_order

Will add ABI document for them.

Best Regards,
Huang, Ying

[toc] | [prev] | [next] | [standalone]


#1696493 — Re: [PATCH -mm -v3 1/6] mm, swap: Add swap cache statistics sysfs interface

FromRik van Riel <riel@redhat.com>
Date2017-07-25 23:10 +0200
SubjectRe: [PATCH -mm -v3 1/6] mm, swap: Add swap cache statistics sysfs interface
Message-ID<u7ffC-82I-81@gated-at.bofh.it>
In reply to#1695339

[Multipart message — attachments visible in raw view] — view raw

On Tue, 2017-07-25 at 09:51 +0800, Huang, Ying wrote:
> From: Huang Ying <ying.huang@intel.com>
> 
> The swap cache stats could be gotten only via sysrq, which isn't
> convenient in some situation.  So the sysfs interface of swap cache
> stats is added for that.  The added sysfs directories/files are as
> follow,
> 
> /sys/kernel/mm/swap
> /sys/kernel/mm/swap/cache_find_total
> /sys/kernel/mm/swap/cache_find_success
> /sys/kernel/mm/swap/cache_add
> /sys/kernel/mm/swap/cache_del
> /sys/kernel/mm/swap/cache_pages
> 
What is the advantage of this vs new fields in
/proc/vmstat, which is where most of the VM
statistics seem to live?

-- 
All rights reversed

[toc] | [prev] | [next] | [standalone]


#1696714

From"Huang\, Ying" <ying.huang@intel.com>
Date2017-07-26 03:40 +0200
Message-ID<u7jsS-29R-13@gated-at.bofh.it>
In reply to#1696493
Hi, Rik,

Rik van Riel <riel@redhat.com> writes:

> On Tue, 2017-07-25 at 09:51 +0800, Huang, Ying wrote:
>> From: Huang Ying <ying.huang@intel.com>
>> 
>> The swap cache stats could be gotten only via sysrq, which isn't
>> convenient in some situation.  So the sysfs interface of swap cache
>> stats is added for that.  The added sysfs directories/files are as
>> follow,
>> 
>> /sys/kernel/mm/swap
>> /sys/kernel/mm/swap/cache_find_total
>> /sys/kernel/mm/swap/cache_find_success
>> /sys/kernel/mm/swap/cache_add
>> /sys/kernel/mm/swap/cache_del
>> /sys/kernel/mm/swap/cache_pages
>> 
> What is the advantage of this vs new fields in
> /proc/vmstat, which is where most of the VM
> statistics seem to live?

As proposed by Andrew, will use debugfs for them, because they are
mostly developer related.

Best Regards,
Huang, Ying

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web