Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp6250329rdb; Thu, 14 Dec 2023 12:29:47 -0800 (PST) X-Google-Smtp-Source: AGHT+IE9nloK+hzt3pKP4+ZaItptI31qoSwttIYS3m3tTdpeBJBZYC5+P8Ra9C0ib0EoWoEmbHCm X-Received: by 2002:a17:907:969f:b0:a1c:d155:17d1 with SMTP id hd31-20020a170907969f00b00a1cd15517d1mr7616158ejc.92.1702585787292; Thu, 14 Dec 2023 12:29:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702585787; cv=none; d=google.com; s=arc-20160816; b=yDft6Oz+qKigQcP/7OT8Opar4ogG4AkZFGRer2BES7NmmfxC9MmgRUwmysfYmut+Y8 ARTaxZVfAw+tryLkOSyo60X1jLDBdHWPA17eF9DjU19iDoISJxnl0bLzSrrmCzuptEm5 V+lWQ/xP69MIAMtHj63EODASZbzssut5DvLeg3TuEzZLk/dJlEFPPZcnysuhaC9yv5PM +ROA/WZi9igenm0Vg6WFI/RHuNcVrZ12b0ldunlYCLMq/4MHaTR5AQfur/h/N2g5YJ03 dBbLXog8DeBaUr5rvxze6ojLjeOJzArOnsz7n2F6wjQU4XGoYszNkS6+TiMetXIpDN4i EWFw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=2zBgjjgr8D/SHxPTnKZMl5g8ELyqfBBSI/orkqxON0Q=; fh=CcmSh0HiimF8Zsm6wh/XwrLc2aYJxF3572jVG2Fg6wo=; b=WpK7XK4jXKaq6EjD0USLRjH5KqLzsOdFoDl3ZBy2M2OJK4NU/AI3+awR86ChtASmZN DVmWAQDyYAKoqE/vWCpeBvr4CreCsZPKfciLmaOjRr8HhbherMDslK8lfT4wxHqlKrub aOgvg1H1NqV9FyHwsnyymbEJZYepAvscEv+TfzjE3S0j7XmTjtliyPtRvzknSsAdpJ/z n0PjCQGYnfRhT4BIUzJpXcetUY2i1fIBtOiKlrtXpQ1YlOv+Ti+rBorS7GqXVbDVXLYl 9Q+qYZ3xRCTeIIs6Xu1y7vxkIAw/N2/CT+DXNR0Bgao0I8LpjG2bZA+7i2cILR2KlD8f YjVQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=NL5yMhgj; spf=pass (google.com: domain of linux-kernel+bounces-67-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-67-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id q10-20020a17090622ca00b00a1fa4ab5207si3905755eja.124.2023.12.14.12.29.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Dec 2023 12:29:47 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-67-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=NL5yMhgj; spf=pass (google.com: domain of linux-kernel+bounces-67-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-67-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com 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 1046D1F221C1 for ; Thu, 14 Dec 2023 20:29:47 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 21BD56A337; Thu, 14 Dec 2023 20:29:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="NL5yMhgj" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-io1-f43.google.com (mail-io1-f43.google.com [209.85.166.43]) (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 761126A33F for ; Thu, 14 Dec 2023 20:29:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-io1-f43.google.com with SMTP id ca18e2360f4ac-7b6fe5d67d4so321399039f.3 for ; Thu, 14 Dec 2023 12:29:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702585772; x=1703190572; darn=vger.kernel.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=NL5yMhgjgjRNGqiZUmqdFhvYoREXQXddQplRe8954yEJSX2pHppKYq0zrS91Do/r+4 GWjaW8Fx1z0gVXBKPugyPJTjsWxQMmpeQY8CcZNu5jluwsKLoFxy4E2at6K8CR9Niobw uw9N3L8phqtFVmOxEAEXJmYiJVFUOcckkMqRG8iV1M5YLWvCAr6R1NTkfx+1/23bQ2K1 eKi1xHB/f7KGppQ8RVakw7h4z9Ve64r/hnkrBB1FZZz0OtzMORijSgvdJsz3CaIa63Cg D6YEXyObSxf4Q0S1sGq2tkpDH+txo3XdmckopEohMOGu67DYS+6/PZgesH2bcMjmYGqB hxXA== 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=vP7nvIeElv6ajbVqnYBwzYS4YwKcYjxmbCStG90q7P1OU1Bcb8FidUdZ3GtBIB419W paLW4qkClcF9EETqZCFETw3semYd+IVQb/C4dSqd4h+ecgaPKRpLWL66kEiOPhYP8oat sxjybaGaZ0aCv8jgjBp+AAJ8TjYTbFhZSNlA8QF4Bvr4Qtcz66ydlOyM94uliKgUhZb/ GD1pabsNHy8Zo4ZXx7m0bd1nBgW3oT1jRmOnafKtKXygFuGtbToT4AKehnL0nV7Bahbl qFKhQK1kMbqiBeoirzwCFD+2T6iSERC1aDKxhWf2JFFoBSM8p5XmhTE08tmZsn1oo4uk Lt2Q== X-Gm-Message-State: AOJu0YyxcAbxkeZp9zyfF2mp3oDIyEHzucQp+hjmORB9cgXbydw7vOJd e3MAAc7fQKsb2aMzvM+nd67WjUujosMray4Wo2c= 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) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 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