From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 24093C47092 for ; Wed, 2 Jun 2021 11:21:57 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E789B6100B for ; Wed, 2 Jun 2021 11:21:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E789B6100B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:Date: Message-ID:From:References:To:Subject:Reply-To:Cc:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=+dJF1gnCCuLHlNpTfPD+m6T2feaBqAcN1UhJtv4gf4A=; b=XZc3tlPbYbLZAdYiytx9nCxute X/FepcQwrQ0aXEAaBVBwAZbN18l4PmS87gE7IO9zr7twbK5xSGbG1MU/XwhlCDvPqf2hEOI//WRlC todVuM7iKizTCOCzsNJK5icuG2dy9ZXAzZFodJzd+Gkw0YFMglrYMqHbwK+h4WSNjUduKvWVlRmtL AtDdFRfteiQYRByIaApilBvw3mieG5CRsxKMkLGHDU21jpPyvvhOZvrUnGCkTz8btrH7gAJW4Vk1O yHUa0d2pao98JXnEuX6fb6pBKmj30fpVBZt+gk63VOzyMaenzk3NqcAq4CSWEgQQZOggsxxoAupda ZrGA0E0A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1loOuK-003gsq-W8; Wed, 02 Jun 2021 11:19:33 +0000 Received: from mga01.intel.com ([192.55.52.88]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1loOtM-003gGs-FJ for linux-arm-kernel@lists.infradead.org; Wed, 02 Jun 2021 11:18:33 +0000 IronPort-SDR: zlZkUJzO+A2Ux2TzisLiEaP7KxdREVAaROfPPiVqO8M0em70Yd6nlmcT/GxDc4oDD3sYpkFYV8 QvWOJ9aBaIrw== X-IronPort-AV: E=McAfee;i="6200,9189,10002"; a="225051858" X-IronPort-AV: E=Sophos;i="5.83,242,1616482800"; d="scan'208";a="225051858" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jun 2021 04:18:31 -0700 IronPort-SDR: jBFkqpqJsLwCoFu1dX6G+w7cN+0fUYsPhXufsWCi5oP2GRnVnyNnwRSImg6Xrfn5l0Tcuog1B2 cdnGu2ae0uKg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.83,242,1616482800"; d="scan'208";a="479672850" Received: from ahunter-desktop.fi.intel.com (HELO [10.237.72.174]) ([10.237.72.174]) by orsmga001.jf.intel.com with ESMTP; 02 Jun 2021 04:18:26 -0700 Subject: Re: [PATCH v2 8/8] perf record: Directly bail out for compat case To: Leo Yan , Arnaldo Carvalho de Melo , Peter Zijlstra , Ingo Molnar , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Thomas Gleixner , x86@kernel.org, "H. Peter Anvin" , Mathieu Poirier , Suzuki K Poulose , Mike Leach , Andi Kleen , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org References: <20210602103007.184993-1-leo.yan@linaro.org> <20210602103007.184993-9-leo.yan@linaro.org> From: Adrian Hunter Organization: Intel Finland Oy, Registered Address: PL 281, 00181 Helsinki, Business Identity Code: 0357606 - 4, Domiciled in Helsinki Message-ID: Date: Wed, 2 Jun 2021 14:18:47 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.10.1 MIME-Version: 1.0 In-Reply-To: <20210602103007.184993-9-leo.yan@linaro.org> Content-Language: en-US X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210602_041832_598392_610BC3C7 X-CRM114-Status: GOOD ( 25.58 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 2/06/21 1:30 pm, Leo Yan wrote: > Since the 64-bit atomicity is not promised in 32-bit perf, directly > report the error and bail out for this case. > > Now only applies on x86_64 and Arm64 platforms. > > Suggested-by: Adrian Hunter Maybe we can do better for the compat case. We can assume the upper 32-bits change very seldom, and always increase. So for the 'read' case: u64 first, second, last; u64 mask = (u64)((u32)-1) << 32; do { first = READ_ONCE(pc->aux_head); rmb(); second = READ_ONCE(pc->aux_head); rmb(); last = READ_ONCE(pc->aux_head); } while ((first & mask) != (last & mask)); return second; For the write case, we can cause a fatal error only if the new tail has non-zero upper 32-bits. That gives up to 4GiB of data before aborting: if (tail & mask) return -1; smp_mb(); WRITE_ONCE(pc->aux_tail, tail); > Signed-off-by: Leo Yan > --- > tools/perf/builtin-record.c | 17 +++++++++++++++++ > 1 file changed, 17 insertions(+) > > diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c > index 3337b5f93336..f47e298281f7 100644 > --- a/tools/perf/builtin-record.c > +++ b/tools/perf/builtin-record.c > @@ -74,6 +74,7 @@ > #include > #include > #include > +#include > > struct switch_output { > bool enabled; > @@ -848,6 +849,22 @@ static int record__mmap_evlist(struct record *rec, > opts->auxtrace_sample_mode; > char msg[512]; > > +#ifndef __LP64__ > + struct utsname uts; > + int ret; > + > + ret = uname(&uts); > + if (ret < 0) > + return ret; > + > + if (!strncmp(uts.machine, "x86_64", 6) || !strncmp(uts.machine, "aarch64", 7) || > + !strncmp(uts.machine, "arm64", 5)) { > + pr_err("Error, 32-bit perf cannot record from a 64-bit kernel.\n" > + "Please use a 64-bit version of perf instead.\n"); > + return -ENOTSUP; > + } > +#endif > + > if (opts->affinity != PERF_AFFINITY_SYS) > cpu__setup_cpunode_map(); > > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel