From nobody Thu Feb 24 10:04:26 2022 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 DCA3A19E06D9; Thu, 24 Feb 2022 10:04:27 +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 4K47mW1XyFz3QZ0; Thu, 24 Feb 2022 10:04:26 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1645697067; 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=c7nNkq2oLkTghGrDDlesVtJ5GgderennrvO7S5snTZ4=; b=W8wYX2c8eE+HHasadaxTVvVpNDOpGLUz9totIzb57CE7opvx3OXD8BuJu1OXX63Tad8r++ lyfHqp6lVmkxu17MrsxeCyCBt2iwq/81leTmeq0akArgyB8G8ob3BQonCggb24Kk25ZaQY XIQlp9aQIgWmk26hA8GfxymqdhPqg1xu97bcrR4jJttd81z0cDGCYWimGhn+IQoQAzFgKg CgQWTu7sGKW3NbmW+lKjkr6bGmYa5HLQZmilkbxU5aEs0rBS8kVttsxLYQGHlNKHZUC8bH IqW7KaLr6Z1JLBo0rqDV5ZqXs+hREKzBCMePA851DC1wX4EeEyalNC2m6K4asQ== 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 7C0F21EEA; Thu, 24 Feb 2022 10:04:26 +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 21OA4QOU003706; Thu, 24 Feb 2022 10:04:26 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 21OA4QQm003705; Thu, 24 Feb 2022 10:04:26 GMT (envelope-from git) Date: Thu, 24 Feb 2022 10:04:26 GMT Message-Id: <202202241004.21OA4QQm003705@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Hans Petter Selasky Subject: git: adcd93a41692 - stable/13 - mlx5en: Use a UMA cache zone for managing TLS send tags 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: hselasky X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: adcd93a41692e45f0440c0e744b811d4fb197712 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1645697067; 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=c7nNkq2oLkTghGrDDlesVtJ5GgderennrvO7S5snTZ4=; b=nD5OXd2dO/PmV5CHyLcAuQl6pQSXyj/HjHq1hj2o50AgN2PuTGzOWZyH0CdOZPZ0qT/ZaC oJ+4RzTkyyCv3JFDPxAsvdbCdbpkGveybtEXylDtQDmsv5pj0dH+cyEH1aeLRl1v9QJVcf WlZ8Pw8zgBjoA6GpSfjCCpzkEwoo8pDrgDrCGMYOVoyZUI1+WXntvdp1D50Q7i/YX0+Mid Pcct+jZSQT8eGIkWctIwEj2od5fJ8IbuXtO5y1L7p7TmEpRO2Xt9UY2/fJm4BMBk6iLInH MaTN2w74nhf5ruhNowyMzJtDhbuvEQXVZdoAUjBAvVFKEGjePqai6MvOPL2iEQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1645697067; a=rsa-sha256; cv=none; b=xNP5aSzu3VslJdVbVY8TLj10u3wLVcfOtJeGhu1wx4stnUKfYPk1yfUuqYGrUJv8tcdDCa 52w84fVy7W8bl2vhq5lIztRHBSLJ3GoUZv/9l8nhx/IneY37bmnl0Wty1dONOa9WUUI4IY YeOE2J+9nQFl6LUxQPaEZjB4q2dyTm8dtmtRVjqtijRSMpCzPgACvG3LIRyqEHtHkfpbb7 CdIPMB+Tks3ANTByG01JpsslyMIe5JZcL7211t5HZiZSW01fGJ0cyTXuv7Uam4c2XVNYQb DyZy6W19gH7xu4Ll86l47eVBqQ5nIGWlfKbemNL7P/rsmSM3TVoNVtrnCnX/ow== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by hselasky: URL: https://cgit.FreeBSD.org/src/commit/?id=adcd93a41692e45f0440c0e744b811d4fb197712 commit adcd93a41692e45f0440c0e744b811d4fb197712 Author: Hans Petter Selasky AuthorDate: 2022-02-24 09:59:19 +0000 Commit: Hans Petter Selasky CommitDate: 2022-02-24 09:59:19 +0000 mlx5en: Use a UMA cache zone for managing TLS send tags Instead of allocating directly from a normal zone. This way import and release are guaranteed to process all allocated and then deallocated items. Also, the release occurs in a sleepable context when caller of uma_zfree() or uma_zdestroy() can sleep itself. Sponsored by: NVIDIA Networking (cherry picked from commit 0f7b6e11c01d5360c9423d6938b160fe2d030ab0) --- sys/dev/mlx5/mlx5_en/mlx5_en_hw_tls.c | 53 ++++++++++++++++++++--------------- 1 file changed, 31 insertions(+), 22 deletions(-) diff --git a/sys/dev/mlx5/mlx5_en/mlx5_en_hw_tls.c b/sys/dev/mlx5/mlx5_en/mlx5_en_hw_tls.c index 359bd9bddc7f..2b1519e5fb0a 100644 --- a/sys/dev/mlx5/mlx5_en/mlx5_en_hw_tls.c +++ b/sys/dev/mlx5/mlx5_en/mlx5_en_hw_tls.c @@ -62,37 +62,45 @@ static const char *mlx5e_tls_stats_desc[] = { static void mlx5e_tls_work(struct work_struct *); static int -mlx5e_tls_tag_zinit(void *mem, int size, int flags) +mlx5e_tls_tag_import(void *arg, void **store, int cnt, int domain, int flags) { - struct mlx5e_tls_tag *ptag = mem; - - MPASS(size == sizeof(*ptag)); - - memset(ptag, 0, sizeof(*ptag)); - mtx_init(&ptag->mtx, "mlx5-tls-tag-mtx", NULL, MTX_DEF); - INIT_WORK(&ptag->work, mlx5e_tls_work); - - return (0); + struct mlx5e_tls_tag *ptag; + int i; + + for (i = 0; i != cnt; i++) { + ptag = malloc_domainset(sizeof(*ptag), M_MLX5E_TLS, + mlx5_dev_domainset(arg), flags | M_ZERO); + mtx_init(&ptag->mtx, "mlx5-tls-tag-mtx", NULL, MTX_DEF); + INIT_WORK(&ptag->work, mlx5e_tls_work); + store[i] = ptag; + } + return (i); } static void -mlx5e_tls_tag_zfini(void *mem, int size) +mlx5e_tls_tag_release(void *arg, void **store, int cnt) { - struct mlx5e_tls_tag *ptag = mem; + struct mlx5e_tls_tag *ptag; struct mlx5e_priv *priv; struct mlx5e_tls *ptls; + int i; - ptls = ptag->tls; - priv = container_of(ptls, struct mlx5e_priv, tls); + for (i = 0; i != cnt; i++) { + ptag = store[i]; + ptls = ptag->tls; + priv = container_of(ptls, struct mlx5e_priv, tls); - flush_work(&ptag->work); + flush_work(&ptag->work); - if (ptag->tisn != 0) { - mlx5_tls_close_tis(priv->mdev, ptag->tisn); - atomic_add_32(&ptls->num_resources, -1U); - } + if (ptag->tisn != 0) { + mlx5_tls_close_tis(priv->mdev, ptag->tisn); + atomic_add_32(&ptls->num_resources, -1U); + } + + mtx_destroy(&ptag->mtx); - mtx_destroy(&ptag->mtx); + free(ptag, M_MLX5E_TLS); + } } static void @@ -136,8 +144,9 @@ mlx5e_tls_init(struct mlx5e_priv *priv) snprintf(ptls->zname, sizeof(ptls->zname), "mlx5_%u_tls", device_get_unit(priv->mdev->pdev->dev.bsddev)); - ptls->zone = uma_zcreate(ptls->zname, sizeof(struct mlx5e_tls_tag), - NULL, NULL, mlx5e_tls_tag_zinit, mlx5e_tls_tag_zfini, UMA_ALIGN_CACHE, 0); + ptls->zone = uma_zcache_create(ptls->zname, + sizeof(struct mlx5e_tls_tag), NULL, NULL, NULL, NULL, + mlx5e_tls_tag_import, mlx5e_tls_tag_release, priv->mdev, 0); /* shared between RX and TX TLS */ ptls->max_resources = 1U << (MLX5_CAP_GEN(priv->mdev, log_max_dek) - 1);