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 50B40C4332F for ; Thu, 14 Dec 2023 15:03:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DC9C86B0141; Thu, 14 Dec 2023 10:03:39 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id D79726B0143; Thu, 14 Dec 2023 10:03:39 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C41676B0147; Thu, 14 Dec 2023 10:03:39 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id B56E56B0141 for ; Thu, 14 Dec 2023 10:03:39 -0500 (EST) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 8B25140CAD for ; Thu, 14 Dec 2023 15:03:39 +0000 (UTC) X-FDA: 81565742958.27.599ECC3 Received: from mail-pj1-f41.google.com (mail-pj1-f41.google.com [209.85.216.41]) by imf04.hostedemail.com (Postfix) with ESMTP id 1039240030 for ; Thu, 14 Dec 2023 15:03:35 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=KD1BW3lm; spf=pass (imf04.hostedemail.com: domain of zhouchengming@bytedance.com designates 209.85.216.41 as permitted sender) smtp.mailfrom=zhouchengming@bytedance.com; dmarc=pass (policy=quarantine) header.from=bytedance.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1702566216; 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=fpQnNUGEK78CSlHK0BOK2Wt8OQGIkPegoGE2UWWfI/k=; b=LyEeaih5IUwDBSWCMrGh1P+/e+zefcNVA29W7tHsjyWjvnIRf2lbP0B0lTRleDT1hYZ790 RbviF9lHKhvZ0tHUab5UIcEvnFwQjW+PYW++H73VGSPBb3yfNVgNX5k4WuC8fEkvzvzl3I Wpo0SUZy9bC0ZmfYGijLVaygJGwsFBY= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1702566216; a=rsa-sha256; cv=none; b=mSywotngZK7TlvuEAs6TxHzdoR5fhhvgwZoiubpETJQS6pcxQvsdc9f8fgCT7n1ieeUF3w LbKZs8Li9fU+EfR7ZAtHZxra3ldgpcUVjcFxbC+9oPWiQ6l6lR2QiCHDL+NLp7gL70xIV3 2ayG59Y0UUQbOReRwa6ND65cCyfhSkc= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=KD1BW3lm; spf=pass (imf04.hostedemail.com: domain of zhouchengming@bytedance.com designates 209.85.216.41 as permitted sender) smtp.mailfrom=zhouchengming@bytedance.com; dmarc=pass (policy=quarantine) header.from=bytedance.com Received: by mail-pj1-f41.google.com with SMTP id 98e67ed59e1d1-28abca51775so1920758a91.1 for ; Thu, 14 Dec 2023 07:03:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1702566214; x=1703171014; darn=kvack.org; h=content-transfer-encoding:in-reply-to:references:cc:to:from :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=fpQnNUGEK78CSlHK0BOK2Wt8OQGIkPegoGE2UWWfI/k=; b=KD1BW3lmr3MiIB7He8D4C5xo3NNtJhgZv32MLyuS9Behr5DpDg6LQZwozYdcIHP/+D nXLUcosj12XWCwMigqOP0MPceLcz/+Vqykxs5nJ968v9B2B51fDL+a76KFX9nunsuSl6 s64m4HuQHxR7e6KVs69p2fneUiDYGbot5XO/D67eO0f+MMioUJMOznkhm5sxBwosxdcM 15XnT/TNYWvUUD8zLAHBTG+DkFQ2IHtVyU9pMC1AL+eVYFiOujpUMCxWIe/F3+9U0XTB ehc/eMxJSvXnVGf4NEPyjjFZ5ozkGgbOBOzlTnY26MgAuG03QBi2EL76nTr1csBBl25W wTKA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702566214; x=1703171014; h=content-transfer-encoding:in-reply-to:references:cc:to:from :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=fpQnNUGEK78CSlHK0BOK2Wt8OQGIkPegoGE2UWWfI/k=; b=CfSaD9ob+d3uZYGMmFjAiTkCEWuRoMiAdNXOE3YsMgCNCpEZRidyIPEBg30CJm8UZI ldW2Exc0j6ZdQeudzRYamd5DwOCqYIB84mQSMbj1LDaPdu+bhp2zmqii9sZYTE7e0C7F at/CebZVyTRBlihi9xbui9Ag1MASIm/BUYu8OW+sEcDmWJuP2KGIBu0KQgvNrwb9S3wA +QawFAREz0u7xbkJ5U6f1VF8AfCCoXtFeST8k3pAi2K0B/svvPs0cWD3aNm/THirXgFb nzZaAPOdFKpZZm9xO3zTXprHV3G1RRSABgcNPPaWzXbE1bCZbblNB011lah00Twr8Sy1 pJjA== X-Gm-Message-State: AOJu0YwQMFGJLBG03uIkddd1fUmySAObjO4Afm7tnjI0gDpw0GIVsXdh VG0Kwjvk+g4V0uWi0rV+dFfrNM5EEkaZAHifDYk= X-Google-Smtp-Source: AGHT+IGYz/2+L0p5SsOU/NDOJKQnVfxunA2s6iKI7KEfAi+/IkBVaiEd6ovyb3samZgQxOKpywWTAg== X-Received: by 2002:a17:90b:890:b0:286:6cc0:b90b with SMTP id bj16-20020a17090b089000b002866cc0b90bmr3947002pjb.66.1702566214512; Thu, 14 Dec 2023 07:03:34 -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 sf3-20020a17090b51c300b0028a42f9d3ebsm12147138pjb.53.2023.12.14.07.03.28 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 14 Dec 2023 07:03:34 -0800 (PST) Message-ID: <7a0e3229-be63-4a24-a3fe-7e3ff517de10@bytedance.com> Date: Thu, 14 Dec 2023 23:03:22 +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 From: Chengming Zhou To: Nhat Pham , Yosry Ahmed Cc: 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> <7a8c77b0-c78c-427d-9545-2b328c7dc727@bytedance.com> In-Reply-To: <7a8c77b0-c78c-427d-9545-2b328c7dc727@bytedance.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Stat-Signature: urbgzrc8nfdnkdywn7sfycyp5z7g8pm9 X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 1039240030 X-Rspam-User: X-HE-Tag: 1702566215-799954 X-HE-Meta: U2FsdGVkX18ES6Xe4QowbUkBRph/pfCoTOEHp+GuzYepuQUzyukSsroMB/ZiRujSydiIiuMEsvT9aqxtiG+JZEAWsTj+J5OD/S6ebxmWQ7HavuMOC5setqrnpDU4eM7mo8siXTrgtDe7Ha/q2UR735ug0wX0SYbBQMtJi6QR4zE+CadEEhZKAaWIhXJEjY8sun+p+SBkBCm0o6585zYFQ4cX1Y9wmiKqrHYm1t+biGz09bkrCoGtHE0bR2K7W99WX1psWflyFLc8jd9dm8DW1t9Ci5Tg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smkn+S8nJx1OXMDKwZo6C+qLNL63zk3ohUnAzHsnA9ZieO12udLyttF3hcocI3A/nksucb5UZbi19m+pvQAUrl8p8aPBACXRb6udom5Wv6oZxGPaie5jxIMSivpaGg6JhxIuw== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000094, 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 2023/12/14 21:57, Chengming Zhou wrote: > 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 I think we shouldn't put these poorly compressed output into zswap, maybe it's better to early return in these cases when compress ratio < threshold ratio, which can be tune by the user? e.g. in the same kernel build testing: bpftrace -e 'k:zpool_malloc {@[(uint32)arg1>2048]=count()}' @[1]: 1597706 @[0]: 10886138