Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp1125727rdb; Wed, 6 Dec 2023 09:12:57 -0800 (PST) X-Google-Smtp-Source: AGHT+IEjWlzy8UKGjkv2F3SSM90SZI14DbMdOCuIVv1T3wt6PHw++/E+3XkPX/UFipn7pD6vePji X-Received: by 2002:a17:90a:4dce:b0:286:6cc1:3f1c with SMTP id r14-20020a17090a4dce00b002866cc13f1cmr1286133pjl.83.1701882776829; Wed, 06 Dec 2023 09:12:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701882776; cv=none; d=google.com; s=arc-20160816; b=hLYxYuAx+3zVERa2VUYRCCHIK51Ij22JWpActLpWzXx/GN+REIwybG7ov/DGaQaL9h xs0mUNqQ/0JrH0GqDIeKjSCCtAqf9oR800/WcT7acJbKmGohOpyGe6j3uRNYQ3v6hx57 EfsxkoMRxJjj4x5ytAXPLnmhTIXXRO48MP3iGlVJn/UK21QpfiZKA1DhaTGwg9DSBYit HvL56u5+0+pg3i+TvFHv/2ORHfIz3tRkEAEHLlX0Piom/hfSeFt+ggqnE2JX1s4zVnye e/ax8kYL/XESu9EGNcenqeOIUCdTpDjaHVdNTgL/IVm53hT6Rpy1zkZnOvNBq6ykNX7m seDg== 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=B+9ip8yZMAtxAFLF3RDeFuB04O8uGSJc2S5II7y6frs=; fh=OYyyqLl+7kHm8cIdrlovIOx10UybNbaabSjUs6DJgRA=; b=aZw05tQ73OnV0AdevH49lmVYcaNFbQkb8IVnfvwjkKp8Z7u9LK4evM/2HMMQbLlu2a 3DyUuIvUX2a/AngxRGvRC7bQI0vKhXXvqLEk7TXHvuRYrDAJ6cfK2DpP8/NPwIc3gXHL gYd6wzOBkF9yb71Em9/BHrapOuHToD6kicXdZZFptOBfBEnFL4BgM81vdMc5Yj9RbT4V CtS/1mXDPLLp39Aj52mj+AVo3WzZYJXVolp0ZyrhvAbnwKzf2Vy+HU/BT8yyrOS494sg gXHgECr+85Up3Wx9IwcmlXtCBcAPvtOIHqXgs7pHWeA22Xu1QUjRhWs80pYo5oUis5SG NypQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=nOEjsI9w; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id mm20-20020a17090b359400b0028526216f31si91754pjb.106.2023.12.06.09.12.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Dec 2023 09:12:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=nOEjsI9w; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 46CE98026DC4; Wed, 6 Dec 2023 09:12:55 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235251AbjLFRMo (ORCPT + 99 others); Wed, 6 Dec 2023 12:12:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57842 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229815AbjLFRMn (ORCPT ); Wed, 6 Dec 2023 12:12:43 -0500 Received: from mail-io1-xd29.google.com (mail-io1-xd29.google.com [IPv6:2607:f8b0:4864:20::d29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 12F9590 for ; Wed, 6 Dec 2023 09:12:50 -0800 (PST) Received: by mail-io1-xd29.google.com with SMTP id ca18e2360f4ac-7b454089e55so94463539f.3 for ; Wed, 06 Dec 2023 09:12:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701882769; x=1702487569; 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=B+9ip8yZMAtxAFLF3RDeFuB04O8uGSJc2S5II7y6frs=; b=nOEjsI9wPICTOEpSEKIab7YisHSI6wyTj//vzR/CfZCoOhR3krBoIaXhWSwHgkLpZp AR75FHZfvw47xhcvsQvpJpY1PW6frZ2uCb2bD9eSSiFrrfdBII8gTbxJPxQE7dIMeaKL SpkZQ27zMQYwMw+V+WWvrFG2BNbBGrGaiRH6f8eI4X2gafNZ+STr82RFXW41qGw2ASRh RLb4o8NP9GqQgt4gVeYpq9KrtlTBLw/Y4K3nImBMVCvhomBavtvm5hXN17/YTgH+ngaV QSGsUnvFq6+Ya5twf0cO2zfMusqhrFbojhPTrw5Z6BbKx6iHeUAWNeh3+mDVFIp1fXvf G0hg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701882769; x=1702487569; 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=B+9ip8yZMAtxAFLF3RDeFuB04O8uGSJc2S5II7y6frs=; b=TgjTyu9S+Fi93mHX7vsaH5uPtPJ0mWGpC7umI2gXSYvbeUvHnQTt3KbRaQ1W24j0wc RzINqoe0gNjjaiQXxUY1aNnq9ADavoqSthOAYHXE5xlW/SzChFN6oKQagYH5ml3W/5W1 SqGSe2mB1wSsFnFeRyNd1GvRJm4dsILYdDY6X1JnYn6tvfjHQNh3muunKqQGMIT2+2eZ Y2iJX+dsa+bRaDamoeQC/49+zeQ8srNOoUCb3rbUOLZYFpuHhZiK0hKaDckzVtGXk6fe jwk1gGKupIdRfV8rX9yugmHQpGZhcXNwBOkebDNOf9/Y6VqSMSJIxIQd7qEGLngsk6N/ ab9A== X-Gm-Message-State: AOJu0YymuH9Z/oa8KkJoBAt5AlKlZiOlSCnEMJ6I41cWzx0P6WeBuwze SFS4Kluvy2uS7bidDSXxo4o4lfPGiJKIIA6HGWs= X-Received: by 2002:a05:6602:4817:b0:7b4:28f8:2670 with SMTP id ed23-20020a056602481700b007b428f82670mr1761277iob.43.1701882769239; Wed, 06 Dec 2023 09:12:49 -0800 (PST) MIME-Version: 1.0 References: <20231206-zswap-lock-optimize-v1-0-e25b059f9c3a@bytedance.com> <20231206-zswap-lock-optimize-v1-4-e25b059f9c3a@bytedance.com> In-Reply-To: <20231206-zswap-lock-optimize-v1-4-e25b059f9c3a@bytedance.com> From: Nhat Pham Date: Wed, 6 Dec 2023 09:12:38 -0800 Message-ID: Subject: Re: [PATCH 4/7] mm/zswap: change dstmem size to one page To: Chengming Zhou Cc: Vitaly Wool , Johannes Weiner , Michal Hocko , Seth Jennings , Dan Streetman , Andrew Morton , Yosry Ahmed , linux-mm@kvack.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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 (snail.vger.email [0.0.0.0]); Wed, 06 Dec 2023 09:12:55 -0800 (PST) On Wed, Dec 6, 2023 at 1:46=E2=80=AFAM 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 =3D kmalloc_node(PAGE_SIZE * 2, GFP_KERNEL, cpu_to_node(cpu))= ; > + dst =3D 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_li= st */ > - 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? 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. > acomp_request_set_params(acomp_ctx->req, &input, &output, PAGE_SI= ZE, dlen); > /* > * it maybe looks a little bit silly that we send an asynchronous= request, > > -- > b4 0.10.1