linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Tejun Heo <tj@kernel.org>
To: Imran Khan <imran.f.khan@oracle.com>
Cc: gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3 1/2] kernfs: use hashed mutex and spinlock in place of global ones.
Date: Thu, 13 Jan 2022 06:37:46 -1000	[thread overview]
Message-ID: <YeBVWmUaSXc/5NQf@slm.duckdns.org> (raw)
In-Reply-To: <20220113104259.1584491-2-imran.f.khan@oracle.com>

Hello,

On Thu, Jan 13, 2022 at 09:42:58PM +1100, Imran Khan wrote:
> +#ifdef CONFIG_SMP
> +#define NR_KERNFS_LOCK_BITS (2 * (ilog2(NR_CPUS < 32 ? NR_CPUS : 32)))

How did the 32 limit come to be? It'd be nice to have a comment explaining
that this is something which affects scalability and brief rationale on the
current number.

> +static inline spinlock_t *open_node_lock_ptr(struct kernfs_node *kn)
> +{
> +	int index = hash_ptr(kn, NR_KERNFS_LOCK_BITS);
> +
> +	return &kernfs_global_locks.open_node_locks[index].lock;
> +}
> +
> +static inline struct mutex *open_file_mutex_ptr(struct kernfs_node *kn)
> +{
> +	int index = hash_ptr(kn, NR_KERNFS_LOCK_BITS);
> +
> +	return &kernfs_global_locks.open_file_mutex[index].lock;
> +}

I wonder whether it'd be useful to provide some helpers so that users don't
have to get the pointer for the lock and then lock it in separate steps.
Would it make sense to provide something which locks and returns the pointer
(or token)?

Thanks.

-- 
tejun

  reply	other threads:[~2022-01-13 16:37 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-13 10:42 [PATCH v3 0/2] kernfs: use hashed mutex and spinlock in place of global ones Imran Khan
2022-01-13 10:42 ` [PATCH v3 1/2] " Imran Khan
2022-01-13 16:37   ` Tejun Heo [this message]
2022-01-13 10:42 ` [PATCH v3 2/2] kernfs: Reduce contention around global per-fs kernfs_rwsem Imran Khan
2022-01-13 10:58   ` Greg KH
2022-01-13 16:42   ` Tejun Heo
2022-01-14 17:08     ` Imran Khan
2022-01-14 17:44       ` Tejun Heo
2022-02-02 15:10     ` Imran Khan
2022-01-25  2:55   ` [kernfs] 8652224976: WARNING:at_kernel/locking/rwsem.c:#up_write kernel test robot
2022-01-13 10:57 ` [PATCH v3 0/2] kernfs: use hashed mutex and spinlock in place of global ones Greg KH

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=YeBVWmUaSXc/5NQf@slm.duckdns.org \
    --to=tj@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=imran.f.khan@oracle.com \
    --cc=linux-kernel@vger.kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).