From patchwork Thu May 31 10:32:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaldo Carvalho de Melo X-Patchwork-Id: 10440709 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id AA380602BF for ; Thu, 31 May 2018 10:48:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9ED0528FA9 for ; Thu, 31 May 2018 10:48:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9354D28FCA; Thu, 31 May 2018 10:48:40 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 0330228FA9 for ; Thu, 31 May 2018 10:48:40 +0000 (UTC) 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:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=Jdfk8Oin4Ws9YwXqVUezQEDTuXVJEzVH4etcS34Kb8c=; b=CvTgrn8hBijeZY7ZPzXWUf9/VW 236n3vtGU06bW/o+YBfnSvNU/IAWcc7YV4eAxk9MxZsdFrL2ESz8vfngyoJcCDNh7PwK/Kt4kFr5N S73s1hbHb8dBXpLBtZ68lm2lRN93w1C9ioY3qugFTqFAxtrXQ9R5rgxPeXlE8VJANT94iFXGshsLX 5RFqHsNsuFGfFWGpMsIWqh3TevpnOBO4TMBKiz+JN1Q96fttG4G0qzvYhu90oEnZEiqCxwoCW0KHK MrXuEsUjaTif2uPNZdIwLl1QNXi7qaKogbdqETul/+IfDlupYwNl188aAQYqnikAMN6DBb9JWcL5A pmt0i7AQ==; 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 1fOL86-0006Ei-UJ; Thu, 31 May 2018 10:48:27 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fOL7g-0005rh-3O for linux-arm-kernel@bombadil.infradead.org; Thu, 31 May 2018 10:48:00 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=XGs3YbR6/IHY8E3Z8pTl3fXWT7uK+qxXsNaXYK92xhE=; b=ClDq1O/vZbE1qDRnF/1vLGELC 4AVaR1Y1t6hRyw9Rw1DfNMTo8uWFrq6XG5Z4PoJjoHBySpvEgp8poB0SAMl76yUYy0X/MLIJb6VD4 IIwxyaZ/16/8lk43JRCFguqCOkBJiUTFLWm0/zVjrZLtRGBsVqYlV+grYG+fwI9i+xL9MrjLHDQUB bjb+uHMbeYdkXM0lZFMsENlbPfjEOGT1DhJA6FIj8AE/K9o19GsCal3/F+99JcWELFIHajNEs/tv8 SojNxyjzVbdWT0JMty8b1qJNtvfgeoOndEay+GWnLc2ltF3GOTbe8Nt6NohK83qhjXT4PZ4UkXqQp u5MgKFvIA==; Received: from mail.kernel.org ([198.145.29.99]) by casper.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fOKt9-0002jZ-7b for linux-arm-kernel@lists.infradead.org; Thu, 31 May 2018 10:33:02 +0000 Received: from jouet.infradead.org (unknown [179.97.41.186]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 3E1CA208B1; Thu, 31 May 2018 10:32:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527762768; bh=DDVrNuv+pJ7wHR4n5ft/aSnTjLyvq5NXUpk0Fu1bYLY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=M46TxJADQG7IsAbZx0hMEF1Hhd3v0vuB6J2ozKKR7AoGsa85BEUkkuLYa3AZ5IBgy qg8CsgL0BDuYCfycMGi605n1KuzuifKqm2/hDxX8BaH5sxoA0X0JW/fiQRzaSyR5Ds 4vdPgnnerZbudq79GlukrQ75bEcVP5bXB5bDsCmQ= From: Arnaldo Carvalho de Melo To: Ingo Molnar Subject: [PATCH 4/7] perf cs-etm: Fix indexing for decoder packet queue Date: Thu, 31 May 2018 07:32:17 -0300 Message-Id: <20180531103220.24684-5-acme@kernel.org> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180531103220.24684-1-acme@kernel.org> References: <20180531103220.24684-1-acme@kernel.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180531_113259_415212_418697AA X-CRM114-Status: GOOD ( 17.59 ) 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: Arnaldo Carvalho de Melo , Mathieu Poirier , Clark Williams , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Alexander Shishkin , Peter Zijlstra , Namhyung Kim , Robert Walker , Jiri Olsa , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: Mathieu Poirier The tail of a queue is supposed to be pointing to the next available slot in a queue. In this implementation the tail is incremented before it is used and as such points to the last used element, something that has the immense advantage of centralizing tail management at a single location and eliminating a lot of redundant code. But this needs to be taken into consideration on the dequeueing side where the head also needs to be incremented before it is used, or the first available element of the queue will be skipped. Signed-off-by: Mathieu Poirier Tested-by: Leo Yan Cc: Alexander Shishkin Cc: Jiri Olsa Cc: Namhyung Kim Cc: Peter Zijlstra Cc: Robert Walker Cc: linux-arm-kernel@lists.infradead.org Link: http://lkml.kernel.org/r/1527289854-10755-1-git-send-email-mathieu.poirier@linaro.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/cs-etm-decoder/cs-etm-decoder.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/tools/perf/util/cs-etm-decoder/cs-etm-decoder.c b/tools/perf/util/cs-etm-decoder/cs-etm-decoder.c index c8b98fa22997..4d5fc374e730 100644 --- a/tools/perf/util/cs-etm-decoder/cs-etm-decoder.c +++ b/tools/perf/util/cs-etm-decoder/cs-etm-decoder.c @@ -96,11 +96,19 @@ int cs_etm_decoder__get_packet(struct cs_etm_decoder *decoder, /* Nothing to do, might as well just return */ if (decoder->packet_count == 0) return 0; + /* + * The queueing process in function cs_etm_decoder__buffer_packet() + * increments the tail *before* using it. This is somewhat counter + * intuitive but it has the advantage of centralizing tail management + * at a single location. Because of that we need to follow the same + * heuristic with the head, i.e we increment it before using its + * value. Otherwise the first element of the packet queue is not + * used. + */ + decoder->head = (decoder->head + 1) & (MAX_BUFFER - 1); *packet = decoder->packet_buffer[decoder->head]; - decoder->head = (decoder->head + 1) & (MAX_BUFFER - 1); - decoder->packet_count--; return 1;