From: Tejun Heo <tj@kernel.org>
To: Imran Khan <imran.f.khan@oracle.com>
Cc: gregkh@linuxfoundation.org, viro@zeniv.linux.org.uk,
m.szyprowski@samsung.com, nathan@kernel.org, michael@walle.cc,
robh@kernel.org, linux-serial@vger.kernel.org,
linux-kernel@vger.kernel.org, guillaume.tucker@collabora.com,
pmladek@suse.com
Subject: Re: [RESEND PATCH] kernfs: Avoid re-adding kernfs_node into kernfs_notify_list.
Date: Tue, 5 Jul 2022 08:33:06 -1000 [thread overview]
Message-ID: <YsSD4k0o6PPYpMBe@slm.duckdns.org> (raw)
In-Reply-To: <deaaabe5-0a0c-b6f9-c85b-5080874f6437@oracle.com>
Hello,
On Sun, Jul 03, 2022 at 09:09:05PM +1000, Imran Khan wrote:
> Can we use kernfs_notify_lock like below snippet to serialize producers
> (kernfs_notify):
>
> spin_lock_irqsave(&kernfs_notify_lock, flags);
> if (kn->attr.notify_next.next != NULL) {
> kernfs_get(kn);
> llist_add(&kn->attr.notify_next, &kernfs_notify_list);
> schedule_work(&kernfs_notify_work);
> }
> spin_unlock_irqsave(&kernfs_notify_lock, flags);
But then what's the point of using llist?
> As per following comments at the beginning of llist.h
>
> * Cases where locking is not needed:
> * If there are multiple producers and multiple consumers, llist_add can be
> * used in producers and llist_del_all can be used in consumers simultaneously
> * without locking. Also a single consumer can use llist_del_first while
> * multiple producers simultaneously use llist_add, without any locking.
>
> Multiple producers and single consumer can work in parallel but as in our case
> addition is dependent on kn->attr.notify_next.next != NULL, we may keep the
> checking and list addition under kernfs_notify_lock and for consumer just lock
> free->next = NULL under kernfs_notify_lock.
It supports multiple producers in the sense that multiple producers can try
to add their own llist_nodes concurrently. It doesn't support multiple
producers trying to add the same llist_node whether that depends on NULL
check or not.
> Having said this, I am okay with reverting the llist change as well, because
> anyways it is not helping in the contentions that we are chasing here, but I
> thought of sharing the above idea to see if it is reliable and better than
> revert option.
The original conversion is broken and the right thing to do, for now, is
reverting it.
Thanks.
--
tejun
next prev parent reply other threads:[~2022-07-05 18:33 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-01 15:46 Imran Khan
2022-07-01 20:11 ` Tejun Heo
2022-07-03 11:09 ` Imran Khan
2022-07-05 18:33 ` Tejun Heo [this message]
2022-07-05 20:18 ` Imran Khan
2022-07-05 22:34 ` Tejun Heo
2022-07-08 15:58 ` Andy Shevchenko
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=YsSD4k0o6PPYpMBe@slm.duckdns.org \
--to=tj@kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=guillaume.tucker@collabora.com \
--cc=imran.f.khan@oracle.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-serial@vger.kernel.org \
--cc=m.szyprowski@samsung.com \
--cc=michael@walle.cc \
--cc=nathan@kernel.org \
--cc=pmladek@suse.com \
--cc=robh@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®