Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp1755816rwl; Thu, 30 Mar 2023 00:44:20 -0700 (PDT) X-Google-Smtp-Source: AKy350Yls65ObJ8l48mJ+2fjpdx2pufxPvr0UA1EWIbcervPkn25R+HPaV6qwhWY7QaExsGCm1mn X-Received: by 2002:a05:6402:5107:b0:502:ffd:74a0 with SMTP id m7-20020a056402510700b005020ffd74a0mr1476522edd.2.1680162260608; Thu, 30 Mar 2023 00:44:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680162260; cv=none; d=google.com; s=arc-20160816; b=puPfdB+WW7lyoUDBStvxYxDh9auqTgZ4gFImecp1Ta10OjDlEWCZa0DEAlbekKUTa+ pF51hVQCQRKgLj1zImiUmAApe9Cs1fuJDkzE/LhbMX4Rf9tmCLstPvRdL6KXiinZG43x exa4XjUPU0WSqfzYLOOSPMv8woTb7Nkoy0CWNoAHqH/8uLXjfdTCuQ/99j5/iQbXVwmS 5zInulZkqGIzJ8Dxu/WyG1V6YKpGygfGkoyz7gf7t4XHIIoHfF1Rvzm8CCKeO58xKDsg KoJ42aWlBU6uB2UUaa+ACjhHTys/x0eh0FmLrodfTZjn8v+poPRqLgAZuvhLGEM4v0ha shwA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature:dkim-signature; bh=dcdGBGxLxQLdtnHwDzVvtW66/+5pqTVU2RqRlNoXsE4=; b=prbxvfIoH+tUf4f+clAfRd9TYPIVG+GtadMHWkt2LpR1vw4vJqTL6pBXA5+xk+lhJW Wg/sPBQc6AyWTkwyIQaqGymbySme4j2CD20TQ/VJ4yPqvGW70sItPm/KN3WilcR/gfCx hU6Bd+xxl0VH2h6mHVgaf07XwzNUCK43wUGrfICr+t4+kCI7DDymvK5K6Jx6LK3YeszC 1t/hdsmkCu7hwxfxZuSAFMGMdVt8PSfYNDwGjhAITSQdEK21UAh/cop4ZLzRwmgsFgmE szy+4WjvbGMlt0sFqK0SXc/T/IbELUZA4Gy4FfbwfFM5VbvSK8ABVZT+JPWVey/ubdjc w4aA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=HS5TVwF3; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q15-20020aa7d44f000000b004fb8724cc4esi36198081edr.292.2023.03.30.00.43.55; Thu, 30 Mar 2023 00:44:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=HS5TVwF3; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229487AbjC3Hmx (ORCPT + 99 others); Thu, 30 Mar 2023 03:42:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42902 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229448AbjC3Hmv (ORCPT ); Thu, 30 Mar 2023 03:42:51 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D80A94213; Thu, 30 Mar 2023 00:42:50 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 98CB121B00; Thu, 30 Mar 2023 07:42:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1680162169; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=dcdGBGxLxQLdtnHwDzVvtW66/+5pqTVU2RqRlNoXsE4=; b=HS5TVwF3MwExjn1RvabFUF3zDzV5HdDpiKPIHLnj3un+d7MqwJtYQ28vwgRAXUk3C16rw1 j4x8fW18uk+W3tBOH2FCvfFRws5zLG+vlrWIoAQqNcPnTdw0r5MPer/F4yh7KprhSpG8Be hy5HgMGnRt/T5wCccKsv6qw1d8a2MnU= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1680162169; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=dcdGBGxLxQLdtnHwDzVvtW66/+5pqTVU2RqRlNoXsE4=; b=BKcGeabqCKyWL1Lzx3puVPICoCpl9wBcoKhmNmhi3r85r3eJaEFvXNYDDph19/SoSxEn/r RgjtYTrnQvuhqoDw== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 702071348E; Thu, 30 Mar 2023 07:42:49 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id CWjZGXk9JWQIfgAAMHmgww (envelope-from ); Thu, 30 Mar 2023 07:42:49 +0000 From: Andreas Herrmann To: Arnaldo Carvalho de Melo Cc: linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Andreas Herrmann Subject: [PATCH] perf bench numa: Fix for loop in do_work Date: Thu, 30 Mar 2023 09:42:02 +0200 Message-Id: <20230330074202.14052-1-aherrmann@suse.de> X-Mailer: git-send-email 2.39.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.5 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,HEXHASH_WORD,RCVD_IN_DNSWL_MED, 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 lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org j is of type int and start/end are of type long. Thus j might become negative and cause segfault in access_data(). Fix it by using long for j as well. Signed-off-by: Andreas Herrmann --- tools/perf/bench/numa.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) Example of segfault (with 6.3.0-rc4) is: # ./perf bench numa mem -d -m -p 2 -t 12 -P 25425 ... threads initialized in 6.052135 seconds. # perf: bench/numa.c:1654: __bench_numa: Assertion `!(!(((wait_stat) & 0x7f) == 0))' failed. Aborted (core dumped) # dmesg | grep segfault [78812.711311] thread 1/3[43215]: segfault at 7f07936c9ec0 ip 00000000004ab6d0 sp 00007f0acb1f9cb0 error 4 [78812.711309] thread 1/9[43221]: segfault at 7f08bda71a70 ip 00000000004ab6d0 sp 00007f0ac81f3cb0 error 4 [78812.711316] thread 1/4[43216]: segfault at 7f07ccf76a08 ip 00000000004ab6d0 sp 00007f0aca9f8cb0 error 4 [78812.711325] thread 1/2[43214]: segfault at 7f08be2f44b0 ip 00000000004ab6d0 sp 00007f0acb9facb0 error 4 [78812.711328] thread 1/8[43220]: segfault at 7f06d3096b20 ip 00000000004ab6d0 sp 00007f0ac89f4cb0 error 4 [78812.711345] thread 1/6[43218]: segfault at 7f0774b46a18 ip 00000000004ab6d0 sp 00007f0ac99f6cb0 error 4 in perf[400000+caa000] likely on CPU 6 (core 8, socket 0) [78812.711366] thread 0/0[43224]: segfault at 7f08a936b130 ip 00000000004ab6d0 sp 00007f0acc9fccb0 error 4 in perf[400000+caa000] likely on CPU 1 (core 1, socket 0) diff --git a/tools/perf/bench/numa.c b/tools/perf/bench/numa.c index 9717c6c17433..1fbd7c947abc 100644 --- a/tools/perf/bench/numa.c +++ b/tools/perf/bench/numa.c @@ -847,7 +847,7 @@ static u64 do_work(u8 *__data, long bytes, int nr, int nr_max, int loop, u64 val if (g->p.data_rand_walk) { u32 lfsr = nr + loop + val; - int j; + long j; for (i = 0; i < words/1024; i++) { long start, end; -- 2.39.1