From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934219AbcAKRFW (ORCPT ); Mon, 11 Jan 2016 12:05:22 -0500 Received: from www62.your-server.de ([213.133.104.62]:50000 "EHLO www62.your-server.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933658AbcAKRFV (ORCPT ); Mon, 11 Jan 2016 12:05:21 -0500 Message-ID: <5693E0C6.2080509@iogearbox.net> Date: Mon, 11 Jan 2016 18:05:10 +0100 From: Daniel Borkmann User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 MIME-Version: 1.0 To: Wang Nan , davem@davemloft.net, acme@kernel.org CC: linux-kernel@vger.kernel.org, netdev@vger.kernel.org, pi3orama@163.com, lizefan@huawei.com, Adrian Hunter , Arnaldo Carvalho de Melo , David Ahern , Ingo Molnar , Peter Zijlstra , Yunlong Song Subject: Re: [PATCH net-next] perf/core: Put size of a sample at the end of it by PERF_SAMPLE_TAILSIZE References: <1452518653-1794-1-git-send-email-wangnan0@huawei.com> In-Reply-To: <1452518653-1794-1-git-send-email-wangnan0@huawei.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Authenticated-Sender: daniel@iogearbox.net Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Wang, On 01/11/2016 02:24 PM, Wang Nan wrote: > This patch introduces a PERF_SAMPLE_TAILSIZE flag which allows a size > field attached at the end of a sample. The idea comes from [1] that, > with tie size at tail of an event, it is possible for user program who > read from the ring buffer parse events backward. > > For example: > > head > | > V > +--+---+-------+----------+------+---+ > |E6|...| B 8| C 11| D 7|E..| > +--+---+-------+----------+------+---+ > > In this case, from the 'head' pointer provided by kernel, user program > can first see '6' by (*(head - sizeof(u64))), then it can get the start > pointer of record 'E', then it can read size and find start position > of record D, C, B in similar way. > > The implementation is easy: adding a PERF_SAMPLE_TAILSIZE flag, makes > perf_output_sample() output size at the end of a sample. > > Following things are done for ensure the ring buffer is safe for > backward parsing: > > - Don't allow two events with different PERF_SAMPLE_TAILSIZE setting > set their output to each other; > > - For non-sample events, also output tailsize if required. > > This patch has a limitation for perf: > > Before reading such ring buffer, perf must ensure all events which may > output to it is already stopped, so the 'head' pointer it get is the > end of the last record. > > [1] http://lkml.kernel.org/g/1449063499-236703-1-git-send-email-wangnan0@huawei.com > > Signed-off-by: Wang Nan > Cc: Adrian Hunter > Cc: Arnaldo Carvalho de Melo > Cc: David Ahern > Cc: Ingo Molnar > Cc: Peter Zijlstra > Cc: Yunlong Song > Cc: David S. Miller [...] As this seems unrelated to networking, net-next tree seems not really appropriate? Cheers, Daniel