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=-6.9 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_PASS,T_DKIMWL_WL_HIGH,URIBL_BLOCKED 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 2E646C004C9 for ; Tue, 7 May 2019 18:00:07 +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 F3783206BF for ; Tue, 7 May 2019 18:00:06 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="VLMzu0mT"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="QvWDlmVS" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org F3783206BF 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+infradead-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.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:To:Subject:Message-ID:Date:From: In-Reply-To:References:MIME-Version:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=8HPYbnCNYzixdzMJG08kXhwCt5YuoWIDOcF/AvZcBn4=; b=VLMzu0mTyXDXve qCS6tf/L2QzOpla3x4YfPU7uMi5+XA4Cx2iMOoqAqkbbN3YLj4re2L74LE9fdJzkgMOc4ykDEpnA/ FHZsuOKq7yujnkHoBupIoaIQnpKUhM4J8bHWRRQl41WDFfpMGzTLIHGTVY5tOdd6cWJ6chNdulaUR HQTwxgsyuxil8slK0ZZqZAzdukFiyjw5NNON5eyJGSzK/F7XYX5KA9GTK//f0ilGOcKiZzMzzkMw8 1DTweyAAsJOl53NXGJeUoKevk+io1+VWI+UdGOaT569K5IQ8rz1wnytQmqwgTHK3fZn6Cygk4cqjg 9IcRmMJ6hJyeKYTdG3LA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1hO4Nk-0001lQ-Cn; Tue, 07 May 2019 18:00:00 +0000 Received: from mail-io1-xd43.google.com ([2607:f8b0:4864:20::d43]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1hO4Nh-0001kh-UK for linux-arm-kernel@lists.infradead.org; Tue, 07 May 2019 17:59:59 +0000 Received: by mail-io1-xd43.google.com with SMTP id m14so14955433ion.13 for ; Tue, 07 May 2019 10:59:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=4m+oft9DKwRRKpp/Oz5bnd1FfF8vprikrXqLhZ7LaKA=; b=QvWDlmVSNh8hvDf6dga3sh4pTncpbYdX89GumOVAhme7hlZnb6O7OzfMK5f7/qq1TZ lsPwSE6Rhq3Llx94n9KEQOxXjUsIw6W4g3W1NprzcMpEWFMtyuZbJNhgwfS+6At2jaiE KhLeEdSCTJkdwmDA1Agmc2bWeI1nKGH65dtI7Grh6gok6A0H6m0CLf/grWeeZxS+wjOB GwkmrMMor4t5D66pkEzF3y0X/LUzj+mGkZ4XmG9QMXTUnqAuwrpjHHpJ38tO2viknPzI GhAu26jwUuhnFJBPJJS6VMZkhnS6oVy58BluCpxh0t4u+1dJ2xO+GRVZHSj73YetvzA4 MEIw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=4m+oft9DKwRRKpp/Oz5bnd1FfF8vprikrXqLhZ7LaKA=; b=jRTI9ukhjlBcqf6jlcbd7w5xFuk6H03BDMQJz/DAJGelRHhRNXxjLuRR0cdxNX75TB +D3PoftIaieNs7a5Pb5UUZZwQ6qtVgmUci3u23by3l5ymE1Illo5/VOoxzt/hoHQ9V3s QzHJlYns5xYrHfrDB663mPvVbgjgQA3t3Fiu3y7l/UIUGy/ygzcAj6Qbi2TcXMstu5+O BbSZVShNsJAU2wDX8GMlNDXoaxrV82DJHVNOE5BfsBPxyjsSYZm46u8IB8TOLnVD7KXu M0/tXnIas6JqshhgQtIhot0rqYjNUq9SDvVqVNyr+h2cbeRW2q56HesaqPCphkInbE+H qTTw== X-Gm-Message-State: APjAAAUJ2nRU5b7ZpLdcFCIdULFe/Q6nHiptNJ1lA1eeqAGIbd6aVbW7 fMxLUdC/VKedMR2guebfRGDWCI9wZsAn+wdJNQYcIA== X-Google-Smtp-Source: APXvYqzNXaPDswfdfFdIYfFolo6sYnthy2HR7telxyZC+1Y4/dsTs4iUrywuOzj+EPHM+owLmdxVZIdxx4yvzGrfn+E= X-Received: by 2002:a6b:6d06:: with SMTP id a6mr6822816iod.11.1557251996915; Tue, 07 May 2019 10:59:56 -0700 (PDT) MIME-Version: 1.0 References: <20190501175052.29667-1-mathieu.poirier@linaro.org> <20190501175052.29667-5-mathieu.poirier@linaro.org> <20190507084404.GD21730@leoy-ThinkPad-X240s> In-Reply-To: <20190507084404.GD21730@leoy-ThinkPad-X240s> From: Mathieu Poirier Date: Tue, 7 May 2019 11:59:46 -0600 Message-ID: Subject: Re: [PATCH 4/5] perf tools: Properly set the value of 'old' in snapshot mode To: Leo Yan X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190507_105957_984881_B63DF03E X-CRM114-Status: GOOD ( 24.90 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jon Corbet , Alexander Shishkin , Coresight ML , "Suzuki K. Poulose" , Arnaldo Carvalho de Melo , Peter Zijlstra , Ingo Molnar , Mike Leach , linux-arm-kernel Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Tue, 7 May 2019 at 02:44, Leo Yan wrote: > > On Wed, May 01, 2019 at 11:50:51AM -0600, Mathieu Poirier wrote: > > In snapshot mode the value of the 'old' pointer needs to be adjusted when > > 'head' has wrapped around in order to get the latest information in the > > buffer and be compatible with the generic AUX ring buffer mechanic. > > > > Signed-off-by: Mathieu Poirier > > --- > > tools/perf/arch/arm/util/cs-etm.c | 12 ++++++++++-- > > 1 file changed, 10 insertions(+), 2 deletions(-) > > > > diff --git a/tools/perf/arch/arm/util/cs-etm.c b/tools/perf/arch/arm/util/cs-etm.c > > index 911426721170..4e73fe1a6978 100644 > > --- a/tools/perf/arch/arm/util/cs-etm.c > > +++ b/tools/perf/arch/arm/util/cs-etm.c > > @@ -541,11 +541,19 @@ static int cs_etm_find_snapshot(struct auxtrace_record *itr __maybe_unused, > > unsigned char *data __maybe_unused, > > u64 *head, u64 *old) > > { > > + bool wrapped; > > + > > pr_debug3("%s: mmap index %d old head %zu new head %zu size %zu\n", > > __func__, idx, (size_t)*old, (size_t)*head, mm->len); > > > > - *old = *head; > > - *head += mm->len; > > + /* > > + * If the last byte in the ring buffer isn't zero, the head has > > + * wrapped around. > > + */ > > + wrapped = !!(data[mm->len - 1]); > > This is confused for me since I can think out two cases might break > this checking. > > The first case is the trace data stream might be zero at the end of the > buffer; I just realized there is a better way to do this - since "*head" is continiously incrementing I will simply compare it to mm->len. If it is equal of bigger, the head has wrapped around. >the second case is that the buffer is not really wrapped around > at this time but the end of buffer contains the stale data by previous > time. That would mean the snapshots were really close together. In that case we'd simply get the tail end of the previous snapshot, which is fine since it is was close enough that we do want that data. > > Could you confirm both cases will not happen? > > Will do more testing for this patch set. > > Thanks, > Leo Yan > > > + > > + if (wrapped) > > + *old = *head - mm->len; > > > > return 0; > > } > > -- > > 2.17.1 > > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel