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 DE2D9C369A4 for ; Wed, 9 Apr 2025 16:55:00 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 278B2280095; Wed, 9 Apr 2025 12:54:59 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 227E0280092; Wed, 9 Apr 2025 12:54:59 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0EE9B280095; Wed, 9 Apr 2025 12:54:59 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id E4AE3280092 for ; Wed, 9 Apr 2025 12:54:58 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 074181210B0 for ; Wed, 9 Apr 2025 16:54:59 +0000 (UTC) X-FDA: 83315105118.26.DC80307 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf21.hostedemail.com (Postfix) with ESMTP id 0F0921C0007 for ; Wed, 9 Apr 2025 16:54:56 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=D6+i0Hqb; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf21.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=sj@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1744217697; a=rsa-sha256; cv=none; b=reQkOZY3q+YYEjQyNhnS3UN+qbLgYJnkuvBgP72HvQM6lUvMB3o2dtv5tFgxM4tymhoOHj UN2mChYEGteb6e4rryEWkauMijtNEme2lF0hENinN6Tus7vJKecd/gM7AeNWRcS5qBOLXb +xiJ94CGEQaAn2u5UBqssF8m1K5Ft6s= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=D6+i0Hqb; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf21.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=sj@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1744217697; 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=7vKb0jSakQTgA+XwJfqVDmaqZoO/kQ8vs+TYj3W9nfo=; b=peMhckNmnKVXNNd3Ldr19fg4JhWWxaevWsY9cg9vIG0g6vmE9O5bcEpOctj0oDwuD13Z2j f1j1XkJdzv4Ok+SQU52NGT+h4apOw5HKPqrPWaJKv+kFpcwmBnywd2JBnbytIRdeFqaE1s qnN/RZ9cBHNdAhpiqJLMROI6b3pY5nM= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id E8AEC5C4030; Wed, 9 Apr 2025 16:52:38 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7E5C9C4CEE9; Wed, 9 Apr 2025 16:54:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1744217695; bh=bn99SfcJAYqnAykVhl5TJzlvHLeMgsMboKs4HfISh8U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=D6+i0HqbWhsp0jdV6uYv+1WdMNxt5e7/3fsO8gn1cw48xntVqhFmlWTw+O+6GwdFK 4QZUJgzUNH9kMblti6zwtkj0CVuaDiez4U2WDeUvovgt0DfYMgQwpG5jWkRcT1nj/Q ydyS/S0Zkq7HkyxHPDLvb6Rl+LR/631lhmnReQy4LxjKMK10V/q0bVyjfjcGJSscAZ WwVRL1iv3l3cx8ZrHXUp4SBqGat3Y80J9UF7jgNqaNdlo5ybuYmvnyzg1q0HADx7dA FlDZmPGv2J0QAeye1pNIAYCYJHFGDcPvKFh7CzNIyPgxLAVs6z5m2dmf/ZrnFzTvjr 03KxELUtEkIlg== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , kernel test robot , Kemeng Shi , llvm@lists.linux.dev, oe-kbuild-all@lists.linux.dev, Linux Memory Management List , Tim Chen , Baoquan He 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 Date: Wed, 9 Apr 2025 09:54:52 -0700 Message-Id: <20250409165452.305371-1-sj@kernel.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250408173959.f501f65ec5d5e52cefe6b129@linux-foundation.org> References: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspam-User: X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 0F0921C0007 X-Stat-Signature: pwzr87cwmhcw17ca39t7c3xrsabnhbbs X-HE-Tag: 1744217696-688816 X-HE-Meta: U2FsdGVkX1+8Vl4NHXMjQXFOd+MdsHYt5SK6Q2FIIfsfHVrq8l5wpeOGc5mLosdiMdbg8K0r9JiZ9+Krm3A1ucQlFkhHb7vU8/TXsmnRfaYzz/oeHqIGzmqVGVeDASGrWSvEmB0ueBhig4IZsE8w2dbl7nb5eRBeKVg/WgvA5Z6qntuFI9vwEBDWoWOyYUkiW/ey4J/yP7FQbDw6xsH5q634L3AG+I2ewELgjz2loEmoZ4rxvLPz+U2U1qgMc0eZ/AXDwT8rAHHzvlGKs8CayxvAoNSLsroxG77vpRRcm5YQdugvsZwOs2LG6oj1g7RFysKQ5RmPzLmCbu290Oo3nYi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Skedov9MNoIcYAXuIFSgYpLx+lv8+Mhtar4uT5ooqzq1RT4CZOC08tTHRQCEClP0mEDcr+eG 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: Hello, On Tue, 8 Apr 2025 17:39:59 -0700 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, > _ This makes my build fails when CONFIG_DEBUG_VM is unset as below. linux/mm/swapfile.c: In function ‘swap_entries_free’: linux/mm/swapfile.c:1565:28: error: implicit declaration of function ‘swap_is_last_ref’; did you mean ‘swap_is_last_map’? [-Werror=implicit-function-declaration] 1565 | VM_BUG_ON(!swap_is_last_ref(*map)); | ^~~~~~~~~~~~~~~~ linux/include/linux/build_bug.h:30:63: note: in definition of macro ‘BUILD_BUG_ON_INVALID’ 30 | #define BUILD_BUG_ON_INVALID(e) ((void)(sizeof((__force long)(e)))) | ^ linux/mm/swapfile.c:1565:17: note: in expansion of macro ‘VM_BUG_ON’ 1565 | VM_BUG_ON(!swap_is_last_ref(*map)); | ^~~~~~~~~ cc1: some warnings being treated as errors Maybe we can open-code the condition, or add a macro implementation of swap_is_last_ref() for !CONFIG_DEBUG_VM case? Thanks, SJ [...]