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 F384CC282DE for ; Thu, 13 Mar 2025 12:09:38 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B66E9280008; Thu, 13 Mar 2025 08:09:34 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 98748280005; Thu, 13 Mar 2025 08:09:34 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6A19A280005; Thu, 13 Mar 2025 08:09:34 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 37AB6280004 for ; Thu, 13 Mar 2025 08:09:34 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 4B1ED1CD399 for ; Thu, 13 Mar 2025 12:09:34 +0000 (UTC) X-FDA: 83216408268.30.B13E2FC Received: from dggsgout11.his.huawei.com (dggsgout11.his.huawei.com [45.249.212.51]) by imf07.hostedemail.com (Postfix) with ESMTP id D52214000B for ; Thu, 13 Mar 2025 12:09:29 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf07.hostedemail.com: domain of shikemeng@huaweicloud.com designates 45.249.212.51 as permitted sender) smtp.mailfrom=shikemeng@huaweicloud.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1741867772; a=rsa-sha256; cv=none; b=T000o3GpUxLLxjnj5Lgd9vq7OALk3lR8csTipWuFTs2Pr77JtJ+hyRV73+JBMuAl/AcFvU lk94iOyMNRYgyLHmVWk9UyrOvIPVEcr5WlWWfKiLknkTKS06fBRjRptHu7gXPIfMg/8Hll GaxOX6AB5ZKhBoByhscWzhUqwg/llp8= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf07.hostedemail.com: domain of shikemeng@huaweicloud.com designates 45.249.212.51 as permitted sender) smtp.mailfrom=shikemeng@huaweicloud.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1741867772; 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:in-reply-to:references:references; bh=r9bg9qJUM/CqXCc4dcqIoUIlnLfgbqcRwLmq7+3vJP4=; b=jNgOQZ0KQprVYmEaaSnF+h4PuPbaWQ+ZXXcv7cJ6TC2ZjsHglT4GihCwa1lHWcvTuqz3bO KAr3biXWB3yz6DVzj4msX2dgPAwqpz9B8DGJm6KdwYxTpElP43vtYzJ5Cns0JckkCJQ7xk pp19ZoEapEQ3Po+QJAnDwaExDDoCg88= Received: from mail.maildlp.com (unknown [172.19.163.216]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4ZD5rg2Zrrz4f3jLh for ; Thu, 13 Mar 2025 20:09:07 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.75]) by mail.maildlp.com (Postfix) with ESMTP id 6DFA01A0A22 for ; Thu, 13 Mar 2025 20:09:24 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.101.6]) by APP2 (Coremail) with SMTP id Syh0CgCnsGPyytJnTaZeGQ--.9643S3; Thu, 13 Mar 2025 20:09:24 +0800 (CST) From: Kemeng Shi To: akpm@linux-foundation.org Cc: kasong@tencent.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/9] mm: swap: rename __swap_[entry/entries]_free[_locked] to swap_[entry/entries]_put[_locked] Date: Fri, 14 Mar 2025 05:05:07 +0800 Message-Id: <20250313210515.9920-2-shikemeng@huaweicloud.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20250313210515.9920-1-shikemeng@huaweicloud.com> References: <20250313210515.9920-1-shikemeng@huaweicloud.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID:Syh0CgCnsGPyytJnTaZeGQ--.9643S3 X-Coremail-Antispam: 1UD129KBjvJXoWxZrWUKFW5Zw1DuF4rGF47CFg_yoWrtFyxpF 9Igrn8KFs7Xr1fGw4xXw48ZrWFvw4xWw18tFy7Gw1avasxJryFqFyDC3y7KFyUCr95Cr90 ya1Utry7GF4jvF7anT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUBjb4IE77IF4wAFF20E14v26r4j6ryUM7CY07I20VC2zVCF04k2 6cxKx2IYs7xG6rWj6s0DM7CIcVAFz4kK6r1j6r18M280x2IEY4vEnII2IxkI6r1a6r45M2 8IrcIa0xkI8VA2jI8067AKxVWUGwA2048vs2IY020Ec7CjxVAFwI0_Jrv_JF4l8cAvFVAK 0II2c7xJM28CjxkF64kEwVA0rcxSw2x7M28EF7xvwVC0I7IYx2IY67AKxVW7JVWDJwA2z4 x0Y4vE2Ix0cI8IcVCY1x0267AKxVW8Jr0_Cr1UM28EF7xvwVC2z280aVAFwI0_GcCE3s1l 84ACjcxK6I8E87Iv6xkF7I0E14v26rxl6s0DM2AIxVAIcxkEcVAq07x20xvEncxIr21l5I 8CrVACY4xI64kE6c02F40Ex7xfMcIj6xIIjxv20xvE14v26r1j6r18McIj6I8E87Iv67AK xVWUJVW8JwAm72CE4IkC6x0Yz7v_Jr0_Gr1lF7xvr2IYc2Ij64vIr41l42xK82IYc2Ij64 vIr41l4I8I3I0E4IkC6x0Yz7v_Jr0_Gr1lx2IqxVAqx4xG67AKxVWUJVWUGwC20s026x8G jcxK67AKxVWUGVWUWwC2zVAF1VAY17CE14v26r126r1DMIIYrxkI7VAKI48JMIIF0xvE2I x0cI8IcVAFwI0_Jr0_JF4lIxAIcVC0I7IYx2IY6xkF7I0E14v26r1j6r4UMIIF0xvE42xK 8VAvwI8IcIk0rVWUJVWUCwCI42IY6I8E87Iv67AKxVWUJVW8JwCI42IY6I8E87Iv6xkF7I 0E14v26r1j6r4UYxBIdaVFxhVjvjDU0xZFpf9x07js2-5UUUUU= X-CM-SenderInfo: 5vklyvpphqwq5kxd4v5lfo033gof0z/ X-Rspamd-Server: rspam07 X-Rspam-User: X-Stat-Signature: n7fuuionbo967hi67tydkday9oqttoeb X-Rspamd-Queue-Id: D52214000B X-HE-Tag: 1741867769-609 X-HE-Meta: U2FsdGVkX1+B/WKNpo2N/J1keuLZ0GvOUYZIpeidfHfapbS4sYY0fry+TwpKWV0+iHPZ8zZRtdzcF8Zqhy2g40UumMpXJcHyeKs1/iOF+vctBowEBcuJB0Gg94FGkHREdttGYXqm9DpZkk810Xn+Vsc8zAsdmztJ61n3h0um2koBPYgNCZabl6Z5nP3YW9+uH30hl4k4d7kgmxAyT0VDNYPzyzce8q+/EjMGHCFiLRxAfryAIXcbeuXJvTH6rpPYyVnLS7smHSQsLxzc2/3IO3p5hF2dsNFMh9D9SOuQFRUkNzuQMAV/abBH9GgYd45hSRk4xEBFNiqwG4HBUI42zUC9Nsi6cKc0NN61TAUW9RwCuBHC2nY9hM8NzwPMih/4zhAgb+juluMNFrf0M4rXY5paMe6Cy2az+t5uEPQz2PygvJVayNGhlleToiWu5qeh/G6+pEA4nBO6TuviisTwOn0ZriDbZ3C0ARHoUF/Ek86kXyUClkAvIH+Fyx5cr+wGi/fm96UeOQWmTFa2bRW/zLyfDVL0KjDB2izWd4NuQjV2WvD7ahPIfscYke3cgjIj2k1kMDoV0JSxDZbDOrWRAFNeEWU1lQkBVjv6qJEQAZSpsvGeppg23b8RUeQzaiweFcvhatdirmOh4uF/BN901uqxZF60WkJ46FnWi9SoT+p/9uPM+2AWNMJS89gSzWlROX6coDEv3eI80p61LDtzDe66lwIWVG/Mzz4bBaX29BNT+1QKQgt05wFNE3eCck57aY6TFcb1ZumA0wSpSwxjFgyBVlOxxMk8zGEzWTrPh7dYCsA/DrdB0b6Efwq7ahi78uWXHTh8YsN6ueJLMlkuFSSgWtV/dftRU5T8czyZCpXZTx8vCl1/y2Mg+whZWxXW2G26NE/8hylNEN4JE4hpvD6iq7+6TpeArsHxk/g8WbSjFXdGb61GcUhKZNPeFG30HyHaXRp0tTmN13ZHdp/ vYoG6Ndn XIdyQGQDHQYbeXvUVAkryM9nn9v6ByC8mLQSu3WdeGFcJBHpNow9ScCC4dMFt4uM+LvFTjLLGYtrdKyPddjCyaCmJeEzrXTTWO1J9NYbqv+sS+1eqb0YfB2tmlXWh87ML/cqRnPZkpu8nZmVXhvvUl8YhrtEfNKMMrD4XYKwsFrCNhddT1/bz20KAOIxOVsU5GeZpxXwIL47PVOLHAKseo8BPeQ== 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: In __swap_entry_free[_locked] and __swap_entries_free, we decrease count first and only free swap entry if count drops to zero. This behavior is more akin to a put() operation rather than a free() operation. Therefore, rename these functions with "put" instead of "free". Additionally, add "_nr" suffix to swap_entries_put to indicate the input range may span swap clusters. Signed-off-by: Kemeng Shi --- mm/swapfile.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/mm/swapfile.c b/mm/swapfile.c index 628f67974a7c..5a775456e26c 100644 --- a/mm/swapfile.c +++ b/mm/swapfile.c @@ -1347,9 +1347,9 @@ static struct swap_info_struct *_swap_info_get(swp_entry_t entry) return NULL; } -static unsigned char __swap_entry_free_locked(struct swap_info_struct *si, - unsigned long offset, - unsigned char usage) +static unsigned char swap_entry_put_locked(struct swap_info_struct *si, + unsigned long offset, + unsigned char usage) { unsigned char count; unsigned char has_cache; @@ -1453,15 +1453,15 @@ struct swap_info_struct *get_swap_device(swp_entry_t entry) return NULL; } -static unsigned char __swap_entry_free(struct swap_info_struct *si, - swp_entry_t entry) +static unsigned char swap_entry_put(struct swap_info_struct *si, + swp_entry_t entry) { struct swap_cluster_info *ci; unsigned long offset = swp_offset(entry); unsigned char usage; ci = lock_cluster(si, offset); - usage = __swap_entry_free_locked(si, offset, 1); + usage = swap_entry_put_locked(si, offset, 1); if (!usage) swap_entry_range_free(si, ci, swp_entry(si->type, offset), 1); unlock_cluster(ci); @@ -1469,8 +1469,8 @@ static unsigned char __swap_entry_free(struct swap_info_struct *si, return usage; } -static bool __swap_entries_free(struct swap_info_struct *si, - swp_entry_t entry, int nr) +static bool swap_entries_put_nr(struct swap_info_struct *si, + swp_entry_t entry, int nr) { unsigned long offset = swp_offset(entry); unsigned int type = swp_type(entry); @@ -1501,7 +1501,7 @@ static bool __swap_entries_free(struct swap_info_struct *si, fallback: for (i = 0; i < nr; i++) { if (data_race(si->swap_map[offset + i])) { - count = __swap_entry_free(si, swp_entry(type, offset + i)); + count = swap_entry_put(si, swp_entry(type, offset + i)); if (count == SWAP_HAS_CACHE) has_cache = true; } else { @@ -1552,7 +1552,7 @@ static void cluster_swap_free_nr(struct swap_info_struct *si, ci = lock_cluster(si, offset); do { - if (!__swap_entry_free_locked(si, offset, usage)) + if (!swap_entry_put_locked(si, offset, usage)) swap_entry_range_free(si, ci, swp_entry(si->type, offset), 1); } while (++offset < end); unlock_cluster(ci); @@ -1599,7 +1599,7 @@ void put_swap_folio(struct folio *folio, swp_entry_t entry) swap_entry_range_free(si, ci, entry, size); else { for (int i = 0; i < size; i++, entry.val++) { - if (!__swap_entry_free_locked(si, offset + i, SWAP_HAS_CACHE)) + if (!swap_entry_put_locked(si, offset + i, SWAP_HAS_CACHE)) swap_entry_range_free(si, ci, entry, 1); } } @@ -1798,7 +1798,7 @@ void free_swap_and_cache_nr(swp_entry_t entry, int nr) /* * First free all entries in the range. */ - any_only_cache = __swap_entries_free(si, entry, nr); + any_only_cache = swap_entries_put_nr(si, entry, nr); /* * Short-circuit the below loop if none of the entries had their @@ -1811,7 +1811,7 @@ void free_swap_and_cache_nr(swp_entry_t entry, int nr) * Now go back over the range trying to reclaim the swap cache. This is * more efficient for large folios because we will only try to reclaim * the swap once per folio in the common case. If we do - * __swap_entry_free() and __try_to_reclaim_swap() in the same loop, the + * swap_entry_put() and __try_to_reclaim_swap() in the same loop, the * latter will get a reference and lock the folio for every individual * page but will only succeed once the swap slot for every subpage is * zero. @@ -3758,7 +3758,7 @@ int add_swap_count_continuation(swp_entry_t entry, gfp_t gfp_mask) * into, carry if so, or else fail until a new continuation page is allocated; * when the original swap_map count is decremented from 0 with continuation, * borrow from the continuation and report whether it still holds more. - * Called while __swap_duplicate() or caller of __swap_entry_free_locked() + * Called while __swap_duplicate() or caller of swap_entry_put_locked() * holds cluster lock. */ static bool swap_count_continued(struct swap_info_struct *si, -- 2.30.0