Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp4984661rdb; Tue, 12 Dec 2023 15:40:12 -0800 (PST) X-Google-Smtp-Source: AGHT+IFymj0hjMHqcrGwfoGY/1x86doDsQCBJ9jiGDrJh1pGjs0dj8tNRUZL2LVcSBcylhcCJo30 X-Received: by 2002:a05:6a21:a5a0:b0:190:230:8ea1 with SMTP id gd32-20020a056a21a5a000b0019002308ea1mr9370080pzc.108.1702424411732; Tue, 12 Dec 2023 15:40:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702424411; cv=none; d=google.com; s=arc-20160816; b=Bi3w7L8tjuPYs6la2C4wVVhq9Q59XPbL9DbwOQUvVxFPjyiq90Bq2lMPafCzfKJPtL SNpatTbq7dR4KLlIBDqxjjv+/W5rgE56gI8k5C/yWt2+2sX1VWvedJ/MyzTsNyn6GIJf nONNHqIdi/vIa4YHqYh122G7q3jK9VFZk55Dpm7PiCgGX3V0/I6Sd7nGEsW+69YQoc1/ KmMJ5+zMMmWZ7yt/DPG1LEA8cab1UVkulIvUz5ASNo3p1e/c/ZE9/RZY6ftuQNShsU+3 ad/6kRUoXldSNMIgixK6Puc/047sitKLoK/yotK7enQUP05NK8VenRqMPhk7CKaA5iAV AZTQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=zXHQF7Ay6V2DwGSP7PW43cHZ4MHQlH5fsUBGMwcWepg=; fh=TnMRHiU8riM8OyC/eIPi+BXxpLIVA/ffHCdWKwQ8ySo=; b=BClz1zbc9fOxH0n75PbjymywM5KlSXrLXL9N/sj4bxXgcJCaa89Cr8U4wOEIjJqVVR vgXxfCObIl0BhrMBB6nELQ13KxIJEv7T5ZDGqN2S4TcrXei+ifYWCQPKc0DwvJzdUXKz aFgmGrPWfOLk9LUAYonsDsHKB49nvwjYwlqOiw2clu2tEB15RhW72UR2lSvhMv24/cai UE2Gcea9dGjhJDivp5Rg+Bvt5QK9UrpjEsOxwO+rRYbEqnuDbgzzNi6SrA8CrNsQg0Cb 8eiHL9h/Fc0Ol+cGFSiv+FULJkbJWGQi7OFCv7uXGfDYc52KSR/q4juMz9rUsu9PXmdO ROCg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ak1A7XbW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id o13-20020a65614d000000b00565f0e9cfbbsi8389069pgv.382.2023.12.12.15.40.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Dec 2023 15:40:11 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ak1A7XbW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 70B9680B81C4; Tue, 12 Dec 2023 15:40:10 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232486AbjLLXkB (ORCPT + 99 others); Tue, 12 Dec 2023 18:40:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50052 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231786AbjLLXj7 (ORCPT ); Tue, 12 Dec 2023 18:39:59 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 47C89A6 for ; Tue, 12 Dec 2023 15:40:06 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C632CC433C9 for ; Tue, 12 Dec 2023 23:40:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1702424405; bh=zXHQF7Ay6V2DwGSP7PW43cHZ4MHQlH5fsUBGMwcWepg=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=ak1A7XbWbA90dkwBKsEigjDs8hvO1EyeHLu5Za7bAtS9gSA3NVJncL8L8ZsonydYL mzisi+1P5FcOez/sAQ1LopGYS88NiYlk0WACaafRLr3RB0HqTwEMKx6t5AZZn0Kb7p BE+5ofqPFyd6p+Lx6pAnhHRkspJ+NCxmpy5Efg840lZyqe77XpE/g6bBqYrjDf994J F6HSNdnfjCrPb7kpbSUyDzgMuGfNFKqJSwVvXZFUzrLWPAIv4pQhj3wpkzKnHE4Aiu NM8K42QyOtFVd1YiX5P50tW8GBIZHfkmcyLNiYEMaHSE3DQJ6l0Gkh+ApjE1X4URw/ nEP6DwW0XuBFw== Received: by mail-pg1-f174.google.com with SMTP id 41be03b00d2f7-5c66e7eafabso5239365a12.0 for ; Tue, 12 Dec 2023 15:40:05 -0800 (PST) X-Gm-Message-State: AOJu0Yy7/laBxabHsIBNUNFULhzpQwcNl1m7uvlRfuFDh6Vo3lpyPhp/ CPDLfQYPFHrpx9Rbe8NB7x4lDrUPyzzbwJSUeqSnBA== X-Received: by 2002:a17:90a:510f:b0:28a:d858:b6ba with SMTP id t15-20020a17090a510f00b0028ad858b6bamr673250pjh.42.1702424385003; Tue, 12 Dec 2023 15:39:45 -0800 (PST) MIME-Version: 1.0 References: <20231207192406.3809579-1-nphamcs@gmail.com> In-Reply-To: From: Chris Li Date: Tue, 12 Dec 2023 15:39:33 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v6] zswap: memcontrol: implement zswap writeback disabling To: Kairui Song Cc: Nhat Pham , akpm@linux-foundation.org, tj@kernel.org, lizefan.x@bytedance.com, hannes@cmpxchg.org, cerasuolodomenico@gmail.com, yosryahmed@google.com, sjenning@redhat.com, ddstreet@ieee.org, vitaly.wool@konsulko.com, mhocko@kernel.org, roman.gushchin@linux.dev, shakeelb@google.com, muchun.song@linux.dev, hughd@google.com, corbet@lwn.net, konrad.wilk@oracle.com, senozhatsky@chromium.org, rppt@kernel.org, linux-mm@kvack.org, kernel-team@meta.com, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, david@ixit.cz, Minchan Kim , Zhongkun He Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Tue, 12 Dec 2023 15:40:10 -0800 (PST) Hi Kairui, Thanks for sharing the information on how you use swap. On Mon, Dec 11, 2023 at 1:31=E2=80=AFAM Kairui Song wrot= e: > > 2) As indicated by this discussion, Tencent has a usage case for SSD > > and hard disk swap as overflow. > > https://lore.kernel.org/linux-mm/20231119194740.94101-9-ryncsn@gmail.co= m/ > > +Kairui > > Yes, we are not using zswap. We are using ZRAM for swap since we have > many different varieties of workload instances, with a very flexible > storage setup. Some of them don't have the ability to set up a > swapfile. So we built a pack of kernel infrastructures based on ZRAM, > which so far worked pretty well. This is great. The usage case is actually much more than I expected. For example, I never thought of zram as a swap tier. Now you mention it. I am considering whether it makes sense to add zram to the memory.swap.tiers as well as zswap. > > The concern from some teams is that ZRAM (or zswap) can't always free > up memory so they may lead to higher risk of OOM compared to a > physical swap device, and they do have suitable devices for doing swap > on some of their machines. So a secondary swap support is very helpful > in case of memory usage peak. > > Besides this, another requirement is that different containers may > have different priority, some containers can tolerate high swap > overhead while some cannot, so swap tiering is useful for us in many > ways. > > And thanks to cloud infrastructure the disk setup could change from > time to time depending on workload requirements, so our requirement is > to support ZRAM (always) + SSD (optional) + HDD (also optional) as > swap backends, while not making things too complex to maintain. Just curious, do you use ZRAM + SSD + HDD all enabled? Do you ever consider moving data from ZRAM to SSD, or from SSD to HDD? If you do, I do see the possibility of having more general swap tiers support and sharing the shrinking code between tiers somehow. Granted there are many unanswered questions and a lot of infrastructure is lacking. Gathering requirements, weight in the priority of the quirement is the first step towards a possible solution. > Currently we have implemented a cgroup based ZRAM compression > algorithm control, per-cgroup ZRAM accounting and limit, and a > experimental kernel worker to migrate cold swap entry from high > priority device to low priority device at very small scale (lack of > basic mechanics to do this at large scale, however due to the low IOPS > of slow device and cold pages are rarely accessed, this wasn't too > much of a problem so far but kind of ugly). The rest of swapping (eg. > secondary swap when ZRAM if full) will depend on the kernel's native > ability. Thanks for confirming usage needs of per cgroup ZRAM enable and flushing between swap devices. I was hoping the swap.tiers can support some thing like that. > So far it works, not in the best form, need more patches to make it > work better (eg. the swapin/readahead patch I sent previously). Some > of our design may also need to change in the long term, and we also > want a well built interface and kernel mechanics to manage multi tier > swaps, I'm very willing to talk and collaborate on this. > Great. Let's continue this discussion in a new thread and start gathering some requirements and priorities from everyone one. The output of this discussion should be some one pager document listing the swap tiers requirement and rate the priorities between different requirements. Once we have that nail down, we can then discuss what are the incremental milestones to get there. I am very interested in this topic and willing to spend time on it as well. Chris