From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CD45C226520 for ; Mon, 7 Apr 2025 12:08:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.156.1 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744027728; cv=none; b=sVhtPz4msvlWpjZscbAoiqCpNKvl0y0t80SCaNqIRblX8t0+a/zaA0EirGVeEaIYO8WKy9mSiB0HFOKNMwAxUvlFDXJAaLN9HRrY+/sxO3Tx+jMnX5vyqOFo0ebsb3/9KT9rWxrdEXuIG+iUilNOJJ5HX1eJmJ2OkF1cLicUz7Y= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744027728; c=relaxed/simple; bh=vSczhStDWJTDkyryvBtdVcdkQFtNueJc4wph3Msl2/g=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=pzqRTIHCCIZ+BOQWkVA3tvaEjAtYgsFB9hOSuztd3UnvG3O3IsTq3lKOgIjux1M2u29ibkhv9Ayt27CmfcQvk2BkxfXLCO/VEtD3+5B1/wTti6ZCoEhzt1LVLa92F5nkmWyxnsvR4yE3sxgxWEuIQ4aXVYnYG7eKI5rGI3O7tdM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=d74wuq7M; arc=none smtp.client-ip=148.163.156.1 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="d74wuq7M" Received: from pps.filterd (m0360083.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 5373jp4P007750; Mon, 7 Apr 2025 12:08:39 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=pp1; bh=uUtBZj lU25r6sM+22jsuRQQkmxTm0zoP535SD0mY4H0=; b=d74wuq7Mh+EbuoXVeWjnCg zxUl3UQpuRa8l62spykZvJhtW/hjGfoJx8LNOLgRALwPNUeV1de668vOcMWpaBTT huxJusD26dw80wlG1O96HIw/cBZvOcKFSrnwotDjiatWOJqiQft5VQKV1OR6Y+pc SPf1tTvXr+bI4cZP4KKhyy6WtUGIfyzxbAJxgupf7o/OYYqmpkV1MZeMAKjR+uE+ 4TbYlV8lOHNa/+Zz71Z6z7Tb97h+hjEuJ//fa9wPgYiJNnEb9cxNh3CFucj0YVFK IcwGrrVwn1nvOR+asZnXMhhGAWuJ0+oHtFhhiWKhptzZooTfVOM7XkqxbN0858xQ == Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 45v739j5dr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 07 Apr 2025 12:08:39 +0000 (GMT) Received: from m0360083.ppops.net (m0360083.ppops.net [127.0.0.1]) by pps.reinject (8.18.0.8/8.18.0.8) with ESMTP id 537BUoKh028422; Mon, 7 Apr 2025 12:08:38 GMT Received: from ppma23.wdc07v.mail.ibm.com (5d.69.3da9.ip4.static.sl-reverse.com [169.61.105.93]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 45v739j5dp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 07 Apr 2025 12:08:38 +0000 (GMT) Received: from pps.filterd (ppma23.wdc07v.mail.ibm.com [127.0.0.1]) by ppma23.wdc07v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 537AUfMW025598; Mon, 7 Apr 2025 12:08:37 GMT Received: from smtprelay05.dal12v.mail.ibm.com ([172.16.1.7]) by ppma23.wdc07v.mail.ibm.com (PPS) with ESMTPS id 45ugbknm4g-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 07 Apr 2025 12:08:37 +0000 Received: from smtpav05.dal12v.mail.ibm.com (smtpav05.dal12v.mail.ibm.com [10.241.53.104]) by smtprelay05.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 537C8aqw42926420 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 7 Apr 2025 12:08:36 GMT Received: from smtpav05.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 18E4A58052; Mon, 7 Apr 2025 12:08:36 +0000 (GMT) Received: from smtpav05.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2AE3B5806A; Mon, 7 Apr 2025 12:08:31 +0000 (GMT) Received: from [9.61.255.9] (unknown [9.61.255.9]) by smtpav05.dal12v.mail.ibm.com (Postfix) with ESMTP; Mon, 7 Apr 2025 12:08:30 +0000 (GMT) Message-ID: Date: Mon, 7 Apr 2025 17:38:28 +0530 Precedence: bulk X-Mailing-List: linux-perf-users@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] tools/lib/perf: Fix -Werror=alloc-size-larger-than in cpumap.c Content-Language: en-GB To: Athira Rajeev , Likhitha Korrapati , Arnaldo Carvalho de Melo , Namhyung Kim Cc: Jiri Olsa , Adrian Hunter , Ian Rogers , "open list:PERFORMANCE EVENTS SUBSYSTEM" , linuxppc-dev , Madhavan Srinivasan References: <20250406163412.897313-1-likhitha@linux.ibm.com> From: Venkat Rao Bagalkote In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 X-Proofpoint-GUID: ifLdxIWfGg5ReWAHUEyAlMZT8v466Gzj X-Proofpoint-ORIG-GUID: aOV48UOyaIGysoPZKNtLYw7igkNJDQDE X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1095,Hydra:6.0.680,FMLib:17.12.68.34 definitions=2025-04-07_03,2025-04-03_03,2024-11-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 mlxlogscore=999 phishscore=0 mlxscore=0 malwarescore=0 suspectscore=0 adultscore=0 priorityscore=1501 bulkscore=0 clxscore=1015 lowpriorityscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2502280000 definitions=main-2504070086 On 07/04/25 12:10 am, Athira Rajeev wrote: > >> On 6 Apr 2025, at 10:04 PM, Likhitha Korrapati wrote: >> >> perf build break observed when using gcc 13-3 (FC39 ppc64le) >> with the following error. >> >> cpumap.c: In function 'perf_cpu_map__merge': >> cpumap.c:414:20: error: argument 1 range [18446744069414584320, 18446744073709551614] exceeds maximum object size 9223372036854775807 [-Werror=alloc-size-larger-than=] >> 414 | tmp_cpus = malloc(tmp_len * sizeof(struct perf_cpu)); >> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ >> In file included from cpumap.c:4: >> /usr/include/stdlib.h:672:14: note: in a call to allocation function 'malloc' declared here >> 672 | extern void *malloc (size_t __size) __THROW __attribute_malloc__ >> | ^~~~~~ >> cc1: all warnings being treated as errors >> >> Error happens to be only in gcc13-3 and not in latest gcc 14. >> Even though git-bisect pointed bad commit as: >> 'commit f5b07010c13c ("libperf: Don't remove -g when EXTRA_CFLAGS are used")', >> issue is with tmp_len being "int". It holds number of cpus and making >> it "unsigned int" fixes the issues. >> >> After the fix: >> >> CC util/pmu-flex.o >> CC util/expr-flex.o >> LD util/perf-util-in.o >> LD perf-util-in.o >> AR libperf-util.a >> LINK perf >> GEN python/perf.cpython-312-powerpc64le-linux-gnu.so >> >> Signed-off-by: Likhitha Korrapati > Looks good to me > > Reviewed-by: Athira Rajeev Tested this patch on perf-tools-next repo, and this patch fixes the issue. Tested-by: Venkat Rao Bagalkote Regards, Venkat. > > Thanks > Athira >> --- >> tools/lib/perf/cpumap.c | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/tools/lib/perf/cpumap.c b/tools/lib/perf/cpumap.c >> index 4454a5987570..c7c784e18225 100644 >> --- a/tools/lib/perf/cpumap.c >> +++ b/tools/lib/perf/cpumap.c >> @@ -398,7 +398,7 @@ bool perf_cpu_map__is_subset(const struct perf_cpu_map *a, const struct perf_cpu >> int perf_cpu_map__merge(struct perf_cpu_map **orig, struct perf_cpu_map *other) >> { >> struct perf_cpu *tmp_cpus; >> - int tmp_len; >> + unsigned int tmp_len; >> int i, j, k; >> struct perf_cpu_map *merged; >> >> -- >> 2.43.5 >> >