Re: [PATCH v9] kernel/fork: beware of __put_task_struct calling context

From: Andrew Morton
Date: Tue May 16 2023 - 18:50:23 EST


On Tue, 16 May 2023 22:41:18 +0100 Matthew Wilcox <willy@xxxxxxxxxxxxx> wrote:

>
> Oh, I missed that put_task_struct() was still inlined. Should it be?
> It seems quite large now.

It's not significantly worse because of this patch. In fact, it's
unchanged for non-RT kernels.

Possibly put_task_struct() *should* be uninlined, because it made the
mistake of using the dang refcount stuff, which never saw a byte which
it couldn't consume :(


I mean...

--- a/fs/open.c~a
+++ a/fs/open.c
@@ -1572,3 +1572,9 @@ int stream_open(struct inode *inode, str
}

EXPORT_SYMBOL(stream_open);
+
+#include <linux/refcount.h>
+bool foo(refcount_t *r)
+{
+ return refcount_dec_and_test(r);
+}
_

is worth

339 bytes of text for an allmodconfig build
67 bytes of text for an allnoconfig build
77 bytes of text for a defconfig build