On Wed, Sep 03, 2008 at 05:11:27AM -0700, Roland McGrath wrote:
That's correct but shouldn't be taken to extreme as usual.
By how many?
Engine part is irrelevant for deciding "struct utrace utrace;" vs
"struct utrace *utrace;"
Let's actually measure something.
1) clean kernel (my usual config, x86_64, NR_CPUS=2, PREEMPT=y, SLUB_DEBUG=y)
2) struct utrace *utrace;
3) struct utrace utrace; (without rcu_head, without check_dead)
taken from symlink
cache /object_size, bytes
----------------------------------------
1) task_struct 1392/1384
2) task_struct 1408/1400
utrace 72/72
3) task_struct 1456/1456
I don't know why "object_size" differs from to where symlink points to
but it's irrelevant.
So, your approach gives +16(+72) bytes, mine gives +72 bytes.
So all this complexity is for ~56 bytes in untraced case. In traced
case, more memory will be used.
For 32-bit difference should be smaller because pointers are smaller.
I mean sticking to simple locking rules if you agree to "struct utrace utrace;":
1) utrace_flags go into struct utrace
2) utrace.lock guards _everything_ under it, no exceptions.
If I understand correctly ->utrace_flags are under utrace->lock, BUT
struct utrace is reattachable itself. Of course you protect against it,
but this doesn't help in convincing someone that there are no problems.
Again, this is just general observation and an example. Checking for
bugs will be much, much simpler.
--