Received: by 2002:a05:6358:111d:b0:dc:6189:e246 with SMTP id f29csp1783759rwi; Thu, 3 Nov 2022 09:02:40 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7o5O61bwi0fZW5PQAxeRH/1t6ItcxCsN+FBdYtI33hf0/vRFv/NrQxXEiWXx0spxdXQ1Rv X-Received: by 2002:a17:907:7203:b0:7a5:b062:2338 with SMTP id dr3-20020a170907720300b007a5b0622338mr30441787ejc.8.1667491359868; Thu, 03 Nov 2022 09:02:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667491359; cv=none; d=google.com; s=arc-20160816; b=aVIU6/Eu6xZRpPtUNPSEqJnAxBLKJ7w9VJn79N0w5RpjdJrZjx+GlZdq4A/ySWh3bA G+fP2qx4CUc/qgmxhWpTRtHlklIBZU6bQSo5p5vTs2q8ow2YNgYAcN6g4yLiYNJhIyXt Bz+zUm/Ua3TXxLFaIT5YJ0lP8gR/8jkIBjYuwBHX/gJW/dfmcirdURVLqoxE78ir32pK QzVGYaQRzEY/09HpAUZxshwjZ5Z0Rn1T7/Riyksnbq49J1PNcHBwWnxpp7EECYFlBV8k IpOfAnSOzitCRTdUJ+Ni5SYc1ZT30W4tek3YUreGEGB3Ufy0peKQpXMJ68d8JyAUZayO usfA== 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:dkim-signature; bh=1Y91EMmWkKaDNLHulFaIVLlw/0EjJtCCjHihzz5PhWk=; b=sSpOBrpfHTTrYMYiF8W1VItmdw5Sfuv0v/sJXPnvHu3OFHGt3EEZfGfdXB/uLW47e6 D2foMvg8vvRPiuFY7Xb3AuBYT41pRPJ2zJXg7DlQx6di/KSbafETn3ODO4f0R+ysAXDL jnQWsgzKDzViExGA9qtQpTA5F12i0y2PrpXLtSyDlIa/1PMElh8u00WHbCS7SXAIXMsJ 4U4hC8UHchrcw2a2LPQrejLJOL2tBpbYP5liCKdMIuE6GuQlsCzksnYnrkFuLy3cSnKB WCf/Pn7AdPsjrnZ2/Zcxku0OoUqYn/ZdThWZOsb602AjMYWBibXjSBggIAQGi7Ti7tGr 8QXw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cmpxchg-org.20210112.gappssmtp.com header.s=20210112 header.b=PccX6Qji; 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=fail (p=NONE sp=NONE dis=NONE) header.from=cmpxchg.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id fy2-20020a1709069f0200b0078d4a0c77f9si1384739ejc.458.2022.11.03.09.02.04; Thu, 03 Nov 2022 09:02:39 -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=@cmpxchg-org.20210112.gappssmtp.com header.s=20210112 header.b=PccX6Qji; 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=fail (p=NONE sp=NONE dis=NONE) header.from=cmpxchg.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231996AbiKCPSE (ORCPT + 98 others); Thu, 3 Nov 2022 11:18:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58360 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230377AbiKCPSD (ORCPT ); Thu, 3 Nov 2022 11:18:03 -0400 Received: from mail-qv1-xf29.google.com (mail-qv1-xf29.google.com [IPv6:2607:f8b0:4864:20::f29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B8D731759F for ; Thu, 3 Nov 2022 08:18:02 -0700 (PDT) Received: by mail-qv1-xf29.google.com with SMTP id i12so1335901qvs.2 for ; Thu, 03 Nov 2022 08:18:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cmpxchg-org.20210112.gappssmtp.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=1Y91EMmWkKaDNLHulFaIVLlw/0EjJtCCjHihzz5PhWk=; b=PccX6QjizeOvlnpoTObOI84VoFlp0uZB37fB7rBt93+yxAolIIErLnWuBNu4i0hxwg dPVH6YwiBblIu/66nxf0sR77eazM57ZGbKjYGBmrS4mRy3K3NaTeWNq+c0aptUG/DjDD DyqUVvJIRrE/Ag34h5nuo6Ra/NFHTK730c1F7k2HlhR1NUZWflyGwtN2ciIT1kSS5VaJ l5OyLyfUqPVv0dEaBAF4/cPhru2PuwuMxMknIKL7k+SN4uvNRVG8Po0/N2cHlC0IDxWO Dr8ZqnSY5fryvhMDwPsW/P3OPvQ+jXM5EKNUnmno5pgAElKzQx4TzFUtVa9efERk/5+J MKwg== 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:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=1Y91EMmWkKaDNLHulFaIVLlw/0EjJtCCjHihzz5PhWk=; b=fbWqHaFRHThfiOo0qRkVYVgdWSaYTQMCiISQBuS/6ycJoJF4IwuVSfCgqGF6kT0Ips nXHpAv+oDsS1IEKSkMswaa3pEXwEfg6n4B50EU6dNpXyDreI6+ndHGbdYdLt3XIK3PIc rhvajgdF1driTSuN8k6dg1riU4Ls4wpOoADdB5PtYEZ4J2wKnAMKlAzFqLLqTf3iO0Iu +aL1VAMAaT9JXAM/9rmQOsAUpNQhI2GChYezIwNiyyHd1i7scER2j2BizAfaCRe+Q2TT TcRV8fpIKsOrYE9IMDwlmIuWfoyAsunNMr3dyDebJGpbU/RRWi+o8lUNkOcIoDORO+f/ cdzQ== X-Gm-Message-State: ACrzQf1GncV3IIRTjJI99Vekoa+/81dCQqYPQshamCyi3M7G8cT3xNRl MmCO5gy4iark56HXBZVu7yS2XQ== X-Received: by 2002:a05:6214:3016:b0:4bb:9e66:1100 with SMTP id ke22-20020a056214301600b004bb9e661100mr27182644qvb.23.1667488681877; Thu, 03 Nov 2022 08:18:01 -0700 (PDT) Received: from localhost ([2620:10d:c091:480::25f1]) by smtp.gmail.com with ESMTPSA id bk14-20020a05620a1a0e00b006f3e6933bacsm881844qkb.113.2022.11.03.08.18.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Nov 2022 08:18:01 -0700 (PDT) Date: Thu, 3 Nov 2022 11:18:04 -0400 From: Johannes Weiner To: Minchan Kim 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.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS 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 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. Regardless, we'll do some benchmarks with filesystems to understand what a reasonable tradeoff would be between overhead and complexity. 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 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. 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 user, of zsmalloc.