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 A2B61CF9C69 for ; Tue, 24 Sep 2024 20:16:04 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 18CFA6B0085; Tue, 24 Sep 2024 16:16:04 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 13DD16B00A3; Tue, 24 Sep 2024 16:16:04 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 005276B00A7; Tue, 24 Sep 2024 16:16:03 -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 D3E326B0085 for ; Tue, 24 Sep 2024 16:16:03 -0400 (EDT) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 59DDE1C5309 for ; Tue, 24 Sep 2024 20:16:03 +0000 (UTC) X-FDA: 82600738206.11.8766525 Received: from nyc.source.kernel.org (nyc.source.kernel.org [147.75.193.91]) by imf09.hostedemail.com (Postfix) with ESMTP id 695E714001C for ; Tue, 24 Sep 2024 20:16:01 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=dq1i9AA1; spf=pass (imf09.hostedemail.com: domain of chrisl@kernel.org designates 147.75.193.91 as permitted sender) smtp.mailfrom=chrisl@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1727208926; 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=L4JAFmKXWJay1Xe97uxm1LfwRJ1m//GLwAQNabhPWN0=; b=qdyZp5s2Skh/3KwDpn+NkRhnwoYkfCo0XAm7LYP9poBbwmidvwLHpX21m30J1xtVK4MSCR z5ZUK+b5HGvd2wqpE9Y97uL35/ey67BikagUUdpJahBUZ/7CHWcx5K+XQxdzTxU8WypOcy T18qazYv/NyNr/8WdOdB4Ex1ZbgUNzA= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=dq1i9AA1; spf=pass (imf09.hostedemail.com: domain of chrisl@kernel.org designates 147.75.193.91 as permitted sender) smtp.mailfrom=chrisl@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1727208926; a=rsa-sha256; cv=none; b=FzLrya+mPFWDf8LPgfqYLP9e5OgcRheeRxaCCY1zXilVDG/4A4uV9o3FFqtExjm7nrnyHJ mjeSfPdyaGJVhlteyqc6I3pBrbKqQsZZ4Zk6juQ3D/ffaxgFXKomN7TdM7WN2WcAxu3tlO ClnRX92NtKK7RK2srxhBFIvC+LZRb7k= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by nyc.source.kernel.org (Postfix) with ESMTP id 82581A43869 for ; Tue, 24 Sep 2024 20:15:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id F33C4C4CED5 for ; Tue, 24 Sep 2024 20:15:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1727208960; bh=20rvow2syaLu5tVCk+B78yC3MbGGW7ZTvE1Kq3+uOwQ=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=dq1i9AA1LNuzBFTScXwDCiStXABMuacKaRCcDzRxsiux5L9oZCJ1MWTyDnYm4lG2a ZGERXQY3o1F+QXsBh9tHxil0PID4v5ZHrKMC7BkPf35VynYCdYcALmZXj8re/59zu4 WSP/i93h5si96ZvDE6Vi4X1xEjHWFM1Gacr3iRR9N/WSc9uiRTaGzIS/m4bo07bpwo ZO+C+YAv1gdJ3E0gdJgO4T+DLX3d7zzNxgHNGlENjpe+7m5W1eQTxL6ZI+zebXXHAh l2drT75a4uN/wY49Dx7YTrtqaDAPLxoTUaGzER4Tpip2GXhgALauTaXFNEZLeLrxQP cBvA2mMXT4mUg== Received: by mail-yw1-f180.google.com with SMTP id 00721157ae682-6dbbe7e51bbso46295137b3.3 for ; Tue, 24 Sep 2024 13:15:59 -0700 (PDT) X-Forwarded-Encrypted: i=1; AJvYcCUdrzcg0SpZ5DP6Headp4TMphjbouN1mpDmxyNs9R0Zxt8k/irWpqssz5qLIeM17CF4pAfsRFrCew==@kvack.org X-Gm-Message-State: AOJu0Yy+qZ8Q7GVo09akBZ+LYqj2CcWh0aKGFUS9Wcax3Ps6akcpAf6d UecHSS27eORqN7OyiZ2ERL2x0lTt50UnYtUFOJfjMGdF7TCC2sb0KpGIwgRh/6lTn6S0MgUta0/ VjzigYkDnq62f5GN5xgs/81l8x7StzRq63DV6cg== X-Google-Smtp-Source: AGHT+IFjFDhhWZCGuynZdnWE2t03n++ZLaLN0gFiJSIupkqGUvhjKjkLAc8km6EoRyp/6Z9QgbBb7Squf0Dmm8RRHqI= X-Received: by 2002:a05:690c:d83:b0:6dd:bf2b:d52f with SMTP id 00721157ae682-6e21d6e189emr7058087b3.1.1727208959070; Tue, 24 Sep 2024 13:15:59 -0700 (PDT) MIME-Version: 1.0 References: <20240923231142.4155415-1-nphamcs@gmail.com> In-Reply-To: <20240923231142.4155415-1-nphamcs@gmail.com> From: Chris Li Date: Tue, 24 Sep 2024 13:15:47 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [RFC PATCH 0/2] remove SWAP_MAP_SHMEM To: Nhat Pham Cc: akpm@linux-foundation.org, hannes@cmpxchg.org, yosryahmed@google.com, hughd@google.com, shakeel.butt@linux.dev, ryan.roberts@arm.com, ying.huang@intel.com, david@redhat.com, kasong@tencent.com, willy@infradead.org, viro@zeniv.linux.org.uk, baohua@kernel.org, chengming.zhou@linux.dev, linux-mm@kvack.org, kernel-team@meta.com, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Rspam-User: X-Stat-Signature: 739rs79soahn4jo3ushtx3ta6iwqze9a X-Rspamd-Queue-Id: 695E714001C X-Rspamd-Server: rspam11 X-HE-Tag: 1727208961-606911 X-HE-Meta: U2FsdGVkX1/QouZlyz1GY3UAwcwUR5thHozGC6l0imF/t4taAuNdoGlB6f3Lmg/xV0WTd/S5BHYBNMobsGcYmJKxKFQm6EaHP2GbNjEB9RkUWs07pXPgz2jX77xApZZt334ITmnqB/vLlV5RqT2BvxJOcOeY5SX9ruxy7M2m1EFkmLbM6KZCoq/d+QmOYwLHwozh020DaKdUjFZxisbHNd5K5Cu1hg4N61bCGstTRFaPs/ALWBa1NtIT7ku/jGm0o5zTw/Bv0Z9N5augcH1wdTHgPACigaPXGiYbX2FgSD17bJUzrlYoVLpHVaErvQYVcsKB0sqGBnydHt5n3QDzWiRBv4222LCjPFVL4Mm5G06T/ZPA7Mb1GUVC0ZitIqGiulTqS+cCmeDpSRhrezJjOAdn3ugxooLxWGP6MJdzrLFMC/zDoHlDxtEieT+rrVRhttKvW0rNqs0/9eABXccbwzt/CtPZirXhZuhV0IeCa6PTj3fsNA8fMGUPsFW4eAjzhpnKAGNAT3WPDm85BdOAWEAHV5rDNNW5cXHlImCeXX6xEOdaRPXFR1dAJVaaQ2Gq91WwvPRSmtlpf9kna2CW3+WNHTUlcm+7WvyGh5fxOJvCcL4Z2s3PdMTwIrwq6Wot2JYDfwIBaAuRl/m9DdbqltnW4OEjaa2PWE2Kdf8ZDSmCwtEQjEikyGorgkCADM123aRMW/a8jn6pGUHhDvXN0Pr95eOnlFYcbrvQZ34wGCLgGCU4R6vlDRoYK4xZa63Vzbd8cUQ6m59c8SYVCgVn/E/0us0RvSMg/P1VLzl/JzThLoqr7QfRSe5Fcle4cxyxwQwYlGDVgFowaoSbFIsDxn7hQT1cbYX8upC/f7WPW+zes8rvwDvAwd4dhGOQu0nBAf/l1PyGaH8LF1l/Og7oiNu14c7fbDIKwR9dgtQne0nu+7ffPYMhNNW5+eCQ6E1EoKPDXRSwmuOM48u45Wl 1pUk9Zr8 sW1784ZiHPU42vof83X2pP97UDEPtpfRsgiW8bZe7hFD4cAls++nHZSTapzABkoe9T0QqY4P3SKgr4fz0jxagVR/koP/7DlEyw09SCczFQTs/BsbfCe6LSb897JQ8/7FO6+BZnSKCB6HVaNgGGlPseJNfEEclazbTEMSBZojfABABRu+UttqcgxUH8Szt4dkJhrDIODkMv6q58I+kN/TD0JSfEaeDnmdk7f1RExL7agclG+919LDfDjgahAu1FfHWgCs2tGV6F9Imd+HF4sLb+Lu1n8p9o/0hI9kSSMXbcgnH9yAA+yqBxHujFGueFB+je2lL3HoDy5oZSwUmA23Jq18yCPhN2pxfMaIj 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: List-Subscribe: List-Unsubscribe: Hi Nhat, On Mon, Sep 23, 2024 at 4:11=E2=80=AFPM Nhat Pham wrote= : > > The SWAP_MAP_SHMEM state was originally introduced in the commit > aaa468653b4a ("swap_info: note SWAP_MAP_SHMEM"), to quickly determine if = a > swap entry belongs to shmem during swapoff. > > However, swapoff has since been rewritten drastically in the commit > b56a2d8af914 ("mm: rid swapoff of quadratic complexity"). Now > having swap count =3D=3D SWAP_MAP_SHMEM value is basically the same as ha= ving > swap count =3D=3D 1, and swap_shmem_alloc() behaves analogously to > swap_duplicate() > > This RFC proposes the removal of this state and the associated helper to > simplify the state machine (both mentally and code-wise). We will also > have an extra state/special value that can be repurposed (for swap entrie= s > that never gets re-duplicated). Please help me understand. After having this patch, the shmem swap entry will also use the swap continue as the only way to count shmem swap entries, am I missing something? That seems to have some performance hit for the shmem. Because unlike anonymous memory, The shmem can easily have a very high swap count. I would expect there to be some performance hit for the high share swap count usage case. Do you have any test number on high shared swap count usage that says it is negligible to remove it? Also if you remove the in the SWAP_MAP_SHMEM, wouldn't you need remove the counter in the shmem as well. Because the shmem counter is no longer connected to the swap count any more. Huge, do you have any feedback on this change? Chris > Another motivation (albeit a bit premature at the moment) is the new swap > abstraction I am currently working on, that would allow for swap/zswap > decoupling, swapoff optimization, etc. The fewer states and swap API > functions there are, the simpler the conversion will be. > > I am sending this series first as an RFC, just in case I missed something > or misunderstood this state, or if someone has a swap optimization in min= d > for shmem that would require this special state. > > Swap experts, let me know if I'm mistaken :) Otherwise if there is no > objection I will resend this patch series again for merging. > > Nhat Pham (2): > swapfile: add a batched variant for swap_duplicate() > swap: shmem: remove SWAP_MAP_SHMEM > > include/linux/swap.h | 16 ++++++++-------- > mm/shmem.c | 2 +- > mm/swapfile.c | 28 +++++++++------------------- > 3 files changed, 18 insertions(+), 28 deletions(-) > > > base-commit: acfabf7e197f7a5bedf4749dac1f39551417b049 > -- > 2.43.5