Received: by 2002:a05:6602:2086:0:0:0:0 with SMTP id a6csp4718176ioa; Wed, 27 Apr 2022 09:34:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxC5XZmI1NTBdLyH4Yqts8VNISf9QtBcO/jqCMJ4Qshg0mSrsD7xtooByv0ouMV6uRnLsZA X-Received: by 2002:a17:903:22c7:b0:15d:3359:ca4c with SMTP id y7-20020a17090322c700b0015d3359ca4cmr10482546plg.59.1651077273264; Wed, 27 Apr 2022 09:34:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651077273; cv=none; d=google.com; s=arc-20160816; b=kRBNSYp19Le/AsjaZinfHhmxxlyM4OzZKkEjxYjU2xg7uzlWkntS/6hG0lB/rqfv7X js/NfY5lnPFEy//fCcFHPF1BCKvlVmmpLFTREuNakYd6xy1ztv59ZYjv6r5eXL9A9aWG jDZ0l5/PdqbY+HE4qEZtBF9IegxYD7xgEAGiZVCgpss5ebHy3hAZJBDAv6jI7QFj2uRy NSej40X7XXdwjeMHmYztNdKzK6HVM9PlAFz3symSUqdNBVAq8nb2Qqe06RdcbR2zuE75 KLcD8Y18sOstVMUdjZkyTyJ5vWJeH49A27t12D7PT95PpEA0rlWoYS7RLjd6YECtcLPA LuAg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=9GL3COHv0leHgkc2xj8IFg2MOsyvROczlu9iqFQTi6c=; b=R8P1U53LqNcbWPuWekSmlboS/KAJdqXuUmkYyL2NeBO4ZDbJ0TT3yWmnzT+/s1lwrf k6go9ZrMONO0SXbNbFqFyWOFnFuZHOWq0DjRWbzHuLIGREZqvOsi0tM04ZUweOhoIzeU 7YYQm663yWYG+8lQA/TePp0x3hqN/RRQVxOIDK5KHP3BN0v7Bsk3KBwWIqmdJsIb5tlF RrDUrcMjE77LxnxhLjTCri+S+hFxkjUFWwgHFbGXP5R5ve7zb/YEnVjKG+qepMXcfDpj SGHyBT02ONySLB7X+iChd5sQ5U23PoG+Ew3L9DE0bnQGnYjzv9/Xl2nA88s0+ydAqHIs ZZeA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cmpxchg-org.20210112.gappssmtp.com header.s=20210112 header.b=EyNosu86; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id s14-20020a17090302ce00b001562e0ba125si1899217plk.504.2022.04.27.09.34.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Apr 2022 09:34:33 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@cmpxchg-org.20210112.gappssmtp.com header.s=20210112 header.b=EyNosu86; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=cmpxchg.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 0CFF03F6108; Wed, 27 Apr 2022 09:04:36 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241468AbiD0QG2 (ORCPT + 99 others); Wed, 27 Apr 2022 12:06:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36020 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242344AbiD0QEh (ORCPT ); Wed, 27 Apr 2022 12:04:37 -0400 Received: from mail-qk1-x72c.google.com (mail-qk1-x72c.google.com [IPv6:2607:f8b0:4864:20::72c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 603D936AF36 for ; Wed, 27 Apr 2022 09:01:14 -0700 (PDT) Received: by mail-qk1-x72c.google.com with SMTP id b189so1594738qkf.11 for ; Wed, 27 Apr 2022 09:01:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cmpxchg-org.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=9GL3COHv0leHgkc2xj8IFg2MOsyvROczlu9iqFQTi6c=; b=EyNosu86WZBzUC9jjE+BB/6+rRUePVNB5D6ZLweYK0cFIUWcYSagiZotbV3kGhvIlS aSvmf4EfGitZgrEkXNDGgBgiz1HC8zvbqhEgPDUnOPd4hguA+FT8asyo6S3j5oDYIoGo 8i8blQjc96SokqKzFW3yhgqj9t2hCvOPMNnicEa5sb4XEiaLxO8ipgY23jPrzflTCMCj e/QXaswu/EhhZnxUl3ooWdUkmRJ2DPmY42IUXuA03tcMHr/j8BJn49Zny7U2+x5RZUMc 5GK7mdC+N0Gj6dvbpJN0oMAU2pAmBPbv0TW1TyQBbPT7Db08uuswrZhBl7kJzgp+QWcy Qw3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=9GL3COHv0leHgkc2xj8IFg2MOsyvROczlu9iqFQTi6c=; b=OXTHtAzyg6f7nPaVxIxISU+2EAJQzwnf1x14Go2gmoCS+jU0ngCQOlTqwaw/4l/iGg SmIiST1tTyWqHk6aPNKSz8ohbg6LvagAyCbuQBYajjUa5YnM0KB9F2k10CHpvVHs1VOi hdtbbrW0AFOfZZMAHwPJmixE+0P+04wZi3QSP0xGPP/OVPBmzACtKj4vjH60gwY8Pd56 +dzUBwn1yM7VzO6XhysWWA9HESmVvTW9aXmvX+++61PxojS8qeCo+4jK27uxvn4gZyCg /lpFA4nG+eAfpXAZMvMnFYQ2fMh2pcHqJuXnlIHz3PSY8M96dstj8EevWLP0GSOHGVnP 5tRQ== X-Gm-Message-State: AOAM532Zhtd4JuqdG64KDX1CJj1a3yRt3aAnKkThApwnJcIz/8xkleLt 0c35PlP3c/mMwjFTOjKICJbIMg== X-Received: by 2002:a05:620a:404f:b0:69f:1160:73e6 with SMTP id i15-20020a05620a404f00b0069f116073e6mr16720445qko.690.1651075256344; Wed, 27 Apr 2022 09:00:56 -0700 (PDT) Received: from localhost ([2620:10d:c091:480::1:f617]) by smtp.gmail.com with ESMTPSA id v67-20020a376146000000b0069ec181a0c6sm8304072qkb.10.2022.04.27.09.00.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Apr 2022 09:00:56 -0700 (PDT) From: Johannes Weiner To: Andrew Morton Cc: Michal Hocko , Roman Gushchin , Shakeel Butt , Seth Jennings , Dan Streetman , linux-mm@kvack.org, cgroups@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-team@fb.com Subject: [PATCH 0/5] zswap: cgroup accounting & control Date: Wed, 27 Apr 2022 12:00:11 -0400 Message-Id: <20220427160016.144237-1-hannes@cmpxchg.org> X-Mailer: git-send-email 2.35.3 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE 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 Zswap backing memory is currently not tracked (and limited) on a per-cgroup basis. As a result, workloads can escape their memory containment and cause resource priority inversions on a shared host. E.g. a lo-pri group fills the global zswap pool and forces a hi-pri group out to disk. Also, zswap doesn't benefit all workloads equally. Some even suffer when memory contents compress poorly, and are better off going to disk swap directly. On a host with mixed workloads, it's currently not possible to enable zswap for one workload but not for the other. This series implements missing cgroup awareness and control for zswap to address both issues. More details on interface and implementation in patch 5. Patches 1-3 clean up related and adjacent options in Kconfig. Not dependencies, just things I noticed during development. Based on v5.18-rc4-mmots-2022-04-26-19-34-5-g5e1fdb02de7a. Documentation/admin-guide/cgroup-v2.rst | 21 ++ drivers/block/zram/Kconfig | 3 +- fs/proc/meminfo.c | 7 + include/linux/memcontrol.h | 54 +++ include/linux/swap.h | 5 + include/linux/vm_event_item.h | 4 + init/Kconfig | 123 ------- mm/Kconfig | 523 +++++++++++++++++++----------- mm/memcontrol.c | 196 ++++++++++- mm/vmstat.c | 4 + mm/zswap.c | 50 ++- 11 files changed, 648 insertions(+), 342 deletions(-)