From: Petr Pavlu <petr.pavlu@suse.com>
To: Sami Tolvanen <samitolvanen@google.com>
Cc: Masahiro Yamada <masahiroy@kernel.org>,
Luis Chamberlain <mcgrof@kernel.org>,
Daniel Gomez <da.gomez@samsung.com>,
linux-modules@vger.kernel.org, linux-kbuild@vger.kernel.org,
linux-kernel@vger.kernel.org,
Giuliano Procida <gprocida@google.com>
Subject: Re: [PATCH 3/4] gendwarfksyms: Add a kABI rule to override type strings
Date: Mon, 5 May 2025 14:17:14 +0200 [thread overview]
Message-ID: <5b0fd8c8-8466-437a-95de-581075f8faf5@suse.com> (raw)
In-Reply-To: <20250430214049.2658716-9-samitolvanen@google.com>
On 4/30/25 23:40, Sami Tolvanen wrote:
> In rare situations where distributions must make significant
> changes to otherwise opaque data structures that have
> inadvertently been included in the published ABI, keeping
> symbol versions stable using the existing kABI macros can
> become tedious.
>
> For example, Android decided to switch to a newer io_uring
> implementation in the 5.10 GKI kernel "to resolve a huge number
> of potential, and known, problems with the codebase," requiring
> "horrible hacks" with genksyms:
>
> "A number of the io_uring structures get used in other core
> kernel structures, only as "opaque" pointers, so there is
> not any real ABI breakage. But, due to the visibility of
> the structures going away, the CRC values of many scheduler
> variables and functions were changed."
> -- https://r.android.com/2425293
>
> While these specific changes probably could have been hidden
> from gendwarfksyms using the existing kABI macros, this may not
> always be the case.
>
> Add a last resort kABI rule that allows distribution
> maintainers to fully override a type string for a symbol or a
> type. Also add a more informative error message in case we find
> a non-existent type references when calculating versions.
>
> Suggested-by: Giuliano Procida <gprocida@google.com>
> Signed-off-by: Sami Tolvanen <samitolvanen@google.com>
> [...]
> @@ -372,9 +405,81 @@ static void type_expand(struct die *cache, struct type_expansion *type,
> cache_free(&expansion_cache);
> }
>
> +static void type_parse(const char *name, const char *str,
> + struct type_expansion *type)
> +{
> + char *fragment;
> + size_t start = 0;
> + size_t end;
> + size_t pos;
> +
> + if (!*str)
> + error("empty type string override for '%s'", name);
> +
> + type_expansion_init(type);
> +
> + for (pos = 1; str[pos]; ++pos) {
> + bool empty;
> + char marker = ' ';
> +
> + if (!is_type_prefix(&str[pos - 1]))
> + continue;
> +
> + end = pos + 1;
> +
> + /*
> + * Find the end of the type reference. If the type name contains
> + * spaces, it must be in single quotes.
> + */
> + if (str[end] == '\'') {
> + marker = '\'';
> + ++end;
> + }
> + while (str[end] && str[end] != marker)
> + ++end;
> +
> + /* Check that we have a non-empty type name */
> + if (marker == '\'') {
> + if (str[end] != marker)
> + error("incomplete %c# type reference for '%s' (string : '%s')",
> + str[pos - 1], name, str);
> + empty = end == pos + 2;
> + ++end;
> + } else {
> + empty = end == pos + 1;
> + }
> + if (empty)
> + error("empty %c# type name for '%s' (string: '%s')",
> + str[pos - 1], name, str);
> +
> + /* Append the part of the string before the type reference */
> + if (pos > start + 1) {
> + fragment = xstrndup(&str[start], pos - start - 1);
> + type_expansion_append(type, fragment, fragment);
> + }
> +
> + /*
> + * Append the type reference -- note that if the reference
> + * is invalid, i.e. points to a non-existent type, we will
> + * print out an error when calculating versions.
> + */
> + fragment = xstrndup(&str[pos - 1], end - pos + 1);
> + type_expansion_append(type, fragment, fragment);
> +
> + pos = start = end;
> + if (!str[pos])
> + break;
> + }
> +
> + /* Append the rest of the type string, if there's any left */
> + if (str[start])
> + type_expansion_append(type, &str[start], NULL);
> +}
> +
I'd find this mini-parser more straightforward, if its main loop started at
pos=0 and looked ahead, instead of starting at pos=1 and looking behind.
The patch otherwise makes sense to me. It looks similar to the override keyword
supported by genksyms.
--
Thanks,
Petr
next prev parent reply other threads:[~2025-05-05 12:17 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-30 21:40 [PATCH 0/4] gendwarfksyms: Add more kABI rules Sami Tolvanen
2025-04-30 21:40 ` [PATCH 1/4] gendwarfksyms: Clean up kABI rule look-ups Sami Tolvanen
2025-05-05 11:56 ` Petr Pavlu
2025-04-30 21:40 ` [PATCH 2/4] gendwarfksyms: Add a kABI rule to override byte_size attributes Sami Tolvanen
2025-05-05 11:57 ` Petr Pavlu
2025-04-30 21:40 ` [PATCH 3/4] gendwarfksyms: Add a kABI rule to override type strings Sami Tolvanen
2025-05-05 12:17 ` Petr Pavlu [this message]
2025-05-05 19:15 ` Sami Tolvanen
2025-04-30 21:40 ` [PATCH 4/4] Documentation/kbuild: Add new gendwarfksyms kABI rules Sami Tolvanen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5b0fd8c8-8466-437a-95de-581075f8faf5@suse.com \
--to=petr.pavlu@suse.com \
--cc=da.gomez@samsung.com \
--cc=gprocida@google.com \
--cc=linux-kbuild@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-modules@vger.kernel.org \
--cc=masahiroy@kernel.org \
--cc=mcgrof@kernel.org \
--cc=samitolvanen@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).