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 51009C46CA0 for ; Thu, 7 Dec 2023 02:59:52 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B24BF6B0085; Wed, 6 Dec 2023 21:59:51 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id AD4F56B0087; Wed, 6 Dec 2023 21:59:51 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 99CBB6B0088; Wed, 6 Dec 2023 21:59:51 -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 8A0936B0085 for ; Wed, 6 Dec 2023 21:59:51 -0500 (EST) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 5DB061C0842 for ; Thu, 7 Dec 2023 02:59:51 +0000 (UTC) X-FDA: 81538517382.04.DEFF29D Received: from mail-pf1-f170.google.com (mail-pf1-f170.google.com [209.85.210.170]) by imf15.hostedemail.com (Postfix) with ESMTP id AF0D4A0007 for ; Thu, 7 Dec 2023 02:59:48 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=gboBRpjF; spf=pass (imf15.hostedemail.com: domain of zhouchengming@bytedance.com designates 209.85.210.170 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=1701917989; 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=vmFTswpdUJE2rTRRw/ViFE7rnEIJVMFOJnLGTDou500=; b=GrGlIXgIP8/l3spB3rOyqJPjw0Fkf/A7zMzTGxTZ1LmHpdg0zonGlljVpSRqZyDOLF9xsq PjnNBAvB7VF8a9KomUZFUKd5J84KCGf2BUgF7GxEKXjKJ43tVjeA6lzXhwPv4vuX1pakRG L4yqC+oPpk3sMuIQ+IpiuFkhEf6EGmQ= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1701917989; a=rsa-sha256; cv=none; b=JXMXleJx+kAAJlOrMsRbc5wIq96H79k3nHntKLsvEN/rXC8/abRLWC1VTOR8ii455fXOm3 Sv9Sen1/4EcicKtxaYavy+L5TPSFNe/cVS9YvU/crcTswfApdXl++l3TeUgoMKHcvm589Z UTwncN2JPnf94Cp6OaStlznurqJFSco= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=gboBRpjF; spf=pass (imf15.hostedemail.com: domain of zhouchengming@bytedance.com designates 209.85.210.170 as permitted sender) smtp.mailfrom=zhouchengming@bytedance.com; dmarc=pass (policy=quarantine) header.from=bytedance.com Received: by mail-pf1-f170.google.com with SMTP id d2e1a72fcca58-6cda22140f2so179154b3a.1 for ; Wed, 06 Dec 2023 18:59:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1701917987; x=1702522787; darn=kvack.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=vmFTswpdUJE2rTRRw/ViFE7rnEIJVMFOJnLGTDou500=; b=gboBRpjFkMcLjICJvJEg0XVAiOba2yWkOmsSRv33dDo7ySD62gkJivnzcPBycH8vTC YJygWmBKb/JCnCLO8tAm9l3P/+PlbYyGZ2tz0ZI6VF30C+rUBFhwR9Pfv/Oz7bd0ws1e jHqmd6RBMQX0K5hyfsjJZHshVrKRZZNr2CNa5SWzbbsEXWU5FHeyHFurKcBufdsdTCAA 3jR5ngDbWFn11FShY8gke7afHAOB9ZWLYcl9PAhaZwY8arocRv3oSzn9fpAvAerOZCoi 0amAWKYnOnOpaP0R9D858XJsbBn6jD5IVhpd6LWsDfrFVMvfiio6XdGNvTOV3HDdp8/L ojBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701917987; x=1702522787; 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=vmFTswpdUJE2rTRRw/ViFE7rnEIJVMFOJnLGTDou500=; b=wpF4uIBsurYhj/th+yjOk3nFHa3E2fVgFSJu3W46oW3rv6fFcA2oIFlcC4SP+/8/er ctNIU3jjZmGQICANW/26PeS4eCyZLWdKTOw+UFyQsRM00CzYRqG0Bx5jh5TGqWd9cyu5 tYQXttTqkY/OvbaldhoMM1SNo8uBV0sL1/QPVsKSDxsmo1o+mjDuV21GF/t6VwIHZPwh sG0gTLBtGqAUSCQhJ3Wq9kwBB21eHGLcKPRPkqCuESBIc5kZAahj0LFmR8W4BXFQTv9t lK9gEQZg9Yyc7FXrxufpBY5/VIYlXfQh9IwzQ6l/RiTZmYrecK2/CNQHbDcPO8q7F1pM Qh5w== X-Gm-Message-State: AOJu0YwXgWAoX1xzi8jrW8by4coySKkw8PllBwiPThTv1tH00Jr7jJ+6 EiZsoPHi6eLEO5L3b1Kjv5iVuA== X-Google-Smtp-Source: AGHT+IF6coN8MfaVzFORuZNxRFOU6lZR6fn17FZb5urBAAU3XzsEYfnAlXJ92fzrZudE1pF+8aj9kg== X-Received: by 2002:a05:6a20:4b03:b0:18f:c42c:d735 with SMTP id fp3-20020a056a204b0300b0018fc42cd735mr2065531pzb.99.1701917987375; Wed, 06 Dec 2023 18:59:47 -0800 (PST) Received: from [10.254.104.27] ([139.177.225.245]) by smtp.gmail.com with ESMTPSA id 26-20020a17090a005a00b00286be9fb3fdsm154565pjb.40.2023.12.06.18.59.43 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 06 Dec 2023 18:59:46 -0800 (PST) Message-ID: <4b864565-faeb-4814-a803-66a1e54e8ae1@bytedance.com> Date: Thu, 7 Dec 2023 10:59:40 +0800 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 4/7] mm/zswap: change dstmem size to one page Content-Language: en-US To: Nhat Pham Cc: Vitaly Wool , Johannes Weiner , Michal Hocko , Seth Jennings , Dan Streetman , Andrew Morton , Yosry Ahmed , linux-mm@kvack.org, linux-kernel@vger.kernel.org References: <20231206-zswap-lock-optimize-v1-0-e25b059f9c3a@bytedance.com> <20231206-zswap-lock-optimize-v1-4-e25b059f9c3a@bytedance.com> From: Chengming Zhou In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: AF0D4A0007 X-Rspam-User: X-Stat-Signature: jaj7tat64a3w9sh6fidzbuaapnn5itcq X-Rspamd-Server: rspam03 X-HE-Tag: 1701917988-889686 X-HE-Meta: U2FsdGVkX1+J/b5prlH5Gvt51uWinmXMjjCiGhI+wfEGRTUp7ZPqBe4ENB3mAem1PQVn/JWYc//dKm3bBBauCRaRyl5gC4FB6tmBCyt2O1+nVC/t8JfiNqzIQUmLPIB2pFPtJEll1ftRjMFWPZXllYtC9SmcQt5Hmi0V8uke3Gwg2sisXa1TthDXb26M2sCo3R/4Xzjhy8VIir7VnMisSDy2nV5KoYIOPaURiQd8a1al4GcZPPNRkCLW2LaU4yp+AWyT5wADAlL0TqsJ1g56fCEOsFpOMhk/rC5BDBxOCdED3D3i3bTybh3flbrHKdmku7oX1RPEJvy0lv7TCRKdiE+/VLOrn+ZVnL7fX40Y82uZZFzm68hHwweb37E1Q6vLvupAC16qswH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ogosity: Ham, tests=bogofilter, spamicity=0.000000, 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/7 01:12, Nhat Pham wrote: > On Wed, Dec 6, 2023 at 1:46 AM Chengming Zhou > wrote: >> >> Maybe I missed something, but the dstmem size of 2 * PAGE_SIZE is >> very confusing, since we only need at most one page when compress, >> and the "dlen" is also PAGE_SIZE in acomp_request_set_params(). >> >> So change it to one page, and fix the comments. >> >> Signed-off-by: Chengming Zhou >> --- >> mm/zswap.c | 5 ++--- >> 1 file changed, 2 insertions(+), 3 deletions(-) >> >> diff --git a/mm/zswap.c b/mm/zswap.c >> index d93a7b58b5af..999671dcb469 100644 >> --- a/mm/zswap.c >> +++ b/mm/zswap.c >> @@ -699,7 +699,7 @@ static int zswap_dstmem_prepare(unsigned int cpu) >> struct mutex *mutex; >> u8 *dst; >> >> - dst = kmalloc_node(PAGE_SIZE * 2, GFP_KERNEL, cpu_to_node(cpu)); >> + dst = kmalloc_node(PAGE_SIZE, GFP_KERNEL, cpu_to_node(cpu)); >> if (!dst) >> return -ENOMEM; >> >> @@ -1649,8 +1649,7 @@ bool zswap_store(struct folio *folio) >> sg_init_table(&input, 1); >> sg_set_page(&input, page, PAGE_SIZE, 0); >> >> - /* zswap_dstmem is of size (PAGE_SIZE * 2). Reflect same in sg_list */ >> - sg_init_one(&output, dst, PAGE_SIZE * 2); >> + sg_init_one(&output, dst, PAGE_SIZE); > > Hmm. This is very weird. It looks very intentional though, so perhaps > we should consult the maintainer or the original author of this logic > to double check this? Yes, it's also weird to me. But it seems to be 2 pages when the zswap code merged in mm 10 years ago. Hope the maintainer or author could shed some light on it. :) > My best guess is for cases where the compression algorithm fails - i.e > the output (header + payload) is somehow bigger than the original > data. But not sure if this happens at all, and if the size > PAGE_SIZE > we don't wanna store the output in zswap anyway. > Agree, so I think one page is enough. >> acomp_request_set_params(acomp_ctx->req, &input, &output, PAGE_SIZE, dlen); And here we just use PAGE_SIZE in the parameter actually. Thanks! >> /* >> * it maybe looks a little bit silly that we send an asynchronous request, >> >> -- >> b4 0.10.1