Hi Philip and Markus,
Let's discuss how to handle compilation for different architectures as
well as different accelerators here.
> > And "raw" format as a lower level format can be used for other arches
> > (e.g., ARM).
>
> Since you provide the ability to use a raw format, are we sure other
> accelerators will never be interested in such PMU filtering?
>
> I'm pretty sure HVF could benefit of it (whether we implement it there
> is another story).
Nice to know it could benefit more cases.
> What do you think about adding this as a generic accelerator feature.
I can implement pmu-filter directly at the "accel" level.
> If a particular accel doesn't support it and we ask to filter, we simply
> report an error.
One of the main issues is how to organize the QAPI scheme:
First we have a "qapi/accelerator.json" like current implementation to
provide:
##
# = Accelerators
##
Then we should have a "qapi/accelerator-target.json" (which will follows
qapi/accelerator.json in qapi-schema.json, just like machine.json &
machine-target.json), and place all pmu-filter related things in this
file with specify the compilation condition, for example:
{ 'struct': 'KvmPmuFilterProperties',
'data': { 'action': 'KvmPmuFilterAction',
'*x86-fixed-counter': 'uint32',
'*events': ['KvmPmuFilterEvent'] },
'if': 'CONFIG_KVM' }
In the future, this could be expanded to: 'if': { 'any': [ 'CONFIG_HVF',
'CONFIG_KVM' ] }.
I understand that there is no way to specify the architecture here,
because it is not possible to specify a combination case like
"TARGET_I386 & CONFIG_KVM", "TARGET_ARM & CONFIG_KVM", "TARGET_ARM & CONFIG_HVF"
(please educate me if such "if" condition be implemented in QAPI :-)).
So, I will put the arch-specific format check in pmu-filter.c by adding
arch macros as I mentioned in this reply:
https://lore.kernel.org/qemu-devel/[email protected]/
And there'll need accel-specific format check (for example, maksed-entry
is KVM specific, and it is not defined in x86 spec). I can check the
accel-specific format in the `check` hook of
object_class_property_add_link(), which links the pmu-filter object to
accelerator.
Do you like this idea?
Thanks,
Zhao