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 C4879EB64D7 for ; Fri, 16 Jun 2023 07:38:31 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4A6336B0074; Fri, 16 Jun 2023 03:38:31 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 456E56B0075; Fri, 16 Jun 2023 03:38:31 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 31EA38E0001; Fri, 16 Jun 2023 03:38:31 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 207FA6B0074 for ; Fri, 16 Jun 2023 03:38:31 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id DF64F1C8E39 for ; Fri, 16 Jun 2023 07:38:30 +0000 (UTC) X-FDA: 80907808380.02.CA21590 Received: from mail-ej1-f41.google.com (mail-ej1-f41.google.com [209.85.218.41]) by imf08.hostedemail.com (Postfix) with ESMTP id 133BB16001A for ; Fri, 16 Jun 2023 07:38:28 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=raHYCTMx; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf08.hostedemail.com: domain of yosryahmed@google.com designates 209.85.218.41 as permitted sender) smtp.mailfrom=yosryahmed@google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1686901109; 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-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=j9HtoWwqGbgtEf/5EsF/+Q8jXO/MVPbsLyMQC67iLCk=; b=ZuCN8+EUTe4oiHElBx3gv58prz4l5rAl2/Gpj+PM3P1wbOwxBF/H/hx3jf/p/6eY4TffNq KyaEFnZn5HvsdZcWc9enlHpWhB0TagSD8GcSxIz463nSMQ4f+36zVqcsdq6CigyaLew7cj WH0PkFSd2kCn13Ts/dKcdkLMSTlGDgM= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=raHYCTMx; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf08.hostedemail.com: domain of yosryahmed@google.com designates 209.85.218.41 as permitted sender) smtp.mailfrom=yosryahmed@google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1686901109; a=rsa-sha256; cv=none; b=TsBpzioyrDjLNNqgY3GXDZ8JpjlMlt7Y6cOjHuAL9iEZ5onMiWP1BumfaNTezSqfJ+kZd+ l292qRKvRvXr3a5gfKHqhHx57zxMqL4nh+SPOaJ+7MP8PTyDFiO++DXLqCk5T31gaLb3ml lnI1yFDtEgZLohfX3Q/nDTEv3c5/9oM= Received: by mail-ej1-f41.google.com with SMTP id a640c23a62f3a-9827109c6e9so48831866b.3 for ; Fri, 16 Jun 2023 00:38:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1686901107; x=1689493107; 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=j9HtoWwqGbgtEf/5EsF/+Q8jXO/MVPbsLyMQC67iLCk=; b=raHYCTMxMkgdF/Ic0WyVRzoA5Z3PZJ8J3oPfOEr5JJr3VIZROzo39uTK/MhsjXI9rv o0j4Ho7dzbjbj6WLakxNQZOwSWTY/nBf9KUsKsOfJcnKCXW9LkMMbJP7k4hTz7+i6Csl 1TNBBLMM4U7orsg9HxATqGLaFS/4NH2HyJiTap2oLgf4nSpkPKC3X3QaZAChSz1BECU8 oCPpa98bKmNgEADhgCArajuAQnaCZ0kmiEF6mCCA/9v+Tt01VZSYUh7rbp1X6AGhbi0M r9h+IEpwWXUBX1XfXGKbh4rQ4c5PfoD5BOzOI7Hv4VRgVDQrUWcChC7Ay70AvBknH2bm MctA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686901107; x=1689493107; 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=j9HtoWwqGbgtEf/5EsF/+Q8jXO/MVPbsLyMQC67iLCk=; b=Xrg0jDKqBit4RGCHSJU0kmUCK+rCEjlCCQvQAWnGWAOrHAe2HOOG+RZS8Jof8Iafhe 6riUMOM/4+8bZhWHAeIm6QWL0vcczTYLueSdla79p9P+IyrwNT1ajArRTaI8U0hhL3X3 v3P7wJyRwh5z6clakVYq7zyySDUBSj8AzsSMNqELJE0kKzI9g2dq4y2MC5D6pI23rkTj BsOevco1VDsFcb72b85zFM/N0CxcV5L3iYm2MLd6B3EGSyojoceh73zOQD52bmAszSAh ypf6+9qexeYVJzvDM2OO9pzYEMrMMOsTXQgyi9rsYdr6sPbuYeTRMk8okrp+p6yXe3pS q+OQ== X-Gm-Message-State: AC+VfDxpzYYOU7G9zOeZKSGZp/yi7LfBQ8w8xIJeLApKTPOpKL59FOSp 8RBft2/TNSZbeKedJKjnXD2HrMr11a7o6dbziT/njg== X-Google-Smtp-Source: ACHHUZ5qBpwKkKtVtdZEG5c2DEr5/clF3Aq7qfIhliNSqNSzhU9ctycSqVNVwKum6jdlnGqGvAlrUXk2TRckHLZW3cg= X-Received: by 2002:a17:906:f250:b0:978:6e73:e841 with SMTP id gy16-20020a170906f25000b009786e73e841mr771948ejb.35.1686901107361; Fri, 16 Jun 2023 00:38:27 -0700 (PDT) MIME-Version: 1.0 References: <20230615034830.1361853-1-hezhongkun.hzk@bytedance.com> In-Reply-To: From: Yosry Ahmed Date: Fri, 16 Jun 2023 00:37:50 -0700 Message-ID: Subject: Re: [External] Re: [RFC PATCH 1/3] zram: charge the compressed RAM to the page's memcgroup To: =?UTF-8?B?6LS65Lit5Z2k?= Cc: Yu Zhao , minchan@kernel.org, senozhatsky@chromium.org, mhocko@suse.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Andrea Arcangeli , David Hildenbrand , Fabian Deutsch Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 133BB16001A X-Stat-Signature: u8ye4nrqm5wuubbzjzqd8p89pc515gnk X-Rspam-User: X-HE-Tag: 1686901108-460450 X-HE-Meta: U2FsdGVkX18cuOG+d3aZAyB5SDqMNWCpIo8bv/2taFPRP9UKlK5FFNli3SWby7PqfwMT05TkTbTGAzDh7kK9HH3Qx4RBd8eaBrWJa0JPxlaJ+3o4P4gUCEdOiKE1O7ygGtSjSyNjuHR1mwN2xi/ncjyGasil59M5Hq7kU0Yv+6mcmHPjEr4ZygzPECoLbxahnqVq4oiyB8F8vIm1yGUQsVGdqhXaA6307PGHKQL8HIoLla1kjs0VcNLhn5P+tLj4/gBsQZfTl8Oh6QMfNZNKfNjjXjYdJmvWA9lTceOuOZLewu5Oeukkh6Xn4icSXVU4g7HtLNVCt5GjTLS7VBQxbvIkhfZKQ/Lnc/Xsh9fcPg5qWx5cCduK9h/kfJhWrPJWIQo87JBIVG8yH4YhiVGVw+ba6RwXKkYPoeL4gr2IKJDHR5f6O7i4S7Kvz4nYME31+iYjTBOwhxL7ifjI3ZPph76P+DH5bvrUFY0GamlBeVuuLaJ3Mu2dtPDD/2yQPkxf9vkrKSndpjjkMQ208f0Lgl9IMXFDgk6695G9ZhekqTSKyNVlyndGba+VuY8Q9eh2gfpNZrYpJqaBRlUOSOZ+sfoDoWzbrcuOQ3XfoyM+BtannQLwCCYrKUOWPrf29kEv/7JFa9RxgR4SaV22kzA0px4MmqUyZOyfhAD3VuJDa1fFbWMZ4E2SLlf+AjPowNRkgZ9EqRr9Pc3ia0c7Y0FPAST64pYmhBlaAgeu+ButEHq4mVv5myckgHEoauIWpDcs6O9PUNs0ETrxbmLJbL5UVbb8YuU3jgDg1yFGO8s+Kpzr2VLz1ghzGQ6CdTu5bzTM/SUW1tx4sOVd6Ti7PLKbRTugJ8qrr/ZpFEFvJXgnwa7GG9bE1PLitWsM5UbPadiZF9+jzP78UeYFhaV6RgwusPx4NT41uycrDA9Yh9XzBmS5XFSAi80RlxosjzwCyXtEBnl8CdTt78u1i9C4pXN Po7M4Iku Gu/zN3DEceKKKiC3msOSosW1clUoCw1KmQbiprZremIBLl+OlDWXhVz50CnNoddAjdUYYmZX5Up3aLwtTh1z9YZwj5fcMlv+hdYtEeKC47QgOK3N5FyuM9HsKB+oBguQmSJopWRS+n1jRJD9hUJScLl/mCakE6Tz1+H+LgOdNBgKILGFlN6gQw7p1eMmUYIeuACstm45DDfBRUZc8thO0PGSP7Iwm8u/aMxrooWhGiPgGZJcCIc6FKl9Bklfwa2RAwKiPxz80CRwF9fjitiaKYxYbEJFVBMSDl0tWi66kAP6acjLUbMQOzUSB/P5BjE1eUUfUQcnGaIi96HILFb8Yagz8Natj+/IY4ART7MFCdbzYB74= 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, Jun 15, 2023 at 9:41=E2=80=AFPM =E8=B4=BA=E4=B8=AD=E5=9D=A4 wrote: > > > Thanks Fabian for tagging me. > > > > I am not familiar with #1, so I will speak to #2. Zhongkun, There are > > a few parts that I do not understand -- hopefully you can help me out > > here: > > > > (1) If I understand correctly in this patch we set the active memcg > > trying to charge any pages allocated in a zspage to the current memcg, > > yet that zspage will contain multiple compressed object slots, not > > just the one used by this memcg. Aren't we overcharging the memcg? > > Basically the first memcg that happens to allocate the zspage will pay > > for all the objects in this zspage, even after it stops using the > > zspage completely? > > It will not overcharge. As you said below, we are not using > __GFP_ACCOUNT and charging the compressed slots to the memcgs. > > > > > (2) Patch 3 seems to be charging the compressed slots to the memcgs, > > yet this patch is trying to charge the entire zspage. Aren't we double > > charging the zspage? I am guessing this isn't happening because (as > > Michal pointed out) we are not using __GFP_ACCOUNT here anyway, so > > this patch may be NOP, and the actual charging is coming from patch 3 > > only. > > YES=EF=BC=8C the actual charging is coming from patch 3. This patch just > delivers the BIO page's memcg to the current task which is not the > consumer. > > > > > (3) Zswap recently implemented per-memcg charging of compressed > > objects in a much simpler way. If your main interest is #2 (which is > > what I understand from the commit log), it seems like zswap might be > > providing this already? Why can't you use zswap? Is it the fact that > > zswap requires a backing swapfile? > > Thanks for your reply and review. Yes, the zswap requires a backing > swapfile. The I/O path is very complex, sometimes it will throttle the > whole system if some resources are short , so we hope to use zram. Is the only problem with zswap for you the requirement of a backing swapfil= e? If yes, I am in the early stages of developing a solution to make zswap work without a backing swapfile. This was discussed in LSF/MM [1]. Would this make zswap usable in for your use case? [1]https://lore.kernel.org/linux-mm/CAJD7tkYb_sGN8mfGVjr2JxdB8Pz8Td=3Dyj9_s= BCMrmsKQo56vTg@mail.gmail.com/ > > > > > Thanks! > >