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 6B076C4332F for ; Thu, 14 Dec 2023 20:29:37 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 716548D00E7; Thu, 14 Dec 2023 15:29:36 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 652FA8D00C7; Thu, 14 Dec 2023 15:29:36 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4A57D8D00E7; Thu, 14 Dec 2023 15:29:36 -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 2D2758D00C7 for ; Thu, 14 Dec 2023 15:29:36 -0500 (EST) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 09CC31603C1 for ; Thu, 14 Dec 2023 20:29:36 +0000 (UTC) X-FDA: 81566564352.10.5A2FFDB Received: from mail-io1-f50.google.com (mail-io1-f50.google.com [209.85.166.50]) by imf11.hostedemail.com (Postfix) with ESMTP id 3BF174000B for ; Thu, 14 Dec 2023 20:29:33 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b="fc/YbPAF"; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf11.hostedemail.com: domain of nphamcs@gmail.com designates 209.85.166.50 as permitted sender) smtp.mailfrom=nphamcs@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1702585773; 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=2zBgjjgr8D/SHxPTnKZMl5g8ELyqfBBSI/orkqxON0Q=; b=C6dhbX/SJ8g1mAUYeTGYldu7aOF92cjoI+fNwRQdpaZqCuYB9DLqjjkePrmZX89lEEnlXT FcpAB7xHXkr0KMib7JmLeOb+3GoOFv5C8nwJQwQPKZOziBVwBxOlFnA02dBcd8hsrRqfuB zVQDDK/CS7zlEVNP29ndFuArRzBEo0Q= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b="fc/YbPAF"; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf11.hostedemail.com: domain of nphamcs@gmail.com designates 209.85.166.50 as permitted sender) smtp.mailfrom=nphamcs@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1702585773; a=rsa-sha256; cv=none; b=oKWcPuO+uC0O78FTbNOl5hda2G9M8M2lkwAMDgxfOfnUi7DlrH4A6LTKD4E63L3yG1Huyl di3DWi0ERsNB2wK13JLxpcDZtL9DtTOukhjstsYqcXK9eqkQTCm9BcYtaczxrPhzPJkYwa 8yHU1gICdstRs6joetVhqy24RQtZIas= Received: by mail-io1-f50.google.com with SMTP id ca18e2360f4ac-7b6fe5d67d4so321399139f.3 for ; Thu, 14 Dec 2023 12:29:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702585772; x=1703190572; 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=2zBgjjgr8D/SHxPTnKZMl5g8ELyqfBBSI/orkqxON0Q=; b=fc/YbPAFzlx/1HATRFU5LK7zDPMKsAW6CWSr1WsGUJbq5oFgA5uMySccvam2td72jx r0Ff+1n8qq+06ziEFw/JDD2NpYnftPB13LEgorXIwrn1NW/Jbgr/tz2y3We8rk6ocJWz +i/0EG0/b+MeIKA0xfezAdCNugRu6Nfa62JLud9JNbo7Od9p4PH4JiO8uaea1SmY14EN JT4D/xuI9BI6mMnAjumDzE+Tgp7zzuVm6X2yaXQP0wKk76ueJXoo96RxOXuxgnrIo1xj mJp9ND0YXGVOKMQ3XGdSeX4OucgdIS66Uz3nrRXPtpYxU5aVINyuMRsDexbVA/qnIOCc a6/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702585772; x=1703190572; 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=2zBgjjgr8D/SHxPTnKZMl5g8ELyqfBBSI/orkqxON0Q=; b=WOXAIwwSX6MJpIXuGBfUbOS5FBRzeBhxnYpGtw3n2dKP9OdsFsIj7nzc0SP9wwSUlK h9LfH2KIeqBxZ3yuwfxhTUrRJPjYqlM0AbcGEuZFSvLABhGtTeZkOLHojKBsohy9zJYC 91/4FYI80JIXy7nrSMXQ9Ysddg94TLlSwEGhQ6HEzvYvDoQCfxHookYWu+ZPZd3Y481L SFhEiezqBiNXrOk1E/+Cfo5tnrSDXHlK3mcRNZly6N5BUqXOkeXEpta1BFyvH1eag8+E 0PY+JwvR5sgWffngkV99/k50LCBJ96oLjpglOVDQ7Yuvedl/+JsZc6AoekTZO7D/qnXG PMDg== X-Gm-Message-State: AOJu0YwoC+YZclunbsSHz5joxEPpaop0/oEf3A7L9IJ+kz6Iat+SzMZY OY3Ypzr/WfUiN2Cv1TZWalRilknh+CVR2qavgNE= X-Google-Smtp-Source: AGHT+IEqbkpIDFaiZ9sABqn7gCj16ftZYkx6C73e7dJ1T8eQXZYsMrospP9F8WaeqyBNAwKXm8Iu811KDPv6ovjH/7A= X-Received: by 2002:a6b:7117:0:b0:7b4:28f8:3ba1 with SMTP id q23-20020a6b7117000000b007b428f83ba1mr10071425iog.36.1702585772146; Thu, 14 Dec 2023 12:29:32 -0800 (PST) MIME-Version: 1.0 References: <20231213-zswap-dstmem-v1-0-896763369d04@bytedance.com> <20231213-zswap-dstmem-v1-2-896763369d04@bytedance.com> <7a8c77b0-c78c-427d-9545-2b328c7dc727@bytedance.com> In-Reply-To: From: Nhat Pham Date: Thu, 14 Dec 2023 12:29:21 -0800 Message-ID: Subject: Re: [PATCH 2/5] mm/zswap: change dstmem size to one page To: Yosry Ahmed Cc: Chengming Zhou , Andrew Morton , Chris Li , Johannes Weiner , Seth Jennings , Dan Streetman , Vitaly Wool , linux-kernel@vger.kernel.org, linux-mm@kvack.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 3BF174000B X-Stat-Signature: 66xwkf7osjuohrywsdznuus46cf8hipd X-Rspam-User: X-HE-Tag: 1702585773-700230 X-HE-Meta: U2FsdGVkX18wLFhtFkBnKkO3oowaCv4Q9qNPD+gLJem9wEqIUPSTiDRiKz0M8mmLs0EikmZh+dZRPiNQpJFYpYZO1SXdSRQAnzeOp6RCDLmROh5zNOOBDcwPOzFU2yYM7oqggiCB3Vj1GMLtGtonEcOlZrDESagEY20XqBzp6JIPPsHSFbQOH5/cXw41CleJJpIuisaxZk1kw7dQagU16vwj+fVu5Q2zvmrLecZSZSfGVJ3igu5EkuZW9rKZ6ITpeUYxjHvVaKBcQ/pTYgFqy0uv7RafZtFzn4kVIh+zQqQF4jFWmx+7vEq4I9B3LxRfiTqceFSXoeIkoXecJlCR3NouBAvXmy01pZ6yYl84M3AVfJtWSaoDZEkA7kgLSUdy9cSkrogT66UlFr5bdv6c5BCPDcxv8zveRWSpMtMFBasbxscRA7BX2gnx/U1TSlq1Nmmxa0GYn7gxe+67k2F98FvZz+bBsS724YJD/rRdctiHVx22OdC36DIub6lRSdL5LzHfU2tewNSx58YAt7gKqTTCjlSR3ll11P0lqhS8QWD9AdVFtDIg0khBvNxXMCyMtkPK+h+jmfcZT7YT4UmtzNB2g3NTOl9MlCcNSFCmbl6U9wlAVv2ZvDA5yxqhsoowa/0E2n9EPOc9TpADPbgXV2p/RDf7vsGUnO7J7XRpOgjgzws4cg1LBEBDfAG4yy6nliqe8BS6Ljtw7BRxSjKtbcdyNQBfONZifqpAvkvpPAn2SfwcSX/UjYYfx/2YKyrgZsxdsGcwTedwuG43Yq7wKdyREJLrHbx0m+g4Un3oqjzqaCHy1eQiIeDqmGlzQlMmzl/BX4RlD89fgpafRlNUWCwnY46PpezdgSxTWQblelors58PZzi7Eu7o25/A0P5J753U4esDk9e3i20XjmuO9ql0udn9jzjCXCmCChZYGWPwKz3/MoA+jPG0tpOe/lMluyAtfn/tc+HtMjcKXR8 3ylLkq14 lEePuWB1yPSrQVCvMr3UghyHc28HGpP5zSoLldT5AKnupYINb1kL2qi4xnnGsti+eKc+xNJC6zKsFp5Jd/lVSCTQRJxKCgqJX1BTxWzrPzBznSJL3Ocblp0SzyG6LAhJ0VOHnlgBUQMhYaIEQx70UKIlGD5Z3XXyA8MZ+cAlvXPcfoniD3JsKgvvzHi8TPtTkMRu9vRvkipyFgDE0QA2XserVX6UJ3sg5wXDsHlvD7TUfGbR4DUBmCgK2KFt9yRCs9BV0Y5Og6BzBMrdKf8ax5Rpp1TbAGBznkX3+0LzJNshrrk4zPkhkrFpeTy8RFoSL7t3fuXuK19ygf1SvAederF5YMEnZwt6Oos6xCeUfQVnxlPdsYx/BQektxQ== X-Bogosity: Ham, tests=bogofilter, spamicity=0.002340, 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 Thu, Dec 14, 2023 at 10:30=E2=80=AFAM Yosry Ahmed wrote: > > On Thu, Dec 14, 2023 at 5:57=E2=80=AFAM Chengming Zhou > wrote: > > > > On 2023/12/14 21:37, Yosry Ahmed wrote: > > > On Thu, Dec 14, 2023 at 5:33=E2=80=AFAM Chengming Zhou > > > wrote: > > >> > > >> On 2023/12/14 08:18, Nhat Pham wrote: > > >>> On Wed, Dec 13, 2023 at 3:34=E2=80=AFPM Yosry Ahmed wrote: > > >>>> > > >>>> On Tue, Dec 12, 2023 at 8:18=E2=80=AFPM Chengming Zhou > > >>>> wrote: > > >>>>> > > >>>>> Change the dstmem size from 2 * PAGE_SIZE to only one page since > > >>>>> we only need at most one page when compress, and the "dlen" is al= so > > >>>>> PAGE_SIZE in acomp_request_set_params(). If the output size > PAG= E_SIZE > > >>>>> we don't wanna store the output in zswap anyway. > > >>>>> > > >>>>> So change it to one page, and delete the stale comment. > > >>>> > > >>>> I couldn't find the history of why we needed 2 * PAGE_SIZE, it wou= ld > > >>>> be nice if someone has the context, perhaps one of the maintainers= . > > >>> > > >>> It'd be very nice indeed. > > >>> > > >>>> > > >>>> One potential reason is that we used to store a zswap header > > >>>> containing the swap entry in the compressed page for writeback > > >>>> purposes, but we don't do that anymore. Maybe we wanted to be able= to > > >>>> handle the case where an incompressible page would exceed PAGE_SIZ= E > > >>>> because of that? > > >>> > > >>> It could be hmm. I didn't study the old zswap architecture too much= , > > >>> but it has been 2 * PAGE_SIZE since the time zswap was first merged > > >>> last I checked. > > >>> I'm not 100% comfortable ACK-ing the undoing of something that look= s > > >>> so intentional, but FTR, AFAICT, this looks correct to me. > > >> > > >> Right, there is no any history about the reason why we needed 2 page= s. > > >> But obviously only one page is needed from the current code and no a= ny > > >> problem found in the kernel build stress testing. > > > > > > Could you try manually stressing the compression with data that > > > doesn't compress at all (i.e. dlen =3D=3D PAGE_SIZE)? I want to make = sure > > > that this case is specifically handled. I think using data from > > > /dev/random will do that but please double check that dlen =3D=3D > > > PAGE_SIZE. FWIW, zsmalloc supports the storing of pages that are PAGE_SIZE in length, so a use case is probably there (although it could be for ZRAM). We tested it during the storing-uncompressed-pages patch. Architecturally, it seems that zswap just lets the backend allocator handle the rejection of compressed objects that are too large, and the compressor to reject pages that are too poorly compressed. > > > > I just did the same kernel build testing, indeed there are a few cases > > that output dlen =3D=3D PAGE_SIZE. > > > > bpftrace -e 'k:zpool_malloc {@[(uint32)arg1=3D=3D4096]=3Dcount()}' > > > > @[1]: 2 > > @[0]: 12011430 > > That's very useful information, thanks for testing that. Please > include this in the commit log. Please also include the fact that we > used to store a zswap header with the compressed page but don't do > that anymore, which *may* be the reason why this was needed back then. > > I still want someone who knows the history to Ack this, but FWIW it > looks correct to me, so low-key: > Reviewed-by: Yosry Ahmed Anyway: Reviewed-by: Nhat Pham