Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 6 Apr 2020 18:52:40 +0000 (UTC)
From:      Konstantin Belousov <kib@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org
Subject:   svn commit: r359666 - stable/12/sys/kern
Message-ID:  <202004061852.036IqeBv050566@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kib
Date: Mon Apr  6 18:52:40 2020
New Revision: 359666
URL: https://svnweb.freebsd.org/changeset/base/359666

Log:
  MFC r359468:
  kern_sendfile.c: add specific malloc type.

Modified:
  stable/12/sys/kern/kern_sendfile.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/kern/kern_sendfile.c
==============================================================================
--- stable/12/sys/kern/kern_sendfile.c	Mon Apr  6 18:48:55 2020	(r359665)
+++ stable/12/sys/kern/kern_sendfile.c	Mon Apr  6 18:52:40 2020	(r359666)
@@ -60,6 +60,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
 
@@ -255,7 +257,7 @@ sendfile_iodone(void *arg, vm_page_t *pg, int count, i
 	SOCK_LOCK(so);
 	sorele(so);
 	CURVNET_RESTORE();
-	free(sfio, M_TEMP);
+	free(sfio, M_SENDFILE);
 }
 
 /*
@@ -530,7 +532,7 @@ vn_sendfile(struct file *fp, int sockfd, struct uio *h
 	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");
 	}
@@ -695,7 +697,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->so = so;
 		sfio->error = 0;
@@ -705,7 +707,7 @@ retry_space:
 		if (error != 0) {
 			if (vp != NULL)
 				VOP_UNLOCK(vp, 0);
-			free(sfio, M_TEMP);
+			free(sfio, M_SENDFILE);
 			goto done;
 		}
 
@@ -817,7 +819,7 @@ prepend_header:
 		if (m == NULL) {
 			KASSERT(softerr, ("%s: m NULL, no error", __func__));
 			error = softerr;
-			free(sfio, M_TEMP);
+			free(sfio, M_SENDFILE);
 			goto done;
 		}
 
@@ -834,7 +836,7 @@ prepend_header:
 			 * we can send data right now without the
 			 * PRUS_NOTREADY flag.
 			 */
-			free(sfio, M_TEMP);
+			free(sfio, M_SENDFILE);
 			error = (*so->so_proto->pr_usrreqs->pru_send)
 			    (so, 0, m, NULL, NULL, td);
 		} else {
@@ -898,7 +900,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);
 	}
 
 	if (error == ERESTART)



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202004061852.036IqeBv050566>