ANDROID: KABI macros to release excess KABI fields for use with backports

With KMI freeze, we reserve padding in structs to be exclusively used
for LTS updates that would otherwise break the KMI. These fields are
reserved via the ANDROID_KABI_RESERVE() macro that adds a u64 field to
the struct. The ANDROID_KABI_USE() macro is used when the field is
needed for an LTS patch backport.

Since these fields must be reserved at KMI freeze time, we have make
our best guess at what might be needed - and sometimes reserve too many
fields. An example of this is the 8 ANDROID_KABI_RESERVE() fields in
`struct net_device` for android13-5.15. We are now 3 years into the
6 year lifetime for android13-5.15 and none of those 8 padding fields
have been used. At this point it is reasonable to allow 1 or 2 of those
fields to be used for non-LTS backports.

We won't relax the rule that ANDROID_KABI_RESERVE() is exclusively
for LTS backports, Instead we'll introduce a new macro,
ANDROID_KABI_BACKPORT_OK() to release some KABI fields for general use
as the branches age and the use of padding for LTS becomes unlikely.

We release the field for use by replacing the ANDROID_KABI_RESERVE()
with the new ANDROID_KABI_BACKPORT_OK() macro, which has the exact
same implementation, but allows others to use it for backporting
features from upstream.

When an ANDROID_KABI_BACKPORT_OK() field is going to be used, the
ANDROID_KABI_BACKPORT_USE() macro is used to indicate that the field
was used for a feature backport, not an LTS patch.

This patch adds the two new macros:

ANDROID_KABI_BACKPORT_OK() : exactly the same as ANDROID_KABI_RESERVE()
ANDROID_KABI_BACKPORT_USE() ; exacly the same as ANDROID_KABI_USE()

Patches that change an ANDROID_KABI_RESERVE() to ANDROID_KABI_BACKPORT_OK() must
be reviewed and get a CR+1 from gregkh@, joneslee@ or tkjos@ to make
sure it really is acceptable to reduce the padding for LTS merges.

Bug: 392673958
Signed-off-by: Todd Kjos <tkjos@google.com>
Change-Id: I19b9dfc16d891fb6fe48ec4379c6fa3dcb6adf24
(cherry picked from commit f1954b6e6cba2533beb6dff539b9d0b079ceb665)
This commit is contained in:
Todd Kjos
2025-01-27 20:53:47 +00:00
committed by Treehugger Robot
parent ac5119631f
commit 9bab050913
+19
View File
@@ -90,6 +90,14 @@
#define ANDROID_KABI_RESERVE(number)
#endif
/*
* ANDROID_KABI_BACKPORT_OK
* Used to allow padding originally reserved with ANDROID_KABI_RESERVE
* to be used for backports of non-LTS patches by partners. These
* fields can by used by replacing with ANDROID_KABI_BACKPORT_USE()
* for partner backports.
*/
#define ANDROID_KABI_BACKPORT_OK(number) ANDROID_KABI_RESERVE(number)
/*
* Macros to use _after_ the ABI is frozen
@@ -104,6 +112,17 @@
#define ANDROID_KABI_USE(number, _new) \
_ANDROID_KABI_REPLACE(_ANDROID_KABI_RESERVE(number), _new)
/*
* ANDROID_KABI_BACKPORT_USE(number, _new)
* Use a previous padding entry that was defined with
* ANDROID_KABI_BACKPORT_OK(). This is functionally identical
* to ANDROID_KABI_USE() except that it differentiates the
* normal use of KABI fields for LTS from KABI fields that
* were released for use with other backports from upstream.
*/
#define ANDROID_KABI_BACKPORT_USE(number, _new) \
ANDROID_KABI_USE(number, _new)
/*
* ANDROID_KABI_USE2(number, _new1, _new2)
* Use a previous padding entry that was defined with ANDROID_KABI_RESERVE for