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 A21BEC36002 for ; Wed, 9 Apr 2025 22:45:59 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E4BE22800B0; Wed, 9 Apr 2025 18:45:57 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DD4B92800AF; Wed, 9 Apr 2025 18:45:57 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C4E012800B0; Wed, 9 Apr 2025 18:45:57 -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 A3A142800AF for ; Wed, 9 Apr 2025 18:45:57 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 734EFACBCB for ; Wed, 9 Apr 2025 22:45:58 +0000 (UTC) X-FDA: 83315989596.05.980E344 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf25.hostedemail.com (Postfix) with ESMTP id 5ED3CA0010 for ; Wed, 9 Apr 2025 22:45:56 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Gl+6nHM2; dmarc=pass (policy=quarantine) header.from=redhat.com; spf=pass (imf25.hostedemail.com: domain of bhe@redhat.com designates 170.10.133.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=1744238756; 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=2Ku4yyWjuqPCXvmLiXxONVvSW85vS72t1vVANWUSZuo=; b=WKtIxS48BcjbvuhJO5TEFO6A1RgmFU5A3XR0+oLqwuK8LMZTKBHIFrcLWjgjuF2VtXiPl2 ipw/yMRFzfVrZ8p2wzvVSBeCx40TS/gUIcE1sL2/wiCjwcwg+ezfVwNw1VGyFwaWHpwWsA L0mRqFvrg5dqwFHSLaMsmp7ehOLGtZo= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1744238756; a=rsa-sha256; cv=none; b=XMOUpC8w8BuZNjAGoZYth+YMwAVDXtfjxhSBtoy5D+nzt8JeV9sVQG1zFSkM6cKIGo4QkO N5jIjqxv7YFFP/PupO/we6vbQIJfhp82B2YzxM+bDccPOLg2aEFKXOM7YQUordUTcy3GHj ulG78B1dhIOq4jStuhy0L0RibOKf7gc= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Gl+6nHM2; dmarc=pass (policy=quarantine) header.from=redhat.com; spf=pass (imf25.hostedemail.com: domain of bhe@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=bhe@redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1744238755; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=2Ku4yyWjuqPCXvmLiXxONVvSW85vS72t1vVANWUSZuo=; b=Gl+6nHM2daXsf4oB7hhpVWVWERXB3ymoQ8kJ6w3WNLmlR0qBDmbF9bCWYANlfk7s3iQk6A 8HPe1U+s1pK1xixJafo06rAeV6KWWmOCjk+tQF8KJOcKs/QAWeQ3Wk9F73UqpWn1GIH4r+ Jz2CyDxOTa1Jc2F6XT/Xh5oi0k1SeOw= Received: from mx-prod-mc-08.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-14-PrFDpZr2ND-Vh4XOVp0KLg-1; Wed, 09 Apr 2025 18:45:54 -0400 X-MC-Unique: PrFDpZr2ND-Vh4XOVp0KLg-1 X-Mimecast-MFC-AGG-ID: PrFDpZr2ND-Vh4XOVp0KLg_1744238752 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (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-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 5B0CD1801A1A; Wed, 9 Apr 2025 22:45:52 +0000 (UTC) Received: from localhost (unknown [10.72.112.38]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 3A4EF180174E; Wed, 9 Apr 2025 22:45:49 +0000 (UTC) Date: Thu, 10 Apr 2025 06:45:45 +0800 From: Baoquan He To: SeongJae Park , kernel test robot Cc: Andrew Morton , Kemeng Shi , 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: <20250408173959.f501f65ec5d5e52cefe6b129@linux-foundation.org> <20250409165452.305371-1-sj@kernel.org> MIME-Version: 1.0 In-Reply-To: <20250409165452.305371-1-sj@kernel.org> X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: yi-WLbNKRWqGQmm6hJnCWV4tC2N-4fQ0PL0HnXdg4pg_1744238752 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 5ED3CA0010 X-Stat-Signature: dedyqmshdc9r4b1179x61bxb9eke9ojn X-Rspam-User: X-HE-Tag: 1744238756-783108 X-HE-Meta: U2FsdGVkX18TtmEIxQ5DCNEy8R28enQLGo5OQQDuXqQMRQJY01RO/qSAS10RBxCzOuz1edPoS1OeUILZhXJ06LCqDWcWJtNYgx6HHY53jBOSLOhGuaYkG2hWYqrE0GBeRoWiTYyRm+dsKHD4K5cQ+uOgXuibeH5uyUZ3KeqXTxYNeoaJgClOx7QiPlOdiV2e1Tn/QvbwvN5SoO3YJtaBzkrdQMcpa4VlkPHXC2Xa+KKHOet+1pNaFtVc48taUnJPOs46X9tJbDvnmludQjCxs7xx62M+XXeIrVXruA/Gairy5NsriVTWPB4NaYt3RC0BsEZSKyWZlTJXDfBate/I9BRVZkquBjjoLnIlQi9VRtFrdO8jFesMDVBP10DC3TCnItLja9XlsQAXZyqU6N29o0BrLXcl9mPNCZzsyyF3Teto+40J+SpEekdhta4yZAs4TmoyZTRRhPtPO7UUHTn3ozwRAf1MV/KbJTXMzEvM/QohWmlUW8EsF+L26FLId9JPXk4R45XsPrdeU1rLRemZne7Fo0hrgqg2zO4pilJBHKnN0Bxdw+24ggepto0Z3k0Xg3TCWdPX/+OYVqmHNsbMbbablliq9PFpmDPxbKYfE9DsYwLJZhg6Tg0syaDCRCc6VLiTc68QGYGYE4FU6gJU6/7WmWgB5eFkkciZJY2pN5wJAUmUrmRaWytfiPFAYqv5HJHc63gaC8MO9peJIZXeAR+iqrlqHFyZhXWuLhQ9xnhfSWRmxMnKp8S08PI6Xwg3xhbLQWxZ7EvsqkJloKot93KZRwcuSolwnpP4hX6jBUIellwWzzHnNU+k3IUYiw+9ohPjWTPQsA/3pRunwnqqRgzuCq80p9KRl7dxRbzBgPYVVt8zBTkRvGvHcvt1blwkTz/m22LkUovxSdNX5UhGEWuCJBXn2uBFB9l6Ct974731+ldXVHH3tfEpFN/ep7HcBmq45+32gJ81jPrnahV kqWuzL+1 JM1/iRPGxC/arn0ISRDLCR0fjWA62aJ5KwpGF29aCnhf7vSGdJgVyDnkRlWvVpt0ZCCZrQa0Fom6V4yHLv8OJdMWDrpE91eRP0yMwJzCSHMKsuMxVL/bN2rreW5sgQ9ao0k0a7UoEM72QN796eaqXj8VoNgtioEb1eMYS81eU2+LmhW+nGrHv1Kgj6C8buDWY+nLe/EDbaKyalk9eOfyHKxe48pYPFZqQibpSh8ObQiCioqF6ZaHQAjccCTAMWyQ/Ld3/DhkWQ10chhOZO4PDEw5KpENxndMrqLO5CTOw3f2X7gC0xTsPJw1KkQ+Ja9JUgPN/QG5rB56NatGEAQaRQH/8FGEVN+pgNTL1iizZCTfNGhKWiWP2r+crGAZVw/ynfESds3XRVXbmJk3MZdypZobvrJbPRLFeAFCiUXV1mGJLRr0P901bZ4lPU05pAApVoKyCjNT4VP+n1Nx7CE6Gf8+8fJ+zwHXz3xVOsvzXQz/hK1jsts67nvovEelU++lF9d4RuREO4XXO9rHfs4syvO2hn7dZYlUlQDuapqBozUC3aVJD8eRBZYgj9CNgueX6D57Rqnbocj8/ewfjzeFqwLhkI9vfkvBTnaHncHvXdgYPExUXgwrm6Ko+iSM1yebyKcnorrjEOPbuGvHIgnS57zKEnOq3rGLO7FjscyCDz6DUD7UthlKXQdrGp34kze+IImiy1mpmW1rvnGZDAGSFAK0zKsRwOjeOwiyXYwenPQA+72Q= 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/09/25 at 09:54am, SeongJae Park wrote: > 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) > > > Hi lkp team, When I tried to reproduce, I got below failure. Please help check what's wrong with it. Thanks in advance. [~]# COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang-21 ~/lkp-tests/kbuild/make.cross W=1 O=build_dir ARCH=hexagon olddefconfig Compiler will be installed in /root/0day Cannot find clang-21 under https://cdn.kernel.org/pub/tools/llvm/files Please set new URL env variable and rerun * crosstool provided by kernel org: export URL=https://cdn.kernel.org/pub/tools/llvm/files * crosstool provided by 0-Day CI: export URL=https://download.01.org/0day-ci/cross-package clang crosstool install failed Install clang compiler failed setup_crosstool failed > > > 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? I think we shold do the similar thing as this commit does: 6e8e04291d81 mm/zsmalloc: add __maybe_unused attribute for is_first_zpdesc() Just add a __maybe_unused attribute to mute the warning. I haven't tested it because the reproducer failed in my side. diff --git a/mm/swapfile.c b/mm/swapfile.c index 2887ed5d34cc..08b52346cc39 100644 --- a/mm/swapfile.c +++ b/mm/swapfile.c @@ -1539,7 +1539,7 @@ 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. */ -static inline bool swap_is_last_ref(unsigned char count) +static inline bool __maybe_unused swap_is_last_ref(unsigned char count) { return (count == SWAP_HAS_CACHE) || (count == 1) || (count == SWAP_MAP_SHMEM);