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 5CC3CC36002 for ; Wed, 9 Apr 2025 06:25:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 385636B0136; Wed, 9 Apr 2025 02:25:43 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 333886B0137; Wed, 9 Apr 2025 02:25:43 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1FC536B0138; Wed, 9 Apr 2025 02:25:43 -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 018E86B0136 for ; Wed, 9 Apr 2025 02:25:42 -0400 (EDT) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id E0C341CEB3C for ; Wed, 9 Apr 2025 06:25:43 +0000 (UTC) X-FDA: 83313519366.13.675B5A6 Received: from dggsgout11.his.huawei.com (dggsgout11.his.huawei.com [45.249.212.51]) by imf20.hostedemail.com (Postfix) with ESMTP id 2E13F1C0007 for ; Wed, 9 Apr 2025 06:25:38 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf20.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=1744179942; 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; bh=c/MGjYL+Qejs1giFsVSF9voVjXooUWfr/b9vv+sGyqo=; b=RwmKtm15gtjlCs795saCmzh6UCnHv3mt8IaNU09uQZwmgXcldv0oEM6BZoWDP2WSw/8xg+ q/Tzgyg4l4vgJmPT0cn25ehg5TAai9Bq/lrQGW8bLYvKvN+vl95/TRe2RYU47drtnF+DiW o1oIaoLilrHXb1gf6zkB9wpurr1KB9E= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1744179942; a=rsa-sha256; cv=none; b=gvQ/QneDV/8Db0RVxBXFlHG+hXkQ2/d7K2yxyYAP3En8D1ZsCL4LI+xehb66lnuihj3R89 k3HL4ECHJaOVg5nTY6WGy3dLo3rI80Vm0WgEU4UKzSXUCMGwl6pisD2zWH0ouHOdH6hGWB uJshiavWU0jyqXHw+EyTtX6eCnr/bSY= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf20.hostedemail.com: domain of shikemeng@huaweicloud.com designates 45.249.212.51 as permitted sender) smtp.mailfrom=shikemeng@huaweicloud.com Received: from mail.maildlp.com (unknown [172.19.93.142]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4ZXXxP41tnz4f3jtK for ; Wed, 9 Apr 2025 14:25:13 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.128]) by mail.maildlp.com (Postfix) with ESMTP id 8DAF11A0AD9 for ; Wed, 9 Apr 2025 14:25:31 +0800 (CST) Received: from [10.174.178.129] (unknown [10.174.178.129]) by APP4 (Coremail) with SMTP id gCh0CgDnR1zCEvZndqnLIw--.31042S2; Wed, 09 Apr 2025 14:25:27 +0800 (CST) Subject: Re: [linux-next:master 1753/1936] mm/swapfile.c:1517:20: warning: function 'swap_is_last_ref' is not needed and will not be emitted To: Andrew Morton , kernel test robot Cc: llvm@lists.linux.dev, oe-kbuild-all@lists.linux.dev, Linux Memory Management List , Tim Chen , Baoquan He References: <202504081841.jbL7yL0r-lkp@intel.com> <20250408173959.f501f65ec5d5e52cefe6b129@linux-foundation.org> From: Kemeng Shi Message-ID: <5560cc75-c219-2f8b-7296-0bfb904172e7@huaweicloud.com> Date: Wed, 9 Apr 2025 14:25:06 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.9.1 MIME-Version: 1.0 In-Reply-To: <20250408173959.f501f65ec5d5e52cefe6b129@linux-foundation.org> Content-Type: text/plain; charset=gbk Content-Transfer-Encoding: 7bit X-CM-TRANSID:gCh0CgDnR1zCEvZndqnLIw--.31042S2 X-Coremail-Antispam: 1UD129KBjvJXoWxXF45WFyDAF13Jr47Gr1rJFb_yoWrWF4xpF W8Wwn8GF48JryxKa9rW3Z8XrySgws3Gw15JFyDKry8ZasrJrWagF9a9rWYkFnrAw1v9FWY vFsFga13ua1qvF7anT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUkEb4IE77IF4wAFF20E14v26r4j6ryUM7CY07I20VC2zVCF04k2 6cxKx2IYs7xG6rWj6s0DM7CIcVAFz4kK6r1j6r18M28lY4IEw2IIxxk0rwA2F7IY1VAKz4 vEj48ve4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_Ar0_tr1l84ACjcxK6xIIjxv20xvEc7Cj xVAFwI0_Gr1j6F4UJwA2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xvwVC2z280aVCY1x 0267AKxVW0oVCq3wAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG 6I80ewAv7VC0I7IYx2IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFV Cjc4AY6r1j6r4UM4x0Y48IcVAKI48JMxk0xIA0c2IEe2xFo4CEbIxvr21lc7CjxVAaw2AF wI0_JF0_Jw1l42xK82IYc2Ij64vIr41l4I8I3I0E4IkC6x0Yz7v_Jr0_Gr1lx2IqxVAqx4 xG67AKxVWUJVWUGwC20s026x8GjcxK67AKxVWUGVWUWwC2zVAF1VAY17CE14v26r126r1D MIIYrxkI7VAKI48JMIIF0xvE2Ix0cI8IcVAFwI0_Jr0_JF4lIxAIcVC0I7IYx2IY6xkF7I 0E14v26r1j6r4UMIIF0xvE42xK8VAvwI8IcIk0rVWUJVWUCwCI42IY6I8E87Iv67AKxVWU JVW8JwCI42IY6I8E87Iv6xkF7I0E14v26r1j6r4UYxBIdaVFxhVjvjDU0xZFpf9x07UK2N tUUUUU= X-CM-SenderInfo: 5vklyvpphqwq5kxd4v5lfo033gof0z/ X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 2E13F1C0007 X-Stat-Signature: rwzrhxsg9zxrkszp6gg39tcm8egt3kse X-Rspam-User: X-HE-Tag: 1744179938-712882 X-HE-Meta: U2FsdGVkX1/Wtrl2/g2PdmOmLOd+1TbXoyAtDCLpJTIrXApqVP7V2zSAB5Th0f+vv4vPKG96mY0wUTs0KrkDcdz2zWSdrBvFP5pdZcXxEg210cyLv9dWJ23sAW5PLZHhkWvVvWh7mjq77EkNz8XGTILq0ynIQ08P9Hn00kcK4j0eUBowdSnu1Z3enHzqMi6OyDUUCNV3H9Ydb8HknyUDqR1TEFjs0bo6Fj3TYoFJofuyzQypRi7baPs9PGZiNJLDhR6B88qK3lB5KomgDoTGJH82CZUl5/E/V/EgTZNcKLl0pub/LwbnxqsrOkPWFCaarcm7tzhGvl3WhN48HxNTbsKP28W6T1kKzXj1YocGGMO8uZzsdz+G7ZVvSmuWs2ydfU16nMcvJYAN/FuTklRtGwjtcLUhJeqWuaSH8YfIS4sligBIXZD6QOip4tiYjfq3wb88PCjJK6tp7KiyBDESCmrLf9vhd8Qi7bEQS6MZc9WPoSSr64YtoFBhtjHKbV4zr9X55Umq/lAWEmf7m8nYhaymVvJzZajpzMAcFPr8Dk718nFRAUzp+IhYi2MfLXFtDj3End8H6cRjy9L29hIm2tvqU4D3e0D8jRM/2xlvTfd+oXwgXFQn30rq/n0MpNaquKsZvMPz04P41hdLuFXRPPT8NdGoNae0S84fZucI9wy5bo/v9NihT3D5aa3Ewp3bZjQ3NG1RX+2ohdDO6zjp/D1EDqeo0IO5b/KMI+RUAYAxdAHoGTgn3DNdtgfLhhjjxbrh2CA8gDMAon1BCjYKK8CxybMGoC0+JRbZoR3KTgtloNr06o1dwTTyqCTyIGCdJ+sYkf3iAfr5kuxT1DjmKzQdWucS0thIijPXPiCE7wEwPY70S9SUqYneiAZPwbXJoAUfZ9KWMkULoOQeeLKscg6WF+PazdKLU4id7Q4SrHlfU6UolG8VjwWu/KbtFDKCuVYC7TetrZmtEV83cLL Vna0aToT qQIznR20pNEMOOBFw728yTFCJtkjgt2/sm2nl3s+QfzFJciwJ3FkzXSuExdHrl1KXwV8XcxCDCmg68IS7qG4KNRkGJSz9akCsl/EQHcJS+8UkGHV71ZAF/ZJIGdpjpNiONuLLVpQ+GoQCYVNnHQKgAA+RSS+R577+RK72TcaXIsR2t5/K+iJeouJuskr1IJvJbE2xnxXwK85visPymc5fyuyJelvLEQVRVTwxeDwaB/5CuOV9yhrIJ38iaCY+E5POPUah4tD7WZpWLRgb7LCLUveeP1xl6ex4k0xgurn1ovr/xv4oKhwyetFqTSwTpkaUhbxgVpzy1gaE9aM= 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: on 4/9/2025 8:39 AM, Andrew Morton wrote: > On Tue, 8 Apr 2025 18:06:11 +0800 kernel test robot wrote: > >> tree: https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master >> head: 7702d0130dc002bab2c3571ddb6ff68f82d99aea >> commit: 6bb001b6b64ec20d900d0d81294a0f031af59c3e [1753/1936] mm: swap: enable swap_entry_range_free() to drop any kind of last ref >> config: hexagon-randconfig-001-20250408 (https://download.01.org/0day-ci/archive/20250408/202504081841.jbL7yL0r-lkp@intel.com/config) >> compiler: clang version 21.0.0git (https://github.com/llvm/llvm-project 92c93f5286b9ff33f27ff694d2dc33da1c07afdd) >> reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250408/202504081841.jbL7yL0r-lkp@intel.com/reproduce) >> >> If you fix the issue in a separate patch/commit (i.e. not just a new version of >> the same patch/commit), kindly add following tags >> | Reported-by: kernel test robot >> | Closes: https://lore.kernel.org/oe-kbuild-all/202504081841.jbL7yL0r-lkp@intel.com/ >> >> All warnings (new ones prefixed by >>): >> >>>> mm/swapfile.c:1517:20: warning: function 'swap_is_last_ref' is not needed and will not be emitted [-Wunneeded-internal-declaration] > > It's annoying that gcc warns about this. > >> 1517 | static inline bool swap_is_last_ref(unsigned char count) >> | ^~~~~~~~~~~~~~~~ >> 1 warning generated. >> >> >> vim +/swap_is_last_ref +1517 mm/swapfile.c >> >> 1512 >> 1513 /* >> 1514 * Drop the last ref(1, SWAP_HAS_CACHE or SWAP_MAP_SHMEM) of swap entries, >> 1515 * caller have to ensure all entries belong to the same cgroup and cluster. >> 1516 */ >>> 1517 static inline bool swap_is_last_ref(unsigned char count) >> 1518 { >> 1519 return (count == SWAP_HAS_CACHE) || (count == 1) || >> 1520 (count == SWAP_MAP_SHMEM); >> 1521 } >> 1522 > > : static inline bool swap_is_last_ref(unsigned char count) > : { > : return (count == SWAP_HAS_CACHE) || (count == 1) || > : (count == SWAP_MAP_SHMEM); > : } > : > : static void swap_entries_free(struct swap_info_struct *si, > : struct swap_cluster_info *ci, > : swp_entry_t entry, unsigned int nr_pages) > : { > : unsigned long offset = swp_offset(entry); > : unsigned char *map = si->swap_map + offset; > : unsigned char *map_end = map + nr_pages; > : > : /* It should never free entries across different clusters */ > : VM_BUG_ON(ci != offset_to_cluster(si, offset + nr_pages - 1)); > : VM_BUG_ON(cluster_is_empty(ci)); > : VM_BUG_ON(ci->count < nr_pages); > : > : ci->count -= nr_pages; > : do { > : VM_BUG_ON(!swap_is_last_ref(*map)); > > > And it's annoying that VM_BUG_ON() doesn't reference its arg when > CONFIG_DEBUG_VM=n. > > I'll add this: Thanks for fixing this. > > --- a/mm/swapfile.c~mm-swap-enable-swap_entry_range_free-to-drop-any-kind-of-last-ref-fix > +++ a/mm/swapfile.c > @@ -1514,11 +1514,13 @@ fallback: > * Drop the last ref(1, SWAP_HAS_CACHE or SWAP_MAP_SHMEM) of swap entries, > * caller have to ensure all entries belong to the same cgroup and cluster. > */ > +#ifdef CONFIG_DEBUG_VM > static inline bool swap_is_last_ref(unsigned char count) > { > return (count == SWAP_HAS_CACHE) || (count == 1) || > (count == SWAP_MAP_SHMEM); > } > +#endif > > static void swap_entries_free(struct swap_info_struct *si, > struct swap_cluster_info *ci, > _ > > Kemeng, can you please review that comment "Drop the last ref...". >>>From its positioning it appears to be describing swap_is_last_ref(), > but swap_is_last_ref() doesn't do those things. > The comment was originally for swap_entries_free() where swap_is_last_ref() is factored out from. The swap_is_last_ref() is only used in swap_entries_free(), so I treat these two functions as a single unit and placed the comment in front of swap_is_last_ref(). If this introduces confusion, I think we can simply move this comment to front of swap_entries_free() to address this. Thanks, Kemeng