From patchwork Mon Sep 23 23:11:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nhat Pham X-Patchwork-Id: 13809994 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 032DCCF9C71 for ; Mon, 23 Sep 2024 23:11:46 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 74A366B0085; Mon, 23 Sep 2024 19:11:46 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6FA206B0088; Mon, 23 Sep 2024 19:11:46 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 574426B0089; Mon, 23 Sep 2024 19:11:46 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 3C2DD6B0085 for ; Mon, 23 Sep 2024 19:11:46 -0400 (EDT) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 00F3E14164C for ; Mon, 23 Sep 2024 23:11:45 +0000 (UTC) X-FDA: 82597552212.17.E6DE4B0 Received: from mail-yw1-f179.google.com (mail-yw1-f179.google.com [209.85.128.179]) by imf27.hostedemail.com (Postfix) with ESMTP id 4409B4000A for ; Mon, 23 Sep 2024 23:11:44 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b="fQ4/5qWY"; spf=pass (imf27.hostedemail.com: domain of nphamcs@gmail.com designates 209.85.128.179 as permitted sender) smtp.mailfrom=nphamcs@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1727133069; 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-transfer-encoding:content-transfer-encoding: in-reply-to:references:dkim-signature; bh=DHKkPqQYYlWv/vbNTvZkuEr8x6McI9yagRLdFXJXWgk=; b=fQynb4czCRJvn88UUEDrLIRCshLVz3y3MJZU0/BIl0kwp++4v55fSrjm2EgbKcYR8qOLdA yx21varPuT9YONQRlUaPtNq8xyeca2Ucfo064FGRFW8QcdagfFMBT5Lab0M7IRO3HdvPRG 0+EgkBnLm2b27zFxWP4t2S9zospLNKs= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b="fQ4/5qWY"; spf=pass (imf27.hostedemail.com: domain of nphamcs@gmail.com designates 209.85.128.179 as permitted sender) smtp.mailfrom=nphamcs@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1727133069; a=rsa-sha256; cv=none; b=spFnrH1skicoJKpcbVz5JI+Jg3Twz4I8yyKnisZa3UpJSvqSUaMa2kglDlXCDbbcvzgKNZ 9z6NdKhiR+syWgL3lP0+WvK4RgmzBtyxi4YHKby6F9Nv2O/paM4ZmQ3boeXbwmWTHXg3bm R0/Ku3uC0jS2VRvCHDaadJCiz0mjp6M= Received: by mail-yw1-f179.google.com with SMTP id 00721157ae682-6de05b9fd0bso39645537b3.1 for ; Mon, 23 Sep 2024 16:11:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727133103; x=1727737903; darn=kvack.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=DHKkPqQYYlWv/vbNTvZkuEr8x6McI9yagRLdFXJXWgk=; b=fQ4/5qWYGBonxVynLXLrCM2J2Qu+uifJXzAQ454SUWKsrzRGPz/kF7qC5+o6ETI0Ll wh0/jPjX+mOeeRqi2nL3CKFFWsfPHLobJ82nrZ5Y9fM5KVErL9Pqw+eODC/K4qMvbEHy omxRyb/IOnXO+plLqowIpztoKrLwVJTlaV9nf6QemkKaJ9gZ03eb+9/vR2kO4QDFAOaF kwO5ncExMa23Y1G3xbDB1D9pmjXvcInBNqELLc5tqn56oTHOpvvU0lEqRfpOdIsGZHAp z8U5BTMUpeaXXFfF2qeJFTgdhwhPfYMBZRheEmPG8w4OsFLtF8tkdlhsR/JyT0yBO/ZA iOzQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727133103; x=1727737903; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=DHKkPqQYYlWv/vbNTvZkuEr8x6McI9yagRLdFXJXWgk=; b=QUqphwLhDTg2SQLY3hGXk7I0bNExwGMGgiEPgNihN0d76CWKkf3xXRLKsnrqJNG6tX EEtajrawmfN5Cx0c80Ktz0LThjlwPPhBYbN75M00fj9sYt6jUnRQu73VL/tJSl29yIPn 40mFAHIxrGS9V91kMPAOgo6wFXK5oQJr3kFtX2939dspLpKmmXTKwh+0KISnI+zrI4vt 5zgjTOuwe+DIAdwxI3UAuRHWm12pS+60l+RwjxmbQBFMHMvHSXinzKxJmdyHo7Q9wZ+0 pxSsAH1aZEvOxE+4bV37cRaV8DVQdd/cKg2ziIf8KTaiOVv/7zO2wz2CJ8vAutncWpQU CLJA== X-Forwarded-Encrypted: i=1; AJvYcCWxOvU/0eeKvwqnKXbqehkxO7gXD1SC+vkoDEraDkV33Gs8bVLVz+ivJLqqJZzrh/bG5bslrwlNxQ==@kvack.org X-Gm-Message-State: AOJu0YyrxLUoVvtiJurqlTsDCFRJJ9PvpKmJp3ETZuWL4/co1u1K8sj3 Wzc/HGBsN77rz28Bu8QEdIgHMNWrhovqZuKyUJkcU1COpFSLjQtt X-Google-Smtp-Source: AGHT+IFd3FdhPUVmHvF03BjWT2MKPtk7UXG3s7ZdOz3aEwuodHwAbZ/TN/xYLkEOz68pRIzcUQq3AQ== X-Received: by 2002:a05:690c:fc1:b0:6e2:f32:bd2c with SMTP id 00721157ae682-6e20f32c4camr1941657b3.29.1727133103225; Mon, 23 Sep 2024 16:11:43 -0700 (PDT) Received: from localhost (fwdproxy-nha-000.fbsv.net. [2a03:2880:25ff::face:b00c]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6e20d06a9d8sm577977b3.59.2024.09.23.16.11.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Sep 2024 16:11:43 -0700 (PDT) From: Nhat Pham To: akpm@linux-foundation.org Cc: hannes@cmpxchg.org, yosryahmed@google.com, hughd@google.com, shakeel.butt@linux.dev, ryan.roberts@arm.com, ying.huang@intel.com, chrisl@kernel.org, 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 Subject: [RFC PATCH 0/2] remove SWAP_MAP_SHMEM Date: Mon, 23 Sep 2024 16:11:40 -0700 Message-ID: <20240923231142.4155415-1-nphamcs@gmail.com> X-Mailer: git-send-email 2.43.5 MIME-Version: 1.0 X-Rspam-User: X-Stat-Signature: m5tkse98jmwoqzkhenj66jj6wser3jj4 X-Rspamd-Queue-Id: 4409B4000A X-Rspamd-Server: rspam11 X-HE-Tag: 1727133104-347695 X-HE-Meta: U2FsdGVkX1+VlO1c561HoNkXca/WIOoqeFQ2dGjsDddScoWmf5sG+nlSNz0EIL63+wKbyzpHHxGk6vp+ko87m/+swxS/asKuWJx8ATqtatEbo46R4tjBfXr13lAZD8Ul6WXrFFGrarLDlIastVXOVDgP5oY7ZAJRwBy0RPnl5fKWsVX6H6cuFKhnpADoxKErVt4NEX8k92Xcyw+TMEv127624FSlgudNtuELaNLYwSectJa3/cyDXodOr/nc3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wD1Wm0RXPzEUqBiAH2gLC/H99hiz2P1TFgBNyjjzhn0ORs37a 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: 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 == SWAP_MAP_SHMEM value is basically the same as having swap count == 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 entries that never gets re-duplicated). 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 mind 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 Reviewed-by: Yosry Ahmed