Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp992617pxb; Fri, 22 Apr 2022 16:11:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwGDDNvjEQTj89yKQHu8ClWyXqkd/9wxBILusATmcjmNEVDm7w/+STRbyOFlAphzQod9QD7 X-Received: by 2002:a17:903:110c:b0:14a:f110:84e1 with SMTP id n12-20020a170903110c00b0014af11084e1mr6698862plh.7.1650669091648; Fri, 22 Apr 2022 16:11:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650669091; cv=none; d=google.com; s=arc-20160816; b=DE9RDncaN2PZ2GEc83QI1/nkXG8mDM5ZseylR2TvmSTGPdZmIWOMUpW0btWMnX346y MdgZiwbZ1TX0AfV9zM8NSfuWvTjfnAZoR/nEz/D/z1XDxIH5oETQ8XPf2CYyK6btDh57 z/JKCIl7xk9tz7ck+DRh75ryMgeEigZ2yWl5u0SBZa0i7KjRjGs6EDczbZlJyoLAqAlI LQLrrql1f7dWJ7bh8biMog/k3xOf0u+xaeXkt23+9k0oi4ZGP4Xl9TCo69r+vXmgkNAp oZNDbx0GK3bYqcj0R12PxgMJrmOJn9MluBS9IEn83i2jCHV668+qG071C9H+bWdCVJZP ADkA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:sender:dkim-signature; bh=iv87v9Yca5TZDg/ZQ/iYjZjkzk7tiOH6BRDDm7Dxt0Y=; b=HmJjA04HUFQa0032R3tf6zgWHW9En5cDI/SPewdSc3ZvwpnZuYpKxiZPBXVjDtZEKN cMFHxQSAlj5w39GGsm0cKzTmEnuaDxSiOwRJ2HX6DECAVNGIWfO69m/Ilg7+ng7Bt8Ny Ko0ltbBg3TPEIrc97T6URAJ4kUTF/Vw4B2FlZ5VqNSCi0f6B0Qy94vyFKYPYM/HaUeRL dWAYd7r9cCnhZxbUmGm+QDCUJScJ59O8J2MyR+5y4kI58HCUzXu2kZE9O2g+REFDQNi4 Y7FE7RSVDcaHaigNyoK37XqqJWBQOgakpBbBQvhW/xh06j9SWZlXM2LQtKJIH/IsC/Gc 1G6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=fu0F1CAV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id b22-20020a17090a8c9600b001d22ac4fe6csi8224595pjo.92.2022.04.22.16.11.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Apr 2022 16:11:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=fu0F1CAV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id C0117315CF3; Fri, 22 Apr 2022 15:12:44 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232294AbiDVWNl (ORCPT + 99 others); Fri, 22 Apr 2022 18:13:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53220 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232983AbiDVWNL (ORCPT ); Fri, 22 Apr 2022 18:13:11 -0400 Received: from mail-pf1-x42f.google.com (mail-pf1-x42f.google.com [IPv6:2607:f8b0:4864:20::42f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2735122C3C3; Fri, 22 Apr 2022 14:00:57 -0700 (PDT) Received: by mail-pf1-x42f.google.com with SMTP id j6so6741681pfe.13; Fri, 22 Apr 2022 14:00:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=iv87v9Yca5TZDg/ZQ/iYjZjkzk7tiOH6BRDDm7Dxt0Y=; b=fu0F1CAVqlD9Irw8VYYm8YmF+EPHITJrPwLkshaOAGcPbpAgnfpdLx0vAZX9gI6xZf SJ3CNdXK9Y4YbnjX5RygQu9E9ZFtDXEPrebfQd3u5POyYIP/Ain4NphhDZtQxZw1qEWm GVHPujZWudp0ogm9MVDdUGMOua6INR1GlA/VTNT+51PUfdHdyWZRxrtZ4UfkIohsoRDZ x6Xb3GJShmjXlrTYFvslFdVuPnj0OIshb7baSnSrKa2AJRzLHtXs4Rigv6SB6J+zEdzD mNcD6DsEGguEyrnS2cSNZ9R4XGpR4i6+Fd8vol5CLckzjVcNBKjroiIYIfPetGqY+Os+ 5New== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to; bh=iv87v9Yca5TZDg/ZQ/iYjZjkzk7tiOH6BRDDm7Dxt0Y=; b=inZsCiCj/gBRuTSaEpp+5cKCK8GA1Pzh8OVgON/XzqBpiZtp9x/ElLyrnxhxDLuRgX q1Z848viyvTt9c9sCcf0HijTOgHAIvUmv/yC7KNiAmKWyozX6Ntka9gS7vqRmls2pTvF LMfMTNHB8KN2zRIpN0D0Pc/Ya26JC+rQXQliC1jmFcA75D7TD6FPY3SGJibe0C/5WPGt Mort2IEILJHtghBgeLu6GvTXwc1MdAYDddzeA3pTWpg2SzM4BiBBt2czutyEm/2XO52D D4U1K88Il7LIWtsr+kRY1QeIIWC37BFK1kTWWnhY53RrW5rr/+iLwSgHOb16jhlOGvBv yacQ== X-Gm-Message-State: AOAM533vbirifgrU71c1BSQXugmjL7DwcqcpL8r3d24xNAHsQ+N7zTQe XV2OgaI0ps27uhnVB/e4MjkO5n7JHuE= X-Received: by 2002:a17:903:2352:b0:159:3fa:261 with SMTP id c18-20020a170903235200b0015903fa0261mr6183552plh.21.1650659239352; Fri, 22 Apr 2022 13:27:19 -0700 (PDT) Received: from google.com ([2620:15c:211:201:2194:db4:85a8:b0df]) by smtp.gmail.com with ESMTPSA id u9-20020a17090a4bc900b001d26f134e43sm7206404pjl.51.2022.04.22.13.27.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Apr 2022 13:27:19 -0700 (PDT) Sender: Minchan Kim Date: Fri, 22 Apr 2022 13:27:17 -0700 From: Minchan Kim To: Alexey Romanov , Sergey Senozhatsky Cc: ngupta@vflare.org, senozhatsky@chromium.org, linux-block@vger.kernel.org, axboe@chromium.org, kernel@sberdevices.ru, linux-kernel@vger.kernel.org, mnitenko@gmail.com, Dmitry Rokosov Subject: Re: [PATCH v1] zram: don't retry compress incompressible page Message-ID: References: <20220422115959.3313-1-avromanov@sberdevices.ru> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220422115959.3313-1-avromanov@sberdevices.ru> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE autolearn=no 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 On Fri, Apr 22, 2022 at 02:59:59PM +0300, Alexey Romanov wrote: > It doesn't make sense for us to retry to compress an uncompressible > page (comp_len == PAGE_SIZE) in zsmalloc slowpath, because we will > be storing it uncompressed anyway. We can avoid wasting time on > another compression attempt. It is enough to take lock > (zcomp_stream_get) and execute the code below. Totally make sense. However, I'd like to discuss removing the double compression logic entirely. Ccing Sergey to get some opinion. [da9556a2367c, zram: user per-cpu compression streams] The 2nd trial allocation under per-cpu pressmption has been used to prevent regression of allocation failure. However, it makes trouble for maintenance without significant benefit. (I gathered some of data from my device and writestall was just 38 for 10 days even though swap was very heap - pswpout 164831211). Even, such 38 attempts don't guarantee 2nd trial allocation was successful because it's timing dependent and __GFP_DIRECT_RECLAIM is never helpful in reclaim context. I'd like to remove the double compression logic and make it simple. What do you think? > > Signed-off-by: Alexey Romanov > Signed-off-by: Dmitry Rokosov > --- > drivers/block/zram/zram_drv.c | 15 +++++++++++++-- > 1 file changed, 13 insertions(+), 2 deletions(-) > > diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c > index cb253d80d72b..bb9dd8b64176 100644 > --- a/drivers/block/zram/zram_drv.c > +++ b/drivers/block/zram/zram_drv.c > @@ -1413,9 +1413,20 @@ static int __zram_bvec_write(struct zram *zram, struct bio_vec *bvec, > handle = zs_malloc(zram->mem_pool, comp_len, > GFP_NOIO | __GFP_HIGHMEM | > __GFP_MOVABLE); > - if (handle) > + if (!handle) > + return -ENOMEM; > + > + if (comp_len != PAGE_SIZE) > goto compress_again; > - return -ENOMEM; > + > + /* > + * If the page is not compressible, you need to acquire the lock and > + * execute the code below. The zcomp_stream_get() call is needed to > + * disable the cpu hotplug and grab the zstrm buffer back. > + * It is necessary that the dereferencing of the zstrm variable below > + * occurs correctly. > + */ > + zstrm = zcomp_stream_get(zram->comp); > } > > alloced_pages = zs_get_total_pages(zram->mem_pool); > -- > 2.30.1 >