From: Sasha Levin <sashal@kernel.org>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>,
Dan Carpenter <dan.carpenter@linaro.org>,
Julia Lawall <julia.lawall@inria.fr>,
"H. Peter Anvin" <hpa@zytor.com>,
ksummit@lists.linux.dev
Subject: Re: [MAINTAINERS SUMMIT] The role of AI and LLMs in the kernel process
Date: Tue, 12 Aug 2025 11:02:50 -0400 [thread overview]
Message-ID: <aJtXmi6IFaH4ST_s@lappy> (raw)
In-Reply-To: <20250812103710.5faf83fc@gandalf.local.home>
On Tue, Aug 12, 2025 at 10:37:10AM -0400, Steven Rostedt wrote:
>One thing I look forward to with AI is that it will likely help me debug my
>own code. I suspect it would be really good at reading my code and say
>"Hey Stupid! You forgot to free this value over here". And things like that.
>In other words, I trust AI to debug my code more than I can debug its code.
I'm surprised that this isn't too common of a practice at this point.
Sure, AI will make mistakes, but I think that:
1. It's much better at reviewing rather than writing.
2. Mistakes aren't critical (you'd review it yourself anyway).
3. No legal issues.
As an example:
$ git ol 391dda1bd7c56de62b96126214f040fe8965561b
391dda1bd7c5 ("tracing: Use hashtable.h for event_hash")
$ git checkout 391dda1bd7c5^
HEAD is now at 7f81f27b1093 tracing: Fix use-after-free in print_graph_function_flags during tracer switching
$ git format-patch -1 391dda1bd7c5
0001-tracing-Use-hashtable.h-for-event_hash.patch
$ echo "I want to send @0001-tracing-Use-hashtable.h-for-event_hash.patch upstream. Carefully review the patch, identify any issues, and write a report." | claude -p
# Patch Review Report: tracing: Use hashtable.h for event_hash
## Summary
This patch converts the manually implemented hash table in `kernel/trace/trace_output.c` to use the generic hashtable API from `<linux/hashtable.h>`. The conversion is technically correct and simplifies the code, but there is one notable issue that should be addressed.
## Review Findings
### ✅ Positive Aspects
1. **Correct API Usage**: The patch properly uses the hashtable.h API:
- `DEFINE_HASHTABLE()` for static initialization
- `hash_add()` for insertion
- `hash_del()` for deletion
- `hash_for_each_possible()` for lookup
2. **Proper Constant Renaming**: The rename from `EVENT_HASHSIZE` to `EVENT_HASH_BITS` correctly reflects the semantic change (from size to bit count).
3. **Functionally Equivalent**: The new implementation maintains the same hash table size (2^7 = 128 entries) and hashing behavior.
4. **Code Simplification**: Removes manual bucket calculation logic, making the code cleaner and more maintainable.
### ❌ Issue Found
**Loss of `__read_mostly` Annotation**
The original implementation declares the hash table with `__read_mostly`:
```c
static struct hlist_head event_hash[EVENT_HASHSIZE] __read_mostly;
```
The patch changes this to:
```c
static DEFINE_HASHTABLE(event_hash, EVENT_HASH_BITS);
```
The `DEFINE_HASHTABLE` macro does not preserve the `__read_mostly` annotation. This could impact performance as:
- The event hash table is primarily read during event lookups
- It's only written during event registration/unregistration (rare operations)
- Without `__read_mostly`, the hash table may not be optimally placed in cache-friendly memory sections
### Recommended Fix
The hashtable.h header provides `DEFINE_READ_MOSTLY_HASHTABLE` macro specifically for this use case. The patch should use:
```c
static DEFINE_READ_MOSTLY_HASHTABLE(event_hash, EVENT_HASH_BITS);
```
This would preserve the performance optimization of the original code.
## Verification Checklist
- [x] Patch applies cleanly
- [x] Hash table size remains unchanged (128 entries)
- [x] Hash function behavior is preserved
- [x] Locking semantics remain the same
- [x] All hash table operations correctly converted
- [ ] Performance annotations preserved (`__read_mostly`)
## Recommendation
**Hold for revision** - The patch should be updated to use `DEFINE_READ_MOSTLY_HASHTABLE` instead of `DEFINE_HASHTABLE` to maintain the performance optimization present in the original code.
--
Thanks,
Sasha
next prev parent reply other threads:[~2025-08-12 15:02 UTC|newest]
Thread overview: 56+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-05 16:03 Lorenzo Stoakes
2025-08-05 16:43 ` James Bottomley
2025-08-05 17:11 ` Mark Brown
2025-08-05 17:23 ` James Bottomley
2025-08-05 17:43 ` Sasha Levin
2025-08-05 17:58 ` Lorenzo Stoakes
2025-08-05 18:16 ` Mark Brown
2025-08-05 18:01 ` Lorenzo Stoakes
2025-08-05 18:46 ` Mark Brown
2025-08-05 19:18 ` Lorenzo Stoakes
2025-08-05 17:17 ` Stephen Hemminger
2025-08-05 17:55 ` Lorenzo Stoakes
2025-08-05 18:23 ` Lorenzo Stoakes
2025-08-12 13:44 ` Steven Rostedt
2025-08-05 18:34 ` James Bottomley
2025-08-05 18:55 ` Lorenzo Stoakes
2025-08-12 13:50 ` Steven Rostedt
2025-08-05 18:39 ` Sasha Levin
2025-08-05 19:15 ` Lorenzo Stoakes
2025-08-05 20:02 ` James Bottomley
2025-08-05 20:48 ` Al Viro
2025-08-06 19:26 ` Lorenzo Stoakes
2025-08-07 12:25 ` Mark Brown
2025-08-07 13:00 ` Lorenzo Stoakes
2025-08-11 21:26 ` Luis Chamberlain
2025-08-12 14:19 ` Steven Rostedt
2025-08-06 4:04 ` Alexey Dobriyan
2025-08-06 20:36 ` Sasha Levin
2025-08-05 21:58 ` Jiri Kosina
2025-08-06 6:58 ` Hannes Reinecke
2025-08-06 19:36 ` Lorenzo Stoakes
2025-08-06 19:35 ` Lorenzo Stoakes
2025-08-05 18:10 ` H. Peter Anvin
2025-08-05 18:19 ` Lorenzo Stoakes
2025-08-06 5:49 ` Julia Lawall
2025-08-06 9:25 ` Dan Carpenter
2025-08-06 9:39 ` Julia Lawall
2025-08-06 19:30 ` Lorenzo Stoakes
2025-08-12 14:37 ` Steven Rostedt
2025-08-12 15:02 ` Sasha Levin [this message]
2025-08-12 15:24 ` Paul E. McKenney
2025-08-12 15:25 ` Sasha Levin
2025-08-12 15:28 ` Paul E. McKenney
2025-12-08 1:12 ` Sasha Levin
2025-12-08 1:25 ` H. Peter Anvin
2025-12-08 1:59 ` Jonathan Corbet
2025-12-08 3:15 ` Steven Rostedt
2025-12-08 3:42 ` James Bottomley
2025-12-08 8:41 ` Mauro Carvalho Chehab
2025-12-08 9:16 ` James Bottomley
2025-12-08 10:22 ` Mauro Carvalho Chehab
2025-12-08 4:15 ` Laurent Pinchart
2025-12-08 4:31 ` Jonathan Corbet
2025-12-08 4:36 ` Laurent Pinchart
2025-12-08 7:00 ` Jiri Kosina
2025-12-08 7:38 ` James Bottomley
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=aJtXmi6IFaH4ST_s@lappy \
--to=sashal@kernel.org \
--cc=dan.carpenter@linaro.org \
--cc=hpa@zytor.com \
--cc=julia.lawall@inria.fr \
--cc=ksummit@lists.linux.dev \
--cc=lorenzo.stoakes@oracle.com \
--cc=rostedt@goodmis.org \
/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