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 F1009C36010 for ; Wed, 9 Apr 2025 02:25:08 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B4F5B28003E; Tue, 8 Apr 2025 22:25:07 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B014328003C; Tue, 8 Apr 2025 22:25:07 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9C61328003E; Tue, 8 Apr 2025 22:25:07 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 7DD3128003C for ; Tue, 8 Apr 2025 22:25:07 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 96A3081925 for ; Wed, 9 Apr 2025 02:25:07 +0000 (UTC) X-FDA: 83312913054.21.02884EF Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf14.hostedemail.com (Postfix) with ESMTP id A58DE100002 for ; Wed, 9 Apr 2025 02:25:05 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=XG80HE1N; dmarc=pass (policy=quarantine) header.from=redhat.com; spf=pass (imf14.hostedemail.com: domain of bhe@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=bhe@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1744165505; 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:in-reply-to:references:references:dkim-signature; bh=viubT93gH39g0FQkvdGZnqOQNHK3ZEdHNZSdQRbLEBE=; b=QgF1EtcwYqxYpL8w0rpEDXqJKzZJGu0PpFPQwoxXY7SAoZOMssLU2oV9Ovdg+L6UD+EDit /hqUScKc4J+bAAWD5iEAdzjDPdtGDmdXrG30idZMeT8pri9GGAynMGBLEMZe9p/dTGuHmY jatdqD1LXaqDkGYzavjkf8VUnzW/vm0= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=XG80HE1N; dmarc=pass (policy=quarantine) header.from=redhat.com; spf=pass (imf14.hostedemail.com: domain of bhe@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=bhe@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1744165505; a=rsa-sha256; cv=none; b=Zn7bvOrNc4l9quyNyg2NhKu1odp2y7SNI3CfVa3p1K+ZgLcATB+OmwM3Y20BfaQGQfpQeI Yvb9+lVRMEnUepNznknNTKVHeg/vOefmZMuyJMooSFXYJFpfuuVjhsfwleeayR20yLsB8L 916j3tW+tUKzu48KX4CtsNPClv5E7OU= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1744165503; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=viubT93gH39g0FQkvdGZnqOQNHK3ZEdHNZSdQRbLEBE=; b=XG80HE1NGEk2mECVsZNsdoLity/PVdDeRaVW8afpalAM5qG0hxI6rGdJMtSKgkvCgjBM1G L5wwE1VRqs9eH1wZzdkPDrzIgnE26yAfm22ygJsJbdzvk0e6huhMYPPFiCWJg38P2aOy+T shyDgD7DpmX9y0ABbuXg37485U8skJ4= Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-543-2UVoF_rkM--J4w6KkhOSBw-1; Tue, 08 Apr 2025 22:24:59 -0400 X-MC-Unique: 2UVoF_rkM--J4w6KkhOSBw-1 X-Mimecast-MFC-AGG-ID: 2UVoF_rkM--J4w6KkhOSBw_1744165498 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id CDEDD180049D; Wed, 9 Apr 2025 02:24:57 +0000 (UTC) Received: from localhost (unknown [10.72.112.61]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 15C963001D0E; Wed, 9 Apr 2025 02:24:55 +0000 (UTC) Date: Wed, 9 Apr 2025 10:24:51 +0800 From: Baoquan He To: Andrew Morton , Kemeng Shi Cc: kernel test robot , llvm@lists.linux.dev, oe-kbuild-all@lists.linux.dev, Linux Memory Management List , Tim Chen 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 Message-ID: References: <202504081841.jbL7yL0r-lkp@intel.com> <20250408173959.f501f65ec5d5e52cefe6b129@linux-foundation.org> MIME-Version: 1.0 In-Reply-To: <20250408173959.f501f65ec5d5e52cefe6b129@linux-foundation.org> X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: u6rwgwouepDbB334rHnpSK_OcekWhDS2HRTvwXdQkX8_1744165498 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Rspamd-Server: rspam01 X-Stat-Signature: jnyg5uyy4abtrtr76b6kcnezo3hnhanf X-Rspam-User: X-Rspamd-Queue-Id: A58DE100002 X-HE-Tag: 1744165505-102194 X-HE-Meta: U2FsdGVkX19fkvN4ofWYybyIeRq59GI0x44wEhg6twS77TIMYNlXmWzxDh5iIKs308D9cyfg8ISFITKLimkHcQYNG7pTkVtvmmoC9tkj0KhcK27JyuRoDUUqUnpD6Nth2ux7nWN5+K3zKeyc0wbX85kaRy6FMgg9EZvDLeQb9wVjOoCyd4jd3xMbFKGkkiR7XGq3VEAxpD95DA8V//dnPJw+DyVJQRiO2v69E4p5jtMkzNLkJXxYe1paEOpuVLu1PuOO89tg4X7WlQ8RZMpa4EuTUZhSUi3yXIXFclcxyWFofG+OJvfsFU7/9BP8IFFFFcfzelwcSE0q5gQPci4I3Eq3eow0F4HR7Z1BaYinGfrF8BvMH2DpWNdSbMg2xNhMOF2q3D0UAVz1p0nNgUMTd0eAN1MJtFa9pJKR4KTmJdirEwNd9O1NsOVYRB3fyPYv9MRIjevbStvxHMk0QuBOIPeF9RqzT6VIPFT6F7fmnsbfst8EjOFlKBnM/MHktQSehuRc2vSOQXaj6bdT+naXe7KiKzaq7FsKM4AcOZPslVKOi3weIDs7F7bpb0I7r9N02m3h5t0rNqtaT6CO6M/UU3XVjA7pv8a0RAWGOhucwZ7mcN69tma4ic0cmSoV4jAk+3pXW55Y0yma38797B/qJtfmMqIJ0NwPDjFTD9AQp3X1+GbPn2fqssv3KA5SOIULeOJTQUH87GyxfxkiL5vgYsF0HDlwq5rNkrtaSQJnUrtWzqsIroft8uWksKpNCrIojYaddyUdtUZu+kuJOobeKNLn76aWw/NSKm0Z2IJYEhdsNmOzqy0/+TrYg025vPFadpEE1pT22VX+Hy76LYsE+tRhiqqIvpJ8fP/zOd/nn5ELBQYOLy7jPtK0fQivgKYkownzyAfgBZxBB4vssyCe+8PV2h1qUpKxcsLEXH8Qa+SVI+y1siOX568EN20tAVbINrIS7GpCwwRqzFKmJiS uDYIAOxo 7Wa9FesR+PTElXK3ayeS61bitk6jUajDt4SLlZ5Ao/hLiq6HeUHJgkui7Jx4dy+VVNiEIl5pUDbWw7DOZVAUS4bqNCZH0u0101uhr19DebJVEylmYNgSIOcTnAsFg6iPCfG0VyMO3EJEMVi0SEGVufKy5yTwIDQhVwdU8b+ImECtaIDxJavM0+G7BKC0urxUAuLgsPS0oeSrLCKWj/MIR8IAzXy1cj9LrIfB5Bi+PalG/Fy/Iut/RhNJ5izy2Yhirj8l3qNUcX2iEmGCUXsuigEPtfdbApjw6imseIjYs7pO/FjU9zFvZFPuhgLVnRDirYFoXuTXJomvWy2qzWoGEoQAtRt9/HcugdM8MwhLLCa27tmkzr04QKM07Ii5qh3wtNhKUTiYEApqsSBPSba9djA2wMOKwCeLolG6IHCJUTQPB6T47Fw4+LoAX6+87eNwJj16R4ouavYFLLD7qZMfN/M+8E4fuiFb7M7lPOk49S/FtWr5ykMdmr+1g6ed99mDuqGPuuk4ESBqLtWleNfKEwtBNYKJHauaWRU+RABqmh4+Eg1YUr1OItu0oZN15jr4F2gT5rnM2vtZPiXJMTq4ncoxu/XA+q28sJtrEI8/jCSxmbD6ObyaNrxsxbj+GkAwyXiC2JeZpnMEVFIEdhzzqGO/PAQ== 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 04/08/25 at 05:39pm, 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: > > --- 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. Indeed, maybe below change can be squashed into above patch from Andrew. diff --git a/mm/swapfile.c b/mm/swapfile.c index 2887ed5d34cc..baaf8ad29a6b 100644 --- a/mm/swapfile.c +++ b/mm/swapfile.c @@ -1536,8 +1536,8 @@ static bool swap_entries_put_map_nr(struct swap_info_struct *si, } /* - * 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. + * Check if it's the last ref of swap entry in the freeing path. + * Qualified vlaue includes 1, SWAP_HAS_CACHE or SWAP_MAP_SHMEM. */ static inline bool swap_is_last_ref(unsigned char count) {