From owner-svn-src-head@FreeBSD.ORG Thu Sep 4 23:53:52 2014 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 730797AB; Thu, 4 Sep 2014 23:53:52 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 5E8C918BB; Thu, 4 Sep 2014 23:53:52 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id s84Nrq3Y034958; Thu, 4 Sep 2014 23:53:52 GMT (envelope-from jmg@FreeBSD.org) Received: (from jmg@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id s84NrpSW034955; Thu, 4 Sep 2014 23:53:51 GMT (envelope-from jmg@FreeBSD.org) Message-Id: <201409042353.s84NrpSW034955@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: jmg set sender to jmg@FreeBSD.org using -f From: John-Mark Gurney Date: Thu, 4 Sep 2014 23:53:51 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r271148 - head/sys/geom/eli X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 04 Sep 2014 23:53:52 -0000 Author: jmg Date: Thu Sep 4 23:53:51 2014 New Revision: 271148 URL: http://svnweb.freebsd.org/changeset/base/271148 Log: use a straight buffer instead of an iov w/ 1 segment... The aesni driver when it hits a mbuf/iov buffer, it mallocs and copies the data for processing.. This improves perf by ~8-10% on my machine... I have thoughts of fixing AES-NI so that it can better handle segmented buffers, which should help improve IPSEC performance, but that is for the future... Modified: head/sys/geom/eli/g_eli_crypto.c head/sys/geom/eli/g_eli_integrity.c head/sys/geom/eli/g_eli_privacy.c Modified: head/sys/geom/eli/g_eli_crypto.c ============================================================================== --- head/sys/geom/eli/g_eli_crypto.c Thu Sep 4 23:50:05 2014 (r271147) +++ head/sys/geom/eli/g_eli_crypto.c Thu Sep 4 23:53:51 2014 (r271148) @@ -32,7 +32,6 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include #else #include #include @@ -63,8 +62,6 @@ g_eli_crypto_cipher(u_int algo, int enc, struct cryptoini cri; struct cryptop *crp; struct cryptodesc *crd; - struct uio *uio; - struct iovec *iov; uint64_t sid; u_char *p; int error; @@ -79,24 +76,13 @@ g_eli_crypto_cipher(u_int algo, int enc, error = crypto_newsession(&sid, &cri, CRYPTOCAP_F_SOFTWARE); if (error != 0) return (error); - p = malloc(sizeof(*crp) + sizeof(*crd) + sizeof(*uio) + sizeof(*iov), - M_ELI, M_NOWAIT | M_ZERO); + p = malloc(sizeof(*crp) + sizeof(*crd), M_ELI, M_NOWAIT | M_ZERO); if (p == NULL) { crypto_freesession(sid); return (ENOMEM); } crp = (struct cryptop *)p; p += sizeof(*crp); crd = (struct cryptodesc *)p; p += sizeof(*crd); - uio = (struct uio *)p; p += sizeof(*uio); - iov = (struct iovec *)p; p += sizeof(*iov); - - iov->iov_len = datasize; - iov->iov_base = data; - - uio->uio_iov = iov; - uio->uio_iovcnt = 1; - uio->uio_segflg = UIO_SYSSPACE; - uio->uio_resid = datasize; crd->crd_skip = 0; crd->crd_len = datasize; @@ -114,8 +100,8 @@ g_eli_crypto_cipher(u_int algo, int enc, crp->crp_olen = datasize; crp->crp_opaque = NULL; crp->crp_callback = g_eli_crypto_done; - crp->crp_buf = (void *)uio; - crp->crp_flags = CRYPTO_F_IOV | CRYPTO_F_CBIFSYNC | CRYPTO_F_REL; + crp->crp_buf = (void *)data; + crp->crp_flags = CRYPTO_F_CBIFSYNC | CRYPTO_F_REL; crp->crp_desc = crd; error = crypto_dispatch(crp); Modified: head/sys/geom/eli/g_eli_integrity.c ============================================================================== --- head/sys/geom/eli/g_eli_integrity.c Thu Sep 4 23:50:05 2014 (r271147) +++ head/sys/geom/eli/g_eli_integrity.c Thu Sep 4 23:53:51 2014 (r271148) @@ -41,7 +41,6 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include #include #include @@ -363,8 +362,6 @@ g_eli_auth_read(struct g_eli_softc *sc, size += sizeof(struct cryptop) * nsec; size += sizeof(struct cryptodesc) * nsec * 2; size += G_ELI_AUTH_SECKEYLEN * nsec; - size += sizeof(struct uio) * nsec; - size += sizeof(struct iovec) * nsec; cbp->bio_offset = (bp->bio_offset / bp->bio_to->sectorsize) * sc->sc_bytes_per_sector; bp->bio_driver2 = malloc(size, M_ELI, M_WAITOK); cbp->bio_data = bp->bio_driver2; @@ -409,8 +406,6 @@ g_eli_auth_run(struct g_eli_worker *wr, struct g_eli_softc *sc; struct cryptop *crp; struct cryptodesc *crde, *crda; - struct uio *uio; - struct iovec *iov; u_int i, lsec, nsec, data_secsize, decr_secsize, encr_secsize; off_t dstoff; int err, error; @@ -449,8 +444,6 @@ g_eli_auth_run(struct g_eli_worker *wr, size += sizeof(*crde) * nsec; size += sizeof(*crda) * nsec; size += G_ELI_AUTH_SECKEYLEN * nsec; - size += sizeof(*uio) * nsec; - size += sizeof(*iov) * nsec; data = malloc(size, M_ELI, M_WAITOK); bp->bio_driver2 = data; p = data + encr_secsize * nsec; @@ -464,8 +457,6 @@ g_eli_auth_run(struct g_eli_worker *wr, crde = (struct cryptodesc *)p; p += sizeof(*crde); crda = (struct cryptodesc *)p; p += sizeof(*crda); authkey = (u_char *)p; p += G_ELI_AUTH_SECKEYLEN; - uio = (struct uio *)p; p += sizeof(*uio); - iov = (struct iovec *)p; p += sizeof(*iov); data_secsize = sc->sc_data_per_sector; if ((i % lsec) == 0) @@ -482,21 +473,13 @@ g_eli_auth_run(struct g_eli_worker *wr, plaindata += data_secsize; } - iov->iov_len = sc->sc_alen + data_secsize; - iov->iov_base = data; - data += encr_secsize; - - uio->uio_iov = iov; - uio->uio_iovcnt = 1; - uio->uio_segflg = UIO_SYSSPACE; - uio->uio_resid = iov->iov_len; - crp->crp_sid = wr->w_sid; - crp->crp_ilen = uio->uio_resid; + crp->crp_ilen = sc->sc_alen + data_secsize; crp->crp_olen = data_secsize; crp->crp_opaque = (void *)bp; - crp->crp_buf = (void *)uio; - crp->crp_flags = CRYPTO_F_IOV | CRYPTO_F_CBIFSYNC | CRYPTO_F_REL; + crp->crp_buf = (void *)data; + data += encr_secsize; + crp->crp_flags = CRYPTO_F_CBIFSYNC | CRYPTO_F_REL; if (g_eli_batch) crp->crp_flags |= CRYPTO_F_BATCH; if (bp->bio_cmd == BIO_WRITE) { Modified: head/sys/geom/eli/g_eli_privacy.c ============================================================================== --- head/sys/geom/eli/g_eli_privacy.c Thu Sep 4 23:50:05 2014 (r271147) +++ head/sys/geom/eli/g_eli_privacy.c Thu Sep 4 23:53:51 2014 (r271148) @@ -41,7 +41,6 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include #include #include @@ -230,8 +229,6 @@ g_eli_crypto_run(struct g_eli_worker *wr struct g_eli_softc *sc; struct cryptop *crp; struct cryptodesc *crd; - struct uio *uio; - struct iovec *iov; u_int i, nsec, secsize; int err, error; off_t dstoff; @@ -254,8 +251,6 @@ g_eli_crypto_run(struct g_eli_worker *wr */ size = sizeof(*crp) * nsec; size += sizeof(*crd) * nsec; - size += sizeof(*uio) * nsec; - size += sizeof(*iov) * nsec; /* * If we write the data we cannot destroy current bio_data content, * so we need to allocate more memory for encrypted data. @@ -280,28 +275,18 @@ g_eli_crypto_run(struct g_eli_worker *wr for (i = 0, dstoff = bp->bio_offset; i < nsec; i++, dstoff += secsize) { crp = (struct cryptop *)p; p += sizeof(*crp); crd = (struct cryptodesc *)p; p += sizeof(*crd); - uio = (struct uio *)p; p += sizeof(*uio); - iov = (struct iovec *)p; p += sizeof(*iov); - - iov->iov_len = secsize; - iov->iov_base = data; - data += secsize; - - uio->uio_iov = iov; - uio->uio_iovcnt = 1; - uio->uio_segflg = UIO_SYSSPACE; - uio->uio_resid = secsize; crp->crp_sid = wr->w_sid; crp->crp_ilen = secsize; crp->crp_olen = secsize; crp->crp_opaque = (void *)bp; - crp->crp_buf = (void *)uio; + crp->crp_buf = (void *)data; + data += secsize; if (bp->bio_cmd == BIO_WRITE) crp->crp_callback = g_eli_crypto_write_done; else /* if (bp->bio_cmd == BIO_READ) */ crp->crp_callback = g_eli_crypto_read_done; - crp->crp_flags = CRYPTO_F_IOV | CRYPTO_F_CBIFSYNC | CRYPTO_F_REL; + crp->crp_flags = CRYPTO_F_CBIFSYNC | CRYPTO_F_REL; if (g_eli_batch) crp->crp_flags |= CRYPTO_F_BATCH; crp->crp_desc = crd;