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 653DBC433EF for ; Thu, 31 Mar 2022 17:33:39 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BECDA6B0072; Thu, 31 Mar 2022 13:33:38 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B9D4B6B0073; Thu, 31 Mar 2022 13:33:38 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A3CF36B0074; Thu, 31 Mar 2022 13:33:38 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0180.hostedemail.com [216.40.44.180]) by kanga.kvack.org (Postfix) with ESMTP id 957866B0072 for ; Thu, 31 Mar 2022 13:33:38 -0400 (EDT) Received: from smtpin22.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 3A585182CCF51 for ; Thu, 31 Mar 2022 17:33:38 +0000 (UTC) X-FDA: 79305378516.22.FBB4559 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf17.hostedemail.com (Postfix) with ESMTP id 89E9B40020 for ; Thu, 31 Mar 2022 17:33:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1648748017; 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=50Lm2+gUhcbOfOCwPpXSj381+JxolC9BpO77iX6eyvs=; b=Ek5GQWnygLkSfVOEpYB4LtmFJj36TYNXZKvhWpZtKWH/SpcIZSvMMbewKnhfYzbKMFm3aN Ju/MoCG/fy1LhZM4TUm44vxTMmmXwBkyj3VmDmtPKzv6WZ4KVwXHO6mN+aHj+nGJOTS3w9 +u7j9RVzZu1ufQSkR+1yi96ruMV/lsw= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-206-pn-eu29cPKewd4NApaAcjA-1; Thu, 31 Mar 2022 13:33:35 -0400 X-MC-Unique: pn-eu29cPKewd4NApaAcjA-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 17DF11C0EDC6; Thu, 31 Mar 2022 17:33:32 +0000 (UTC) Received: from [10.18.17.215] (dhcp-17-215.bos.redhat.com [10.18.17.215]) by smtp.corp.redhat.com (Postfix) with ESMTP id 44A4E400E420; Thu, 31 Mar 2022 17:33:25 +0000 (UTC) Message-ID: <3ffaa931-bc25-efff-173b-397824422842@redhat.com> Date: Thu, 31 Mar 2022 13:33:24 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.5.0 Subject: Re: [PATCH v3] mm/sparsemem: Fix 'mem_section' will never be NULL gcc 12 warning Content-Language: en-US To: kernel test robot , Andrew Morton Cc: kbuild-all@lists.01.org, Linux Memory Management List , linux-kernel@vger.kernel.org, "Kirill A . Shutemov" , Ingo Molnar , Justin Forbes , Rafael Aquini References: <20220330205919.2713275-1-longman@redhat.com> <202203312327.XGeCiD5T-lkp@intel.com> From: Waiman Long In-Reply-To: <202203312327.XGeCiD5T-lkp@intel.com> Content-Type: text/plain; charset=UTF-8; format=flowed X-Scanned-By: MIMEDefang 2.84 on 10.11.54.2 X-Rspamd-Server: rspam09 X-Rspam-User: X-Stat-Signature: j7csomqtsarfzwxwp4jc8sja9cmtneus Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Ek5GQWny; dmarc=pass (policy=none) header.from=redhat.com; spf=none (imf17.hostedemail.com: domain of longman@redhat.com has no SPF policy when checking 170.10.133.124) smtp.mailfrom=longman@redhat.com X-Rspamd-Queue-Id: 89E9B40020 X-HE-Tag: 1648748017-85620 Content-Transfer-Encoding: quoted-printable 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: On 3/31/22 11:54, kernel test robot wrote: > Hi Waiman, > > I love your patch! Perhaps something to improve: > > [auto build test WARNING on hnaz-mm/master] > > url: https://github.com/intel-lab-lkp/linux/commits/Waiman-Long/mm-s= parsemem-Fix-mem_section-will-never-be-NULL-gcc-12-warning/20220331-05004= 9 > base: https://github.com/hnaz/linux-mm master > config: arm-randconfig-c024-20220330 (https://download.01.org/0day-ci/a= rchive/20220331/202203312327.XGeCiD5T-lkp@intel.com/config) > compiler: arm-linux-gnueabi-gcc (GCC) 11.2.0 > reproduce (this is a W=3D1 build): > wget https://raw.githubusercontent.com/intel/lkp-tests/master/= sbin/make.cross -O ~/bin/make.cross > chmod +x ~/bin/make.cross > # https://github.com/intel-lab-lkp/linux/commit/2098f1d78cde33= 8e81b3ba596ea39f37824e496e > git remote add linux-review https://github.com/intel-lab-lkp/l= inux > git fetch --no-tags linux-review Waiman-Long/mm-sparsemem-Fix-= mem_section-will-never-be-NULL-gcc-12-warning/20220331-050049 > git checkout 2098f1d78cde338e81b3ba596ea39f37824e496e > # save the config file to linux build tree > mkdir build_dir > COMPILER_INSTALL_PATH=3D$HOME/0day COMPILER=3Dgcc-11.2.0 make.= cross O=3Dbuild_dir ARCH=3Darm SHELL=3D/bin/bash security/keys/encrypted-= keys/ > > If you fix the issue, kindly add following tag as appropriate > Reported-by: kernel test robot > > All warnings (new ones prefixed by >>): > > In file included from include/linux/gfp.h:6, > from include/linux/umh.h:4, > from include/linux/kmod.h:9, > from include/linux/module.h:17, > from security/keys/encrypted-keys/encrypted.c:15: > security/keys/encrypted-keys/encrypted.c: In function 'derived_key_= encrypt.constprop': >>> include/linux/mmzone.h:1432:23: warning: array subscript 32 is outsid= e array bounds of 'struct mem_section[32][1]' [-Warray-bounds] > 1432 | unsigned long map =3D section->section_mem_map; > | ^~~ > include/linux/mmzone.h:1390:27: note: while referencing 'mem_sectio= n' > 1390 | extern struct mem_section mem_section[NR_SECTION_ROOTS][SEC= TIONS_PER_ROOT]; > | ^~~~~~~~~~~ > > > vim +1432 include/linux/mmzone.h > > 29751f6991e845 Andy Whitcroft 2005-06-23 1429 > 29751f6991e845 Andy Whitcroft 2005-06-23 1430 static inline struct pa= ge *__section_mem_map_addr(struct mem_section *section) > 29751f6991e845 Andy Whitcroft 2005-06-23 1431 { > 29751f6991e845 Andy Whitcroft 2005-06-23 @1432 unsigned long map =3D = section->section_mem_map; > 29751f6991e845 Andy Whitcroft 2005-06-23 1433 map &=3D SECTION_MAP_M= ASK; > 29751f6991e845 Andy Whitcroft 2005-06-23 1434 return (struct page *)= map; > 29751f6991e845 Andy Whitcroft 2005-06-23 1435 } > 29751f6991e845 Andy Whitcroft 2005-06-23 1436 > This warning happens with !CONFIG_SPARSEMEM_VMEMMAP && CONFIG_SPARSEMEM.=20 In this case, __section_mem_map_addr() is used only by __pfn_to_page()=20 and __page_to_pfn().=C2=A0 My patch only modifies __nr_to_section. In thi= s=20 particular case, it is removing The !mem_section[32] check. Perhaps it=20 is somewhat equivalent to a (sec >=3D 32) check for gcc 11.2. However,=20 this check will cause a warning in gcc 12. I will update the patch to=20 add an explicit (sec >=3D NR_SECTION_ROOTS) then. Thanks, Longman