aboutsummaryrefslogtreecommitdiff
path: root/sys/kern/kern_sendfile.c
diff options
context:
space:
mode:
authorKonstantin Belousov <kib@FreeBSD.org>2020-03-30 21:50:51 +0000
committerKonstantin Belousov <kib@FreeBSD.org>2020-03-30 21:50:51 +0000
commit8f0a223c78964c347946fe2573b6f4e4ab4d2e06 (patch)
tree155891dd6938fd233e02b60557076ddab0322e3d /sys/kern/kern_sendfile.c
parentda8c654e9982d86fc3973a16f885b53bc7ffd56b (diff)
downloadsrc-8f0a223c78964c347946fe2573b6f4e4ab4d2e06.tar.gz
src-8f0a223c78964c347946fe2573b6f4e4ab4d2e06.zip
kern_sendfile.c: add specific malloc type.
Now sfio leaks are more easily seen in the malloc statistics than e.g. just wired or busy pages leak. Reviewed by: glebius, markj Tested by: pho Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D24038
Notes
Notes: svn path=/head/; revision=359468
Diffstat (limited to 'sys/kern/kern_sendfile.c')
-rw-r--r--sys/kern/kern_sendfile.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/sys/kern/kern_sendfile.c b/sys/kern/kern_sendfile.c
index 229e003667cb..4b9d95185c51 100644
--- a/sys/kern/kern_sendfile.c
+++ b/sys/kern/kern_sendfile.c
@@ -65,6 +65,8 @@ __FBSDID("$FreeBSD$");
#include <vm/vm_object.h>
#include <vm/vm_pager.h>
+static MALLOC_DEFINE(M_SENDFILE, "sendfile", "sendfile dynamic memory");
+
#define EXT_FLAG_SYNC EXT_FLAG_VENDOR1
#define EXT_FLAG_NOCACHE EXT_FLAG_VENDOR2
#define EXT_FLAG_CACHE_LAST EXT_FLAG_VENDOR3
@@ -283,7 +285,7 @@ sendfile_iodone(void *arg, vm_page_t *pg, int count, int error)
* to the socket yet.
*/
MPASS((curthread->td_pflags & TDP_KTHREAD) == 0);
- free(sfio, M_TEMP);
+ free(sfio, M_SENDFILE);
return;
}
@@ -338,7 +340,7 @@ sendfile_iodone(void *arg, vm_page_t *pg, int count, int error)
out_with_ref:
#endif
CURVNET_RESTORE();
- free(sfio, M_TEMP);
+ free(sfio, M_SENDFILE);
}
/*
@@ -640,7 +642,7 @@ vn_sendfile(struct file *fp, int sockfd, struct uio *hdr_uio,
SFSTAT_ADD(sf_rhpages_requested, SF_READAHEAD(flags));
if (flags & SF_SYNC) {
- sfs = malloc(sizeof *sfs, M_TEMP, M_WAITOK | M_ZERO);
+ sfs = malloc(sizeof(*sfs), M_SENDFILE, M_WAITOK | M_ZERO);
mtx_init(&sfs->mtx, "sendfile", NULL, MTX_DEF);
cv_init(&sfs->cv, "sendfile");
}
@@ -826,7 +828,7 @@ retry_space:
npages, rhpages);
sfio = malloc(sizeof(struct sf_io) +
- npages * sizeof(vm_page_t), M_TEMP, M_WAITOK);
+ npages * sizeof(vm_page_t), M_SENDFILE, M_WAITOK);
refcount_init(&sfio->nios, 1);
sfio->obj = obj;
sfio->error = 0;
@@ -1135,7 +1137,7 @@ out:
KASSERT(sfs->count == 0, ("sendfile sync still busy"));
cv_destroy(&sfs->cv);
mtx_destroy(&sfs->mtx);
- free(sfs, M_TEMP);
+ free(sfs, M_SENDFILE);
}
#ifdef KERN_TLS
if (tls != NULL)