From: Imran Khan <imran.f.khan@oracle.com>
To: Marek Szyprowski <m.szyprowski@samsung.com>,
tj@kernel.org, gregkh@linuxfoundation.org,
viro@zeniv.linux.org.uk
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH v7 2/4] kernfs: Change kernfs_notify_list to llist.
Date: Fri, 1 Jul 2022 22:20:24 +1000 [thread overview]
Message-ID: <9e95f138-9ec5-90fc-7ea9-cf8cff8bf180@oracle.com> (raw)
In-Reply-To: <270b640d-d5e8-b775-9a16-5d5d07f959ff@samsung.com>
Hello Marek,
On 1/7/22 9:22 pm, Marek Szyprowski wrote:
> Hi All,
>
> On 15.06.2022 04:10, Imran Khan wrote:
>> At present kernfs_notify_list is implemented as a singly linked
>> list of kernfs_node(s), where last element points to itself and
>> value of ->attr.next tells if node is present on the list or not.
>> Both addition and deletion to list happen under kernfs_notify_lock.
>>
>> Change kernfs_notify_list to llist so that addition to list can heppen
>> locklessly.
>>
>> Suggested by: Al Viro <viro@zeniv.linux.org.uk>
>> Signed-off-by: Imran Khan <imran.f.khan@oracle.com>
>> Acked-by: Tejun Heo <tj@kernel.org>
>
> This patch landed in linux next-20220630 as commit b8f35fa1188b
> ("kernfs: Change kernfs_notify_list to llist."). Unfortunately, it
> causes serious regression on my test systems. It can be easily noticed
> in the logs by the following warning:
>
> ------------[ cut here ]------------
> WARNING: CPU: 1 PID: 34 at fs/kernfs/dir.c:531 kernfs_put.part.0+0x1a4/0x1d8
> kernfs_put: console/active: released with incorrect active_ref 0
> Modules linked in:
> CPU: 1 PID: 34 Comm: kworker/1:4 Not tainted
> 5.19.0-rc4-05465-g5732b42edfd1 #12317
> Hardware name: Samsung Exynos (Flattened Device Tree)
> Workqueue: events kernfs_notify_workfn
> unwind_backtrace from show_stack+0x10/0x14
> show_stack from dump_stack_lvl+0x40/0x4c
> dump_stack_lvl from __warn+0xc8/0x13c
> __warn from warn_slowpath_fmt+0x90/0xb4
> warn_slowpath_fmt from kernfs_put.part.0+0x1a4/0x1d8
> kernfs_put.part.0 from kernfs_notify_workfn+0x1a0/0x1d0
> kernfs_notify_workfn from process_one_work+0x1ec/0x4cc
> process_one_work from worker_thread+0x58/0x54c
> worker_thread from kthread+0xd0/0xec
> kthread from ret_from_fork+0x14/0x2c
> Exception stack(0xf099dfb0 to 0xf099dff8)
> ...
> ---[ end trace 0000000000000000 ]---
>
Thanks for reporting this issue. It has been reported earlier in [1] as well. I
am unable to reproduce it locally. Could you please test with following patch on
top of linux next-20220630 and let me know if it helps:
From 6bf7f1adc4b091dc6d6c60e0dd0f16247f61f374 Mon Sep 17 00:00:00 2001
From: Imran Khan <imran.f.khan@oracle.com>
Date: Fri, 1 Jul 2022 14:27:52 +1000
Subject: [PATCH] kernfs: Avoid re-adding kernfs_node into kernfs_notify_list.
---
fs/kernfs/file.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/fs/kernfs/file.c b/fs/kernfs/file.c
index bb933221b4bae..e8ec054e11c63 100644
--- a/fs/kernfs/file.c
+++ b/fs/kernfs/file.c
@@ -917,6 +917,7 @@ static void kernfs_notify_workfn(struct work_struct *work)
if (free == NULL)
return;
+ free->next = NULL;
attr = llist_entry(free, struct kernfs_elem_attr, notify_next);
kn = attribute_to_node(attr, struct kernfs_node, attr);
root = kernfs_root(kn);
@@ -992,9 +993,11 @@ void kernfs_notify(struct kernfs_node *kn)
rcu_read_unlock();
/* schedule work to kick fsnotify */
- kernfs_get(kn);
- llist_add(&kn->attr.notify_next, &kernfs_notify_list);
- schedule_work(&kernfs_notify_work);
+ if (kn->attr.notify_next.next != NULL) {
+ kernfs_get(kn);
+ llist_add(&kn->attr.notify_next, &kernfs_notify_list);
+ schedule_work(&kernfs_notify_work);
+ }
}
EXPORT_SYMBOL_GPL(kernfs_notify);
base-commit: 6cc11d2a1759275b856e464265823d94aabd5eaf
--
2.30.2
Thanks
-- Imran
[1]: https://lore.kernel.org/lkml/0b3c1362-5f0d-44d5-d3e7-c01de59a4e86@oracle.com/
next prev parent reply other threads:[~2022-07-01 12:20 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-15 2:10 [PATCH v7 0/4] kernfs: make ->attr.open RCU protected Imran Khan
2022-06-15 2:10 ` [PATCH v7 1/4] " Imran Khan
2022-06-15 6:12 ` Tejun Heo
2022-06-15 2:10 ` [PATCH v7 2/4] kernfs: Change kernfs_notify_list to llist Imran Khan
[not found] ` <CGME20220701112210eucas1p2d2db45881086f41b73527f7536537aa5@eucas1p2.samsung.com>
2022-07-01 11:22 ` Marek Szyprowski
2022-07-01 12:20 ` Imran Khan [this message]
2022-07-01 12:49 ` Marek Szyprowski
2022-07-01 15:06 ` Imran Khan
2022-07-05 15:18 ` Geert Uytterhoeven
2022-06-15 2:10 ` [PATCH v7 3/4] kernfs: Introduce interface to access global kernfs_open_file_mutex Imran Khan
2022-06-15 2:10 ` [PATCH v7 4/4] kernfs: Replace global kernfs_open_file_mutex with hashed mutexes Imran Khan
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=9e95f138-9ec5-90fc-7ea9-cf8cff8bf180@oracle.com \
--to=imran.f.khan@oracle.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=m.szyprowski@samsung.com \
--cc=tj@kernel.org \
--cc=viro@zeniv.linux.org.uk \
/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
all inboxes | Powered by JetHome®