Re: [PATCH v7 2/5] perf cpumap: Add reference count checking

From: Arnaldo Carvalho de Melo
Date: Wed Apr 12 2023 - 11:42:03 EST


Em Tue, Apr 11, 2023 at 03:19:06PM -0300, Arnaldo Carvalho de Melo escreveu:
> Em Fri, Apr 07, 2023 at 04:04:02PM -0700, Ian Rogers escreveu:
> > This change is intended to catch:
> > - use after put: using a cpumap after you have put it will cause a
> > segv.
> > - unbalanced puts: two puts for a get will result in a double free
> > that can be captured and reported by tools like address sanitizer,
> > including with the associated stack traces of allocation and frees.
> > - missing puts: if a put is missing then the get turns into a memory
> > leak that can be reported by leak sanitizer, including the stack
> > trace at the point the get occurs.

> I think this should be further split into self contained patches as it
> does:

> 3. Shouldn't we have a map__refcnt(map) accessor to avoid using those
> verbose macros outside the object that is having its reference counts
> checked?

So I added this one, in the end its just to avoid