lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20230826072957.GA75980@leoy-huanghe.lan>
Date:   Sat, 26 Aug 2023 15:29:57 +0800
From:   Leo Yan <leo.yan@...aro.org>
To:     Namhyung Kim <namhyung@...nel.org>
Cc:     Jonathan Corbet <corbet@....net>,
        Arnaldo Carvalho de Melo <acme@...nel.org>,
        Ian Rogers <irogers@...gle.com>,
        Thomas Richter <tmricht@...ux.ibm.com>,
        Peter Zijlstra <peterz@...radead.org>,
        Adrian Hunter <adrian.hunter@...el.com>,
        Jiri Olsa <jolsa@...nel.org>, linux-doc@...r.kernel.org,
        linux-kernel@...r.kernel.org, linux-perf-users@...r.kernel.org
Subject: Re: [PATCH v6] Documentation: userspace-api: Document perf ring
 buffer mechanism

Hi Namhyung,

On Tue, Aug 22, 2023 at 09:26:05PM -0700, Namhyung Kim wrote:

[...]

> > > > +Why ring buffers are mapped with above two different modes?  Here the
> > > > +write direction matters.  The forward writing starts to save data from
> > > > +the beginning of the ring buffer and wrap around when overflow, which is
> > > > +used with the read-write mode in the normal ring buffer.  When the
> > > > +consumer doesn't keep up with the producer, it would lose some data, the
> > > > +kernel keeps how many records it lost and generates the
> > > > +``PERF_RECORD_LOST`` records in the next time when it finds a space in the
> > > > +ring buffer.
> > >
> > > Thanks for the update.  It's unclear to me if all 4 combination of
> > > (rw, ro) x (fwd, bwd) are possible (yes!).  The rw mode and back-
> > > ward is also possible but just not used for perf tool.
> >
> > I can add a matrix for the combinations:
> >
> >   The combination is supported in perf tool:
> >
> >   ---+------------+-----------
> >      |  Forward   | Backward
> >   ---+------------+-----------
> >   rw |  Yes       |   No
> >   ---+------------+-----------
> >   ro |  X         |   Yes
> >   ---+------------+-----------
> >
> >   Yes: is supported
> >   No: is not supported
> >   X: is not feasible
> 
> I think they are all supported.  You can use rw mode with backward
> direction but it's just not intuitive.  Also ro mode with forward direction
> is working but there's a chance to miss the start position of the
> previous event.

I am a bit confused for the all four modes are supported.

>From the code [1], we can see there have only two combinations:

- overwrite + read-only mode (PROT_READ);
- no-overwrite + read-write mode (PROT_READ | PROT_WRITE);

And I think perf tool must use the backward writing for "overwrite",
and use the forward writing for "non-overwrite" mode.  I think the
code [2] can help us to conclude this.

In the end, the perf tool doesn't support the combinations:

- overwrite + read-write mode
- no-overwrite + read-only mode

I have sent a v6 patch, please let me know if you have any concerns or
if I misunderstand anything.  Thanks!

Leo

[1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/tools/lib/perf/evlist.c#n474
[2] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/tools/lib/perf/mmap.c#n141

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ