From: "Eric W. Biederman" <ebiederm@xmission.com>
To: Imran Khan <imran.f.khan@oracle.com>
Cc: tj@kernel.org, viro@zeniv.linux.org.uk,
gregkh@linuxfoundation.org, akpm@linux-foundation.org,
linux-kernel@vger.kernel.org
Subject: Re: [RESEND PATCH v7 1/8] kernfs: Introduce interface to access global kernfs_open_file_mutex.
Date: Fri, 18 Mar 2022 12:10:14 -0500 [thread overview]
Message-ID: <87r16z191l.fsf@email.froward.int.ebiederm.org> (raw)
In-Reply-To: <20220317072612.163143-2-imran.f.khan@oracle.com> (Imran Khan's message of "Thu, 17 Mar 2022 18:26:05 +1100")
Imran Khan <imran.f.khan@oracle.com> writes:
> This allows to change underlying mutex locking, without needing to change
> the users of the lock. For example next patch modifies this interface to
> use hashed mutexes in place of a single global kernfs_open_file_mutex.
>
> Signed-off-by: Imran Khan <imran.f.khan@oracle.com>
> ---
> fs/kernfs/file.c | 26 +++++++++++++++-----------
> fs/kernfs/kernfs-internal.h | 18 ++++++++++++++++++
> 2 files changed, 33 insertions(+), 11 deletions(-)
>
> diff --git a/fs/kernfs/file.c b/fs/kernfs/file.c
> index 7aefaca876a0..99793c32abc3 100644
> --- a/fs/kernfs/file.c
> +++ b/fs/kernfs/file.c
> @@ -30,7 +30,7 @@
> * kernfs_open_node->files, which is protected by kernfs_open_file_mutex.
> */
> static DEFINE_SPINLOCK(kernfs_open_node_lock);
> -static DEFINE_MUTEX(kernfs_open_file_mutex);
> +DEFINE_MUTEX(kernfs_open_file_mutex);
^^^^^????
Why when you want things more localized are you making a lock more
global?
> diff --git a/fs/kernfs/kernfs-internal.h b/fs/kernfs/kernfs-internal.h
> index eeaa779b929c..df00a5f5a367 100644
> --- a/fs/kernfs/kernfs-internal.h
> +++ b/fs/kernfs/kernfs-internal.h
> @@ -164,4 +164,22 @@ void kernfs_drain_open_files(struct kernfs_node *kn);
> */
> extern const struct inode_operations kernfs_symlink_iops;
>
> +extern struct mutex kernfs_open_file_mutex;
> +
> +static inline struct mutex *kernfs_open_file_mutex_ptr(struct kernfs_node *kn)
> +{
> + return &kernfs_open_file_mutex;
> +}
> +
> +static inline struct mutex *kernfs_open_file_mutex_lock(struct kernfs_node *kn)
> +{
> + struct mutex *lock;
> +
> + lock = kernfs_open_file_mutex_ptr(kn);
> +
> + mutex_lock(lock);
> +
> + return lock;
> +}
Why don't these functions live in fs/kern/fs/file.c
Eric
next prev parent reply other threads:[~2022-03-18 17:10 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-17 7:26 [RESEND PATCH v7 0/8] " Imran Khan
2022-03-17 7:26 ` [RESEND PATCH v7 1/8] " Imran Khan
2022-03-17 21:34 ` Al Viro
2022-04-05 5:36 ` Imran Khan
2022-04-05 14:24 ` Al Viro
2022-04-06 4:54 ` Imran Khan
2022-04-06 14:54 ` Al Viro
2022-04-06 15:18 ` Tejun Heo
2022-04-14 0:01 ` Imran Khan
2022-03-18 17:10 ` Eric W. Biederman [this message]
2022-03-21 0:10 ` Imran Khan
2022-03-17 7:26 ` [RESEND PATCH v7 2/8] kernfs: Replace global kernfs_open_file_mutex with hashed mutexes Imran Khan
2022-03-17 7:26 ` [RESEND PATCH v7 3/8] kernfs: Introduce interface to access kernfs_open_node_lock Imran Khan
2022-03-17 7:26 ` [RESEND PATCH v7 4/8] kernfs: Replace global kernfs_open_node_lock with hashed spinlocks Imran Khan
2022-03-17 7:26 ` [RESEND PATCH v7 5/8] kernfs: Use a per-fs rwsem to protect per-fs list of kernfs_super_info Imran Khan
2022-03-17 7:26 ` [RESEND PATCH v7 6/8] kernfs: Introduce interface to access per-fs rwsem Imran Khan
2022-03-17 7:26 ` [RESEND PATCH v7 7/8] kernfs: Replace per-fs rwsem with hashed rwsems Imran Khan
2022-03-18 0:07 ` Al Viro
2022-03-21 1:57 ` Imran Khan
2022-03-21 7:29 ` Al Viro
2022-03-21 16:46 ` Tejun Heo
2022-03-21 17:55 ` Al Viro
2022-03-21 19:20 ` Tejun Heo
2022-03-22 2:40 ` Al Viro
2022-03-22 17:08 ` Tejun Heo
2022-03-22 20:26 ` Al Viro
2022-03-22 21:20 ` Tejun Heo
2022-03-28 0:15 ` Imran Khan
2022-03-28 17:30 ` Tejun Heo
2022-03-30 2:23 ` Imran Khan
2022-03-17 7:26 ` [RESEND PATCH v7 8/8] kernfs: Add a document to describe hashed locks used in kernfs 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=87r16z191l.fsf@email.froward.int.ebiederm.org \
--to=ebiederm@xmission.com \
--cc=akpm@linux-foundation.org \
--cc=gregkh@linuxfoundation.org \
--cc=imran.f.khan@oracle.com \
--cc=linux-kernel@vger.kernel.org \
--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®