Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp3113710rwb; Fri, 20 Jan 2023 11:20:55 -0800 (PST) X-Google-Smtp-Source: AMrXdXsNV1MYD6Adxyos1CJzhQkHtE97NakJJZ8gXMFCrPkX/bhErALLS0JaTzvIuNhyCCmD2sIl X-Received: by 2002:a17:907:1c07:b0:86f:2819:2760 with SMTP id nc7-20020a1709071c0700b0086f28192760mr30190525ejc.41.1674242455401; Fri, 20 Jan 2023 11:20:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674242455; cv=none; d=google.com; s=arc-20160816; b=dk5sX5D9x5a542IjKbpnvq/37EXJ+u41pfQCc1+f/8O3ZMQKDSy70HwMeQ4e0EN+LF nqyh2Vuv1WyeNcQNkWsVb4NjlAhqOsZldYscEQcf6ceXOdwOjzVCreZsNWewDjOp7jwv OoEuzoOJnPB0/7zPUrnSPrDYoLAGNtG5DhPpPv2J48GpVRikRWvAtns6L21G8zEgSey4 cMhjA1CEphQYWKjVqEp2locIzCYqEp78/PEanEbgmJsc7/ScJW2IXgDF838DqAL9cNy9 a8mDWyGxx9SNH7IrVCk28VKsrRSyq60ElhzMsVQrHZ87C7GZqvKgznq7awTgNIQ6Emt5 RBdA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=4Q+aLB5M5/TtTEFhcMDlKLReVmNxD7MHhEY2/008DlU=; b=NOoPFYQy4ZEA1ZhDB2iJ32OIu5krwYk/9h7BgKngSYagOo60+C8DjEV/yvg82A0t5g Hhch/GbqCuvnFpsBVz3UGngNZo1v+IWsH5ukz+E/6ddHj+EkKQss9DhMRSqKe3wo07Hg ua8b7Nw2cG+Fd1eA4F0PmpQUvBtQcFtG0EtjonjDdylUm3JCxQkJ8qUvIF7S1QcDPFP2 JK14Alev8xEC1xI34zbiPMnqWd2O20Kmaz87tAIY1/Ic7t8G0hxDoZJB75E/Ii9azLz1 //Mfwcz7gH0AWxZZTz2jV92Ig1Ve+J/JfcJZjAxkc9J5gw2v19GbdE0jPSnO9IzGvIf+ 4VDg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@arista.com header.s=google header.b="E7t1/+Gn"; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=arista.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g8-20020a1709065d0800b00870e366aa27si19444450ejt.99.2023.01.20.11.20.24; Fri, 20 Jan 2023 11:20:55 -0800 (PST) Received-SPF: pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@arista.com header.s=google header.b="E7t1/+Gn"; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=arista.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229547AbjATTLl (ORCPT + 99 others); Fri, 20 Jan 2023 14:11:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46960 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230196AbjATTLk (ORCPT ); Fri, 20 Jan 2023 14:11:40 -0500 Received: from mail-wr1-x434.google.com (mail-wr1-x434.google.com [IPv6:2a00:1450:4864:20::434]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B18C58CE5A for ; Fri, 20 Jan 2023 11:11:37 -0800 (PST) Received: by mail-wr1-x434.google.com with SMTP id r9so5705227wrw.4 for ; Fri, 20 Jan 2023 11:11:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=arista.com; s=google; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=4Q+aLB5M5/TtTEFhcMDlKLReVmNxD7MHhEY2/008DlU=; b=E7t1/+Gnjzurlpr/Yn6EkM1klgtAtjeaa9iuyyqal5uLsl85A71nsHcV5EA8YN/c4q ct0GFvERpjIf6/1GmvemEYA2IhVLf2RKXGH+Yjlse7avRmqkJD7QTI5CtfaPPsv89hFD vA9/8Q9vqMkQgmvhzWh4vc8uCppxObhEpllCqzrCMOl2z04M4K7K/fa09Ec97/lMaP24 By/BW1aS2Meunp9N9i/Yctxn4l3KehCL1zD5DBQ8Maz0Hf65N2p1UX0h+q+1N8LdAikL i5HEU9sA9F2xfhaEObOuwpM7nCHcQo/OlFyWFs/9507UwOyn7Q9yV/aRkl4mGO5Kpb+u XuyQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=4Q+aLB5M5/TtTEFhcMDlKLReVmNxD7MHhEY2/008DlU=; b=7jFMMtbiZeow+urIg4lRT1R8qvT5UKQTjb1Y7Wdg3eYz1F5KXZ0kWoHBuLwH4DIrSQ ZpXURSpTMXcz7jXASkmWmS8oClQdFSxN3Ycm6t5xqlPB2Ry8CyMDOq2tbPDpwfOGzpiK 0qoO/hgt+Nxyav9xk/5nHGdI4TA9T9N0gt6k86BhdcjWPfuEqZE0yVk1ZdaZ8b/aFdj9 p0haZ5Y1HbQFeoIlO7clHca1HCdBT5NHnQPw8kL6ykZBg3Twpc2+rP0EcCKws4dpSrWV H0dkdWKFEJLF69FHsp1ueGO2J2O8hxFDicsaVCaBIDlDyEX2qfIsRF4VmW6Ho5Ljyls0 xx/Q== X-Gm-Message-State: AFqh2krMvhrtsnAmXNCG0juBFXfgsGLuI5XewOgrBzLRTBx/4DvONLcl EJlJf/zGiAo84m+xL/ZS6piRlg== X-Received: by 2002:adf:eacd:0:b0:2bb:f4bf:e763 with SMTP id o13-20020adfeacd000000b002bbf4bfe763mr23954624wrn.51.1674241896145; Fri, 20 Jan 2023 11:11:36 -0800 (PST) Received: from [10.83.37.24] ([217.173.96.166]) by smtp.gmail.com with ESMTPSA id g2-20020a5d4882000000b00286ad197346sm36404269wrq.70.2023.01.20.11.11.34 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 20 Jan 2023 11:11:35 -0800 (PST) Message-ID: <59125aa9-ad7c-93d7-1c48-63773fa5a82e@arista.com> Date: Fri, 20 Jan 2023 19:11:29 +0000 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.6.1 Subject: Re: [PATCH v4 1/4] crypto: Introduce crypto_pool Content-Language: en-US To: Herbert Xu Cc: linux-kernel@vger.kernel.org, David Ahern , Eric Dumazet , Jakub Kicinski , "David S. Miller" , Andy Lutomirski , Bob Gilligan , Dmitry Safonov <0x7f454c46@gmail.com>, Hideaki YOSHIFUJI , Leonard Crestez , Paolo Abeni , Salam Noureddine , netdev@vger.kernel.org, linux-crypto@vger.kernel.org References: <20230118214111.394416-1-dima@arista.com> <20230118214111.394416-2-dima@arista.com> <7c4138b4-e7dd-c9c5-11ac-68be90563cad@arista.com> From: Dmitry Safonov In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org On 1/20/23 08:49, Herbert Xu wrote: > On Thu, Jan 19, 2023 at 06:03:40PM +0000, Dmitry Safonov wrote: >> >> - net/ipv4/ah4.c could benefit from it: currently it allocates >> crypto_alloc_ahash() per every connection, allocating user-specified >> hash algorithm with ahash = crypto_alloc_ahash(x->aalg->alg_name, 0, 0), >> which are not shared between each other and it doesn't provide >> pre-allocated temporary/scratch buffer to calculate hash, so it uses >> GFP_ATOMIC in ah_alloc_tmp() >> - net/ipv6/ah6.c is copy'n'paste of the above >> - net/ipv4/esp4.c and net/ipv6/esp6.c are more-or-less also copy'n'paste >> with crypto_alloc_aead() instead of crypto_alloc_ahash() > > No they should definitely not switch over to the pool model. In > fact, these provide the correct model that you should follow. > > The correct model is to allocate the tfm on the control/slow path, > and allocate requests on the fast path (or reuse existing memory, > e.g., from the skb). Ok, I see. Do you think, it's worth having a pool of tfms? If not, I can proceed with TCP-AO patches set and implement pool of ahash tfms that will be used only for TCP-MD5 and TCP-AO, does that sound good to you? I see that ahash tfm allocation doesn't eat a lot of memory, rather little more than 100 bytes, but even so, I don't see why not saving some memory "for free", especially if one can have thousands of keys over different sockets. Where there's not much complexity in sharing tfms & scratch buffers? Thanks, Dmitry