From nobody Wed Sep 04 08:50:25 2024 X-Original-To: dev-commits-src-main@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 4WzGR61vDxz5TRjl; Wed, 04 Sep 2024 08:50:26 +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 "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4WzGR56PlKz4WDZ; Wed, 4 Sep 2024 08:50:25 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1725439825; 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=RPpz4GI5BDE8t2JTtn1PgWqYKI/SVn0UwGm3YrJ1dso=; b=Pelk0nzvacVeqem5ntQUCtRCicf+kpB3F+/CDr44YzWbs9nWQ/yuswxLeVtIbmBk4UEdJB nwlUcJoQ+InnLVXTpwowAvObLMm/9cANh1UtN1EiqJjVaH6LUXkxUuPstUFoz+KZE2nuXq GKYIZ0tymUsINOPeEZnclqKW4ZrnKPv85DCLNwFBVqTiYxEstwoFvh6cEuTPDjN9RPCEkY z/qyy2uFHoq9oGAgIIn/qI4lnAXgEPEL11VsMDyG6y0j6bskychi/wF0z4K21hsKwSkvNo CsM55Ej6SlA3YY8zOjtgXlTawubxUPAb4H5SAUSJ9/NOpWnIc+DbU+b6rKEWnw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1725439825; a=rsa-sha256; cv=none; b=Dr5FyNQ0mtMRRnunAERGEVaHkuhlSVFuTBraOQkvpSaMJzSJgQsSrXbvCChQDtASpW/2wY HX2cXIxvtCIC2ILDEoVZYK3+1+ZrncPFT4oKpc6MIWn/lIZPnknYsovZKUnzG5bEJZJc4p 0ky+L/H1ofzCGszXqpfBAo7ikIaBhulC0e83+isX9zemeNMRXe0FR5UVFt6rc40PMjbvkB x7xGlcmkaKi8gG5/BCi5NN7Ioxg/myzkzfnhUG0Q7fyE35xkMODVwUGlBvx5wR3yuZNdj0 mm/OgBDdyJeDvAf2OLx8N5T2cJUsWWPZUOcNGAJowzAFxTTuIAr4sxV5BsRKrw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1725439825; 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=RPpz4GI5BDE8t2JTtn1PgWqYKI/SVn0UwGm3YrJ1dso=; b=pgQyWIUacedBCSujtn5fQ+82aqb0g/TkVfqD5/kGpUwf/3LRcQBsBkWP29oDcAl8BvhdCq HIPd1qeU3i42lzIJUAuwFcYjeDdH5plp4z+1kygl2mQI/v8vRRYosPg1eVYRtADbQeC8Rq xMTTn8EPiMu1+DjTrPHEXe5RsLz2NO8BHVGiwQxtyF/OUgxW8TluToZkOMWCo0ZUlznq7p rK1rq4TGNlMcgX5C9+NYDQnaeiuJ/MtwOX9UcN/Tzxz+cxDq3R0eo1s4r6gyDmxxZB2vlT 1f0pUfwL68zl1ylG3++bvlxuSG07XYtDbD5TmnzBADAU8az7ApVyi057g7FG/w== 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 4WzGR55SqszHQG; Wed, 4 Sep 2024 08:50:25 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 4848oPDd096862; Wed, 4 Sep 2024 08:50:25 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 4848oPXu096859; Wed, 4 Sep 2024 08:50:25 GMT (envelope-from git) Date: Wed, 4 Sep 2024 08:50:25 GMT Message-Id: <202409040850.4848oPXu096859@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: f76826b892de - main - ipsec offload: use private taskqueue thread List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: f76826b892de38ed25e407c9d5e73aec1229f728 Auto-Submitted: auto-generated The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=f76826b892de38ed25e407c9d5e73aec1229f728 commit f76826b892de38ed25e407c9d5e73aec1229f728 Author: Konstantin Belousov AuthorDate: 2024-08-30 17:17:50 +0000 Commit: Konstantin Belousov CommitDate: 2024-09-04 08:49:38 +0000 ipsec offload: use private taskqueue thread Using global taskqueue_thread XXX with the vnet tasks scheduled during VNET destruction. VNET shutdown needs to wait for all vnet-scoped SAs/SPs to be handled, and doing that from taskqueue_thread task deadlocks because the same thread proceeds the removals. Reviewed by: markj Sponsored by: NVidia networking Differential revision: https://reviews.freebsd.org/D46494 --- sys/netipsec/ipsec_offload.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/sys/netipsec/ipsec_offload.c b/sys/netipsec/ipsec_offload.c index 5e8755d5f243..a06e91ada1a1 100644 --- a/sys/netipsec/ipsec_offload.c +++ b/sys/netipsec/ipsec_offload.c @@ -69,6 +69,7 @@ static struct mtx ipsec_accel_sav_tmp; static struct unrhdr *drv_spi_unr; static struct mtx ipsec_accel_cnt_lock; +static struct taskqueue *ipsec_accel_tq; struct ipsec_accel_install_newkey_tq { struct secasvar *sav; @@ -166,6 +167,11 @@ ipsec_accel_init(void *arg) mtx_init(&ipsec_accel_cnt_lock, "ipascn", MTX_DEF, 0); drv_spi_unr = new_unrhdr(IPSEC_ACCEL_DRV_SPI_MIN, IPSEC_ACCEL_DRV_SPI_MAX, &ipsec_accel_sav_tmp); + ipsec_accel_tq = taskqueue_create("ipsec_offload", M_WAITOK, + taskqueue_thread_enqueue, &ipsec_accel_tq); + (void)taskqueue_start_threads(&ipsec_accel_tq, + 1 /* Must be single-threaded */, PWAIT, + "ipsec_offload"); ipsec_accel_sa_newkey_p = ipsec_accel_sa_newkey_impl; ipsec_accel_forget_sav_p = ipsec_accel_forget_sav_impl; ipsec_accel_spdadd_p = ipsec_accel_spdadd_impl; @@ -207,6 +213,8 @@ ipsec_accel_fini(void *arg) clean_unrhdr(drv_spi_unr); /* avoid panic, should go later */ clear_unrhdr(drv_spi_unr); delete_unrhdr(drv_spi_unr); + taskqueue_drain_all(ipsec_accel_tq); + taskqueue_free(ipsec_accel_tq); mtx_destroy(&ipsec_accel_sav_tmp); mtx_destroy(&ipsec_accel_cnt_lock); } @@ -344,7 +352,7 @@ ipsec_accel_sa_newkey_act(void *context, int pending) /* * If ipsec_accel_forget_sav() raced with us and set * the flag, do its work. Its task cannot execute in - * parallel since taskqueue_thread is single-threaded. + * parallel since ipsec_accel taskqueue is single-threaded. */ if ((sav->accel_flags & SADB_KEY_ACCEL_DEINST) != 0) { tqf = (void *)sav->accel_forget_tq; @@ -385,7 +393,7 @@ ipsec_accel_sa_newkey_impl(struct secasvar *sav) TASK_INIT(&tq->install_task, 0, ipsec_accel_sa_newkey_act, tq); tq->sav = sav; tq->install_vnet = curthread->td_vnet; /* XXXKIB liveness */ - taskqueue_enqueue(taskqueue_thread, &tq->install_task); + taskqueue_enqueue(ipsec_accel_tq, &tq->install_task); } static int @@ -508,7 +516,7 @@ ipsec_accel_forget_sav_impl(struct secasvar *sav) TASK_INIT(&tq->forget_task, 0, ipsec_accel_forget_sav_act, tq); tq->forget_vnet = curthread->td_vnet; tq->sav = sav; - taskqueue_enqueue(taskqueue_thread, &tq->forget_task); + taskqueue_enqueue(ipsec_accel_tq, &tq->forget_task); } static void @@ -696,7 +704,7 @@ ipsec_accel_spdadd_impl(struct secpolicy *sp, struct inpcb *inp) in_pcbref(inp); TASK_INIT(&tq->adddel_task, 0, ipsec_accel_spdadd_act, sp); key_addref(sp); - taskqueue_enqueue(taskqueue_thread, &tq->adddel_task); + taskqueue_enqueue(ipsec_accel_tq, &tq->adddel_task); } static void @@ -751,7 +759,7 @@ ipsec_accel_spddel_impl(struct secpolicy *sp) tq->adddel_vnet = curthread->td_vnet; TASK_INIT(&tq->adddel_task, 0, ipsec_accel_spddel_act, sp); key_addref(sp); - taskqueue_enqueue(taskqueue_thread, &tq->adddel_task); + taskqueue_enqueue(ipsec_accel_tq, &tq->adddel_task); } static void @@ -1124,7 +1132,7 @@ ipsec_accel_sa_lifetime_op_impl(struct secasvar *sav, static void ipsec_accel_sync_imp(void) { - taskqueue_drain_all(taskqueue_thread); + taskqueue_drain_all(ipsec_accel_tq); } static struct mbuf *