Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp35111991rwd; Mon, 10 Jul 2023 02:45:15 -0700 (PDT) X-Google-Smtp-Source: APBJJlEfqyBPjbQKNieqSHqFHnrWAe0o0efG/sdGVfvuV/YxroYl8zWBN1t20rYKkd54vUBMJ5st X-Received: by 2002:a17:90a:e996:b0:260:fe48:491f with SMTP id v22-20020a17090ae99600b00260fe48491fmr9372538pjy.45.1688982314971; Mon, 10 Jul 2023 02:45:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688982314; cv=none; d=google.com; s=arc-20160816; b=GA+KCv100JdVtNMPAW8dq8IW8Y3nKPBxGEdSVERuiEswmfmIrEeVYX9GdWLCGfr8uh X5yYQ5cepc2bB8iPxd7jbkb9+UebtcWOI9hvrZJWzF4BZN0H7dpC3QyNVySUhuCxs7+v wSFPfI19fa36XsledBJC3BjkV7E1Vl1mDj1c2GcTQxaChxj3Ofsv+mli9BxUZ/Iz8YNu 0MRTuNjj6CjBUBJSHjdRphxoTsEuoePKlDJFggbjq4RQeCm+iWe5GhWkqt+mwAlBlDZD 5hdhX8W9VIcj3wkJbyCulohBCis/ifj7DJWlZwi0rh49ZqrymhScn6SDJQqdepp5J7ei /SBQ== 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=n8cUDQW2Wt1AG6yqZ6YmxY8FJixhGQFCyAPOkkh57CY=; fh=h0kQsJhtYA3Q8xmJZmrfszQqSQU8m9TBo5AopfUYmPQ=; b=BAh1Gj81Nf3RpcAoRNy9Q/dTXfjkRyGb5z6+08hmMb35DJUz5EBzLxAMZUbsjenjod ihUwZzY++NafpKQnJHMtgd6iGAkAjG+ggZJG/kvO0sXJ8C4jsUEhr1cJZM0pSVCGrnVb fqnAPVwlo5ZxJLz6QBl41dc1ikYIbo21TUg0WvANDtz55i9qY57TZ9e/Fl7nzjeYI7Rv 75Cc1bXmqkyznbCBRTqM+iNpgdA2hj75y1cxhY7S3/1VsanoY7+soyajrB8Sm6Psw2gz JbuWWRKmChy39QeaaF4PDJejy+oQu47eDfasPW/8mdhlxUqUYvMrICn1H7QKj28BmIMf QB4w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=iimXhKYp; 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=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q91-20020a17090a756400b002532c9b252asi6821628pjk.73.2023.07.10.02.45.03; Mon, 10 Jul 2023 02:45:14 -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=@bytedance.com header.s=google header.b=iimXhKYp; 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=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231493AbjGJJiR (ORCPT + 99 others); Mon, 10 Jul 2023 05:38:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54304 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232678AbjGJJhf (ORCPT ); Mon, 10 Jul 2023 05:37:35 -0400 Received: from mail-oa1-x29.google.com (mail-oa1-x29.google.com [IPv6:2001:4860:4864:20::29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 26E442128 for ; Mon, 10 Jul 2023 02:35:20 -0700 (PDT) Received: by mail-oa1-x29.google.com with SMTP id 586e51a60fabf-1b06777596cso3713312fac.2 for ; Mon, 10 Jul 2023 02:35:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1688981719; x=1691573719; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=n8cUDQW2Wt1AG6yqZ6YmxY8FJixhGQFCyAPOkkh57CY=; b=iimXhKYpBw1g4ac9eGc3nJen/n2A8NgPXrXgsxRPJ1RlsxtNZnuwgxZUE77/6K1AnE crPiCiKpc+kq7i9me7Wkh/ZJe3+qh8sRUVHsLMDjS8Z3xYixN7DXf8q2OINo5ZqhhRQj 4b/nkAHMYm1uhsYLY8b13HBvYGEz9LlwnKEZaUm+nMTH4pTjrYv/CUSFtTqNb/TXWbSO GTZKUoSZVVe3axHra6Nc62xEtGzUKg2NByK9iR+4mHtTH4brQmDv8CA9ErLj1atGz5oE i8ePuuNa1f6hqn1i8qVFG2Lcsq+jAwyQSMNrIB1IpkhsV3Ong7I2Cbv6SMRB2+J248Vp j8Ig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688981719; x=1691573719; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=n8cUDQW2Wt1AG6yqZ6YmxY8FJixhGQFCyAPOkkh57CY=; b=gBkVuYc3AltUGqSj3MArkdyFhsOTg1UxRClYfBh3m29//j2V70JjZS6XsxkZ9lkJfu KR2TVp1gm/CtbcNkTfnQLTtjNd3K6FCmq9yfHMkxJKD2HNbFzZoR0ILo2ZN8KKDShU5k vlXOCS7g3/Vu3B//YWiBaDSfDzpM0EKMf0XRtg1Bsg7B1ScCUX7u9/RemGN7qMMXD9Me bdFO7IzWFhwfC2VIijxw77lVWbZGtdNoN8O8O9QHrkleubRjubL9y7eR6XkVeZxMqz3U lMZKbO6rzWxQqLMlfatQihhEbK/DRweoEFZ893O0dTMYJzDZ3xXIT2rzCB8C55EFHPPp UZNA== X-Gm-Message-State: ABy/qLZIPET65sJp+r6xhL5cTExG9rHHIVfp6izFUuaFnt2GPwtycPTW ozlGFp1qjPrAp+jfkbH3MP44IS4tyY/YNOL3fwz33A== X-Received: by 2002:a05:6870:f698:b0:1b0:3a5a:4039 with SMTP id el24-20020a056870f69800b001b03a5a4039mr11287379oab.56.1688981719290; Mon, 10 Jul 2023 02:35:19 -0700 (PDT) MIME-Version: 1.0 References: <20230707044613.1169103-1-hezhongkun.hzk@bytedance.com> In-Reply-To: From: =?UTF-8?B?6LS65Lit5Z2k?= Date: Mon, 10 Jul 2023 17:35:07 +0800 Message-ID: Subject: Re: [External] Re: [RFC PATCH 0/2] zram: objects charge to mem_cgroup To: Michal Hocko Cc: minchan@kernel.org, senozhatsky@chromium.org, david@redhat.com, yosryahmed@google.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org 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,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 On Fri, Jul 7, 2023 at 10:44=E2=80=AFPM Michal Hocko wrot= e: > > Why do we want/need that? Applications can currently escape their cgroup memory containment when zram is enabled regardless of indirect(swapfile) or direct usage(disk) . This patch adds memcg accounting to fix it. Zram and zswap have the same problem=EF=BC=8Cplease refer to the patch corresponding to zswap[1]. [1] https://lore.kernel.org/all/20220510152847.230957-7-hannes@cmpxchg.org/ > > > summarize the previous discussion: > > [1] As I can see, Michal's concern is that the charges are going to fai= l > > and swapout would fail. > > > > The indirect use of zram is in the context of PF_MEMALLOC, so > > the charge must be successful. > > No, this was not my concern. Please read through that more carefully. My > concern was that the hard limit reclaim would fail. PF_MEMALLOC will not > help in that case as this is not a global reclaim path. > Sorry for my expression. I mean the hard limit reclaim would fail. As i can see, the PF_MEMALLOC is not only used in global reclaim path but the mem_cgroup reclaim. try_charge_memcg try_to_free_mem_cgroup_pages noreclaim_flag =3D memalloc_noreclaim_save(); nr_reclaimed =3D do_try_to_free_pages(zonelist, &sc); memalloc_noreclaim_restore(noreclaim_flag); > Also let's assume you allow swapout charges to succeed similar to > PF_MEMALLOC. That would mean breaching the limit in an unbounded way, > no? > -- Chage compressed page once, mean a page will be freed. the size of compress= ed page is less than or equal to the page to be freed. So not an unbounded way= . > Michal Hocko > SUSE Labs