Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp520845pxb; Wed, 25 Aug 2021 08:34:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzOKUPVVPZ5Dvy5v+6/1efyettj+18+q2fWHf2MTTK/rV+m56KoPcl1qzBsxoUI40f9gSAS X-Received: by 2002:a05:6e02:8f2:: with SMTP id n18mr31486580ilt.256.1629905674829; Wed, 25 Aug 2021 08:34:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629905674; cv=none; d=google.com; s=arc-20160816; b=AYFQy+6RJ4FamnnPQA0R/Zuhx++IEBD4UqQTzp0gtBe22xbsFcjSP4a1gQzrF2gssI aPyLYdeHiTUIrduXQc/ls62keB5F40SZ2/+E65SQXLsFbgByZVL19JTLQsZRo14jpRGd dMz5zVO4lYfUKy5hLnHr2SY8Er0KNkKo3cENvP46j6BOZ7yhbJKtYxPZ+ZiuJpGwXK+v AjideqMd67LoprcGc5HUQBPT2fHQH/DcrIOcG/Zx9lz7zHEXOHd72gIW9PvKX/Aj45+Z CJ2hi9crx1v1xlq3HgSpfsJophSV596iQYlRi8kO48DVXhcBan8HmrXZsFPf4iswYe1i Iwgg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=wvL1J8KEhyvF/ZLVKb8SP9iGmx/rrgPK1Hb5hBuqIvo=; b=AKIMaiILZqRYgwl7ywrLrgeyO3dQSm/IHdcNvJ1vVEwSqxdPUYhotK8FlmUJWoIHhG CdNOR2+6zoxQbilOS3kH8hZoquQoXyz/uwqedDv6A722xw2FC1I+8ANMynhQRgrH3UBd pvF3Rv7OLBr98NlYgPbAla7NFiINv2yBRTcswjmxuN2RD5CLAC7jI+5FV+lTvYw0iLcz at3UPoY1XVjv0AQr3uq6uZaJhDH5ilXHNALebS+Qkq4QZy09bbFBsSqiNKgHpbVYHiOP fNGtCkywOXqOqOaNAZxne5+fALllMQnAS+zTyHidw9ac+FCZoee/WZkDSUMzwOrJFF1N bNcA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=L7jPwTZZ; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x13si2202572jas.84.2021.08.25.08.34.09; Wed, 25 Aug 2021 08:34:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=L7jPwTZZ; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236512AbhHYO4r (ORCPT + 99 others); Wed, 25 Aug 2021 10:56:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47330 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231971AbhHYO4r (ORCPT ); Wed, 25 Aug 2021 10:56:47 -0400 Received: from mail-yb1-xb34.google.com (mail-yb1-xb34.google.com [IPv6:2607:f8b0:4864:20::b34]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A56ADC0613D9 for ; Wed, 25 Aug 2021 07:56:01 -0700 (PDT) Received: by mail-yb1-xb34.google.com with SMTP id i8so48510173ybt.7 for ; Wed, 25 Aug 2021 07:56:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=wvL1J8KEhyvF/ZLVKb8SP9iGmx/rrgPK1Hb5hBuqIvo=; b=L7jPwTZZT3jOI6gXuF9VZTYs592tZM+gktGr8MUWZIcKJjVlKdUag4gOINbV8YIZIk PRvoI+0GPDaLYpQKItO/lsUAJAUgrnfbV48dIv74TezzcZjQiLs/ZNImptNNOsbjfGcX a5lngTlixGTPXYqpLRus2JepcNK2FxaoOdvb80MPkiiCb4qDTKZJci4SzwTBqHzvzJl5 5wx5Tn9GUbQ0NBZXHbKlp3zUDtwhJObYAlS0+LJGulL2eVjSvAuqZHd5GKBXff9DnC2T 82J4aTjwEHrOJFWeFYaeOgYGbNxxMIEec7ttnkuC9jfwwbPbNatiG+GH/oDJcVGRfCAT nbdQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=wvL1J8KEhyvF/ZLVKb8SP9iGmx/rrgPK1Hb5hBuqIvo=; b=pI2Nee5r303xgHDzk1C3fN+dLr61nTr9fGDORr2zB+Cw3qn9Qcxx+B0SWXjeZypsRv pdJVyNzUJPORbbTVowgjxCfyImUteYXLMgpeI84AROqjJXF186fB0S4neKYrZcU5D/Kw pzwQFBsK33JsUZ+6CXWDOkgokwunDuVrLVLNV8+BxrmUvqHtztDTGHKa4sQWKjXR7qv1 Px6Amu9azNh3vKzDIdm1tP0z0gHFyFtE2W2e6tY9oezHtTGVgtR15XiDXa92wd7Vvt5m R19uBWw3/RkK2N2FSwJIGvOQzMkmbymKQUufSrAt5z3LYdvpkeRozuLvmZeHXn7KxqFc jCjg== X-Gm-Message-State: AOAM530woiQibqwIOrFn0knLBelDBhQ3EYHxJ6RPkk/20BIuQ6Ksg9MS aYfDzwAg6DVSprDNWDvypyUjE7XukFfaFTmNZQfmpg== X-Received: by 2002:a25:2cd5:: with SMTP id s204mr10240667ybs.452.1629903360317; Wed, 25 Aug 2021 07:56:00 -0700 (PDT) MIME-Version: 1.0 References: <30f73293-ea03-d18f-d923-0cf499d4b208@gmail.com> <20210825080817.GA19149@gondor.apana.org.au> In-Reply-To: <20210825080817.GA19149@gondor.apana.org.au> From: Eric Dumazet Date: Wed, 25 Aug 2021 07:55:49 -0700 Message-ID: Subject: Re: [RFCv3 05/15] tcp: authopt: Add crypto initialization To: Herbert Xu Cc: Eric Dumazet , Ard Biesheuvel , Eric Biggers , Leonard Crestez , Dmitry Safonov <0x7f454c46@gmail.com>, David Ahern , Shuah Khan , "David S. Miller" , Kuniyuki Iwashima , Hideaki YOSHIFUJI , Jakub Kicinski , Yuchung Cheng , Francesco Ruggeri , Mat Martineau , Christoph Paasch , Ivan Delalande , Priyaranjan Jha , Menglong Dong , netdev , "open list:HARDWARE RANDOM NUMBER GENERATOR CORE" , "open list:KERNEL SELFTEST FRAMEWORK" , LKML Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org On Wed, Aug 25, 2021 at 1:08 AM Herbert Xu wrote: > > On Tue, Aug 24, 2021 at 04:34:58PM -0700, Eric Dumazet wrote: > > > > On 8/24/21 2:34 PM, Leonard Crestez wrote: > > > The crypto_shash API is used in order to compute packet signatures. The > > > API comes with several unfortunate limitations: > > > > > > 1) Allocating a crypto_shash can sleep and must be done in user context. > > > 2) Packet signatures must be computed in softirq context > > > 3) Packet signatures use dynamic "traffic keys" which require exclusive > > > access to crypto_shash for crypto_setkey. > > > > > > The solution is to allocate one crypto_shash for each possible cpu for > > > each algorithm at setsockopt time. The per-cpu tfm is then borrowed from > > > softirq context, signatures are computed and the tfm is returned. > > > > > > > I could not see the per-cpu stuff that you mention in the changelog. > > Perhaps it's time we moved the key information from the tfm into > the request structure for hashes? Or at least provide a way for > the key to be in the request structure in addition to the tfm as > the tfm model still works for IPsec. Ard/Eric, what do you think > about that? What is the typical size of a ' tfm' and associated data ? per-cpu tfm might still make sense, if we had proper NUMA affinities. AFAIK, currently we can not provide a numa node to crypto allocations. So using construct like this ends up allocating all data on one single NUMA node for_each_possible_cpu(cpu) { tfm = crypto_alloc_shash(algo->name, 0, 0); if (IS_ERR(tfm)) return PTR_ERR(tfm); p_tfm = per_cpu_ptr(algo->tfms, cpu); *p_tfm = tfm; }