From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id B0D04E7716F for ; Wed, 4 Dec 2024 22:55:44 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2006F6B008C; Wed, 4 Dec 2024 17:55:44 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 1B10A6B0092; Wed, 4 Dec 2024 17:55:44 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 078536B0093; Wed, 4 Dec 2024 17:55:44 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id DA2706B008C for ; Wed, 4 Dec 2024 17:55:43 -0500 (EST) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 94F961211B2 for ; Wed, 4 Dec 2024 22:55:43 +0000 (UTC) X-FDA: 82858784946.24.C709D16 Received: from mail-qv1-f54.google.com (mail-qv1-f54.google.com [209.85.219.54]) by imf03.hostedemail.com (Postfix) with ESMTP id 04D0220013 for ; Wed, 4 Dec 2024 22:55:34 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=dyZ5n51l; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf03.hostedemail.com: domain of yosryahmed@google.com designates 209.85.219.54 as permitted sender) smtp.mailfrom=yosryahmed@google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1733352934; a=rsa-sha256; cv=none; b=pkr2ZJD+5oWH6aHDpTPZwSlGFIdv5Xsy4uozDwlpzhGAcgdHgIV8DFJCnmQAFUKVdAFq8H TK3jY1qn7uRjLE8sPt2gpSuF165OA1h8rmOpNLZTUdNWzXX1UzfXIk4aVil7jOvDj8qd9g wuxxLcgIzqtYZ5dRyIN/OVH3JS91k0E= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=dyZ5n51l; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf03.hostedemail.com: domain of yosryahmed@google.com designates 209.85.219.54 as permitted sender) smtp.mailfrom=yosryahmed@google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1733352934; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=h8PrHsy7yaVJu8qpxJGFoxRiq8VZTbuR/cuaMqNGRsc=; b=Bi22vY+HyTNnZ1CSQwn5SL7L0O4UWVqoVCCQySGwLNAlXnbfki13kPFM52kXGh/Nvi4TI+ 3NrQjB5/itLkxXlp+QUlab1ihcPickSY67wk8rFXkUHbsNW0P3zyqzsqV2lH4Pk0K6d1ss py59XdCjw7LrrbWooMCPqUM5RzrQD1o= Received: by mail-qv1-f54.google.com with SMTP id 6a1803df08f44-6d8843c44cfso3942156d6.3 for ; Wed, 04 Dec 2024 14:55:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1733352941; x=1733957741; darn=kvack.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=h8PrHsy7yaVJu8qpxJGFoxRiq8VZTbuR/cuaMqNGRsc=; b=dyZ5n51l4OrCYUOXoxObC5GsoECkxGIGXfoCLBrmDVJQi34raBnEltY/LFBaEyyWtD bv2HMJlnlkRdB+9DCQE8KqaNyr/N1UIKF/pzxAaZFTwP96f77Bs3gR/CeA3ZVKrVzj66 QKR/74M4Ea0VMa0f/NHUSaH2vI5xFmP678YWlzzypkc82kwgGKgAe+1SbELtOI9H7FNk fh1q0x2f/EzGqZuFwe90Piiry+xO2d5m+t0hemUKI9jkNeaH8lFc1hbM2Vr2MRqNE6Ns JKT8DR3Os6sjDAXclp0m+9FAZr5h4Dm38B1INf5U6F5XaYA7Bc/aeK1yhMz7qgqA6QMD APkw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733352941; x=1733957741; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=h8PrHsy7yaVJu8qpxJGFoxRiq8VZTbuR/cuaMqNGRsc=; b=HZFl9/K2OYzIFSaetrvy7u9gP3YHsGn32J4Mrx3UyI7SrV+AgW48Pu1ZeLelQErN9Q KHBCYSR4HkRy70xv0r8cgJq2aAks276clfkMm4BnaQa7Lzpr6AzHPL/ig64gZeOozU3t QhX5RQqf/7Kz+fuQhI8QzBbPaPgR3E5/y/Ej6BsC2hIsf2WOHWYYmx1LGg0XFcPMbEb6 rnEqiQFx/hERZYZ6lj9BTDHmX2ua2lx2Swqis7nhmtNsg3ZF9BserIr/eeFI/GPc5vMH 1EXqToCvSobHjsCov0sdVjPZdE0epXqJS2OBfz1bEoTRGCLeXxK81zP93oEVY26Lb2TI IhIw== X-Forwarded-Encrypted: i=1; AJvYcCW96lNDeYI5FQtUTJwacEjcIOaSGal8ynoNCwvycZ8RRjzJTPnzO1NGNkthc3v/2VfOGYUFh/Uivg==@kvack.org X-Gm-Message-State: AOJu0Yyeq6k5rP3HBuKKkHHuvIBLh10KN+YtX/qt/YnaZEUSvAWxy1/S YtulT0s2jlNJIvp/tPs5jYysmHoZ2lz31SRkEddzsU2GU/zpJM868Q3GWE5GnHP3324S3cvSq43 NgVv8PRl5hvO7DxtDlirqDGoh4tRZBjegj6Rp X-Gm-Gg: ASbGncvoZdX5SDodbI3euNJuQ5POJzNYPvIhYssm4uVz5mbwijdS/JTW27goUAl6g2Y ZFCfENLvt/tTj/4R2wdOWlupb2zFe X-Google-Smtp-Source: AGHT+IFHMvdGJnDSH/n2cmR1dw1uCaoTdi4uTiVuOPJ7MAJXp/aLmZCowxUTvoBD+ogJikqJuWi8/DrgUYgZfKbTBzw= X-Received: by 2002:ad4:5f8a:0:b0:6d4:1662:348c with SMTP id 6a1803df08f44-6d8b73067b5mr123350746d6.17.1733352940619; Wed, 04 Dec 2024 14:55:40 -0800 (PST) MIME-Version: 1.0 References: <20241123070127.332773-1-kanchana.p.sridhar@intel.com> <20241123070127.332773-10-kanchana.p.sridhar@intel.com> In-Reply-To: From: Yosry Ahmed Date: Wed, 4 Dec 2024 14:55:03 -0800 Message-ID: Subject: Re: [PATCH v4 09/10] mm: zswap: Allocate pool batching resources if the crypto_alg supports batching. To: "Sridhar, Kanchana P" Cc: Herbert Xu , Nhat Pham , "linux-kernel@vger.kernel.org" , "linux-mm@kvack.org" , "hannes@cmpxchg.org" , "chengming.zhou@linux.dev" , "usamaarif642@gmail.com" , "ryan.roberts@arm.com" , "ying.huang@intel.com" , "21cnbao@gmail.com" <21cnbao@gmail.com>, "akpm@linux-foundation.org" , "linux-crypto@vger.kernel.org" , "davem@davemloft.net" , "clabbe@baylibre.com" , "ardb@kernel.org" , "ebiggers@google.com" , "surenb@google.com" , "Accardi, Kristen C" , "Feghali, Wajdi K" , "Gopal, Vinodh" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Rspam-User: X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 04D0220013 X-Stat-Signature: e8ectifgih3d9tkds9zfwtr8quo9rzzz X-HE-Tag: 1733352934-280020 X-HE-Meta: U2FsdGVkX19YBXifa66INd+XVjGK6j/bK/4/igjUl/FcT7wGjUIz0JySQ5L0AKFG0C9ma1U3ETt5vligk8veE0QmfbmNmMmsu5teJ0Nv0ySdqIBYi5bKVZ9qtlpAFyh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K6bNJ+Pl+wzn/O3Y+Wvrfp8TaiTmrJbl8R933RuSJxgwl1nxFFJfl+N3PkdyXu7pJCvK9EOSHJC9E9nS3NFHzxUpz0J23BLL9QrebYD3n7l8SQb1qMrnfMVTzgJ+aBove0UzimeoJ92DaBxpuPTAj4l4HZPaPNagBXx35ZTByWWNGEetxx7Y7vWSQ+p5xROqqokhze80lJU5/vm14r21Wv9OhsiVeJBPG1vZPDivwYlu9lvNC9+R+n2Jek8iFI9b0VfalqDwrMFvWnFmDv8tV4Y9itTGa9k7I7CB7sRYkPlxrOjDTcrEuFDqBDEhm9vy9OTSwdiLJgUE7vuBgs9bc9TgMRCSxFS4ApahZccjhYWCcLHUVqEAjUEURl7PkttaEseguipMMr4BQ+xUBx/+5/qvubwqnZTrkkDnzK22eNU43YmZsWsgC3xEsqKSpJvUFP6S8+HxbllrCOS10WJCp7JerPr3C8sbM7q96XC1SokEAafHDvr8bcQHKFSYPrKHIJjWlqAPZYI40a7HQfSgFSoTDhjtmKZmPk+Rw88qf3+qwmci/h3pjI4ZvAt+Kxc X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On Wed, Dec 4, 2024 at 2:49=E2=80=AFPM Sridhar, Kanchana P wrote: > > > > -----Original Message----- > > From: Yosry Ahmed > > Sent: Wednesday, December 4, 2024 2:36 PM > > To: Herbert Xu > > Cc: Sridhar, Kanchana P ; Nhat Pham > > ; linux-kernel@vger.kernel.org; linux-mm@kvack.org; > > hannes@cmpxchg.org; chengming.zhou@linux.dev; > > usamaarif642@gmail.com; ryan.roberts@arm.com; ying.huang@intel.com; > > 21cnbao@gmail.com; akpm@linux-foundation.org; linux- > > crypto@vger.kernel.org; davem@davemloft.net; clabbe@baylibre.com; > > ardb@kernel.org; ebiggers@google.com; surenb@google.com; Accardi, > > Kristen C ; Feghali, Wajdi K > > ; Gopal, Vinodh > > Subject: Re: [PATCH v4 09/10] mm: zswap: Allocate pool batching resourc= es if > > the crypto_alg supports batching. > > > > On Tue, Dec 3, 2024 at 5:42=E2=80=AFPM Herbert Xu > > wrote: > > > > > > On Tue, Dec 03, 2024 at 01:44:00PM -0800, Yosry Ahmed wrote: > > > > > > > > Does this mean that instead of zswap breaking down the folio into > > > > SWAP_CRYPTO_BATCH_SIZE -sized batches, we pass all the pages to the > > > > crypto layer and let it do the batching as it pleases? > > > > > > You provide as much (or little) as you're comfortable with. Just > > > treat the acomp API as one that can take as much as you want to > > > give it. > > > > In this case, it seems like the batch size is completely up to zswap, > > and not necessarily dependent on the compressor. That being said, > > Intel IAA will naturally prefer a batch size that maximizes the > > parallelization. > > > > How about this, we can define a fixed max batch size in zswap, to > > provide a hard limit on the number of buffers we preallocate (e.g. > > MAX_BATCH_SIZE). The compressors can provide zswap a hint with their > > desired batch size (e.g. 8 for Intel IAA). Then zswap can allocate > > min(MAX_BATCH_SIZE, compressor_batch_size). > > > > Assuming software compressors provide 1 for the batch size, if > > MAX_BATCH_SIZE is >=3D 8, Intel IAA gets the batching rate it wants, an= d > > software compressors get the same behavior as today. This abstracts > > the batch size needed by the compressor while making sure zswap does > > not preallocate a ridiculous amount of memory. > > > > Does this make sense to everyone or am I missing something? > > Thanks Yosry, this makes perfect sense. I can declare a default > CRYPTO_ACOMP_BATCH_SIZE=3D1, and a crypto API that zswap can > query, acomp_get_batch_size(struct crypto_acomp *tfm) that > can call a crypto algorithm interface if it is registered, for e.g. > crypto_get_batch_size() that IAA can register to return the max > batch size for IAA. If a compressor does not provide an > implementation for crypto_get_batch_size(), we would return > CRYPTO_ACOMP_BATCH_SIZE. This way, nothing specific will > need to be done for the software compressors for now. Unless > they define a specific batch_size via say, another interface, > crypto_set_batch_size(), the acomp_get_batch_size() will return 1. I still think zswap should define its own maximum to avoid having the compressors have complete control over the amount of memory that zswap preallocates. For the acomp stuff I will let Herbert decide what he thinks is best. >From the zswap side, I just want: - A hard limit on the amount of memory we preallocate. - No change for the software compressors. > > Thanks, > Kanchana