Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp4693343pxb; Tue, 5 Oct 2021 08:24:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwq7I1nAW+TWbD/T2QQc/EShfQJr8Zx2wRJ9BU6zllLZkJJpUb/ys8Jo9yRpZalEISGyhb5 X-Received: by 2002:a05:6402:744:: with SMTP id p4mr10623405edy.263.1633447458403; Tue, 05 Oct 2021 08:24:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633447458; cv=none; d=google.com; s=arc-20160816; b=cYDqxmcCfiDf0MhhntlAFU8f/d6uiSep/qsiSCByJlgzBaXqW8skb3gJs7XXWs3G3D bT6QEFpAzqRUMlLX4AErA+8d+BmhdJ6pyWKsr+sutCS0cHLj5D4ovrKFblm6bNQVFbit r5wT840R9up2q1S0cXKw6B7BL7nehWV5fd+lVCLoxkmGFWMfkhYs35eHdvsnzTtVTBv3 nVUS9BqN06HNYjZ8p6oguyucHf2WWxM/LTcayV1HJvhgyT++WvhV5JVOyr32M+HuuX8x AiOlvD8uKoWhoSWK+F6td3hQirSwK4ErErVWP2dsORuXY768ysYRAtELNRyOIvmLBNlM QYfg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=uXvbj1RYdFStR8mOgmKx85W1SzZn5CdUbt0kPqVxu7U=; b=EFtPOQ7zCU7MJoqVdAE5Sw8NJC+h7p2IidnOJ13T9JDjHqMAYeNwPalJBV3ydK8ilN HKkbdYP5LDvKtdojcE6jdTmlRHRTRRftI6NQV1bkns5VOOqn5ErivtNnixZ1VZ1wjp0S R7d5nzWMRG5B3JGA9dmKNhIj6GEB66/HocSm3wYKOVLDTxTtdrJFKrD3BpR9xMwxtY6d xSB90Rx/iXke0legs9N0voej3XeVRhMxpG5X0TyIrC2C+Jb5c6ILPU5/NR7WXEaXppu3 MiX0dOGepPEz4t5x2fVeuQOCHjS1qrSLF9QXaW59+7e3grxEVrN7FEsI4ttHyB1mNDkc SuSw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=GPL5pcd4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q17si1393044edi.310.2021.10.05.08.23.52; Tue, 05 Oct 2021 08:24:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=GPL5pcd4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234416AbhJEPVI (ORCPT + 99 others); Tue, 5 Oct 2021 11:21:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57266 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229488AbhJEPVH (ORCPT ); Tue, 5 Oct 2021 11:21:07 -0400 Received: from mail-ed1-x529.google.com (mail-ed1-x529.google.com [IPv6:2a00:1450:4864:20::529]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8881DC061749 for ; Tue, 5 Oct 2021 08:19:16 -0700 (PDT) Received: by mail-ed1-x529.google.com with SMTP id v18so236296edc.11 for ; Tue, 05 Oct 2021 08:19:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=uXvbj1RYdFStR8mOgmKx85W1SzZn5CdUbt0kPqVxu7U=; b=GPL5pcd4au0pQkOdAj5r+sYOunLp6UQmEpcQ/49JUfIfltVmskiS2/jbeuPp0aAMnm x9EPY+9YI2ZdYSYqNLsd01wpWaSHSbyVleHVTGsTrzM0oaFy+ExmM4IUUSlSY1v7tXII B9dYh7FTmb5K14gbIy0mIdBuZspzKrQ5+8oe1F9T65PaVl1boqLAidmynvOW7Na9tlSg 7BShU7N3lwJjXfeyV6rAt0IAEQs7MrXWmPoLeXcVOOrTMvE/+NyC2gmmjHB4OZeHcaqt 2BQtsSMsShgsVVYxcygnepxH9ygmJsGeKJVozSBDFSaqfyvpfJvt65oz0RJUtHv3PGXI aCmw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=uXvbj1RYdFStR8mOgmKx85W1SzZn5CdUbt0kPqVxu7U=; b=3lrwTPnE733GLYwDTXVSJExV76zr0vMv9rYRmQARJcTsOEScG3ktvvXoVuk8CDazeQ 89lm+dKF/lbxCIAwgI8oFJEUKncTFM/G8WOX7wUWve2y/wEq5fevR/DgZfsGolSoKA7H d1UlpLCL/djW4rzGZ29QQPtPfmsoKMy0XKcSqEahLH1lcx/RIeCPGeoEDwHpy2G05Oj0 oIO3CtPYv6tFVmFO8UqwCdOKHUP2kjKOo5JTPLXBnwC6g78H8ZKsFBTFtvcGJMD29ejS 8LWdcl0QiTq26ZfaxVFZcjMb0+l0IElVAhNqHmn5zTYbpbbKKtgCsJ669+in+fYph200 bqKg== X-Gm-Message-State: AOAM5326ni0/jrVWn8vu0z3F/dRHKZ7aO2AL5P5yk75dUYI/BcOgQXEC 4HgyLDady86qG3u2GwJDO7w+9IErTcqVgwAQEguGBg== X-Received: by 2002:a50:cf87:: with SMTP id h7mr27483539edk.152.1633447154850; Tue, 05 Oct 2021 08:19:14 -0700 (PDT) MIME-Version: 1.0 References: <20211001181627.394921-1-bgeffon@google.com> In-Reply-To: From: Brian Geffon Date: Tue, 5 Oct 2021 11:18:38 -0400 Message-ID: Subject: Re: [PATCH] zram: Allow backing device to be assigned after init To: Minchan Kim Cc: Andrew Morton , Nitin Gupta , Sergey Senozhatsky , Jonathan Corbet , LKML , linux-doc@vger.kernel.org, linux-block@vger.kernel.org, Suleiman Souhlal , Jesse Barnes Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > On Mon, Oct 4, 2021 at 4:55 PM Minchan Kim wrote: > > > > On Mon, Oct 04, 2021 at 02:40:52PM -0400, Brian Geffon wrote: > > > On Mon, Oct 4, 2021 at 2:29 PM Minchan Kim wrote: > > > > > > > > On Fri, Oct 01, 2021 at 11:16:27AM -0700, Brian Geffon wrote: > > > > > There does not appear to be a technical reason to not > > > > > allow the zram backing device to be assigned after the > > > > > zram device is initialized. > > > > > > > > > > This change will allow for the backing device to be assigned > > > > > as long as no backing device is already assigned. In that > > > > > event backing_dev would return -EEXIST. > > > > > > > > > > Signed-off-by: Brian Geffon > > > > > --- > > > > > drivers/block/zram/zram_drv.c | 6 +++--- > > > > > 1 file changed, 3 insertions(+), 3 deletions(-) > > > > > > > > > > diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c > > > > > index fcaf2750f68f..12b4555ee079 100644 > > > > > --- a/drivers/block/zram/zram_drv.c > > > > > +++ b/drivers/block/zram/zram_drv.c > > > > > @@ -462,9 +462,9 @@ static ssize_t backing_dev_store(struct device *dev, > > > > > return -ENOMEM; > > > > > > > > > > down_write(&zram->init_lock); > > > > > - if (init_done(zram)) { > > > > > - pr_info("Can't setup backing device for initialized device\n"); > > > > > - err = -EBUSY; > > > > > + if (zram->backing_dev) { > > > > > + pr_info("Backing device is already assigned\n"); > > > > > + err = -EEXIST; > > > > > goto out; > > > > > > > > Hi Brian, > > > > > > > > > > Hi Minchan, > > > > > > > I am worry about the inconsistency with other interface of current zram > > > > set up. They were supposed to set it up before zram disksize setting > > > > because it makes code more simple/maintainalbe in that we don't need > > > > to check some feature on the fly. > > > > > > > > Let's think about when zram extends the writeback of incompressible > > > > page on demand. The write path will need the backing_dev under > > > > down_read(&zarm->init_lock) or other conditional variable to check > > > > whether the feature is enabled or not on the fly. > > > > > > I don't follow what you mean by that, writeback_store already holds > > > down_read(&zarm->init_lock). > > > > I should have explained a bit more. Sorry about that. > > I am thinking about a feature to deal with incompressible page. > > Let's have an example to handle incompressible page for that. > > > > zram_bvec_rw > > zram_bvec_write > > if (comp_len >= huge_class) > > zs_page_writeback > > down_read(&zram->init_lock) or some other way > > > > It's just idea for incompressible page but we might intorduce > > the way for other compresible pages, too at some condition. (sorry for the top post before) Hi Minchan, I guess the point I was trying to make was that so long as we allow a reset operation we'll need to be taking the init lock in read mode before doing any writeback. Does that seem right? Brian