From nobody Tue Nov 23 23:12:59 2021 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 8E46A18A1C7A; Tue, 23 Nov 2021 23:13:05 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HzKgK2cW3z3vq8; Tue, 23 Nov 2021 23:13:01 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 197D81F550; Tue, 23 Nov 2021 23:13:00 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1ANNCxT0037813; Tue, 23 Nov 2021 23:12:59 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1ANNCxIa037812; Tue, 23 Nov 2021 23:12:59 GMT (envelope-from git) Date: Tue, 23 Nov 2021 23:12:59 GMT Message-Id: <202111232312.1ANNCxIa037812@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: John Baldwin Subject: git: 351541661ce0 - stable/13 - crypto: Use a single "crypto" kproc for all of the OCF kthreads. List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jhb X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 351541661ce00f78873e693331433f48c6161ee0 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1637709182; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=wK0LfxDH1b5sXcykR1EfznWtKNr+XmsbCXyjbEE7N48=; b=ybK29N0PX52j+bTU2enJbI+blpCjVtOZkzSnBG/j1WLxH3POVL6eb12goEDpwtSGRR5xnp 4/NlJBnjhhEnu/3iaMpk2f0iYpl4r+yvnYBf/GiDgPkx+bukwMeEFCRxYX75a+S0JOdk2j JnaIow7l+AyVZ/hj6IPUnJADp9FWx9R/5a2h2hBkFXHFPG3EZ/z8LJEsGFqWb8Oy4JoX9d XTSBUk02+oQqklxjKJVEbhy3T2h28VTYE8xJ6TdvPsgBhw33l+Io1lHQQmtHLVZoXCMJos gNUBjS2bZvP5f3QlVUIbFKd5WT0NDw5VLt04T/3p6TePIw2Wy0CILWvAFwRZJw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1637709182; a=rsa-sha256; cv=none; b=WMI3PgrVbqRsrGWGmbT26ZJLQJUJThqe9jb4bhiFWSknST9/3LWlxuSJT+wNABpAWUda0D zzC4qesX7g3yLxI+0JntTPWqwy5psT2KVA5fDJKobh+n9vTOPsY6Xc6CuE3bM2k/nQDqM0 P1bNRkCiKu8oHupl0K/zhCgM7U1VhShI+pAEOO17x9PKMRlUEMQTXgb2rsIxjsKosofLbP Rg+AP9xEU22IaN8FOKwzKoG/8pRNzkEQdtSimUTrmKZrux/og1lJjP0GpKS1dvoSa1PD+l PtWyxKLX2T7007ccUj4379LcryxpkUynP3xsjpLgjuuihLVf+4dpvucDJfWy/g== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=351541661ce00f78873e693331433f48c6161ee0 commit 351541661ce00f78873e693331433f48c6161ee0 Author: John Baldwin AuthorDate: 2021-11-02 18:26:21 +0000 Commit: John Baldwin CommitDate: 2021-11-23 23:11:45 +0000 crypto: Use a single "crypto" kproc for all of the OCF kthreads. Reported by: julian Reviewed by: markj Sponsored by: Chelsio Communications Differential Revision: https://reviews.freebsd.org/D32739 (cherry picked from commit 717857819223d9c0f81eb38abd0df200532e1cdc) --- 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 f0fd3fe662a9..a151ee21dce7 100644 --- a/sys/opencrypto/crypto.c +++ b/sys/opencrypto/crypto.c @@ -181,7 +181,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; @@ -229,9 +229,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 int crypto_kinvoke(struct cryptkop *krp); @@ -324,6 +324,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", @@ -350,8 +351,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); @@ -371,8 +373,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); @@ -396,20 +399,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); } } @@ -472,9 +471,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??? */ @@ -1987,14 +1986,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 cryptkop *krp; @@ -2126,7 +2125,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); } @@ -2142,8 +2141,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; struct cryptkop *krpt; @@ -2187,7 +2187,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); }