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


Groups > linux.kernel > #1374517

[PATCH v6 1/2] mm, vmstat: calculate particular vm event

From Ebru Akagunduz <ebru.akagunduz@gmail.com>
Newsgroups linux.kernel
Subject [PATCH v6 1/2] mm, vmstat: calculate particular vm event
Date 2016-04-09 01:10 +0200
Message-ID <rlNHj-3DR-1@gated-at.bofh.it> (permalink)
References <rlNxD-3ez-9@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


Currently, vmstat can calculate specific vm event with all_vm_events()
however it calculates all vm events at a time. This patch introduces
a new function to calculate only single event at a time.

Signed-off-by: Ebru Akagunduz <ebru.akagunduz@gmail.com>
Suggested-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Acked-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Reviewed-by: Rik van Riel <riel@redhat.com>
Acked-by: Vlastimil Babka <vbabka@suse.cz>
Acked-by: Christoph Lameter <cl@linux.com>
---
Changes in v2:
 - this patch newly created in this version
 - create sum event function to
   calculate particular vm event (Kirill A. Shutemov)

Changes in v3:
 - add dummy definition of sum_vm_event
   when CONFIG_VM_EVENTS is not set
   (Kirill A. Shutemov)

Changes in v4:
 - add Suggested-by tag (Vlastimil Babka)

Changes in v5:
 - CC'ed Christoph Lameter <cl@linux.com> (Andrew Morton)

Changes in v6:
 - Fix commit log (Christoph Lameter)

 include/linux/vmstat.h |  6 ++++++
 mm/vmstat.c            | 12 ++++++++++++
 2 files changed, 18 insertions(+)

diff --git a/include/linux/vmstat.h b/include/linux/vmstat.h
index 02fce41..723be2c 100644
--- a/include/linux/vmstat.h
+++ b/include/linux/vmstat.h
@@ -53,6 +53,8 @@ static inline void count_vm_events(enum vm_event_item item, long delta)
 
 extern void all_vm_events(unsigned long *);
 
+extern unsigned long sum_vm_event(enum vm_event_item item);
+
 extern void vm_events_fold_cpu(int cpu);
 
 #else
@@ -73,6 +75,10 @@ static inline void __count_vm_events(enum vm_event_item item, long delta)
 static inline void all_vm_events(unsigned long *ret)
 {
 }
+static inline unsigned long sum_vm_event(enum vm_event_item item)
+{
+	return 0;
+}
 static inline void vm_events_fold_cpu(int cpu)
 {
 }
diff --git a/mm/vmstat.c b/mm/vmstat.c
index 070fd90..d6b6c03 100644
--- a/mm/vmstat.c
+++ b/mm/vmstat.c
@@ -34,6 +34,18 @@
 DEFINE_PER_CPU(struct vm_event_state, vm_event_states) = {{0}};
 EXPORT_PER_CPU_SYMBOL(vm_event_states);
 
+unsigned long sum_vm_event(enum vm_event_item item)
+{
+	int cpu;
+	unsigned long ret = 0;
+
+	get_online_cpus();
+	for_each_online_cpu(cpu)
+		ret += per_cpu(vm_event_states, cpu).event[item];
+	put_online_cpus();
+	return ret;
+}
+
 static void sum_vm_events(unsigned long *ret)
 {
 	int cpu;
-- 
1.9.1

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH v6 0/2] mm, thp: Fix unnecessarry resource consuming in swapin Ebru Akagunduz <ebru.akagunduz@gmail.com> - 2016-04-09 01:00 +0200
  [PATCH v6 1/2] mm, vmstat: calculate particular vm event Ebru Akagunduz <ebru.akagunduz@gmail.com> - 2016-04-09 01:10 +0200
  [PATCH v6 2/2] mm, thp: avoid unnecessary swapin in khugepaged Ebru Akagunduz <ebru.akagunduz@gmail.com> - 2016-04-09 01:10 +0200

csiph-web