The branch main has been updated by markj:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=d1816248899aca31db94b1a3d7a21d52f6b3ede6

commit d1816248899aca31db94b1a3d7a21d52f6b3ede6
Author:     Mark Johnston <ma...@freebsd.org>
AuthorDate: 2021-01-20 01:34:35 +0000
Commit:     Mark Johnston <ma...@freebsd.org>
CommitDate: 2021-01-20 01:34:35 +0000

    opencrypto: Embed the driver softc in the session structure
    
    Store the driver softc below the fields owned by opencrypto.  This is
    a bit simpler and saves a pointer dereference when fetching the driver
    softc when processing a request.
    
    Get rid of the crypto session UMA zone.  Session allocations are
    frequent or performance-critical enough to warrant a dedicated zone.
    
    No functional change intended.
    
    Reviewed by:    cem, jhb
    Sponsored by:   Rubicon Communications, LLC ("Netgate")
    Differential Revision:  https://reviews.freebsd.org/D28158
---
 sys/opencrypto/crypto.c | 17 ++++-------------
 1 file changed, 4 insertions(+), 13 deletions(-)

diff --git a/sys/opencrypto/crypto.c b/sys/opencrypto/crypto.c
index cf02667e2a35..7bc230140568 100644
--- a/sys/opencrypto/crypto.c
+++ b/sys/opencrypto/crypto.c
@@ -134,7 +134,6 @@ static      int crypto_drivers_size = 0;
 
 struct crypto_session {
        struct cryptocap *cap;
-       void *softc;
        struct crypto_session_params csp;
 };
 
@@ -201,7 +200,6 @@ SYSCTL_INT(_kern, OID_AUTO, crypto_workers_num, 
CTLFLAG_RDTUN,
 #endif
 
 static uma_zone_t cryptop_zone;
-static uma_zone_t cryptoses_zone;
 
 int    crypto_userasymcrypto = 1;
 SYSCTL_INT(_kern_crypto, OID_AUTO, asym_enable, CTLFLAG_RW,
@@ -332,9 +330,6 @@ crypto_init(void)
        cryptop_zone = uma_zcreate("cryptop",
            sizeof(struct cryptop), NULL, NULL, NULL, NULL,
            UMA_ALIGN_PTR, UMA_ZONE_ZINIT);
-       cryptoses_zone = uma_zcreate("crypto_session",
-           sizeof(struct crypto_session), NULL, NULL, NULL, NULL,
-           UMA_ALIGN_PTR, UMA_ZONE_ZINIT);
 
        crypto_drivers_size = CRYPTO_DRIVERS_INITIAL;
        crypto_drivers = malloc(crypto_drivers_size *
@@ -487,8 +482,6 @@ crypto_destroy(void)
        }
        free(crypto_drivers, M_CRYPTO_DATA);
 
-       if (cryptoses_zone != NULL)
-               uma_zdestroy(cryptoses_zone);
        if (cryptop_zone != NULL)
                uma_zdestroy(cryptop_zone);
        mtx_destroy(&crypto_q_mtx);
@@ -515,7 +508,7 @@ crypto_ses2caps(crypto_session_t crypto_session)
 void *
 crypto_get_driver_session(crypto_session_t crypto_session)
 {
-       return (crypto_session->softc);
+       return (crypto_session + 1);
 }
 
 const struct crypto_session_params *
@@ -895,8 +888,7 @@ crypto_deletesession(crypto_session_t cses)
 
        cap = cses->cap;
 
-       zfree(cses->softc, M_CRYPTO_DATA);
-       uma_zfree(cryptoses_zone, cses);
+       zfree(cses, M_CRYPTO_DATA);
 
        CRYPTO_DRIVER_LOCK();
        cap->cc_sessions--;
@@ -948,10 +940,9 @@ crypto_newsession(crypto_session_t *cses,
        cap->cc_sessions++;
        CRYPTO_DRIVER_UNLOCK();
 
-       res = uma_zalloc(cryptoses_zone, M_WAITOK | M_ZERO);
+       res = malloc(sizeof(*res) + cap->cc_session_size, M_CRYPTO_DATA,
+           M_WAITOK | M_ZERO);
        res->cap = cap;
-       res->softc = malloc(cap->cc_session_size, M_CRYPTO_DATA, M_WAITOK |
-           M_ZERO);
        res->csp = *csp;
 
        /* Call the driver initialization routine. */
_______________________________________________
dev-commits-src-main@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/dev-commits-src-main
To unsubscribe, send any mail to "dev-commits-src-main-unsubscr...@freebsd.org"

Reply via email to