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 19100C6FD1F for ; Fri, 22 Mar 2024 00:38:35 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4E0596B0083; Thu, 21 Mar 2024 20:38:34 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 48F236B0087; Thu, 21 Mar 2024 20:38:34 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 37ED16B0089; Thu, 21 Mar 2024 20:38:34 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 2A0656B0083 for ; Thu, 21 Mar 2024 20:38:34 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id BCEE6A1BE3 for ; Fri, 22 Mar 2024 00:38:33 +0000 (UTC) X-FDA: 81922814106.04.C6204AB Received: from mail-ej1-f41.google.com (mail-ej1-f41.google.com [209.85.218.41]) by imf24.hostedemail.com (Postfix) with ESMTP id DE44A180008 for ; Fri, 22 Mar 2024 00:38:31 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=xQABzwop; spf=pass (imf24.hostedemail.com: domain of yosryahmed@google.com designates 209.85.218.41 as permitted sender) smtp.mailfrom=yosryahmed@google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1711067912; 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=R/4ll8Tw2n8UfNJ4aLe64KwZGlq2gigpprOLTzXjsAc=; b=EaSgt8pG0xycWwHugTgs7Qib+VAQ6PLdEqFaQCi6HyCTA3HVr6TyCTnnmT01DeZrQoh+IN wuMfWvSib2XVzZr3a/D7mfANNZ9tiy3Flz2TZGcuycdfYT0e90sSIsEnAGP5J5pVO2XbcT EZX7ThBhVxNG1ThmlE3d7hDhzoSfRL8= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1711067912; a=rsa-sha256; cv=none; b=FeSRIZKFrs872vQAsbjySAAdasIZTw1+EW9W15NpKXCzKLt039hTe7MqD5H/feE4nSfmY4 HuGnY3dNPgXCL2fr0rhklOCz8DODd3d141wbJNc7/gRvNNHujiQuJyAnbLLoQMI9v3oOgO Sau3n8UwrEEpuqI+mTBQZVYrfhttcDM= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=xQABzwop; spf=pass (imf24.hostedemail.com: domain of yosryahmed@google.com designates 209.85.218.41 as permitted sender) smtp.mailfrom=yosryahmed@google.com; dmarc=pass (policy=reject) header.from=google.com Received: by mail-ej1-f41.google.com with SMTP id a640c23a62f3a-a4715d4c2cbso164266266b.1 for ; Thu, 21 Mar 2024 17:38:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1711067910; x=1711672710; darn=kvack.org; 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=R/4ll8Tw2n8UfNJ4aLe64KwZGlq2gigpprOLTzXjsAc=; b=xQABzwopi3Thdq6eojsuSkUErXa+Z5yeQIfeHJYMfwU8vbOolK6gqfl0aHrA/3E8Tz KhW8xf5awIW/shavZzAZMJVzmBVQG4j4mV/xY7n7hCrBvpBgzW5cFfpYKQM4T1iXqlnm Fxz2oTf2e+p2leTjGU9Fe3YNGvyrwlueTiizza+1HKTeMtqXDVm4wNwk60WEpHbWLMN/ v4KzgQfpHtH5RdVhWVrYzbQK6mLBcLESLnCN02JvJqlneiZpHDTjxkFDhhOU5zVGBl+X 66lNjtX6xtNPjBMGtYd4vpL7Ksvg1SoxfPY7dd7ev1v4HkPgYfZDz+wUDs9G795PjSG9 I//Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711067910; x=1711672710; 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=R/4ll8Tw2n8UfNJ4aLe64KwZGlq2gigpprOLTzXjsAc=; b=g/ZrOzYcEEoO44T0wQ0QK551/iUIELOakeLmxmVPEskGi1LDta6o6TZDc54ot4ItjL kuU6UTbyOuNBKrYCRSMi9jXyUKk+7PbSJN5JXUblKyXzveu3CWYW4ZO7RidlAz2VDL84 3OQzxu2Ipoh9uDT5vjgQInFWjpHMRCNNye68LXYScZfunKJleK4pLuKRyBLKFTXLU1oV soMG2kYJdaQ/8W8B+leqreOJUOtzG2met+bxjEO65N3BogtDTGXAhAd4xc0XFNb1XOuf 97OJlIYMaK+urlMGHWrXEuhskOT1F+wgA+lTr8zKuIbURn6zrlZKf18ygwb0vpWaA0/H zA/w== X-Forwarded-Encrypted: i=1; AJvYcCUCRB7/1ogHSR9T7hfvoLB2FnQkDYbh6j3kPiPPKI/EAFDCFONAMzAWDinjAD2NJceRnGGjeeCOsH4POscyOjneDSQ= X-Gm-Message-State: AOJu0Yz87SV4yqwkSEcFB6pHiLTgOVwzVJcNYYCMcTI+s1/8xIRVAUHM JVOYQgWvY3Mlm7KZuwivbl9gkq+BUj5Gna12vl/yjB8DYohPlKGec1xXjjiCh34yh3ixqub30aQ We3wcv1hp8lThk26JqYEU0k1MO36JzmMUAjH+UrHNJlyAMiUrJQ== X-Google-Smtp-Source: AGHT+IEMbCliFrO0xtxTTtehc5J5QB8M/oZq9Yl+sE+REjuKRkG2qUVueq2Mg6o4jtvX4Z56lwg/Mz1gPzUWOsBkrH8= X-Received: by 2002:a17:906:2a82:b0:a47:2e79:cffc with SMTP id l2-20020a1709062a8200b00a472e79cffcmr219682eje.55.1711067910150; Thu, 21 Mar 2024 17:38:30 -0700 (PDT) MIME-Version: 1.0 References: <20240320210716.GH294822@cmpxchg.org> <20240320211945.GI294822@cmpxchg.org> <7d7b755a-e13e-4267-b1b5-a4e2ff33d6e0@linux.dev> <20240321192912.GB3154@cmpxchg.org> In-Reply-To: From: Yosry Ahmed Date: Thu, 21 Mar 2024 17:37:54 -0700 Message-ID: Subject: Re: [RFC] Storing same-filled pages without a zswap_entry To: Chris Li Cc: Johannes Weiner , Chengming Zhou , Nhat Pham , Linux-MM Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Rspamd-Queue-Id: DE44A180008 X-Rspam-User: X-Stat-Signature: 18yzxrff8y516a791fkx5xts815c95nd X-Rspamd-Server: rspam03 X-HE-Tag: 1711067911-572527 X-HE-Meta: U2FsdGVkX19RpEB2EXDf8dOK+sxpik6Ysi7Wbkcy1qBN+/afVO8TQOZ/R0NqG2jQp/PiAyKGWQLtQ8epqkeOxBa3KzldU2y89CFunufV/otpSLpjSyfu+vX9ePPL0u9IP0xzXhBH55rsNJSNMnoi3BPuXLK6cmzHB4ntMRoPcI38EW7tJYysRATRCuNctR4ahFLwZyVtmms4tVJ1sA+cqzhdjZPoavbRr9UkcliXmUB76QjYil722CeKHvhHdRIkeUlyJoaDH3WXPXs/Z92gMRTiGqLyuHI4N41qnFHyNjtjpF/FIJhGWiilNxytJozBRHTJlaKLPrEIF3Mns2IdK2Oa6D6deBNseW/YKFLd1PWlmKue6W3KmE/l61ZLQSNdJJZLwzzpqBRlk4wUX7CSqdYtLWaxjIRgAh8rSMEEhfOUNN0WFu/hzGcRvwTdhrseiKifUNHVpEdLKBb0zAzfCQL8C0ykyx+xaPl2OTKWN5wYCnOHJHJcye/9auPYmNFNf5WAgUegnHonbBZ/h7Vwpu9VP05OQIB+ml7LBGEFRP9NtwglC+CRZ+68dxM5CnwWn7kkYusCM1BqA2VBF+QHsmL9MESLCnR5hGKFcu3Cgg6D//cwiC/HAPjvX34U3I0WupDQMd7sJvkz7qmQL5r6kTFej688fwPXTtUoNibR/nu/gTOIXk5zcHjlEsnZtoaED5V4CvWq5YvCkD8UUDokrJWK8t18HzDuTZzTccYAlj/GTs0DXSECFoPkrIe7wHa1gzfLdJzt8867optvAulInUSmwDCf1RJ4CFMgf4UznTvEQcA1x+HjNwqyfC74l/bUJ1OdD0UM5LVkIHwvzbJZJ8i+GLUJW62BxI+reP0tQpGZWNm9qE/9LFm743u6B/3kOs+YDO9PndRuFYJfCHWnj4dBvasJlsgxQ8CXabRr7XVzhUviKgsGrlQudpnsBIwfcPAYOVsF1xq8jfVL8I/ hIXymKXt 3cNGe922x72aczQwIfqUstxYCaja9UvFXfT2nLWm3cGW2AtZ3xBVYkogeL3obqM/SVhjdLdJUwtUeAKpHht22u/Dihx4h7Nw58iEwjKIo93H+d1VkvImspYBmpkQtG0p7pNQDFDbFBLffEEKpCPBY5CCLnNqL08cn+dhi0NFjnRzscwxMa4TmdEw5Cily4PQxPMSq6B4p8H0tZ3ZQOl/7zBr0vYYTuE2kYkn0Pzd0PpOHgb3koyRdQIJ96dna5dsUYT79D+UE/KOHcyWIYkiDqY/V0MWIUkl0ER+Ce/K3cOdCNc369KXSMmae1vdCQa/nfPCBHZqkKeYC8ayNwBmOm9g9t89Iu5QDan/lizWii5ex86z3Stx7AZ/LDQ17QjErKbrN4s1Qj6ucCkF/1oaUYJ6NzhAKdeFqe2Ma X-Bogosity: Ham, tests=bogofilter, spamicity=0.006189, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On Thu, Mar 21, 2024 at 5:29=E2=80=AFPM Chris Li wrote: > > On Thu, Mar 21, 2024 at 12:58=E2=80=AFPM Yosry Ahmed wrote: > > > > On Thu, Mar 21, 2024 at 12:29=E2=80=AFPM Johannes Weiner wrote: > > > > > > On Thu, Mar 21, 2024 at 06:44:54PM +0000, Yosry Ahmed wrote: > > > > > In some cases where the current objcg is not "correct", the testc= ases in > > > > > test_zswap.c may break? Maybe we can use swap_cgroup info to char= ge the > > > > > stats to the correct memcg? Not sure if this is feasible. > > > > > > > > For cgroup v1, swap_cgroup will be cleared from > > > > mem_cgroup_swapin_uncharge_swap() before the zswap load. > > > > > > > > I think the current objcg will remain correct as long as swapin hap= pens > > > > from the same memcg as swapout (or if swapin happens from the paren= t > > > > memcg and the swapout memcg was offlined). > > > > > > Swap readahead will pull in physically adjacent entries that may > > > belong to somebody unrelated. > > > > Right. For those as well the current objcg would be correct if they > > are readahead from the same memcg as the one they were swapped out > > from, but I understand your point that readahead makes that more > > likely to not be the case. > > > > I am slightly nervous about using the current objcg tbh, even though > > it only affects the stats. It's just less straightforward this way. I > > think I prefer either: > > (a) Only supporting zero-filled pages and storing the objcg directly > > in the xarray. > > We can add the zero-filled page as a special case to speed it up. I > don't think we should remove non zero values of the same fill pages > from zswap though. We can never declare the non zero same filled page > is not going to happen. In that case, the current same fill is still > better than going through the zsmalloc. If we do this, we still need to support same-filled entries in zswap_entry, which means we still cannot separate the logic completely. Also, it would be weird to have zero-filled pages and same-filled pages handled differently. How common do we think same-filled but not zero-filled pages are? Are there known user space usages or patterns that lead to this? The only thing I can think of is if user space initializes a large array to the same non-zero value, and then it gets swapped out before it is modified. If it is not common, perhaps it's not worth optimizing it.