Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp3324430rdb; Wed, 13 Sep 2023 08:42:17 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHg9K107ImEWZhntqkpUiSPjwCMjjyvqhQglYaXo6wamfZj/9tqzqBUUHmoyffb7aK4meiD X-Received: by 2002:a05:6a20:9190:b0:153:63b9:8bf9 with SMTP id v16-20020a056a20919000b0015363b98bf9mr3064097pzd.0.1694619737331; Wed, 13 Sep 2023 08:42:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694619737; cv=none; d=google.com; s=arc-20160816; b=L+kbbnnjsW6kppCWXpwWNasNZjzGCdJ9HIDMCY+PC7Cx0k0DAijizuQoY11VaeFhUn 2p1WcTPYtCa2u/NFeYM6g9aDSPctYVDhiHHim6vv7Ox+hv0FzypcE0qCtEWIo6VjXjx7 zc7dO2u73igX5/xCyrQIM7zofr5n3fc8uHei2fLXZvFtBah555ppJr+Ldwu9PvSQ0ED/ WbRiJApgs2Z6Yjc/vILGKQ0v34hVDf4wyBaMd5TUsrnUTOVhHTH5lU2vueQBvQDEn+Wp wr8LzJgfct5I/VZ89aOmKlWawswoUi2QV0G+4sERq3/SvtColM1ZnxNYBwpIA0blOPqz 5LOw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:references :cc:to:from:content-language:subject:user-agent:mime-version:date :message-id; bh=9WatZxW57fNS8rE5Ijtw2vAVdkh+Iwo92KwhDvvcpQ4=; fh=0uv8E5ljGQ9PFTiB7Q7c/3zozo6yyEUZgZ3U5DsSw9g=; b=EAmIjXsAtOkMu47DRc6Stp/492dpquzDB5mv3ZDSNnGGyFr6VihJmubBZP31NyKZ8N 0joxGpuvtTywD+Ns+ZGNJQeSwmdeehqkmIC/EM84KJZx0JEYZwC2kkcYWiFn6M6yUi9A 1i7WxZKGgFDAvTWWSnp0YVSyiWOhoZ6Txg81cWf9fim+GJ8HzUf7PemNeFPemuByY4y2 8m3ie/93HxsKevNhggzfx7bhW970NrOZQFtywLzyn2PAFEVD2Z3VZqOXdW6uDlSONrn7 LX8+MvZx7wLRMJ+/BfViKJvjXlrDItHpejPa3mDDMfdmCEzxLkCCaKK6ZBvSHJXf1hW+ 7MBA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id l6-20020a056a00140600b0068e4c3f3ac2si10372503pfu.245.2023.09.13.08.42.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Sep 2023 08:42:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 163FD801BF68; Wed, 13 Sep 2023 08:37:45 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229691AbjIMPhq (ORCPT + 99 others); Wed, 13 Sep 2023 11:37:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59958 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229540AbjIMPhp (ORCPT ); Wed, 13 Sep 2023 11:37:45 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id ADD5493; Wed, 13 Sep 2023 08:37:40 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 8F4FC1FB; Wed, 13 Sep 2023 08:38:17 -0700 (PDT) Received: from [192.168.1.3] (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 33C1B3F5A1; Wed, 13 Sep 2023 08:37:32 -0700 (PDT) Message-ID: <36a4405d-0133-5ee7-4bdf-b85a26defb4f@arm.com> Date: Wed, 13 Sep 2023 16:37:27 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.9.0 Subject: Re: [PATCH 5/7] perf pmu: Move pmu__find_core_pmu() to pmus.c Content-Language: en-US From: James Clark To: Arnaldo Carvalho de Melo Cc: linux-perf-users@vger.kernel.org, irogers@google.com, John Garry , Will Deacon , Mike Leach , Leo Yan , Peter Zijlstra , Ingo Molnar , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Adrian Hunter , Kan Liang , Jing Zhang , Haixin Yu , Kajol Jain , Ravi Bangoria , Yang Jihong , Eduard Zingerman , Chen Zhongjin , Miguel Ojeda , Liam Howlett , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org References: <20230831151632.124985-1-james.clark@arm.com> <20230831151632.124985-6-james.clark@arm.com> In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Wed, 13 Sep 2023 08:37:45 -0700 (PDT) X-Spam-Status: No, score=-2.2 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email On 13/09/2023 11:32, James Clark wrote: > > > On 13/09/2023 11:20, James Clark wrote: >> >> >> On 12/09/2023 20:26, Arnaldo Carvalho de Melo wrote: >>> Em Thu, Aug 31, 2023 at 04:16:16PM +0100, James Clark escreveu: >>>> pmu__find_core_pmu() more logically belongs in pmus.c because it >>>> iterates over all PMUs, so move it to pmus.c >>>> >>>> At the same time rename it to perf_pmus__find_core_pmu() to match the >>>> naming convention in this file. >>>> >>>> Signed-off-by: James Clark >>> >>> So, this one is hitting this: >>> >>> CC /tmp/build/perf-tools-next/util/expr.o >>> In file included from /var/home/acme/git/perf-tools-next/tools/include/linux/list.h:7, >>> from util/pmus.c:2: >>> In function ‘perf_pmus__scan_core’, >>> inlined from ‘perf_pmus__find_core_pmu’ at util/pmus.c:601:16: >>> /var/home/acme/git/perf-tools-next/tools/include/linux/kernel.h:36:45: error: array subscript 0 is outside array bounds of ‘struct list_head[1]’ [-Werror=array-bounds] >>> 36 | const typeof(((type *)0)->member) * __mptr = (ptr); \ >>> | ^~~~~~ >>> /var/home/acme/git/perf-tools-next/tools/include/linux/list.h:352:9: note: in expansion of macro ‘container_of’ >>> 352 | container_of(ptr, type, member) >>> | ^~~~~~~~~~~~ >>> /var/home/acme/git/perf-tools-next/tools/include/linux/list.h:404:9: note: in expansion of macro ‘list_entry’ >>> 404 | list_entry((pos)->member.next, typeof(*(pos)), member) >>> | ^~~~~~~~~~ >>> /var/home/acme/git/perf-tools-next/tools/include/linux/list.h:494:20: note: in expansion of macro ‘list_next_entry’ >>> 494 | for (pos = list_next_entry(pos, member); \ >>> | ^~~~~~~~~~~~~~~ >>> util/pmus.c:274:9: note: in expansion of macro ‘list_for_each_entry_continue’ >>> 274 | list_for_each_entry_continue(pmu, &core_pmus, list) >>> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ >>> util/pmus.c: In function ‘perf_pmus__find_core_pmu’: >>> util/pmus.c:35:18: note: at offset -128 into object ‘core_pmus’ of size 16 >>> 35 | static LIST_HEAD(core_pmus); >>> | ^~~~~~~~~ >>> /var/home/acme/git/perf-tools-next/tools/include/linux/list.h:23:26: note: in definition of macro ‘LIST_HEAD’ >>> 23 | struct list_head name = LIST_HEAD_INIT(name) >>> | ^~~~ >>> cc1: all warnings being treated as errors >>> make[4]: *** [/var/home/acme/git/perf-tools-next/tools/build/Makefile.build:97: /tmp/build/perf-tools-next/util/pmus.o] Error 1 >>> make[4]: *** Waiting for unfinished jobs.... >>> LD /tmp/build/perf-tools-next/ui/browsers/perf-in.o >>> >>> >>> So I applied up to 4/7 >>> >>> Please continue from what will be in tmp.perf-tools-next in some >>> jiffies. >>> >>> - Arnaldo >> >> I wasn't able to reproduce this on x86 or Arm, with either Clang or GCC. >> >> That was with this patch applied onto 999b81b907e on tmp.perf-tools-next >> and a pretty normal "make WERROR=1" command. >> >> It seems like the 0 here is just to get the type rather than access >> anything, if that's the 0 that the "array subscript 0" error is about, >> so something seems a bit strange: >> >>> /var/home/acme/git/perf-tools-next/tools/include/linux/kernel.h:36:45: >> error: array subscript 0 is outside array bounds of ‘struct >> list_head[1]’ [-Werror=array-bounds] >>> 36 | const typeof(((type *)0)->member) * __mptr = (ptr); \ > > Nevermind, I managed to reproduce it. With a DEBUG=1 build on x86 there > is no error, it only happens with a non debug one. > > I will look into it. Sent a v3 with the fix. It's some kind of awkward semi-undefined behavior in the linked list implementation that was always there but the compiler could only see when I moved that function so it was all in one compilation unit. It also required -O2 and I always build with DEBUG=1 so I missed it.