Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp6188330rdb; Thu, 14 Dec 2023 10:31:23 -0800 (PST) X-Google-Smtp-Source: AGHT+IGPblDZl925SJHWn4YyQiOiK4HA/Phvf0kU8ohB1/oJjg+h042Wwnbx5hkN8q+/hmb7MwNl X-Received: by 2002:a17:902:cecc:b0:1d3:6955:4ea2 with SMTP id d12-20020a170902cecc00b001d369554ea2mr989198plg.65.1702578682837; Thu, 14 Dec 2023 10:31:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702578682; cv=none; d=google.com; s=arc-20160816; b=bhXqoipqIvyjgXu9UzWJGpn1JvHDTCAXqMSw0uXxnvY9H3qBMaKGJJGp0kH6IaHaCC RpANTLnOdQBpb08gfEW6JWLMrGcuNu1VYkkS6+wq+LDQacPCGWntmEyHSMUy6yFvAUIv wRcCDsCEYf/K+jQot+kHjmybjOWwawaSicusGuS+2fkN1enRVUuMRJ/qkpwyCDabUM4U rUZHJo7Kc1BlWUoPoFB+xev3ENe9yCZbcSre5CLWAqQtc4d5sNIm/LeEKA7HHpl5XtAJ iDRhPLZWk9kEn36fB0JfnrwvbTdYGu7JVN1xYb3CMj3k3QZ+j//1TrJI3UblyJAizbE2 mOFQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=d0isHYCiVxibANo8wxo3LG8B7bIVEbLb07RnvwdIrmw=; fh=4RRs7CAQSG5mR3Za3X8IpDzzb5a/VTK08eyf2dCENi8=; b=KQ5VshAnvvKfqdUw998zIhielUdVrdwzfqGofwVlL0z4HOW78O2lEHdgQIoFeTRqLJ CFeIIWVSJ51CXuZjwKhtF9vMyPDGsr2OHy9CdlZ5KV/fuENpce2Gc1D6T/n5Pd3aTxtF /lH15BClHaaKz4FOvKBz6GPZ3Fz6il9XAu5ekyqMY8hXmbXo852z8oQe037MENUHNkiu 7FH9Qv0dzd4KK0TntB3nZ+fUzD6f5Ef1d7fkVNNfX0V1VcAoiEXRSkR4GGQj3aY+Oc0P txZe6YtAwsTzPvNlfCo8WUCsIE8LPWHf+wp+Rfq6wkCRMB3Du94jR3s5wzKX/tX7GwEX Tdpg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b="p3YT405/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id x24-20020a170902821800b001d34d365654si3270914pln.464.2023.12.14.10.31.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Dec 2023 10:31:22 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b="p3YT405/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 0033F8184525; Thu, 14 Dec 2023 10:31:12 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235737AbjLNSax (ORCPT + 99 others); Thu, 14 Dec 2023 13:30:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32926 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235727AbjLNSav (ORCPT ); Thu, 14 Dec 2023 13:30:51 -0500 Received: from mail-ej1-x62e.google.com (mail-ej1-x62e.google.com [IPv6:2a00:1450:4864:20::62e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 21E3C10E for ; Thu, 14 Dec 2023 10:30:57 -0800 (PST) Received: by mail-ej1-x62e.google.com with SMTP id a640c23a62f3a-a1db99cd1b2so1091300166b.2 for ; Thu, 14 Dec 2023 10:30:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1702578655; x=1703183455; 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=d0isHYCiVxibANo8wxo3LG8B7bIVEbLb07RnvwdIrmw=; b=p3YT405/v5n574k2njC7i9lCzfplElKudeRMDTToPb8fe3k9/PKxdnKXiJNO+ErhYN WAEXaNgwkxkLxMnQMw8M9TQ0HW6h3DTJv9d9R/LbvRWafDVQfqsBT3FtXeeyjiojrT1D ojndw8TiAXSbU/Ydw3wqkr5mIPkBYsVPdIZ69/rWw7SumdcdmBw3kvn3zyDo3r19yWjr 90ofbtCLJe5nvf1mvZ9syNwFEn75Jf7VsLffRRdTCPaQfyRJ/qLQNGmydZI6Kh/agfTs I1WZ2KNsZ3wrhhceGPAc9QtRS5MgCMGsMbr/RZaKbtJ8/+gtARB2EgX9Po5GnywKbIec 2aUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702578655; x=1703183455; 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=d0isHYCiVxibANo8wxo3LG8B7bIVEbLb07RnvwdIrmw=; b=TV6PkW6eQZHxkn4iQhLlViqb0Y/TAMDud0+BNof+S+WUJ2F+fzPKEM1bufO913H4oD blswDcGuBtUndJl4di8co8hR+UQKUEgontAWbU597EAeLNSvXQllywYEBCTwRUN39xTZ kmqooVOi+j84ERTsihBmElPQufroKiH1NEadceW5VCQnVmTvPX0Ws+/XN1kpjcjY4JFZ aQo3j/DnOmH2I2Vk58tCACKbLMzLXqXfjGi5LQgjPukOfsrhrWsF8ewznn98V0bZ8Lhr BLts4qIS5qb4/a2FFml21wRAWdOmYYiUSUx9gKUqaDdMbP91h5YQY9c+BfFlTdfRGf+G O9KA== X-Gm-Message-State: AOJu0YyHmbP4FeKTSxjx7N+cQWkcPI7W+6Cf/p4/J7q3DENj8AmpNGcT jPXXVx3pI1xwW77MiQZ6wIkW0pdQc9IlH5sjRfxbRA== X-Received: by 2002:a17:907:6d07:b0:9fd:ab4:5859 with SMTP id sa7-20020a1709076d0700b009fd0ab45859mr4569015ejc.66.1702578655351; Thu, 14 Dec 2023 10:30:55 -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: <7a8c77b0-c78c-427d-9545-2b328c7dc727@bytedance.com> From: Yosry Ahmed Date: Thu, 14 Dec 2023 10:30:19 -0800 Message-ID: Subject: Re: [PATCH 2/5] mm/zswap: change dstmem size to one page To: Chengming Zhou Cc: Nhat Pham , 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-Spam-Status: No, score=-8.4 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Thu, 14 Dec 2023 10:31:13 -0800 (PST) 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 also > >>>>> PAGE_SIZE in acomp_request_set_params(). If the output size > PAGE_= 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 would > >>>> 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 t= o > >>>> handle the case where an incompressible page would exceed PAGE_SIZE > >>>> 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 looks > >>> so intentional, but FTR, AFAICT, this looks correct to me. > >> > >> Right, there is no any history about the reason why we needed 2 pages. > >> But obviously only one page is needed from the current code and no any > >> 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 su= re > > 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. > > 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