From patchwork Thu Mar 30 07:42:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Herrmann X-Patchwork-Id: 76935 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp949349vqo; Thu, 30 Mar 2023 00:54:05 -0700 (PDT) X-Google-Smtp-Source: AKy350YspJYJ7ToSleg3uKR+kbkVsm9HW/0e8NwVewIO4ztsiWvuQ89SeFKPnbAYyg8Y7bR3Aq1+ X-Received: by 2002:a17:907:161f:b0:932:7f5c:4bb2 with SMTP id hb31-20020a170907161f00b009327f5c4bb2mr27455769ejc.75.1680162845291; Thu, 30 Mar 2023 00:54:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680162845; cv=none; d=google.com; s=arc-20160816; b=GLraidcca64/ZdszRpxW8OSmNp81V8F8Xw+zTFKOw8LK1Vufkyc4/4IGMmPPTJ0eiZ 5ZSSUuxlf/cNjUpFFmX9igSdoQfACRAhOvIOZEpWC1PiAAi8C6e4/ZvCCEeimvOCdNJL lg0S5Rnrxab2P1n6wUuOR/B1bUn2NPd8Ep5aEh/2c+AcI5lLhYgwagHdcuG2ZiLCjLnj PtssuAVF18gjo0JY/9q8rbZ2swzVfEQ+Zgk80/aplTVRgycx9Mhl9QVTMI7S9I0VkvEo /VXL5sJvQRUV0XLQoyj5cNIWQTaX+JaBJlAbvSoVtLgaCzYiQGN5J43BmemOeMCjRnLF lYyw== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ke24-20020a17090798f800b008b178585afcsi31922523ejc.250.2023.03.30.00.53.41; Thu, 30 Mar 2023 00:54:05 -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 S229508AbjC3Hmx (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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1761778435673882286?= X-GMAIL-MSGID: =?utf-8?q?1761778435673882286?= 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 Reviewed-by: James Clark --- 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;