Received: by 2002:a05:6500:2018:b0:1fb:9675:f89d with SMTP id t24csp256241lqh; Thu, 30 May 2024 23:34:57 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWLziPruHUVY2pKP9vqeFzcpvfcL25rA64Hy1zL7BM92EdIzJfTSjLvgfPHnK9ugXyNnY9yBj9hkt/RUqWOiMTOiOfUkXkSTYiuNjKFDg== X-Google-Smtp-Source: AGHT+IE8UHrkew0yiIPZKoGvrW9gO6WWy07rdrDWZm/LXy7l7Bz+L+08bS5J66McnJyuGGRhC2YB X-Received: by 2002:a50:bb62:0:b0:57a:30e6:86b4 with SMTP id 4fb4d7f45d1cf-57a363e0247mr645688a12.24.1717137296831; Thu, 30 May 2024 23:34:56 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717137296; cv=pass; d=google.com; s=arc-20160816; b=RVfk5zYQfJKt75eUvWdiyS2bZTQm6Sr7dGd49iVQjPMHo0LyUIWUNC+G01rbp9MekM nYyHB5mYlDX3cojrFeAy0GNUq9vXoS+FZIzwXBbIMwswZPi2hLMzgoGeWpoQdkg88gXt XefoTcuCx22TfS7894prBGF3rmF+sS/FcRcNr4wHXNIz8HXUB93h63Ypw/1Ks+SnA8MF 66qEsvOuhSUeISR/bcfitPpE4jqP/rBWagcgcluzh8lyaoo9tPmMyfKIDvhKDoH3nMYL lMiCtu36d2tncU55JMK9gVXBAeQ2WI9GXLpra0mYoprWJm7pcUGUymI43P/UkUd5mUrA hKPg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=GEbjNd2SwxM+bzXhuQx2b6GIzGtjhTQDBWBT7w2BeSY=; fh=7h10UUybZVzqtuQRgFLirrXdXyUJu6au1lspDNLcTO0=; b=sb9ySJ6L7H2Aqfx3FhEgJ2GqXpsxd3uLXOsDCRjxm3VQU0F+kaP8p4s9wHMKeG6lHf OJ80K6rUh27BdvbC8MH4GRhZxdBRt5DT+GLnEY2kH/JsCY8vxsLP5A9VuZLJxzPMcb8e pgGRuMVpRqksZnvpDtzVaFVYvC0dY48IxJ+A5uvkpZsO3JR2X9NQ5jXtkxRttzpBgtD+ rVxBHySqVEP3IxHk3Wh+0hnaFQBo98twdvOCqDgsp9aE8fWy5MyZ0801dzqEsOqrh/ug E+mjChDoRItmcaYOFiMbDjLb5BRNB4C9U06pR5Ni93xqjM75VjKS40R2c858VhkPmBCI r8yA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=KCwirEhq; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-crypto+bounces-4581-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-crypto+bounces-4581-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id 4fb4d7f45d1cf-57a31b817e9si611863a12.16.2024.05.30.23.34.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 May 2024 23:34:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto+bounces-4581-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=KCwirEhq; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-crypto+bounces-4581-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-crypto+bounces-4581-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 832741F2418C for ; Fri, 31 May 2024 06:34:56 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BABED7FBA0; Fri, 31 May 2024 06:34:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="KCwirEhq" X-Original-To: linux-crypto@vger.kernel.org Received: from mail-pf1-f179.google.com (mail-pf1-f179.google.com [209.85.210.179]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 16A504CDF9 for ; Fri, 31 May 2024 06:34:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.179 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717137291; cv=none; b=iuCntAKAJRRLhs/mhy5P8JyL2gVlM5qPeYJDJaWMf68qxNBLGS3eSIKNHbIOIbqBjNETRgo24K8v95JWTAJ+cb8KfVkW+hfO6mQI5onjOCw628jNUX0JKHtGGFFqALQESGEjqgZ27PfyIHMallYqlTlLnocHuRn8tu9RrEfbh84= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717137291; c=relaxed/simple; bh=8S+CcgH6MFMNQiCnuud0916L3xkZ0U132fyJ/b06AZ0=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=liHDKuBf+Urt0G1dleXtJleFce6aDcdEymSmwRz6EFFnhwwk5AGJRZDjbFSocMOhMf/pw1igkgs4NLYwVHH1SEvMZUHtJj7VC018QINOlPlm98qNwVyf7hl5bn0w7KrRMY8sSZ7jc9RXtuxxaMkJ/tjeO2+nwZ/Gto1rxTbT0yw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=KCwirEhq; arc=none smtp.client-ip=209.85.210.179 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Received: by mail-pf1-f179.google.com with SMTP id d2e1a72fcca58-70244776719so370015b3a.2 for ; Thu, 30 May 2024 23:34:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1717137289; x=1717742089; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=GEbjNd2SwxM+bzXhuQx2b6GIzGtjhTQDBWBT7w2BeSY=; b=KCwirEhqCXFmbcDqaaujsUMfQin/kEucDB0WggIuMusQ3nFIw1SC/tHWD4hE6/qkIg 7Zyy4f1uwJytkxy001zek9iRVPy2eocf9o9sp8xjsc8imOho6mY0EOJeJfYEP8Ox0T9d LXONtMLgd5k3Z2rWvZBlfQKbTdss2zwG3xyh8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717137289; x=1717742089; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=GEbjNd2SwxM+bzXhuQx2b6GIzGtjhTQDBWBT7w2BeSY=; b=wuJVwp8ugMIwjEQtMSEqAgmjOctMlSBLUwKMnrTU6plV+oQeoXzHGUyaOwbNLx3opF 8OEF3LuD9znjb20aBrrzlKj4kBF9Mtag/mnEDQp9eV95kH86Iuslb3dnjRVtPSB24HZ+ ala6S5CV9SDgXZegok4KHb/A6OAcOIdXz5shkSi9+gyTPkGt9TeR1D3/mZ72jBfmww4J 5gOA8FnoRs4DhsPgPcoA/eB++7osxHbZowuzK3271wqN6S1VDw7IWYrhT29/ZGFNjk37 cylECDe9zOp5+Qnh6YYmVuseLm970qFaLHiwXf5rGqw35uY/kmep/99PedK1POYMwGWZ oa5w== X-Gm-Message-State: AOJu0Yy8UMWvr8833a71MWrraj/FgCS2fvaeC73IYD2oxRYUx52tH3fg cV0geUaePPbtzOQ31sXhMoWCJtVKxZMEdrPI+oi7UGv1oQCR8+qJV59qN/ZxE8w373wLURRNSCE = X-Received: by 2002:a05:6a00:1414:b0:6ed:d164:3433 with SMTP id d2e1a72fcca58-702477f9d07mr1034014b3a.14.1717137289158; Thu, 30 May 2024 23:34:49 -0700 (PDT) Received: from google.com ([2401:fa00:8f:203:b7f3:e557:e6df:620b]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-702423c7be4sm740902b3a.9.2024.05.30.23.34.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 May 2024 23:34:48 -0700 (PDT) Date: Fri, 31 May 2024 15:34:44 +0900 From: Sergey Senozhatsky To: Herbert Xu Cc: Linux Crypto Mailing List , Sergey Senozhatsky Subject: Re: [PATCH 1/3] crypto: scomp - Add setparam interface Message-ID: <20240531063444.GG8400@google.com> References: <84523e14722d0629b2ee9c8e7e3c04aa223c5fb5.1716202860.git.herbert@gondor.apana.org.au> <20240531054759.GE8400@google.com> Precedence: bulk X-Mailing-List: linux-crypto@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240531054759.GE8400@google.com> On (24/05/31 14:47), Sergey Senozhatsky wrote: > On (24/05/20 19:04), Herbert Xu wrote: > [..] > > +int crypto_scomp_setparam(struct crypto_scomp *tfm, const u8 *param, > > + unsigned int len) > > +{ > > + struct scomp_alg *scomp = crypto_scomp_alg(tfm); > > + int err; > > + > > + err = scomp->setparam(tfm, param, len); > > + if (unlikely(err)) { > > + scomp_set_need_param(tfm, scomp); > > + return err; > > + } > > + > > + crypto_scomp_clear_flags(tfm, CRYPTO_TFM_NEED_KEY); > > + return 0; > > +} > > Is the idea here that each compression driver will have its own structure > for params? > > In other words, something like this? > > static int setup_tfm(...) > { > ... > this_cpu->tfm = crypto_alloc_comp(name, 0, 0); > > if (!strcmp(name, "zstd")) { > struct crypto_comp_param_zstd param; > > param.dict = ... > param.cleve = ... > > crypto_scomp_setparam(tfm, ¶m, sizeof(param)); > } > > if (!strcmp(name, "lz4")) { > struct crupto_comp_param_lz4 param; > ... > } > > if (!strcmp(name, "lzo")) { > struct crupto_comp_param_lzo param; > ... > } > ... > } > > Or should it be "struct crypto_comp_params param"? So passing "raw" algorithm parameters to crypto_scomp_setparam(tfm) can be suboptimal, depending on the compression driver. For instance, for zstd (what is currently done in zram [1]) we pre-process "raw" parameters: parse dictionary in order to get zstd_cdict and zstd_ddict which are then shared by all tfm-s (as they access C/D dictionaries in read-only mode). For zram/zswap doing this per-tfm would result in extra per-CPU zstd_cdict/zstd_ddict allocations, which is a significant overhead. Does this sound like adding two more callbacks to drivers (e.g. parseparam/freeparam)? [1] https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/tree/drivers/block/zram/backend_zstd.c?h=next-20240529