summaryrefslogtreecommitdiffstats
path: root/sys/vm/vm_fault.c
diff options
context:
space:
mode:
authortrasz <trasz@FreeBSD.org>2016-04-07 04:23:25 +0000
committertrasz <trasz@FreeBSD.org>2016-04-07 04:23:25 +0000
commit825d80e01c65efad6bfe7302038a657bbc08e06a (patch)
tree38459686f8eedbb80701f99097b1b51ee3363aa8 /sys/vm/vm_fault.c
parentcc1aaf5a1a88524a7d9ff817b98dcfb66049f5f8 (diff)
downloadFreeBSD-src-825d80e01c65efad6bfe7302038a657bbc08e06a.zip
FreeBSD-src-825d80e01c65efad6bfe7302038a657bbc08e06a.tar.gz
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
Diffstat (limited to 'sys/vm/vm_fault.c')
-rw-r--r--sys/vm/vm_fault.c16
1 files changed, 16 insertions, 0 deletions
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 <sys/lock.h>
#include <sys/mman.h>
#include <sys/proc.h>
+#include <sys/racct.h>
#include <sys/resourcevar.h>
#include <sys/rwlock.h>
#include <sys/sysctl.h>
@@ -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++;
OpenPOWER on IntegriCloud