[Devel] [PATCH vz7 1/3] vzstat: account "page_in" and "swap_in" in nanoseconds

Konstantin Khorenko khorenko at virtuozzo.com
Mon Nov 12 16:00:08 MSK 2018


Up to now "page_in" and "swap_in" in /proc/vz/latency has been provided
in cpu cycles while other latencies are in nanoseconds there.

Let's make a single measure unit for all latencies, so provide swap_in
and page_in in nanoseconds as well.

https://pmc.acronis.com/browse/VSTOR-16659

Signed-off-by: Konstantin Khorenko <khorenko at virtuozzo.com>
---
 mm/memory.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/mm/memory.c b/mm/memory.c
index 3d26170d4529..67e0a0131d0c 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -2619,9 +2619,9 @@ static int do_swap_page(struct mm_struct *mm, struct vm_area_struct *vma,
 	int locked;
 	int exclusive = 0;
 	int ret = 0;
-	cycles_t start;
+	u64 start;
 
-	start = get_cycles();
+	start = ktime_to_ns(ktime_get());
 	if (!pte_unmap_same(mm, pmd, page_table, orig_pte))
 		goto out;
 
@@ -2781,7 +2781,8 @@ static int do_swap_page(struct mm_struct *mm, struct vm_area_struct *vma,
 	pte_unmap_unlock(page_table, ptl);
 out:
 	local_irq_disable();
-	KSTAT_LAT_PCPU_ADD(&kstat_glob.swap_in, get_cycles() - start);
+	start = ktime_to_ns(ktime_get()) - start;
+	KSTAT_LAT_PCPU_ADD(&kstat_glob.swap_in, start);
 	local_irq_enable();
 
 	return ret;
@@ -2895,7 +2896,7 @@ static int __do_fault(struct vm_area_struct *vma, unsigned long address,
 {
 	struct vm_fault vmf;
 	int ret;
-	cycles_t start;
+	u64 start;
 
 	vmf.virtual_address = (void __user *)(address & PAGE_MASK);
 	vmf.pgoff = pgoff;
@@ -2907,7 +2908,7 @@ static int __do_fault(struct vm_area_struct *vma, unsigned long address,
 	vmf.pmd = pmd;
 	vmf.vma = vma;
 
-	start = get_cycles();
+	start = ktime_to_ns(ktime_get());
 	ret = vma->vm_ops->fault(vma, &vmf);
 	if (unlikely(ret & (VM_FAULT_ERROR | VM_FAULT_NOPAGE | VM_FAULT_RETRY |
 			    VM_FAULT_DONE_COW)))
@@ -2926,7 +2927,8 @@ static int __do_fault(struct vm_area_struct *vma, unsigned long address,
 		VM_BUG_ON_PAGE(!PageLocked(vmf.page), vmf.page);
 
 	local_irq_disable();
-	KSTAT_LAT_PCPU_ADD(&kstat_glob.page_in, get_cycles() - start);
+	start = ktime_to_ns(ktime_get()) - start;
+	KSTAT_LAT_PCPU_ADD(&kstat_glob.page_in, start);
 	local_irq_enable();
 
 	*page = vmf.page;
-- 
2.15.1



More information about the Devel mailing list