From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0DBA0C433FE for ; Thu, 3 Nov 2022 20:37:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 28CB26B0072; Thu, 3 Nov 2022 16:37:10 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1EF486B0073; Thu, 3 Nov 2022 16:37:10 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 067F36B0074; Thu, 3 Nov 2022 16:37:09 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id E57F96B0072 for ; Thu, 3 Nov 2022 16:37:09 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id B78A21213D1 for ; Thu, 3 Nov 2022 20:37:09 +0000 (UTC) X-FDA: 80093290578.02.45D1C9C Received: from mail-pl1-f178.google.com (mail-pl1-f178.google.com [209.85.214.178]) by imf15.hostedemail.com (Postfix) with ESMTP id 4F79CA0005 for ; Thu, 3 Nov 2022 20:37:09 +0000 (UTC) Received: by mail-pl1-f178.google.com with SMTP id j12so3037835plj.5 for ; Thu, 03 Nov 2022 13:37:09 -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=t3rQUgLm8fBWl2kuinK6VEZwttob14gVREydxcGaYLE=; b=n7dpLZsp9QsfpKft5JtDmRudTBmPlymTDKtL73g/Z6i+84E2LG0wmnkG0F2xD57aAo 6siPmc4STIiGlRb31n6Urifgom7bAEVJkGL2v8WLvGEZ9qjqsmKJbQtWXNZMN0C3KlbU HxAOgYoLImlAWdg3/tbTPObFlHXwrZ0SRCH73s0rt/9O9mbV1sctwKs3pmtz9JrG2hlX sSfvjqWbSRauteqg1h5pRkrSfu8+XbQvoxLspG4M10LqaHg//ODoj7l0T62JlI+xbI/q EVeS9nBZAgxuWHiEqvtcfXDf9QImghEaA6JNaO2AIbQG9aYKkqCUEcvKDlxGX2NG9aOT JPIg== 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=t3rQUgLm8fBWl2kuinK6VEZwttob14gVREydxcGaYLE=; b=cgLi/Lx85gfj24TVcEg3nIAokiSXygm9dcUOCBPwYrmfTlD4z6FU3Nz4osP7O+GieH s61mYW0MnbIMDd4vMKqikH3l4csrkodM46WuEmSTqS/4DExQFAacr0QcqWz31jJFZsLm tF8+Yz9Vf97Gz2mh8AiHBt96B9F88VRVcm9OnOhTSa6yPZc196zMm1oU4R/L7SsaVmqb BePtv6aMgbDz48Xxt5vCAZ1POOaEuKbv5qYd5LRNdRCvD06cf34576jdBqs0fUtHca07 rlNGsBuqguH7lSUR3YFyyOcaZEkKkPtrZYbHBGAy9WDwH62PrBlkVujYFi6aIU82Fx0d XFyA== X-Gm-Message-State: ACrzQf3VusmncqiZ8w59pK2iTwj2z31nrMIc6xTjcOi9gKNwUD/fhhy5 eeBYGZXsuf+x2UncRSr6+0w= X-Google-Smtp-Source: AMsMyM4oez8H1wGMXberIcFEq6joXWDqvXDYVvoLDsMSLZ2Fh7IY2ZQKV6MT7qcYmZP+MVWM+DNVLw== X-Received: by 2002:a17:902:ef47:b0:179:d18e:4262 with SMTP id e7-20020a170902ef4700b00179d18e4262mr31259428plx.22.1667507828142; Thu, 03 Nov 2022 13:37:08 -0700 (PDT) Received: from google.com ([2620:15c:211:201:3d65:7dc2:c62a:5d98]) by smtp.gmail.com with ESMTPSA id ep6-20020a17090ae64600b0020de216d0f7sm413754pjb.18.2022.11.03.13.37.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Nov 2022 13:37:07 -0700 (PDT) Date: Thu, 3 Nov 2022 13:37:05 -0700 From: Minchan Kim To: Yosry Ahmed Cc: Johannes Weiner , 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: ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1667507829; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=t3rQUgLm8fBWl2kuinK6VEZwttob14gVREydxcGaYLE=; b=JKNaOKzspa1f+j20kxGHaIdE0IDZCbqeZ6cHy/aWjMrusBBIhD8rFRfv9+OZb/wpDf8R8j NU8j9CwsYiZOX6h9MnkCUc2ijw/ouErJi5wdmDw57KFDt4WVmcmWmdIF+W3HCA3AXWOqZy TAKSM6m/T38og6SUZymS/WY5iWwZL/0= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=n7dpLZsp; spf=pass (imf15.hostedemail.com: domain of minchan.kim@gmail.com designates 209.85.214.178 as permitted sender) smtp.mailfrom=minchan.kim@gmail.com; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=kernel.org (policy=none) ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1667507829; a=rsa-sha256; cv=none; b=ZCgpsFRRXe/vWA6PLl7rfeVTrkQsSIFVWPkHWMKvgZTu0zzc4PkE+cHNqhNOfHQwMz6k/i KIvNoJ6sB/YVKNT/kigDs+MlXvKrqaklHUpNfymIVbZwiJwbmqSFm1nh4OzxOw69Chf3fx yPgaXPPOSEySXY53Utv9d6D7d3DVDxY= X-Rspam-User: X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 4F79CA0005 Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=n7dpLZsp; spf=pass (imf15.hostedemail.com: domain of minchan.kim@gmail.com designates 209.85.214.178 as permitted sender) smtp.mailfrom=minchan.kim@gmail.com; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=kernel.org (policy=none) X-Stat-Signature: reatgctc7jzhay5i99qrfnrzbkzm3ewk X-HE-Tag: 1667507829-526253 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Thu, Nov 03, 2022 at 11:10:47AM -0700, Yosry Ahmed wrote: < snip > > > > > > 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. > > > > So there is actually an ongoing effort to do that. Yosry and I have > > spent quite some time on coming up with an LRU design that's > > independent from compression policy over email and at Plumbers. > > > > My concern is more about the order of doing things: > > > > 1. The missing writeback support is a gaping hole in zsmalloc, which > > affects production systems. A generalized LRU list is a good idea, > > but it's a huge task that from a user pov really is not > > critical. Even from a kernel dev / maintainer POV, there are bigger > > fish to fry in the zswap code base and the backends than this. > > > > 2. Refactoring existing functionality is much easier than writing > > generalized code that simultaneously enables new behavior. zsmalloc > > is the most complex of our backends. To make its LRU writeback work > > we had to patch zswap's ->map ordering to accomodate it, e.g. Such > > tricky changes are easier to make and test incrementally. > > > > The generalized LRU project will hugely benefit from already having > > a proven writeback implementation in zsmalloc, because then all the > > requirements in zswap and zsmalloc will be in black and white. > > > > > > 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. > > > > I think we're on the same page about the longer term goals. > > > > Yeah. As Johannes said, I was also recently looking into this. This > can also help solve other problems than consolidating implementations. > Currently if zswap rejects a page, it goes into swap, which is > more-or-less a violation of page LRUs since hotter pages that are more > recently reclaimed end up in swap (slow), while colder pages that were > reclaimed before are in zswap. Having a separate layer managing the > LRU of swap pages can also make sure this doesn't happen. True. > > More broadly, making zswap a separate layer from swap enables other > improvements such as using zswap regardless of the presence of a > backend swapfile and not consuming space in swapfiles if a page is in > zswap. Of course, this is a much larger surgery. If we could decouple the LRU writeback from zswap and supports compression without backing swapfile, sounds like becoming more of zram. ;-) > > I am intending to spend more time looking further into this, but other > things keep popping up :) Same with me. Thanks for looking it, Yosry!