Received: by 2002:a05:6358:111d:b0:dc:6189:e246 with SMTP id f29csp1788824rwi; Thu, 3 Nov 2022 09:05:14 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5goMtfWFxkULv3oBH964N2qn01gexz0fzQJL9fkP8jljuUedK0dnJOHnv9bG0YIXiCPNFP X-Received: by 2002:a17:907:2672:b0:780:8bb5:25a3 with SMTP id ci18-20020a170907267200b007808bb525a3mr30281940ejc.281.1667491514016; Thu, 03 Nov 2022 09:05:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667491514; cv=none; d=google.com; s=arc-20160816; b=O6h88P6dGihS1DEq2Chyppvfw3jxKh3lEInsBg3mJMQzh9xsb4HrLm0yRpMAKyHg7A vdtpwUxTGDTSXD6mkUAYM0cEkgO/QWvSec3D2BIazFU7yoTPmcp3PpMm+Yf8nzflyXZM eaEi9Kbw9SfMHUBR4iV8ki6Ik20487+7sXvFWs6ImJ85OhIinalpxKhW+ITW+WmeDxO2 6wa7B8+yRglDeERUWlim7k16NfaFR4ZR0h/o+dc8UsGoJ+eInfQ3NlBZ+oOHoG+xM27E sMGuo7wxAyI2y36x2Dr1YY1jsd520tH9Xfq61ayByLjFXYJkoroZ7KXoodGFg/Guui3W yyxg== 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=iefhXYcFca+HyMrTaCiWzQ24fHFIs/brIYiJSEqSUcQ=; b=UV27vfuwQL7ITYlvMGS65uMd/Ub7l9DBklrkrsRB5sYWZUr2BIuTTpWueoUCz/qEOA PwK4i9pUU46qx0pjrqXOkL2SV0SilT12twNLDTZKRWQhwPvjIU6p4Sd91Wj2V7Uismo+ Jrg48iEHiO7oEBekPXMJYyQ5In3tXvCqcNAfrDBOYrxVpqjK5m68EvhMOnziXX6j/etg F7hvyU1TA+jCzl52rGwPgrLui7I1/sKSllOJzoSGTXgalv5cP0s0mRdozIj14o3dHt13 Z1YBsGzhdxpqT/q9B7QgkBJfeWZJU6iXoe1XerTiOs9JNKX/jFVpS05jxTdbckr2Umov oscA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=mnEgPRYk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ss28-20020a170907c01c00b0079e925b0200si1497625ejc.59.2022.11.03.09.04.39; Thu, 03 Nov 2022 09:05:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=mnEgPRYk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232100AbiKCPxf (ORCPT + 97 others); Thu, 3 Nov 2022 11:53:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57600 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231770AbiKCPxd (ORCPT ); Thu, 3 Nov 2022 11:53:33 -0400 Received: from mail-pg1-x52d.google.com (mail-pg1-x52d.google.com [IPv6:2607:f8b0:4864:20::52d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8854D167DA for ; Thu, 3 Nov 2022 08:53:32 -0700 (PDT) Received: by mail-pg1-x52d.google.com with SMTP id s196so2032162pgs.3 for ; Thu, 03 Nov 2022 08:53:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:sender:from:to:cc:subject:date:message-id :reply-to; bh=iefhXYcFca+HyMrTaCiWzQ24fHFIs/brIYiJSEqSUcQ=; b=mnEgPRYk2PPB666Mwc6QMzwxTKX+rHctMioHYBKj2e0+U0kbTQLPG0Vk5U7nmSb9wV PISe2i9oNNIXplC90+WVjOWIs8l49/kPSfcN5II4Ot73q+9bAJawAHd55MYPSnkXs/qj FIRWz0djKi2SgpHLqSCp3pK9HC57ylPOzHGkWmSRlY6zO929FS1SFMnoj31Gdvi6PF9V JSPUHze4LGYGvzrfdncqMAS65bVQF/8vr7ji42neU0tBUIHYsKx7ATT+TXTyhdDxBW6g OIvvRJPvZqzRKqXvqCisKq8OrHP5H5/DI8tUlmMMR+ZE8FtbzYgWXqDHgm6CsU4OuH85 VXIQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:sender:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=iefhXYcFca+HyMrTaCiWzQ24fHFIs/brIYiJSEqSUcQ=; b=T1/SHSAjDqMDRdf55d4/koayv4KiaKaFIAOW3WF+7Cx0l2xtElhnG8vKSE6NkIiT0b ULDYL30Y1fYDzweGplZEgZO1RtsU5Wm01FhqsBcyWY309atEHytCYjiY80PpEV5btlUn C4sGeZvXkesgjROL76Cm25lhWLRdsB3lJuZ5ovKWGi3ev3qnbJd+b8dxOdLX1ZI+mdVl FnJ6lDQH0EfBbC5IbbzU1u8DCQm6WyCFwg7luLQeI3t8JrSrZ3qVYO28qJuIz6WqAHJ3 hwL8MNQ0aoqIoWXCiqExNFPFMuisahioHfjx+7u8jRPpShKzGWgxTWTAURmaDxPZtysw c//w== X-Gm-Message-State: ACrzQf0046LuXWdvWX7GRss15uZ1IWfVku+G3yoU32UhcLUlNIchcwQA bgwCkyv1l1KqFSwxLcnGU6ZFFi0+W8c= X-Received: by 2002:a63:e007:0:b0:46f:d715:3704 with SMTP id e7-20020a63e007000000b0046fd7153704mr15322741pgh.108.1667490811941; Thu, 03 Nov 2022 08:53:31 -0700 (PDT) Received: from google.com ([2620:15c:211:201:3d65:7dc2:c62a:5d98]) by smtp.gmail.com with ESMTPSA id k9-20020a17090a3cc900b00212d9a06edcsm125728pjd.42.2022.11.03.08.53.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Nov 2022 08:53:31 -0700 (PDT) Sender: Minchan Kim Date: Thu, 3 Nov 2022 08:53:29 -0700 From: Minchan Kim To: Johannes Weiner Cc: Sergey Senozhatsky , Nhat Pham , akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, ngupta@vflare.org, sjenning@redhat.com, ddstreet@ieee.org, vitaly.wool@konsulko.com Subject: Re: [PATCH 2/5] zsmalloc: Consolidate zs_pool's migrate_lock and size_class's locks Message-ID: References: <20221026200613.1031261-1-nphamcs@gmail.com> <20221026200613.1031261-3-nphamcs@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, FSL_HELO_FAKE,HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS 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 Thu, Nov 03, 2022 at 11:18:04AM -0400, Johannes Weiner wrote: > On Wed, Nov 02, 2022 at 02:36:35PM -0700, Minchan Kim wrote: > > On Wed, Nov 02, 2022 at 12:28:56PM +0900, Sergey Senozhatsky wrote: > > > On (22/10/26 13:06), Nhat Pham wrote: > > > > struct size_class { > > > > - spinlock_t lock; > > > > struct list_head fullness_list[NR_ZS_FULLNESS]; > > > > /* > > > > * Size of objects stored in this class. Must be multiple > > > > @@ -247,8 +245,7 @@ struct zs_pool { > > > > #ifdef CONFIG_COMPACTION > > > > struct work_struct free_work; > > > > #endif > > > > - /* protect page/zspage migration */ > > > > - rwlock_t migrate_lock; > > > > + spinlock_t lock; > > > > }; > > > > > > I'm not in love with this, to be honest. One big pool lock instead > > > of 255 per-class locks doesn't look attractive, as one big pool lock > > > is going to be hammered quite a lot when zram is used, e.g. as a regular > > > block device with a file system and is under heavy parallel writes/reads. > > TBH the class always struck me as an odd scope to split the lock. Lock > contention depends on how variable the compression rate is of the > hottest incoming data, which is unpredictable from a user POV. > > My understanding is that the primary usecase for zram is swapping, and > the pool lock is the same granularity as the swap locking. People uses the zram to store caching object files in build server. > > Regardless, we'll do some benchmarks with filesystems to understand > what a reasonable tradeoff would be between overhead and complexity. Thanks. > Do you have a particular one in mind? (I'm thinking journaled ones are > not of much interest, since their IO tends to be fairly serialized.) > > btrfs? I am not sure what FSes others are using but at least for me, just plain ext4. > > > I am also worry about that LRU stuff should be part of allocator > > instead of higher level. > > I'm sorry, but that's not a reasonable objection. > > These patches implement a core feature of being a zswap backend, using > standard LRU and locking techniques established by the other backends. > > I don't disagree that it would nicer if zswap had a strong abstraction > for backend pages and a generalized LRU. But that is major surgery on > a codebase of over 6,500 lines. It's not a reasonable ask to change > all that first before implementing a basic feature that's useful now. With same logic, folks added the LRU logic into their allocators without the effort considering moving the LRU into upper layer. And then trend is still going on since I have seen multiple times people are trying to add more allocators. So if it's not a reasonable ask to consier, we couldn't stop the trend in the end. > > I get that your main interest is zram, and so this feature isn't of > interest to you. But zram isn't the only user, nor is it the primary I am interest to the feature but my interest is more of general swap layer to manage the LRU so that it could support any hierarchy among swap devices, not only zswap.