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 8C086C54E58 for ; Wed, 20 Mar 2024 20:49:58 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CA7816B0085; Wed, 20 Mar 2024 16:49:57 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C58BA6B0088; Wed, 20 Mar 2024 16:49:57 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B1EF46B0089; Wed, 20 Mar 2024 16:49:57 -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 A2A176B0085 for ; Wed, 20 Mar 2024 16:49:57 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 239B3806D2 for ; Wed, 20 Mar 2024 20:49:57 +0000 (UTC) X-FDA: 81918609234.20.356807B Received: from mail-ej1-f53.google.com (mail-ej1-f53.google.com [209.85.218.53]) by imf23.hostedemail.com (Postfix) with ESMTP id 6FC66140002 for ; Wed, 20 Mar 2024 20:49:55 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=gLN8y0yx; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf23.hostedemail.com: domain of yosryahmed@google.com designates 209.85.218.53 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=1710967795; 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:in-reply-to: references:dkim-signature; bh=CDM9BjVo/DzdAoCb2pFFjfhSAUTGGn/mWvxlN1DwMPk=; b=CV/VLcK58oa8UPGdOZhZT7u5f1OkLCSJLUxxCoNmkUB2pQaaUEIli3sx8hINUrrvG1CLZr K5aJ7L4ObS+h26CCEGU8KS4rsM3JoUeC5mA5bIGb2IbioYggzNHtvlZM21fH3h19PG9cIW daMMCTpY/fdDjF5mBqIFeI1xJ6XAGzs= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=gLN8y0yx; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf23.hostedemail.com: domain of yosryahmed@google.com designates 209.85.218.53 as permitted sender) smtp.mailfrom=yosryahmed@google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1710967795; a=rsa-sha256; cv=none; b=ACN8YH6wAhz+6LFYrs4HfenO1ikZ1uFNWYmUcbwMxlbKZJUwrzpEXAaWvLYXfqDvjg93qt LbToqxc2gN2SK3Q04GCm0R8txthWtpjgVi2kcfNkOumOAlRC9gJum0Im0ftj+dhdwhEo6C Fguo0ZMsyjLo/9Kot+yq/oyfhRRqpIc= Received: by mail-ej1-f53.google.com with SMTP id a640c23a62f3a-a466fc8fcccso35981666b.1 for ; Wed, 20 Mar 2024 13:49:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1710967794; x=1711572594; darn=kvack.org; h=cc:to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=CDM9BjVo/DzdAoCb2pFFjfhSAUTGGn/mWvxlN1DwMPk=; b=gLN8y0yxwAEa9/V2l9jXPAz7zsM7UfYMPHIEX1n+mBznp8Db8kqHsw0G6TWS9YTClM eyl/HjGIi+zoSr7RkDvgL44uNYYS3QTiwwoIUwbYvrNYpwAqPCmcsKXVePDlaY8+iGYn vjGXv3N8YauZLXRrWUGOCaA2Zl/7yLdmcct28/r4jBXf+VHQd6Hr9Ni04kFI2Xu4DnQM 589Hx9rxmKFZgrurRkcONmDpmvvVpJl55vqsncsuMhSdtGoRvpClgGTFtCrx6eylPX7t I9AlHv8PL7qmKswMGQbK0CHpEeLKKPBEZfFJ/dprey8jMtXaHBX8bM3LFBH//qCTVn7P OeIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710967794; x=1711572594; h=cc:to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=CDM9BjVo/DzdAoCb2pFFjfhSAUTGGn/mWvxlN1DwMPk=; b=kxzloRCCw1WFGczD87fuIKNoZdcCW2hH7ZPB4sNjzwxjwMjE4m8R41quCyODU3BN87 hc4nhqOoJSjFIH5+mqNXSQwTTIuDxerG5gD0d0p0vnb22Y8fkN1qxEMuKoXtfvCq4ryI dPeAbF60aeaQ8enNlqUOAbTN/PHLHaPytmL2WqkRdXHWuz53VFEMhgaNNCKic7Uhl9Fy 4T/sP1oDIYdG3iJPInvJOuTvm4NhDGw4gdJKXmb8+bS9FtSeGexLSog4ab9d2nRyc70A RMF4+Dfi55UuyPpM7wBP8WH2YhLHDrKeZ8EsH5cfUAbLMIsVGG+dzONVjdll5zkWgbqT 8ZOw== X-Gm-Message-State: AOJu0YzVSLUPTEgOY3oinapZq0ksd5HeXcTelrX235RcGygvHmL/ou0t U0Wwoy2gRz2orWbQ41owFLilI+ONgAESjNDmgz0q48JiRFJJHraZaxvbe4aaOa4atjMo/fUtg52 6VmZRD/3CS4j4/xFHDBMPpzXG3TeTZ7suDx94 X-Google-Smtp-Source: AGHT+IGhbJJlOhvoycj5gdL/ibnjmQRzCmEDsjFzGg9miRmUBGg2hXL7O8kwGRgMRwdF4AHqquNAgsrLrBKP0udObh8= X-Received: by 2002:a17:906:6a1c:b0:a46:bbb3:f0d2 with SMTP id qw28-20020a1709066a1c00b00a46bbb3f0d2mr25436ejc.47.1710967793520; Wed, 20 Mar 2024 13:49:53 -0700 (PDT) MIME-Version: 1.0 From: Yosry Ahmed Date: Wed, 20 Mar 2024 13:49:17 -0700 Message-ID: Subject: [RFC] Storing same-filled pages without a zswap_entry To: Johannes Weiner , Nhat Pham , Chengming Zhou , Chris Li Cc: Linux-MM Content-Type: text/plain; charset="UTF-8" X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 6FC66140002 X-Stat-Signature: mbah8axh38bj8hmptm96c4pywaaupeqt X-HE-Tag: 1710967795-869260 X-HE-Meta: U2FsdGVkX1+9mFORx4a0oSUnr7ZDCcysp3n9LOXNJ6JDlj8t2Xmp1ppr0n+b6oDPTdARjqFilMyDDVkYwU1ApSwgm6bwXYgmdUa/XU2Wzl6Ylw6ouPWHxBvclvXQeiB7UnvVYe5b0/j8vq5w+UgxwzabYS61tRRQtbuG8l/tja5jlS/X44OeNglNC98si3xJK6uZDUWW1EoSszLr5oS+0b9y4WzgqR7Hxwy7f3DXycjPN7MEdq2Lpvl33vDlKddwzyj5lLlmS0WcX41FGXxa6whUoowNtG2lkBO2vaJhtMMftThgzK8HH/m5QwAl2vwMid/bZM97Bii/AgAknU+1ypB4uXIrJ8BzMxOZR3Gi+h8F8btElBqF4+G8KYT8DshnvKeFonC5QD+SfCKWh1AZjhCeyOlc84qDgBEXu/5dUamckTTfU3vqn/fXPwELftKu8RL1cXapNKFytx1e71twxmelIok8osyhZaMr0Jk49dIDLKAACql/NFEZz+HtmQ9/GLz0CnZt2nPD1xKEKXD/xUlWq0meS8IQ7blsFzFQsVQv07soRRkZXOKMIOPG37+VOhptDdtK0+AUkod78Qv8nDLGeAk90V7mi3PQALVAGaV7xa+fN3T+kyMyAHUUcwOaAJE1ruKEnwQnIhrR0DKILpRpXmZYn6LgxK6gBo3Gd08nsa9A3w5d4U7uMJmf+EYd4HiJx8q3mMY/4yrLp104m9GfDHlZZPiRE4aniDqjduBJSVDHt8gcdxdoJ+wOnlTvm/DjwHfy+zTZbSONrZHczFGOFrn43Q9SzYC3WwOxzG0QV+w4XqWDQznsOnYFH+CLLuYJapDDP5abzlO9f3Vv54VDeqMmJj0ravvwPb0LYK2rRTiZt05cVhnI0XTLC5OEAtcjDxZhyeSSI65Bes/aXqZz+d+nvWzLegUjhvC4ZWj/1AwzuFXCBMMQqgjJrAnNzJfjdZ7sewMCfkQf877 OHhVlO+U z7SOY1/VH20dF5TZRjdxIxQtscKxZe4h7pk8Rb6/VvTom1iN7tHPmgtC5TeK9qdwETr3ExQ6QtnZ3IUlotBFZGahTYYpxu4G/Q+Cwu1MdXBGggFgjv0GKLvRA/5FuAfOqAyUkr/svZd8tPceKtG9KbqPeV1gP9iZq+B2q4tzPlpYX/PfnzZwiLm27Hpo/xMxEz9B94sT4VSMj+ta2fMtZEaPQEDM2CY01FGGlIYoaOnflboHmBaORRtZTyISLfbUBjN32vHq6yccg7jI= X-Bogosity: Ham, tests=bogofilter, spamicity=0.002674, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Hey folks, I was looking at cleaning up the same-filled handling code in zswap, when it hit me that after the xarray conversion, the only member of struct zwap_entry that is relevant to same-filled pages is now the objcg pointer. The xarray allows a pointer to be tagged by up to two tags (1 and 3), so we can completely avoid allocating a zswap_entry for same-filled pages by storing a tagged objcg pointer directly in the xarray instead. Basically the xarray would then either have a pointer to struct zswap_entry or struct obj_cgroup, where the latter is tagged as SAME_FILLED_ONE or SAME_FILLED_ZERO. There are two benefits of this: - Saving some memory (precisely 64 bytes per same-filled entry). - Further separating handling of same-filled pages from compressed pages, which results in some nice cleanups (especially in zswap_store()). It also makes further improvements easier (e.g. skipping limit checking for same-filled entries). The disadvantage is obviously the complexity needed to handle two different types of pointers in the xarray, although I think with the correct abstractions this is not a big deal. I have some untested patches that implement this that I plan on testing and sending out at some point, the reason I am sending this RFC now is to gauge interest. I am not sure how common same-filled pages are. Unfortunately, this data is not easy to collect from our fleet (still working on it), so if someone has data from actual workloads that would be helpful. Running the kernel build test only shows a small amount of same-filled pages landing in zswap, but I am thinking maybe actual workloads have more zerod pages lying around.