Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp4634969yba; Wed, 10 Apr 2019 01:26:33 -0700 (PDT) X-Google-Smtp-Source: APXvYqxSRazFIQc0kmKFf7tuKk5UMSwj7coUnCW6fPRWgXPb2dq3Eaf8MXjImRJk4DRJddyDKetJ X-Received: by 2002:a17:902:768c:: with SMTP id m12mr41946001pll.160.1554884793460; Wed, 10 Apr 2019 01:26:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554884793; cv=none; d=google.com; s=arc-20160816; b=b2yoAJevf5mUU8h65yusvo9bEaBqnZrnx9nuhAgFkEdmzV0AiWX0EFWwmU60zS6kS5 pdlouspxvq8xm+3AAwQXvEqeu/LiRFDqTbzUZ/iYy5WMVPl9S6egqFcyE3gfnp8SRJJI yEEqrQ+mAOThU4OM6h1MGAos8R/Fk3AFLO+TOWvo1oDfkTDtfZdkrdbVcYHArKHMJ/bi aZfgzv8+YGtJ7ZetndRmAjEsPR6Oql3g42pKSIOdNIDwwtYEiktxPNiw4YCeoJe3Ck6Y tdZxJFsevUzvF1+ECRXrsm7PLNOxnA1w7cXzKmsAWZ0L8Wi0MopUOGT/OpjNiklaF1br cROA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:references :in-reply-to:message-id:date:subject:cc:to:from; bh=oYJVpUNK4qUiZ1ay7WA+cdwC+b+S+hyWuaInttHOSjE=; b=wrCzfUuVaf2UWd1NuEIgqcPzcVEApPKXMuC9RcTtwLzGgW7rpezFjWnTVMAz+X6gA6 hUFhP/mWAgr27g97B/YfIfI30buyXcI8n/gniqgeIAc3DeI8S8yReLPlgjoUXEmn55e4 lS5awKdruQHlRa6s/jImuRPz9kSHbdzq8VPCa92awJPXmbu3UOxHaYfQJn9aTGJuGEoG 74n4JZkPvfL5Xt/sGLDt6bKSCiG8Izq4JmaoDra+kx9mVaRX03mcJpvBJH22x/JQXDsP ZOOKNHVwaIV2cSxexseTIYaQB+q5WJj++b69x1oucS2VV44TVlwm74V24OC4aCRlti7b MByg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v25si31235420pgo.317.2019.04.10.01.26.17; Wed, 10 Apr 2019 01:26:33 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729544AbfDJIZF (ORCPT + 99 others); Wed, 10 Apr 2019 04:25:05 -0400 Received: from smtp2200-217.mail.aliyun.com ([121.197.200.217]:35261 "EHLO smtp2200-217.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729258AbfDJIZE (ORCPT ); Wed, 10 Apr 2019 04:25:04 -0400 X-Alimail-AntiSpam: AC=CONTINUE;BC=0.09094457|-1;CH=green;DM=CONTINUE|CONTINUE|true|0.0532965-0.00602425-0.940679;FP=0|0|0|0|0|-1|-1|-1;HT=e01a16384;MF=han_mao@c-sky.com;NM=1;PH=DS;RN=8;RT=8;SR=0;TI=SMTPD_---.EJJhwoT_1554884687; Received: from localhost(mailfrom:han_mao@c-sky.com fp:SMTPD_---.EJJhwoT_1554884687) by smtp.aliyun-inc.com(10.147.41.158); Wed, 10 Apr 2019 16:24:48 +0800 From: Mao Han To: linux-kernel@vger.kernel.org Cc: Mao Han , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Alexander Shishkin , Jiri Olsa , Namhyung Kim Subject: [PATCH v3 1/3] perf: use hweight64 instead of hweight_long Date: Wed, 10 Apr 2019 16:16:43 +0800 Message-Id: <29ad7947dc8fd1ff0abd2093a72cc27a2446be9f.1554883878.git.han_mao@c-sky.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 32-bits platform with more than 32 registers, the 64 bits mask is truncate to the lower 32 bits and the return value of hweight_long will always smaller than 32. When kernel outputs more than 32 registers, but the user perf program only counts 32, there will be a data mismatch result to overflow check fail. CC: Peter Zijlstra CC: Ingo Molnar CC: Arnaldo Carvalho de Melo CC: Alexander Shishkin CC: Jiri Olsa CC: Namhyung Kim Signed-off-by: Mao Han --- tools/perf/util/evsel.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c index 7835e05..73c78be 100644 --- a/tools/perf/util/evsel.c +++ b/tools/perf/util/evsel.c @@ -2322,7 +2322,7 @@ int perf_evsel__parse_sample(struct perf_evsel *evsel, union perf_event *event, if (data->user_regs.abi) { u64 mask = evsel->attr.sample_regs_user; - sz = hweight_long(mask) * sizeof(u64); + sz = hweight64(mask) * sizeof(u64); OVERFLOW_CHECK(array, sz, max_size); data->user_regs.mask = mask; data->user_regs.regs = (u64 *)array; -- 2.7.4