Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/netipsec Use pool_cache(9) instead of pool(9) for tdb_cr...



details:   https://anonhg.NetBSD.org/src/rev/4b91f94df015
branches:  trunk
changeset: 355688:4b91f94df015
user:      ozaki-r <ozaki-r%NetBSD.org@localhost>
date:      Thu Aug 10 06:33:51 2017 +0000

description:
Use pool_cache(9) instead of pool(9) for tdb_crypto objects

The change improves network throughput especially on multi-core systems.

diffstat:

 sys/netipsec/xform_ah.c     |  29 +++++++++++++++--------------
 sys/netipsec/xform_esp.c    |  29 +++++++++++++++--------------
 sys/netipsec/xform_ipcomp.c |  29 +++++++++++++++--------------
 3 files changed, 45 insertions(+), 42 deletions(-)

diffs (truncated from 359 to 300 lines):

diff -r c7b785a9f243 -r 4b91f94df015 sys/netipsec/xform_ah.c
--- a/sys/netipsec/xform_ah.c   Thu Aug 10 06:11:24 2017 +0000
+++ b/sys/netipsec/xform_ah.c   Thu Aug 10 06:33:51 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: xform_ah.c,v 1.72 2017/08/09 09:48:11 ozaki-r Exp $    */
+/*     $NetBSD: xform_ah.c,v 1.73 2017/08/10 06:33:51 ozaki-r Exp $    */
 /*     $FreeBSD: src/sys/netipsec/xform_ah.c,v 1.1.4.1 2003/01/24 05:11:36 sam Exp $   */
 /*     $OpenBSD: ip_ah.c,v 1.63 2001/06/26 06:18:58 angelos Exp $ */
 /*
@@ -39,7 +39,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: xform_ah.c,v 1.72 2017/08/09 09:48:11 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xform_ah.c,v 1.73 2017/08/10 06:33:51 ozaki-r Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_inet.h"
@@ -123,7 +123,7 @@
 
 const uint8_t ah_stats[256] = { SADB_AALG_STATS_INIT };
 
-static struct pool ah_tdb_crypto_pool;
+static pool_cache_t ah_tdb_crypto_pool_cache;
 static size_t ah_pool_item_size;
 
 /*
@@ -702,7 +702,7 @@
 
        KASSERTMSG(size <= ah_pool_item_size,
            "size=%zu > ah_pool_item_size=%zu\n", size, ah_pool_item_size);
-       tc = pool_get(&ah_tdb_crypto_pool, PR_NOWAIT);
+       tc = pool_cache_get(ah_tdb_crypto_pool_cache, PR_NOWAIT);
        if (tc == NULL) {
                DPRINTF(("%s: failed to allocate tdb_crypto\n", __func__));
                stat = AH_STAT_CRYPTO;
@@ -775,7 +775,7 @@
 
 bad:
        if (tc != NULL)
-               pool_put(&ah_tdb_crypto_pool, tc);
+               pool_cache_put(ah_tdb_crypto_pool_cache, tc);
        if (crp != NULL)
                crypto_freereq(crp);
        if (m != NULL)
@@ -909,7 +909,7 @@
        /* Copyback the saved (uncooked) network headers. */
        m_copyback(m, 0, skip, ptr);
 
-       pool_put(&ah_tdb_crypto_pool, tc);
+       pool_cache_put(ah_tdb_crypto_pool_cache, tc);
        tc = NULL;
 
        /*
@@ -957,7 +957,7 @@
        if (m != NULL)
                m_freem(m);
        if (tc != NULL)
-               pool_put(&ah_tdb_crypto_pool, tc);
+               pool_cache_put(ah_tdb_crypto_pool_cache, tc);
        if (crp != NULL)
                crypto_freereq(crp);
        return error;
@@ -1117,7 +1117,7 @@
        crda->crd_klen = _KEYBITS(sav->key_auth);
 
        /* Allocate IPsec-specific opaque crypto info. */
-       tc = pool_get(&ah_tdb_crypto_pool, PR_NOWAIT);
+       tc = pool_cache_get(ah_tdb_crypto_pool_cache, PR_NOWAIT);
        if (tc == NULL) {
                crypto_freereq(crp);
                DPRINTF(("%s: failed to allocate tdb_crypto\n", __func__));
@@ -1151,7 +1151,7 @@
            skip, ahx->type, 1);
        if (error != 0) {
                m = NULL;       /* mbuf was free'd by ah_massage_headers. */
-               pool_put(&ah_tdb_crypto_pool, tc);
+               pool_cache_put(ah_tdb_crypto_pool_cache, tc);
                crypto_freereq(crp);
                goto bad;
        }
@@ -1165,7 +1165,7 @@
        if (__predict_false(isr->sp->state == IPSEC_SPSTATE_DEAD ||
            sav->state == SADB_SASTATE_DEAD)) {
                pserialize_read_exit(s);
-               pool_put(&ah_tdb_crypto_pool, tc);
+               pool_cache_put(ah_tdb_crypto_pool_cache, tc);
                crypto_freereq(crp);
                AH_STATINC(AH_STAT_NOTDB);
                error = ENOENT;
@@ -1269,7 +1269,7 @@
        m_copyback(m, 0, skip, ptr);
 
        /* No longer needed. */
-       pool_put(&ah_tdb_crypto_pool, tc);
+       pool_cache_put(ah_tdb_crypto_pool_cache, tc);
        crypto_freereq(crp);
 
 #ifdef IPSEC_DEBUG
@@ -1299,7 +1299,7 @@
        IPSEC_RELEASE_GLOBAL_LOCKS();
        if (m)
                m_freem(m);
-       pool_put(&ah_tdb_crypto_pool, tc);
+       pool_cache_put(ah_tdb_crypto_pool_cache, tc);
        crypto_freereq(crp);
        return error;
 }
@@ -1350,8 +1350,9 @@
        ah_pool_item_size = sizeof(struct tdb_crypto) +
            sizeof(struct ip) + MAX_IPOPTLEN +
            sizeof(struct ah) + sizeof(uint32_t) + ah_max_authsize;
-       pool_init(&ah_tdb_crypto_pool, ah_pool_item_size,
-           0, 0, 0, "ah_tdb_crypto", NULL, IPL_SOFTNET);
+       ah_tdb_crypto_pool_cache = pool_cache_init(ah_pool_item_size,
+           coherency_unit, 0, 0, "ah_tdb_crypto", NULL, IPL_SOFTNET,
+           NULL, NULL, NULL);
 
        xform_register(&ah_xformsw);
 }
diff -r c7b785a9f243 -r 4b91f94df015 sys/netipsec/xform_esp.c
--- a/sys/netipsec/xform_esp.c  Thu Aug 10 06:11:24 2017 +0000
+++ b/sys/netipsec/xform_esp.c  Thu Aug 10 06:33:51 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: xform_esp.c,v 1.70 2017/08/09 09:48:11 ozaki-r Exp $   */
+/*     $NetBSD: xform_esp.c,v 1.71 2017/08/10 06:33:51 ozaki-r Exp $   */
 /*     $FreeBSD: src/sys/netipsec/xform_esp.c,v 1.2.2.1 2003/01/24 05:11:36 sam Exp $  */
 /*     $OpenBSD: ip_esp.c,v 1.69 2001/06/26 06:18:59 angelos Exp $ */
 
@@ -39,7 +39,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: xform_esp.c,v 1.70 2017/08/09 09:48:11 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xform_esp.c,v 1.71 2017/08/10 06:33:51 ozaki-r Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_inet.h"
@@ -104,7 +104,7 @@
 
 const uint8_t esp_stats[256] = { SADB_EALG_STATS_INIT };
 
-static struct pool esp_tdb_crypto_pool;
+static pool_cache_t esp_tdb_crypto_pool_cache;
 static size_t esp_pool_item_size;
 
 /*
@@ -383,7 +383,7 @@
        KASSERTMSG(sizeof(*tc) + extra <= esp_pool_item_size,
            "sizeof(*tc) + extra=%zu > esp_pool_item_size=%zu\n",
            sizeof(*tc) + extra, esp_pool_item_size);
-       tc = pool_get(&esp_tdb_crypto_pool, PR_NOWAIT);
+       tc = pool_cache_get(esp_tdb_crypto_pool_cache, PR_NOWAIT);
        if (tc == NULL) {
                DPRINTF(("%s: failed to allocate tdb_crypto\n", __func__));
                error = ENOBUFS;
@@ -437,7 +437,7 @@
         */
        if (__predict_false(sav->state == SADB_SASTATE_DEAD)) {
                pserialize_read_exit(s);
-               pool_put(&esp_tdb_crypto_pool, tc);
+               pool_cache_put(esp_tdb_crypto_pool_cache, tc);
                crypto_freereq(crp);
                ESP_STATINC(ESP_STAT_NOTDB);
                return ENOENT;
@@ -481,7 +481,7 @@
        return crypto_dispatch(crp);
 
 out2:
-       pool_put(&esp_tdb_crypto_pool, tc);
+       pool_cache_put(esp_tdb_crypto_pool_cache, tc);
 out1:
        crypto_freereq(crp);
 out:
@@ -608,7 +608,7 @@
        }
 
        /* Release the crypto descriptors */
-       pool_put(&esp_tdb_crypto_pool, tc);
+       pool_cache_put(esp_tdb_crypto_pool_cache, tc);
        tc = NULL;
        crypto_freereq(crp), crp = NULL;
 
@@ -699,7 +699,7 @@
        if (m != NULL)
                m_freem(m);
        if (tc != NULL)
-               pool_put(&esp_tdb_crypto_pool, tc);
+               pool_cache_put(esp_tdb_crypto_pool_cache, tc);
        if (crp != NULL)
                crypto_freereq(crp);
        return error;
@@ -905,7 +905,7 @@
                crda = crp->crp_desc;
 
        /* IPsec-specific opaque crypto info. */
-       tc = pool_get(&esp_tdb_crypto_pool, PR_NOWAIT);
+       tc = pool_cache_get(esp_tdb_crypto_pool_cache, PR_NOWAIT);
        if (tc == NULL) {
                crypto_freereq(crp);
                DPRINTF(("%s: failed to allocate tdb_crypto\n", __func__));
@@ -923,7 +923,7 @@
        if (__predict_false(isr->sp->state == IPSEC_SPSTATE_DEAD ||
            sav->state == SADB_SASTATE_DEAD)) {
                pserialize_read_exit(s);
-               pool_put(&esp_tdb_crypto_pool, tc);
+               pool_cache_put(esp_tdb_crypto_pool_cache, tc);
                crypto_freereq(crp);
                ESP_STATINC(ESP_STAT_NOTDB);
                error = ENOENT;
@@ -1043,7 +1043,7 @@
                AH_STATINC(AH_STAT_HIST + ah_stats[sav->alg_auth]);
 
        /* Release crypto descriptors. */
-       pool_put(&esp_tdb_crypto_pool, tc);
+       pool_cache_put(esp_tdb_crypto_pool_cache, tc);
        crypto_freereq(crp);
 
 #ifdef IPSEC_DEBUG
@@ -1077,7 +1077,7 @@
        IPSEC_RELEASE_GLOBAL_LOCKS();
        if (m)
                m_freem(m);
-       pool_put(&esp_tdb_crypto_pool, tc);
+       pool_cache_put(esp_tdb_crypto_pool_cache, tc);
        crypto_freereq(crp);
        return error;
 }
@@ -1102,8 +1102,9 @@
        extern int ah_max_authsize;
        KASSERT(ah_max_authsize != 0);
        esp_pool_item_size = sizeof(struct tdb_crypto) + ah_max_authsize;
-       pool_init(&esp_tdb_crypto_pool, esp_pool_item_size,
-           0, 0, 0, "esp_tdb_crypto", NULL, IPL_SOFTNET);
+       esp_tdb_crypto_pool_cache = pool_cache_init(esp_pool_item_size,
+           coherency_unit, 0, 0, "esp_tdb_crypto", NULL, IPL_SOFTNET,
+           NULL, NULL, NULL);
 
 #define        MAXIV(xform)                                    \
        if (xform.ivsize > esp_max_ivlen)               \
diff -r c7b785a9f243 -r 4b91f94df015 sys/netipsec/xform_ipcomp.c
--- a/sys/netipsec/xform_ipcomp.c       Thu Aug 10 06:11:24 2017 +0000
+++ b/sys/netipsec/xform_ipcomp.c       Thu Aug 10 06:33:51 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: xform_ipcomp.c,v 1.51 2017/08/09 09:48:11 ozaki-r Exp $        */
+/*     $NetBSD: xform_ipcomp.c,v 1.52 2017/08/10 06:33:51 ozaki-r Exp $        */
 /*     $FreeBSD: src/sys/netipsec/xform_ipcomp.c,v 1.1.4.1 2003/01/24 05:11:36 sam Exp $       */
 /* $OpenBSD: ip_ipcomp.c,v 1.1 2001/07/05 12:08:52 jjbg Exp $ */
 
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: xform_ipcomp.c,v 1.51 2017/08/09 09:48:11 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xform_ipcomp.c,v 1.52 2017/08/10 06:33:51 ozaki-r Exp $");
 
 /* IP payload compression protocol (IPComp), see RFC 2393 */
 #if defined(_KERNEL_OPT)
@@ -89,7 +89,7 @@
 
 const uint8_t ipcomp_stats[256] = { SADB_CALG_STATS_INIT };
 
-static struct pool ipcomp_tdb_crypto_pool;
+static pool_cache_t ipcomp_tdb_crypto_pool_cache;
 
 const struct comp_algo *
 ipcomp_algorithm_lookup(int alg)
@@ -165,7 +165,7 @@
                return ENOBUFS;
        }
        /* Get IPsec-specific opaque pointer */
-       tc = pool_get(&ipcomp_tdb_crypto_pool, PR_NOWAIT);
+       tc = pool_cache_get(ipcomp_tdb_crypto_pool_cache, PR_NOWAIT);
        if (tc == NULL) {
                m_freem(m);
                crypto_freereq(crp);
@@ -178,7 +178,7 @@
        if (error) {
                DPRINTF(("%s: m_makewritable failed\n", __func__));
                m_freem(m);
-               pool_put(&ipcomp_tdb_crypto_pool, tc);
+               pool_cache_put(ipcomp_tdb_crypto_pool_cache, tc);
                crypto_freereq(crp);
                IPCOMP_STATINC(IPCOMP_STAT_CRYPTO);
                return error;
@@ -192,7 +192,7 @@
         */
        if (__predict_false(sav->state == SADB_SASTATE_DEAD)) {
                pserialize_read_exit(s);
-               pool_put(&ipcomp_tdb_crypto_pool, tc);
+               pool_cache_put(ipcomp_tdb_crypto_pool_cache, tc);
                crypto_freereq(crp);
                IPCOMP_STATINC(IPCOMP_STAT_NOTDB);
                return ENOENT;
@@ -318,7 +318,7 @@
        clen = crp->crp_olen;           /* Length of data after processing */
 
        /* Release the crypto descriptors */
-       pool_put(&ipcomp_tdb_crypto_pool, tc);
+       pool_cache_put(ipcomp_tdb_crypto_pool_cache, tc);



Home | Main Index | Thread Index | Old Index