From 825d80e01c65efad6bfe7302038a657bbc08e06a Mon Sep 17 00:00:00 2001 From: trasz Date: Thu, 7 Apr 2016 04:23:25 +0000 Subject: Add four new RCTL resources - readbps, readiops, writebps and writeiops, for limiting disk (actually filesystem) IO. Note that in some cases these limits are not quite precise. It's ok, as long as it's within some reasonable bounds. Testing - and review of the code, in particular the VFS and VM parts - is very welcome. MFC after: 1 month Relnotes: yes Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D5080 --- sys/vm/vm_fault.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'sys/vm/vm_fault.c') diff --git a/sys/vm/vm_fault.c b/sys/vm/vm_fault.c index a7e3d37..13a5757 100644 --- a/sys/vm/vm_fault.c +++ b/sys/vm/vm_fault.c @@ -83,6 +83,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -994,6 +995,21 @@ vnode_locked: if (hardfault) { PCPU_INC(cnt.v_io_faults); curthread->td_ru.ru_majflt++; +#ifdef RACCT + if (racct_enable && fs.object->type == OBJT_VNODE) { + PROC_LOCK(curproc); + if ((fault_type & (VM_PROT_COPY | VM_PROT_WRITE)) != 0) { + racct_add_force(curproc, RACCT_WRITEBPS, + PAGE_SIZE + behind * PAGE_SIZE); + racct_add_force(curproc, RACCT_WRITEIOPS, 1); + } else { + racct_add_force(curproc, RACCT_READBPS, + PAGE_SIZE + ahead * PAGE_SIZE); + racct_add_force(curproc, RACCT_READIOPS, 1); + } + PROC_UNLOCK(curproc); + } +#endif } else curthread->td_ru.ru_minflt++; -- cgit v1.1