Re: [PATCH 0/3] Fix duplicated VAR and secinfo

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, 2025-02-18 at 08:54 -0800, Stephen Brennan wrote:
> Alan Maguire <alan.maguire@xxxxxxxxxx> writes:

Hi Stephen, Alan,

[...]

> I wonder if there's a hidden catch here... DECL_TAGs can refer to VARs,
> but as far as I can tell, the semantics are that the DECL_TAG actually
> *modifies* the VAR - it says "this variable declaration had this
> annotation / tag / whatever". This is fundamentally because the
> var_secinfo doesn't point at a chain of DECL_TAGs, it points directly at
> the VAR. (Compare that to, e.g. const/volatile/restrict qualifiers)
> 
> So, in a hypothetical situation where there are two variables of the
> same name & type, but one of them has a DECL_TAG referring to it, would
> the deduplication keep these separate?  It seems to me that would be the
> correct behavior.

This is something too look out for.
E.g. this is certainly true for decl tags attached to structs.

[...]

> > Anyway I'd be interested to hear what others think about whether solving
> > this in BTF dedup itself or pahole makes most sense. Thanks!
> 
> Thanks for taking a look into this! Hoping to hear from other
> experienced voices on this question as well.

[...]

Deduplication for variables would be a bit of a weird one.
As Alan notes in the previous email, for each data section there is a:
- 'btf_type' entry of kind BTF_KIND_DATASEC where 'vlen' specifies
  the number of variables in the section;
- followed by a number of 'btf_var_secinfo' entries,
  with 'type' referring to 'btf_type' entries of kind 'BTF_KIND_VAR,
  and 'offset' specifying offset of the variable within section.

So, we are talking about deduplication of these 'btf_var_secinfo'
entries. Nothing in existing dedup algorithm handles deduplication of
"addendum" items like 'btf_var_secinfo', the subject of deduplication
always has an ID.

A new step, walking each BTF_KIND_DATASEC and collapsing identical
'btf_var_secinfo' entries can of-course be added.
(Which also raises a question, whether this has to be done in a loop
 with an attempt to collapse duplicate BTF_KIND_DATASEC entries?).

A case can be made both for and against this, but given the
"weirdness" described above and the fact that Stephen already has the
code, I think performing this deduplication at the pahole level is
Ok at the moment.

Thanks,
Eduard







[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux