Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp3124808pxb; Tue, 24 Aug 2021 16:03:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw6tR6T3m6QpK+UJLSnulm+K+IoQJczWD51Jm5x6kmwcGYZlGFK6M1ZuK+ve9Pjqn8VmZMN X-Received: by 2002:a5d:9bcf:: with SMTP id d15mr32927883ion.88.1629846182072; Tue, 24 Aug 2021 16:03:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629846182; cv=none; d=google.com; s=arc-20160816; b=HP5wK7aMuKRibre/Qb7yXMmvN4kqCDIflpt5V7/bgJoNrpK3RJRaTBwCstDTWrQEov X5VV/EX/HbniICtDbyTiCOrAByIz7oqlN+s+yw/dNDLqXAhPdkUcDZIwNXDofn9yuhnx pk/SQE5tS1vioNvHlKIocZCPOjcBULMPq/giHtD7Btssc2bXHa6/WsE3VdAIuJVL2OjA 18V3V6TOh3FrOYmhJYbW8hwgTD2L0zjbG+eK56AZEgj0e9inZJhx/IBmt5aFKEJnTiG0 /ri2QJkHBDHRO7nkBrkpmeJM/CgZc95vMmPpzw0U1L9OCSXqejfuyb4zQSI432Jn6ouF LrEA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=oRutMmfmW+MGy1iLNBbS8khgGdiC/2DVGIuLCvRzIxc=; b=OuRt2smMu4dSgM19JafTI+w5r+AK7k+HqM8S2d+/eHWCU7IsLE9P82fBD6bQfeLLz5 zZnpMvzWAs8QhQIdds79XYhkEtj8C2efLEabahNQdx5/w1u6Mi5T17UkZNfs8AP7EnfH KaMQImWQoYpzblyqS3V8r3gT3Q6CdxXOEnDRq9hIAaWBR04SPpLqXXCRWkUPJ3j4qhAC Y8BhihHHNxBhSHQmQN3hAsBTxX93NCXagzp96iHh5vrKLla5gcj6HaKdGKWo16bPCWXU zuokfQCabWUwVagolUkp8aZuRmvuHy07LYlhh+A5uXrDkFwVgsp3RCt+/Ilsa29kSc3A 2uzg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=D12KbHKD; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ay15si2099989iob.92.2021.08.24.16.02.39; Tue, 24 Aug 2021 16:03:02 -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=@gmail.com header.s=20161025 header.b=D12KbHKD; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231767AbhHXXDV (ORCPT + 99 others); Tue, 24 Aug 2021 19:03:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55366 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231444AbhHXXDU (ORCPT ); Tue, 24 Aug 2021 19:03:20 -0400 Received: from mail-pj1-x1031.google.com (mail-pj1-x1031.google.com [IPv6:2607:f8b0:4864:20::1031]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1D75BC061757; Tue, 24 Aug 2021 16:02:36 -0700 (PDT) Received: by mail-pj1-x1031.google.com with SMTP id n13-20020a17090a4e0d00b0017946980d8dso2851963pjh.5; Tue, 24 Aug 2021 16:02:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=oRutMmfmW+MGy1iLNBbS8khgGdiC/2DVGIuLCvRzIxc=; b=D12KbHKDX2FItHHdsbeVU0omV3ybH8+TUrbldLtROeNhVf75RjAD6kgMQS6JJ0N78/ rIDDzdPWPMwD0f7rdL321JW1R3vLftlZTC9ULJYImUqc3fQrXizDoFchG7b07MJcSfWm 0Pkp5qCreURDK6hoRzhzZV1RZ+fzYi0ivF+UCNqfIPlXNJmNTsK7y+3fHoe+zYooRXv7 sPi/20yLCoYYe1LxbJokFyQHV2SffHx4Qj2AMp/XJ3pUV3gpQy1txUoq0JUBWzmk6ZJZ 8TOUshr8LqRb00pL3UUsEfwTRinlHg95pZD3bEM7xIyn6n72r4Ll10Tl7umXvukF9hsh chJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=oRutMmfmW+MGy1iLNBbS8khgGdiC/2DVGIuLCvRzIxc=; b=G4oQTnY4JpX3aFED1RmzWNNr4b5ixr1P6Mj86SRuIYTwuGvysdN3I/cQ5r3tVUtB+P K9zvYoNcZNGh51PCY2F/gOE7PnnSBE2iXoZp+8k9JgUJEqqqszJJHuEJ65nPqJAgmhvw IPH5WaZncGa0f+NtQJ5ZR456BnEF5coybJhySG/FG6Ch8udsUSftfUznxpoHRCiwuYEB ntfhAVPI1RcJXl0BpHJDuk5L9vWjL+Y4rkBgPhNKcLOMMk3B1YsUU1cdoTr4gRBja7a+ 7WCQdewZ+EyeMDvkXaDw4C7siay/EAQzW2SrkIiQK9TwTa0OwJ4XRJ7FQKkl3Z5kBBdY jMKA== X-Gm-Message-State: AOAM530xYZeWH/Q/ptMejpO2MaldYtvjkgp3+4dY4VEQxjCXjVRRGoY8 rS1A/FQG+lLZOFuif+A8R5VSM9AKsLk= X-Received: by 2002:a17:90b:4b0b:: with SMTP id lx11mr7085430pjb.70.1629846155436; Tue, 24 Aug 2021 16:02:35 -0700 (PDT) Received: from [192.168.86.235] (c-73-241-150-58.hsd1.ca.comcast.net. [73.241.150.58]) by smtp.gmail.com with ESMTPSA id y3sm24128749pgc.67.2021.08.24.16.02.33 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 24 Aug 2021 16:02:35 -0700 (PDT) Subject: Re: [RFCv3 05/15] tcp: authopt: Add crypto initialization To: Leonard Crestez , Dmitry Safonov <0x7f454c46@gmail.com>, David Ahern , Shuah Khan Cc: Eric Dumazet , "David S. Miller" , Herbert Xu , Kuniyuki Iwashima , Hideaki YOSHIFUJI , Jakub Kicinski , Yuchung Cheng , Francesco Ruggeri , Mat Martineau , Christoph Paasch , Ivan Delalande , Priyaranjan Jha , Menglong Dong , netdev@vger.kernel.org, linux-crypto@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org References: From: Eric Dumazet Message-ID: <72d126d8-1d44-de0c-fa1d-4362774ea3db@gmail.com> Date: Tue, 24 Aug 2021 16:02:32 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.12.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org 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. > > The pool for each algorithm is reference counted, initialized at > setsockopt time and released in tcp_authopt_key_info's rcu callback > > I don't know, why should we really care and try so hard to release the tfm per cpu ? I would simply allocate them at boot time. This would avoid the expensive refcounting (potential false sharing)