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=-9.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS 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 3D4B5C47095 for ; Wed, 9 Jun 2021 09:33:16 +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 11C7561285 for ; Wed, 9 Jun 2021 09:33:15 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 11C7561285 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org 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:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=CxsoiM6E9ZendwKe55bM+LkrpK5F9j3kkEl4Jj1ayIk=; b=xoTd9x9zG6PLnM vy/MpLlTTE8Tdu01S90AoZdE5ef3ql7pRfYsJnf7wMbd33VoLQgFvRbin1VZ8+XaEvi69VlshsROC RIIfs9gk05WOy/JeItgyqYOVQwVvYwTc70Q+a60UW5mH+YvXn38D2fxmGZ8qE3w8hT0I1snw2A41e tOxXkJuEFbhWC95UIafvowmYrtcCXmadz4lwhaRH787oVFZEj+/DnD23laB0HT9Mj9eqWOBhFyY0Q lXXjYcupgLEbSG6CNrS4I+S5meoMc7BUwRMBgCqPbIjrmqbpqCMtiMiwD5mA0+Sp1X3MxI8CaUBSA hmFVm3tTWwcBIhuXeKHA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lquWs-00CgLt-Iu; Wed, 09 Jun 2021 09:29:43 +0000 Received: from mail-pj1-x1035.google.com ([2607:f8b0:4864:20::1035]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1lqu22-00CWL5-4p for linux-arm-kernel@lists.infradead.org; Wed, 09 Jun 2021 08:57:51 +0000 Received: by mail-pj1-x1035.google.com with SMTP id g24so957901pji.4 for ; Wed, 09 Jun 2021 01:57:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=bVQYTBu0a1Kk4T/+mZeiDj1CUGFrrISY4m2gx4+3p0Y=; b=zWLJH9Fpk2rU9on5mQyq6ez7pr8woPsp5xGdYeyxyqpKOW2MwbTx4zpipsZguP8C6e kgFol/kYXEtXr4ttFEbd0C22l2C7sTjBwEd+8FLsdNT4nXo+SpkE287hmWSlSD6ftAjB YcMEBtfMFEpbWUleniM808BgHP1nB+j4s6C/O8xVMHRurEliFkPO19Xnwq2DXDzg0bIt gGy08AN7CX3X26DCPHsS1T168Jx76nSwuNQnxCx0o0xXzRryzrqZCIYBcGcFYqI9O8fZ +66QZf6f1YX0qtOZOWP1LHUIT900FJGKwrzKf9O+oCJTeVhs65gvjcmw1IqWtEg5YGz4 YGDQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=bVQYTBu0a1Kk4T/+mZeiDj1CUGFrrISY4m2gx4+3p0Y=; b=Gw3duiqR1de55yb5CMnU9L5diB1Xt9pHUguXJZqIP5g6ukYzaHBh2WZ/YHA+cpRjAd QHx3HrXdYISfRXZU2ikfkhQr1GKa/FJfhhHQ412jYwM60kMuybaML68Z+/mIhVmW4Xb0 a3XuR19f24i/Go49jJJjOIvn2zrOlp/cOJP09kagsjiPmhN5rDrUAQRe+i5kvbWHhlNg EMepB5RKcSt/DUATyp/6WqgUwUGF4v+mojBPjE2AmksHpgzy2bGV3V8YSqBLc2nUB3Ja awO19UQ6fd0qNOjNQN4VwLG1asMzlRSes/FltOT/1Xsy1cw7NddDlHUUiXNruGq7MtWq 84cA== X-Gm-Message-State: AOAM531pGGZYNhAzxeKtruaacdghJWeowiauzht2vScEMjviG7f9bS89 TgEP/H5GbfQayIFjaU7aajOwKA== X-Google-Smtp-Source: ABdhPJzPFkcMwOFYo5oqKyhE4y8nEnWIB/h6N4itRbJrqLCe+yXMoko7eVGUr2PWg4oJur4fbapZ3A== X-Received: by 2002:a17:90a:f304:: with SMTP id ca4mr32399766pjb.177.1623229068832; Wed, 09 Jun 2021 01:57:48 -0700 (PDT) Received: from leoy-ThinkPad-X240s (ec2-18-167-84-74.ap-east-1.compute.amazonaws.com. [18.167.84.74]) by smtp.gmail.com with ESMTPSA id t1sm12394038pfe.61.2021.06.09.01.57.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Jun 2021 01:57:48 -0700 (PDT) Date: Wed, 9 Jun 2021 16:57:41 +0800 From: Leo Yan To: Adrian Hunter 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 Subject: Re: [PATCH v2 8/8] perf record: Directly bail out for compat case Message-ID: <20210609085741.GF4640@leoy-ThinkPad-X240s> References: <20210602103007.184993-1-leo.yan@linaro.org> <20210602103007.184993-9-leo.yan@linaro.org> <20210602123847.GE10272@leoy-ThinkPad-X240s> <96e5fac6-17a2-ea03-9b15-338b84321ecf@intel.com> <20210607150903.GC1071897@leoy-ThinkPad-X240s> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210609_015750_234639_DE4A9330 X-CRM114-Status: GOOD ( 28.34 ) 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 Hi Adrian, On Wed, Jun 09, 2021 at 11:23:25AM +0300, Adrian Hunter wrote: [...] > >> 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. > > > > Because I don't want to introduce the complexity for read/write head > > and tail, and we also need to handle the same issue for the perf ring > > buffer. So how about below change? > > > > The main idea for below change is it allows the perf to run normally > > on the compat mode and exitly if detects the buffer head is close to > > the low 32-bit's overflow: when detect the low 32-bit value is bigger > > than 0xf0000000 (so we have 256MiB margin to the overflow), it reports > > error and exit. > > > > diff --git a/tools/perf/util/auxtrace.c b/tools/perf/util/auxtrace.c > > index 1b4091a3b508..2a9965bfeab4 100644 > > --- a/tools/perf/util/auxtrace.c > > +++ b/tools/perf/util/auxtrace.c > > @@ -1693,6 +1693,14 @@ static int __auxtrace_mmap__read(struct mmap *map, > > pr_debug3("auxtrace idx %d old %#"PRIx64" head %#"PRIx64" diff %#"PRIx64"\n", > > mm->idx, old, head, head - old); > > > > +#ifdef BITS_PER_LONG == 32 > > + if (kernel_is_64bit() && head >= 0xf0000000) { > > You are assuming the head never increases by more than 256MiB which > means you should limit the buffer size to 256MiB maximum. > > To me this seems a bit too far from an ideal solution. > > I would have thought separating out the compat case makes things > simpler to understand. Agreed. I will follow up the suggestions to add compat variants for accessing AUX head and tail, and will distinguish compat case with global env variable for 64-bit kernel. After get ready, will send out for review. Thanks a lot for suggestions! Leo _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel