Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3140368pxj; Mon, 7 Jun 2021 03:25:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzgx5hZE0J6wXt6QjkZpWUof5dmbjrNk+ad6OsPnA+d8NovahaX3QqPGEfsbepLUvgHsYSb X-Received: by 2002:aa7:d64f:: with SMTP id v15mr18872761edr.255.1623061545204; Mon, 07 Jun 2021 03:25:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623061545; cv=none; d=google.com; s=arc-20160816; b=pTu/O/YbuafKcHxV2W99hj3/vkohZVPQVXv2MEpCR6CcIvxUL4lOJV2cxamsRUh33q eELqZEx/jdfJzoW3hPfZqwPJIwQGdpkVC2CoU61gw3NZZaFCux7SE8rubPycUliM2SdX 452QutmgWcC3gQd9DTnMDTQBcfpzQyy1iLiTKGtJmbwu8jBMqLcDOTqLGyNNE/Mqw3GJ 78eSmuhrvAS+mkBaxAawmetOzIQl76/HxD04tUPHChoKlXhNDUUDKyuu6WStLCm2CFUH JpBSzt4uPJXMExSQDGzwoMjfY3ZlSeoOQMmf0MRfgEAjoDEHuhuIESndUH4e5PMTt7U4 znoA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:organization :from:references:cc:to:subject:ironport-sdr:ironport-sdr; bh=GsCIzZtR7J9gGxHw/p05Igz9ts8Y6Z0Wb0tjEWaLhfc=; b=xfMuI37VDp8yoeNt2SdrEV8l7O+6k1BulEehZWoXE2Hbh3ZmaBlvSrt3MSSjgtYWTD kNLxWjl6waCuqfmOigHRHseqdfPFLnY3uC/b67CrRlMb08CUi+RifaMpZ7JjzCpeiqdf /TlmCDf6pOPlFBjFfOzXgNWP7B/Z+p5DO/pl49fRYGfWz+mVO40ea+olA7ovlR2unK8T UnWBm1K0pTD5RXyYPpYSaDfEtfDRWDtmi9teaOjwXxG4L46eFaqR9vMP6VLwTvNmzM5l wYZKIGGPl7DMnakLgYcDvgglzYW5C0AMqFzBmlBazgCVPEOf08neNy63lvwPHEa0cG9X q69g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y10si12326866ejk.718.2021.06.07.03.25.22; Mon, 07 Jun 2021 03:25:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230394AbhFGKZZ (ORCPT + 99 others); Mon, 7 Jun 2021 06:25:25 -0400 Received: from mga06.intel.com ([134.134.136.31]:1083 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230355AbhFGKZW (ORCPT ); Mon, 7 Jun 2021 06:25:22 -0400 IronPort-SDR: 2zjjMgRhiUzi/VvT3pcdxuW4VTv/NCsVMBYMb8Zb++SupHjsnnoRhMXlN8RFtDHjTOuFvb9ubA WmQWv/TEN2Uw== X-IronPort-AV: E=McAfee;i="6200,9189,10007"; a="265750749" X-IronPort-AV: E=Sophos;i="5.83,254,1616482800"; d="scan'208";a="265750749" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Jun 2021 03:23:30 -0700 IronPort-SDR: 6KMKnIbtqCdKX6P8IKQCGifSJPd27S+5hs7Sg2E/hDInGVq3EvHkHIlOxuDoyPdh33ib2f0jAL Tl6R3qQTFOqA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.83,254,1616482800"; d="scan'208";a="484727860" Received: from ahunter-desktop.fi.intel.com (HELO [10.237.72.174]) ([10.237.72.174]) by fmsmga002.fm.intel.com with ESMTP; 07 Jun 2021 03:23:25 -0700 Subject: Re: [PATCH v2 8/8] perf record: Directly bail out for compat case To: Leo Yan Cc: 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> <20210602123847.GE10272@leoy-ThinkPad-X240s> From: Adrian Hunter Organization: Intel Finland Oy, Registered Address: PL 281, 00181 Helsinki, Business Identity Code: 0357606 - 4, Domiciled in Helsinki Message-ID: <96e5fac6-17a2-ea03-9b15-338b84321ecf@intel.com> Date: Mon, 7 Jun 2021 13:23:43 +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: <20210602123847.GE10272@leoy-ThinkPad-X240s> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2/06/21 3:38 pm, Leo Yan wrote: > Hi Adrain, > > On Wed, Jun 02, 2021 at 02:18:47PM +0300, Adrian Hunter wrote: >> 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); > > Seems to me, it's pointless to only support aux_head for 64-bit and > support aux_tail for 32-bit. I understand this can be helpful for the > snapshot mode which only uses aux_head, but it still fails to support > the normal case for AUX ring buffer using 64-bit head/tail. I am not sure why you say it is pointless. 'perf record' would still be able to capture up to 4GiB of data. Do you mean you usually capture more than 4GiB of data? I was thinking we would separate out the compat case: #if BITS_PER_LONG == 32 if (kernel_is_64_bit) return compat_auxtrace_mmap__[read_head/write_tail]() #endif So the non-compat cases would not be affected.