Date: Tue, 2 Nov 2021 19:18:30 GMT From: John Baldwin <jhb@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Subject: git: 717857819223 - main - crypto: Use a single "crypto" kproc for all of the OCF kthreads. Message-ID: <202111021918.1A2JIU9L019569@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch main has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=717857819223d9c0f81eb38abd0df200532e1cdc commit 717857819223d9c0f81eb38abd0df200532e1cdc Author: John Baldwin <jhb@FreeBSD.org> AuthorDate: 2021-11-02 18:26:21 +0000 Commit: John Baldwin <jhb@FreeBSD.org> CommitDate: 2021-11-02 19:18:05 +0000 crypto: Use a single "crypto" kproc for all of the OCF kthreads. Reported by: julian Reviewed by: markj MFC after: 1 week Sponsored by: Chelsio Communications Differential Revision: https://reviews.freebsd.org/D32739 --- sys/opencrypto/crypto.c | 50 ++++++++++++++++++++++++------------------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/sys/opencrypto/crypto.c b/sys/opencrypto/crypto.c index 85c22fd51ee2..436444869e90 100644 --- a/sys/opencrypto/crypto.c +++ b/sys/opencrypto/crypto.c @@ -168,7 +168,7 @@ struct crypto_ret_worker { uint32_t reorder_ops; /* total ordered sym jobs received */ uint32_t reorder_cur_seq; /* current sym job dispatched */ - struct proc *cryptoretproc; + struct thread *td; }; static struct crypto_ret_worker *crypto_ret_workers = NULL; @@ -204,9 +204,9 @@ SYSCTL_INT(_kern, OID_AUTO, cryptodevallowsoft, CTLFLAG_RWTUN, MALLOC_DEFINE(M_CRYPTO_DATA, "crypto", "crypto session records"); -static void crypto_proc(void); -static struct proc *cryptoproc; -static void crypto_ret_proc(struct crypto_ret_worker *ret_worker); +static void crypto_dispatch_thread(void *arg); +static struct thread *cryptotd; +static void crypto_ret_thread(void *arg); static void crypto_destroy(void); static int crypto_invoke(struct cryptocap *cap, struct cryptop *crp, int hint); static void crypto_task_invoke(void *ctx, int pending); @@ -296,6 +296,7 @@ static int crypto_init(void) { struct crypto_ret_worker *ret_worker; + struct proc *p; int error; mtx_init(&crypto_drivers_mtx, "crypto", "crypto driver table", @@ -321,8 +322,9 @@ crypto_init(void) taskqueue_start_threads(&crypto_tq, crypto_workers_num, PRI_MIN_KERN, "crypto"); - error = kproc_create((void (*)(void *)) crypto_proc, NULL, - &cryptoproc, 0, 0, "crypto"); + p = NULL; + error = kproc_kthread_add(crypto_dispatch_thread, NULL, &p, &cryptotd, + 0, 0, "crypto", "crypto"); if (error) { printf("crypto_init: cannot start crypto thread; error %d", error); @@ -341,8 +343,9 @@ crypto_init(void) mtx_init(&ret_worker->crypto_ret_mtx, "crypto", "crypto return queues", MTX_DEF); - error = kproc_create((void (*)(void *)) crypto_ret_proc, ret_worker, - &ret_worker->cryptoretproc, 0, 0, "crypto returns %td", CRYPTO_RETW_ID(ret_worker)); + error = kthread_add(crypto_ret_thread, ret_worker, p, + &ret_worker->td, 0, 0, "crypto returns %td", + CRYPTO_RETW_ID(ret_worker)); if (error) { printf("crypto_init: cannot start cryptoret thread; error %d", error); @@ -366,20 +369,16 @@ bad: * for the other half of this song-and-dance. */ static void -crypto_terminate(struct proc **pp, void *q) +crypto_terminate(struct thread **tdp, void *q) { - struct proc *p; + struct thread *td; mtx_assert(&crypto_drivers_mtx, MA_OWNED); - p = *pp; - *pp = NULL; - if (p) { + td = *tdp; + *tdp = NULL; + if (td != NULL) { wakeup_one(q); - PROC_LOCK(p); /* NB: insure we don't miss wakeup */ - CRYPTO_DRIVER_UNLOCK(); /* let crypto_finis progress */ - msleep(p, &p->p_mtx, PWAIT, "crypto_destroy", 0); - PROC_UNLOCK(p); - CRYPTO_DRIVER_LOCK(); + mtx_sleep(td, &crypto_drivers_mtx, PWAIT, "crypto_destroy", 0); } } @@ -442,9 +441,9 @@ crypto_destroy(void) if (crypto_tq != NULL) taskqueue_drain_all(crypto_tq); CRYPTO_DRIVER_LOCK(); - crypto_terminate(&cryptoproc, &crp_q); + crypto_terminate(&cryptotd, &crp_q); FOREACH_CRYPTO_RETW(ret_worker) - crypto_terminate(&ret_worker->cryptoretproc, &ret_worker->crp_ret_q); + crypto_terminate(&ret_worker->td, &ret_worker->crp_ret_q); CRYPTO_DRIVER_UNLOCK(); /* XXX flush queues??? */ @@ -1708,14 +1707,14 @@ crypto_finis(void *chan) CRYPTO_DRIVER_LOCK(); wakeup_one(chan); CRYPTO_DRIVER_UNLOCK(); - kproc_exit(0); + kthread_exit(); } /* * Crypto thread, dispatches crypto requests. */ static void -crypto_proc(void) +crypto_dispatch_thread(void *arg __unused) { struct cryptop *crp, *submit; struct cryptocap *cap; @@ -1804,7 +1803,7 @@ crypto_proc(void) crp_sleep = 1; msleep(&crp_q, &crypto_q_mtx, PWAIT, "crypto_wait", 0); crp_sleep = 0; - if (cryptoproc == NULL) + if (cryptotd == NULL) break; CRYPTOSTAT_INC(cs_intrs); } @@ -1820,8 +1819,9 @@ crypto_proc(void) * callbacks typically are expensive and would slow interrupt handling. */ static void -crypto_ret_proc(struct crypto_ret_worker *ret_worker) +crypto_ret_thread(void *arg) { + struct crypto_ret_worker *ret_worker = arg; struct cryptop *crpt; CRYPTO_RETW_LOCK(ret_worker); @@ -1858,7 +1858,7 @@ crypto_ret_proc(struct crypto_ret_worker *ret_worker) */ msleep(&ret_worker->crp_ret_q, &ret_worker->crypto_ret_mtx, PWAIT, "crypto_ret_wait", 0); - if (ret_worker->cryptoretproc == NULL) + if (ret_worker->td == NULL) break; CRYPTOSTAT_INC(cs_rets); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202111021918.1A2JIU9L019569>