Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp5999582rdb; Thu, 14 Dec 2023 05:57:34 -0800 (PST) X-Google-Smtp-Source: AGHT+IGk6n4szIuhjUojYVrJ437sYkQTNuPyQzIb71HLCMhKtnje33jco6q0eDXOF2//G7Ae3LR3 X-Received: by 2002:a17:902:784a:b0:1d0:6ffd:e2d6 with SMTP id e10-20020a170902784a00b001d06ffde2d6mr7594033pln.112.1702562254156; Thu, 14 Dec 2023 05:57:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702562254; cv=none; d=google.com; s=arc-20160816; b=Zqcx892Pkssjkcwd0zpBZq/4OPZmE+REhC3HvIZ7pZzb93ZjOQnpWVO8qc6HwDGbAA nQHO7fpM/C0eHKuuYMnSInEmebthyD28+N5O5MrbZmHtLxPJbdAan0oQ1t5ONjz/lUCH +Idgs3t51BOxatn8JkP11zZJYCiA17VEy8vQBsp10rji1IhPr3fHozAawuyu8/5DTxTH /yxKetZrQLjN7KsuyuEju2x4N5tctlLUGM8745V54aGmJygh02yig8AzYTg7VTbVN+hX o8Dbvev+hKZW6x/OezxjOw8ITIxlzoW8xLBuPCu5RwQ72VyXEcKjZwXwvL2MWlCE5mFP U/bw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=2jpS4/YpWlHXphGbgZwi2ZTYcCMufm/oKHMDiir1pd4=; fh=pBm2nNGCbof//3MeEeLx54hP4fue7kw7/7lpfs3/LJo=; b=u16ix7RKePg1i6MtM0JC4FwvwDgQhRgn0RIvJC5gou2KXDurxlVuzyIb/l2DHIz41O LV6+ar363IkCF6Tv863kLJwwzO8AnbrrLvauely8pKjL6u61jPZP4eYb9mbs5meOXj0G alfNOu1li/IRJEIH3NTDhcwfHnZ8TqwWceYlPjV6UHttHwls18eqBlq7x9Ot+bHIyMGW OPH10Cemi+IL9RlXCWers0JT2Ou0FIARsK9vbPaEVwn4pjBGQ4IPJEpEzhGJJiwD3EX+ TRva6vxfa7wqyd+8YQmEpPifc6uZLCnAKt7Vmc+D4s2qWVToD+IRp7qOVf6wydLiVdil gj5g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=S2EAKUku; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Return-Path: Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id jo5-20020a170903054500b001d344ae8411si3644642plb.151.2023.12.14.05.57.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Dec 2023 05:57:34 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=S2EAKUku; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 9BD3E801BA65; Thu, 14 Dec 2023 05:57:31 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229897AbjLNN5S (ORCPT + 99 others); Thu, 14 Dec 2023 08:57:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37078 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229567AbjLNN5Q (ORCPT ); Thu, 14 Dec 2023 08:57:16 -0500 Received: from mail-pj1-x1034.google.com (mail-pj1-x1034.google.com [IPv6:2607:f8b0:4864:20::1034]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2B220A7 for ; Thu, 14 Dec 2023 05:57:23 -0800 (PST) Received: by mail-pj1-x1034.google.com with SMTP id 98e67ed59e1d1-28b0cee2abaso434594a91.0 for ; Thu, 14 Dec 2023 05:57:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1702562242; x=1703167042; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=2jpS4/YpWlHXphGbgZwi2ZTYcCMufm/oKHMDiir1pd4=; b=S2EAKUku5+jNe0+Ut5VugDrpq6RdLvGb9Gr7DOcRn0Kew6syWYigYeeCFfT22s8oCA Rt8w5fUPZb+5wpgSLbMiIU8fmUjHkXfncOLhxaHZ+KN7p4d5/+/ul71e2fRKX2Zxx3rj mco2RY+25eJy7qQUh2tj3kNNZ6K6n/pNkS/nAzK29/0AqCjmuH6s2IhW/WzS0+7u0OQ6 p4ivpwEcFsDZosl7xdkiFtaD3ewaE5LU6aM0yC0wQNkgshUiMOxkD7BNPZE6RHXIo7DH ujX7y2BzBqX72w8m6S6r1KBa9OxkmNb8CQazvQCR+PPtGc8fXnsNH0bJRlEEcvqvSXj2 Hu0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702562242; x=1703167042; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=2jpS4/YpWlHXphGbgZwi2ZTYcCMufm/oKHMDiir1pd4=; b=PnOZi9msgVlNxDXk57akpiSV51DYATRw1SbODrjvia+Upa3HB3wKBCXaodr3ZeF+xZ u7OpelupgsKT8OaCvKzhCy2WqtTMDijlkL0yh6zg0TiZ+8AB22drR1aIYExHV4STKrZL Ty7qjAPiAQUd/W894q+JnRXRJtCePDuxoame9IzkYrLOT0J+oIbC51FLMh3Md+hU00VJ NxsQwL+BAqFGZAbQ+MANLvR0q0huf/lYhtlFoBGVPLiU2lh7z35JNKKTQORBubBL4xjU TnoNVjOcCSq6sjeDnXCPu8qPHt73bEDXIVfBzkJkWnaiK/oloDL/d4VxVxwpca/vIRDV GeRw== X-Gm-Message-State: AOJu0YwFd92EXSoKFZro5iws54qYu2mZ0dT4avoM2oUnBT7495iJQckM Xik6Cv0ZEvaormUk0T8w7N2n6A== X-Received: by 2002:a17:90b:b93:b0:286:9e2f:475c with SMTP id bd19-20020a17090b0b9300b002869e2f475cmr7568315pjb.47.1702562242612; Thu, 14 Dec 2023 05:57:22 -0800 (PST) Received: from ?IPV6:2409:8a28:e64:34f0:4525:57e4:217e:6e2c? ([2409:8a28:e64:34f0:4525:57e4:217e:6e2c]) by smtp.gmail.com with ESMTPSA id p12-20020a17090a348c00b00286f2b39a95sm14225348pjb.31.2023.12.14.05.57.16 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 14 Dec 2023 05:57:22 -0800 (PST) Message-ID: <7a8c77b0-c78c-427d-9545-2b328c7dc727@bytedance.com> Date: Thu, 14 Dec 2023 21:57:12 +0800 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 2/5] mm/zswap: change dstmem size to one page Content-Language: en-US To: Yosry Ahmed Cc: Nhat Pham , Andrew Morton , Chris Li , Johannes Weiner , Seth Jennings , Dan Streetman , Vitaly Wool , linux-kernel@vger.kernel.org, linux-mm@kvack.org References: <20231213-zswap-dstmem-v1-0-896763369d04@bytedance.com> <20231213-zswap-dstmem-v1-2-896763369d04@bytedance.com> From: Chengming Zhou In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.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 (agentk.vger.email [0.0.0.0]); Thu, 14 Dec 2023 05:57:31 -0800 (PST) On 2023/12/14 21:37, Yosry Ahmed wrote: > On Thu, Dec 14, 2023 at 5:33 AM Chengming Zhou > wrote: >> >> On 2023/12/14 08:18, Nhat Pham wrote: >>> On Wed, Dec 13, 2023 at 3:34 PM Yosry Ahmed wrote: >>>> >>>> On Tue, Dec 12, 2023 at 8:18 PM 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 to >>>> 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 == 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 == > PAGE_SIZE. I just did the same kernel build testing, indeed there are a few cases that output dlen == PAGE_SIZE. bpftrace -e 'k:zpool_malloc {@[(uint32)arg1==4096]=count()}' @[1]: 2 @[0]: 12011430