From patchwork Fri Jul 7 04:46:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhongkun He X-Patchwork-Id: 13304387 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 76A32EB64DA for ; Fri, 7 Jul 2023 04:46:47 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E9DA98D0005; Fri, 7 Jul 2023 00:46:46 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E4B8E8D0001; Fri, 7 Jul 2023 00:46:46 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D3B308D0005; Fri, 7 Jul 2023 00:46:46 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id C538B8D0001 for ; Fri, 7 Jul 2023 00:46:46 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 790D3140507 for ; Fri, 7 Jul 2023 04:46:46 +0000 (UTC) X-FDA: 80983580412.22.512B1BF Received: from mail-pf1-f169.google.com (mail-pf1-f169.google.com [209.85.210.169]) by imf16.hostedemail.com (Postfix) with ESMTP id C6BF618000F for ; Fri, 7 Jul 2023 04:46:43 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=cYoFrKnX; dmarc=pass (policy=quarantine) header.from=bytedance.com; spf=pass (imf16.hostedemail.com: domain of hezhongkun.hzk@bytedance.com designates 209.85.210.169 as permitted sender) smtp.mailfrom=hezhongkun.hzk@bytedance.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1688705204; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:references:dkim-signature; bh=+8KrRjriTlWtsSChPn/s5oP2eGKo7GVW4eTsZHk6Ir8=; b=O/ULVzvl/ZGUGWXmrV1IYQCrGhGhEFGyWljg3zWl08t2Ml62gFNejyodVUf9FA0bCpkKvk nkJ+0WNcB1C/G4IZ1U3C26ugjULKsrk8JHieOd75OYG0A5qGNqo6OEXF4AV7pK4WE/Yhix 2mVDkORg6CF/i5RIh+/GY2bGAq/ZwP8= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=cYoFrKnX; dmarc=pass (policy=quarantine) header.from=bytedance.com; spf=pass (imf16.hostedemail.com: domain of hezhongkun.hzk@bytedance.com designates 209.85.210.169 as permitted sender) smtp.mailfrom=hezhongkun.hzk@bytedance.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1688705204; a=rsa-sha256; cv=none; b=etyMxnLYtldKh1bOyr687kGRRlcsrGsr0ciQzZitTg4ReR7nodmNaHq7xU9mPPQb5K0Mga BOkpuFGVYfpBhl2gUlv0oTx2fQUFSDcGJCm3jojrVrJl3FF5ryJPWE8abc/3i82o/m9gPx +cXDIc5sTTArHLfBnh+QyZ/CLLjdYMI= Received: by mail-pf1-f169.google.com with SMTP id d2e1a72fcca58-66767d628e2so1143362b3a.2 for ; Thu, 06 Jul 2023 21:46:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1688705202; x=1691297202; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=+8KrRjriTlWtsSChPn/s5oP2eGKo7GVW4eTsZHk6Ir8=; b=cYoFrKnXiO+tDsFSsK1B1T1ZBRIT6BcP5+RMU9iiBwFEGpc/P6Ii4QVhDvxiK+kjEZ coApwrD87wyCH9lFoZItavQ3uWqGeqH4QqyVfeidIHdjpHY9YRzocmCPt4Mlje6+Lug7 KQXhMElZZn+AJeJRlLG/4oV7peNLjlRFC97krGhJK+ncxy9nFt+h9GAJ1kr/TA4knJJ0 QVg61Ye2jktdt+i9ZOjFhRJBNrMGUjyW9Xi+0MWAyotjd1k5c9Hut0pCQGJ1dt9i7c8q mdl6JRCWnNIcTM+CDDujnsyn3Y0/yUQMkQUPAjDWnD7ofmwBKkSL8KseMbhfCYFkYR+e 3HTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688705202; x=1691297202; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=+8KrRjriTlWtsSChPn/s5oP2eGKo7GVW4eTsZHk6Ir8=; b=EV6RSf34EAk1N+mTRK39k0JUpMHP2vKKOv1YMuwkeJR26Qt7QpBlfF2Aaw5w9q9470 gENbLoIVvKEzbdj2XY1x2ZieCzC0L3YEFdEdI33NWVpRkyHOZEdpWI+UVUBLlxqEdWzQ aQFp+owK+bAI23yyxSIzCw9FfCncPQ8Q8feL3IqzL1jb+XCo2xPJwxBR10bGGGaPz255 FzKbdu34BOw6nfATHgKqytXY6oTrzZDIks+1v2+mPWu401Uom5OxQ5GvsGoOa7rCnzP5 XNXHJLG9pGG9NmjWXQm361xMtT1z0VfvtN4/zwiQMusgry+vFk53lr/dR4nXCLQY0EUZ GntA== X-Gm-Message-State: ABy/qLZrOBFSdK64LouINeqvaTVtggpEBeCB0eVE/fAUyX4O2gDSUgQc Tf20ifIAYlKuj94HUAAQcByDLA== X-Google-Smtp-Source: APBJJlE+46zk9//AWNid+YikU2na+nPHt/wQKFs/Qk3UE1jZtuou5ZQg0EjDa9LUwhKDJ5lyTcwYfA== X-Received: by 2002:a05:6a00:228a:b0:64d:1c59:6767 with SMTP id f10-20020a056a00228a00b0064d1c596767mr3699062pfe.24.1688705202320; Thu, 06 Jul 2023 21:46:42 -0700 (PDT) Received: from Tower.bytedance.net ([203.208.167.147]) by smtp.gmail.com with ESMTPSA id x53-20020a056a000bf500b0064d32771fa8sm2027315pfu.134.2023.07.06.21.46.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Jul 2023 21:46:41 -0700 (PDT) From: Zhongkun He To: minchan@kernel.org, senozhatsky@chromium.org, mhocko@suse.com Cc: david@redhat.com, yosryahmed@google.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Zhongkun He Subject: [RFC PATCH 0/2] zram: objects charge to mem_cgroup Date: Fri, 7 Jul 2023 12:46:13 +0800 Message-Id: <20230707044613.1169103-1-hezhongkun.hzk@bytedance.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Rspamd-Queue-Id: C6BF618000F X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: qdubruu1k5wi76g3y4bppwyg5qm9irzt X-HE-Tag: 1688705203-465657 X-HE-Meta: U2FsdGVkX1+1cp6n89vRwQvKmL8BNWdiLOzSZxrr/OiJjzZEI/rGK5aONt6ZHL8scRN7nB8iRF8xSWlgPZVmlBvglm1mno31PnCZ6ijZXbv4UZdM5HgXXe8hsWFo5CsK3WfqONhEVR3U0iV6cbsw4y/VIG0PWHZCUOZDNDB1/JiyqFBvOWLh0ojvBZOgAOU0lUbb2xghBnBHlGpLsC34tjZzjn6N9sdTouyG4r4FaNo1d23VY/jA3GDinUQdmSlNl32kC21Q5tNqrZ9t05t4g1sd1JtV19i8TrvExpy5aoeGYOHnWVHail2Gq+JOWhwIvbbjqntAaY8UyKd27MnQmHeFOI2bBF9HHswl29g0qtzIB96QUjwXfluWPQk5Jgi2xWZlPjSpi+041zIRMWeh6186WihTTrvWlGXk9ZeA8bept551BSbuU2MwbYsIBPW2I4AHPUZUh/hSoK3lKwyS8+gTa8s42kZ58Uwf8B31ll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sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: This is a new solution to charge ZRAM objects,more simple than previous one[1],The compressed RAM is currently charged to kernel,not to any memory cgroup. As we know, zram can be used in two ways, direct and indirect, this patchset can charge memory in both cases. Direct zram usage by process within a cgroup will fail to charge if there is no memory. Indirect zram usage by process within a cgroup via swap in PF_MEMALLOC context, will charge successfully. [1] https://lore.kernel.org/all/20230615034830.1361853-1-hezhongkun.hzk@bytedance.com/ Zhongkun He (2): memcg: Add support for zram object charge zram: charge the compressed RAM to the page's memcgroup drivers/block/zram/zram_drv.c | 43 +++++++++++++++++++++++++++++++++++ drivers/block/zram/zram_drv.h | 1 + include/linux/memcontrol.h | 10 ++++++++ mm/memcontrol.c | 23 +++++++++++++++++++ 4 files changed, 77 insertions(+)