Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp1036970yba; Tue, 2 Apr 2019 00:34:32 -0700 (PDT) X-Google-Smtp-Source: APXvYqylYf2hd1IopRBGQPVhCGmMvI0VpwG6wa7Ie5CcQWqxqgWxMW2zLSXAe5fQKpsnmqQhU3LC X-Received: by 2002:a63:1a1b:: with SMTP id a27mr57594182pga.59.1554190472370; Tue, 02 Apr 2019 00:34:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554190472; cv=none; d=google.com; s=arc-20160816; b=SaoftgU3Qm84U7WPflfwTMJo3uQ4qx0/tCcSTuYTmpwIJah8CYS4aeEATudBqD3UTe mgwoFUcyvrd+B3E/l3q7LIj07gcw0hH0Hk+fi3QajH6djpwdOagn3/HsLo/0yhVg4mBs XozxC8+SLDkLSpiQR1NP3+797//L6AWFcAXtpmbuLj0D0z8SOK0vGmKelD17nGSBctuw XectPo5C5WvuPh6yeR1YGJe7hKouPZrKq/F1GfPKQ5F2DZQV95E+cXFkYnPmsaESp8dK QmEPH908FWRGZAlN0BmuNlCN2DmHbEUYiZYiYQGf3ohwdqrr5hvLXK/iqal6DP/WEqai UhHQ== 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:message-id:date :subject:cc:to:from; bh=hD18is9Zu9kkZC0XIAoa+/nxDqKzeATtrLo5pFrTuhw=; b=bcHrIsCOOXL6qQ+h8FjvK3lj4Iw1NqOcD6pvnioWu4EK4Hlyps1AZ5GHEDsxWfE8qU mqManXv4IQQH+DMKAn8cTsUKJqPeQaBgRkFzg56Zp4Fh5qEoASTi9x5BtIQ/BHA9J3Bi WWAuvr1RKlW/7jRFvjx5s2UhbrKalx3YUf2V6XL4kfhMI66RgOkH33jWwTy1xGTroQGf uGsdgmoQPBc0uVKXQciaZf/z16QZLMBBYrCLtGVJpjzR2/uhVApA9nUz9bmyBVhS2maR zvhv05PA8ctugqhKcWYRK3atp/3CzoxJPFtufri2ew1Cxcxll1bk9JAkERIU8eu6egXX Dnsw== 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 n11si10372108pgu.562.2019.04.02.00.34.03; Tue, 02 Apr 2019 00:34:32 -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 S1729246AbfDBGkt (ORCPT + 99 others); Tue, 2 Apr 2019 02:40:49 -0400 Received: from smtp2200-217.mail.aliyun.com ([121.197.200.217]:34439 "EHLO smtp2200-217.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729203AbfDBGkp (ORCPT ); Tue, 2 Apr 2019 02:40:45 -0400 X-Alimail-AntiSpam: AC=CONTINUE;BC=0.08712801|-1;CH=green;DM=CONTINUE|CONTINUE|true|0.0578554-0.00589887-0.936246;FP=0|0|0|0|0|-1|-1|-1;HT=e01l07391;MF=han_mao@c-sky.com;NM=1;PH=DS;RN=9;RT=9;SR=0;TI=SMTPD_---.EFvSTAz_1554187241; Received: from localhost(mailfrom:han_mao@c-sky.com fp:SMTPD_---.EFvSTAz_1554187241) by smtp.aliyun-inc.com(10.147.42.22); Tue, 02 Apr 2019 14:40:41 +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 , Guo Ren Subject: [PATCH v2 1/1] perf: use hweight64 instead of hweight_long Date: Tue, 2 Apr 2019 14:35:42 +0800 Message-Id: <29ad7947dc8fd1ff0abd2093a72cc27a2446be9f.1554186265.git.han_mao@c-sky.com> X-Mailer: git-send-email 2.7.4 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 CC: Guo Ren 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