All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 0/4] kernfs: make ->attr.open RCU protected.
@ 2022-05-11  9:51 Imran Khan
  2022-05-11  9:51 ` [PATCH v3 1/4] " Imran Khan
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Imran Khan @ 2022-05-11  9:51 UTC (permalink / raw)
  To: tj, gregkh, viro; +Cc: linux-kernel

The patches in this version of the patch set are as follows:

PATCH-1: Make kernfs_open_node->attr.open RCU protected.

PATCH-2: Change kernfs_notify_list to llist.

PATCH-3: Introduce interface to access kernfs_open_file_mutex.

PATCH-4: Replace global kernfs_open_file_mutex with hashed mutexes.

Changes since v2:
 - Rebase on tag next-20220510
 - Remove PATCH-1 of v2 because it is present in tag next-20220510
 - Include Acked-by tags from Tejun for the acked patches (PATCH-2 and PATCH-3)


Cover letter for v2:
--------------------------------------------------------------------------

I have not yet received any feedback about v1 of this patchset [2] but
in the meantime an old version of first patch from [3] has been integrated in
linux-next. Functionally first patch in both [2] and [3] are identical.
It's just that [2] has renamed one of the functions to better reflect the fact
that we are no longer using reference counting for kernfs_open_node.

In this version, I have just modified first patch of v1 so that we use the
modified function name as done in [2] and avoid those parts that are already
present in linux-next now. The remaining 4 patches (PATCH-2 to PATCH-5) are
identical in both v1 and v2 albeit v2 has been rebased on tag next-20220503.

Changes since v1:
 - Rebase on tag next-20220503

[2]: https://lore.kernel.org/lkml/20220428055431.3826852-1-imran.f.khan@oracle.com/
[3]: https://lore.kernel.org/lkml/20220324103040.584491-1-imran.f.khan@oracle.com/

Original cover letter
-------------------------------------------------------

This patchset contains subset of patches (after addressing review comments)
discussed at [1]. Since [1] is replacing multiple global locks and since
each of these locks can be removed independently, it was decided that we
should make these changes in parts i.e first get one set of optimizations
integrated and then work on top of those further.

The patches in this change set introduce following changes:

PATCH-1: Remove reference counting for kernfs_open_node.

PATCH-2: Make kernfs_open_node->attr.open RCU protected.

PATCH-3: Change kernfs_notify_list to llist.

PATCH-4: Introduce interface to access kernfs_open_file_mutex.

PATCH-5: Replace global kernfs_open_file_mutex with hashed mutexes.

[1] https://lore.kernel.org/lkml/YmLfxHcekrr89IFl@slm.duckdns.org/

----------------------------------------------------------------

Imran Khan (4):
  kernfs: make ->attr.open RCU protected.
  kernfs: Change kernfs_notify_list to llist.
  kernfs: Introduce interface to access global kernfs_open_file_mutex.
  kernfs: Replace global kernfs_open_file_mutex with hashed mutexes.

 fs/kernfs/file.c            | 237 ++++++++++++++++++++++--------------
 fs/kernfs/kernfs-internal.h |   4 +
 fs/kernfs/mount.c           |  19 +++
 include/linux/kernfs.h      |  61 +++++++++-
 4 files changed, 226 insertions(+), 95 deletions(-)


base-commit: 3bf222d317a20170ee17f082626c1e0f83537e13
-- 
2.30.2


^ permalink raw reply	[flat|nested] 7+ messages in thread
* Re: [PATCH v3 1/4] kernfs: make ->attr.open RCU protected.
  2022-05-11  9:51 ` [PATCH v3 1/4] " Imran Khan
@ 2022-05-16 11:44 ` Dan Carpenter
  -1 siblings, 0 replies; 7+ messages in thread
From: kernel test robot @ 2022-05-14  9:30 UTC (permalink / raw)
  To: kbuild

[-- Attachment #1: Type: text/plain, Size: 6165 bytes --]

CC: kbuild-all(a)lists.01.org
BCC: lkp(a)intel.com
In-Reply-To: <20220511095157.478522-2-imran.f.khan@oracle.com>
References: <20220511095157.478522-2-imran.f.khan@oracle.com>
TO: Imran Khan <imran.f.khan@oracle.com>

Hi Imran,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on 3bf222d317a20170ee17f082626c1e0f83537e13]

url:    https://github.com/intel-lab-lkp/linux/commits/Imran-Khan/kernfs-make-attr-open-RCU-protected/20220511-175730
base:   3bf222d317a20170ee17f082626c1e0f83537e13
:::::: branch date: 3 days ago
:::::: commit date: 3 days ago
config: i386-randconfig-m021 (https://download.01.org/0day-ci/archive/20220514/202205141708.2SQYmW1K-lkp(a)intel.com/config)
compiler: gcc-11 (Debian 11.2.0-20) 11.2.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>

New smatch warnings:
fs/kernfs/file.c:282 kernfs_file_read_iter() warn: inconsistent returns '&of->mutex'.

Old smatch warnings:
fs/kernfs/file.c:255 kernfs_file_read_iter() warn: possible memory leak of 'buf'
fs/kernfs/file.c:282 kernfs_file_read_iter() warn: possible memory leak of 'buf'

vim +282 fs/kernfs/file.c

414985ae23c031 Tejun Heo         2013-11-28  219  
414985ae23c031 Tejun Heo         2013-11-28  220  /*
414985ae23c031 Tejun Heo         2013-11-28  221   * As reading a bin file can have side-effects, the exact offset and bytes
414985ae23c031 Tejun Heo         2013-11-28  222   * specified in read(2) call should be passed to the read callback making
414985ae23c031 Tejun Heo         2013-11-28  223   * it difficult to use seq_file.  Implement simplistic custom buffering for
414985ae23c031 Tejun Heo         2013-11-28  224   * bin files.
414985ae23c031 Tejun Heo         2013-11-28  225   */
4eaad21a6ac986 Christoph Hellwig 2021-01-20  226  static ssize_t kernfs_file_read_iter(struct kiocb *iocb, struct iov_iter *iter)
414985ae23c031 Tejun Heo         2013-11-28  227  {
4eaad21a6ac986 Christoph Hellwig 2021-01-20  228  	struct kernfs_open_file *of = kernfs_of(iocb->ki_filp);
4eaad21a6ac986 Christoph Hellwig 2021-01-20  229  	ssize_t len = min_t(size_t, iov_iter_count(iter), PAGE_SIZE);
414985ae23c031 Tejun Heo         2013-11-28  230  	const struct kernfs_ops *ops;
302de586c74f7b Imran Khan        2022-05-11  231  	struct kernfs_open_node *on;
414985ae23c031 Tejun Heo         2013-11-28  232  	char *buf;
414985ae23c031 Tejun Heo         2013-11-28  233  
4ef67a8c95f32e NeilBrown         2014-10-14  234  	buf = of->prealloc_buf;
e4234a1fc343ca Chris Wilson      2016-03-31  235  	if (buf)
e4234a1fc343ca Chris Wilson      2016-03-31  236  		mutex_lock(&of->prealloc_mutex);
e4234a1fc343ca Chris Wilson      2016-03-31  237  	else
414985ae23c031 Tejun Heo         2013-11-28  238  		buf = kmalloc(len, GFP_KERNEL);
414985ae23c031 Tejun Heo         2013-11-28  239  	if (!buf)
414985ae23c031 Tejun Heo         2013-11-28  240  		return -ENOMEM;
414985ae23c031 Tejun Heo         2013-11-28  241  
414985ae23c031 Tejun Heo         2013-11-28  242  	/*
4ef67a8c95f32e NeilBrown         2014-10-14  243  	 * @of->mutex nests outside active ref and is used both to ensure that
e4234a1fc343ca Chris Wilson      2016-03-31  244  	 * the ops aren't called concurrently for the same open file.
414985ae23c031 Tejun Heo         2013-11-28  245  	 */
414985ae23c031 Tejun Heo         2013-11-28  246  	mutex_lock(&of->mutex);
c637b8acbe079e Tejun Heo         2013-12-11  247  	if (!kernfs_get_active(of->kn)) {
414985ae23c031 Tejun Heo         2013-11-28  248  		len = -ENODEV;
414985ae23c031 Tejun Heo         2013-11-28  249  		mutex_unlock(&of->mutex);
414985ae23c031 Tejun Heo         2013-11-28  250  		goto out_free;
414985ae23c031 Tejun Heo         2013-11-28  251  	}
414985ae23c031 Tejun Heo         2013-11-28  252  
302de586c74f7b Imran Khan        2022-05-11  253  	on = kernfs_deref_on_raw(of, of->kn);
302de586c74f7b Imran Khan        2022-05-11  254  	if (!on)
302de586c74f7b Imran Khan        2022-05-11  255  		return -EINVAL;
302de586c74f7b Imran Khan        2022-05-11  256  
302de586c74f7b Imran Khan        2022-05-11  257  	of->event = atomic_read(&unrcu_pointer(on)->event);
324a56e16e44ba Tejun Heo         2013-12-11  258  	ops = kernfs_ops(of->kn);
414985ae23c031 Tejun Heo         2013-11-28  259  	if (ops->read)
4eaad21a6ac986 Christoph Hellwig 2021-01-20  260  		len = ops->read(of, buf, len, iocb->ki_pos);
414985ae23c031 Tejun Heo         2013-11-28  261  	else
414985ae23c031 Tejun Heo         2013-11-28  262  		len = -EINVAL;
414985ae23c031 Tejun Heo         2013-11-28  263  
e4234a1fc343ca Chris Wilson      2016-03-31  264  	kernfs_put_active(of->kn);
e4234a1fc343ca Chris Wilson      2016-03-31  265  	mutex_unlock(&of->mutex);
e4234a1fc343ca Chris Wilson      2016-03-31  266  
414985ae23c031 Tejun Heo         2013-11-28  267  	if (len < 0)
e4234a1fc343ca Chris Wilson      2016-03-31  268  		goto out_free;
414985ae23c031 Tejun Heo         2013-11-28  269  
4eaad21a6ac986 Christoph Hellwig 2021-01-20  270  	if (copy_to_iter(buf, len, iter) != len) {
414985ae23c031 Tejun Heo         2013-11-28  271  		len = -EFAULT;
e4234a1fc343ca Chris Wilson      2016-03-31  272  		goto out_free;
414985ae23c031 Tejun Heo         2013-11-28  273  	}
414985ae23c031 Tejun Heo         2013-11-28  274  
4eaad21a6ac986 Christoph Hellwig 2021-01-20  275  	iocb->ki_pos += len;
414985ae23c031 Tejun Heo         2013-11-28  276  
414985ae23c031 Tejun Heo         2013-11-28  277   out_free:
e4234a1fc343ca Chris Wilson      2016-03-31  278  	if (buf == of->prealloc_buf)
e4234a1fc343ca Chris Wilson      2016-03-31  279  		mutex_unlock(&of->prealloc_mutex);
e4234a1fc343ca Chris Wilson      2016-03-31  280  	else
414985ae23c031 Tejun Heo         2013-11-28  281  		kfree(buf);
414985ae23c031 Tejun Heo         2013-11-28 @282  	return len;
414985ae23c031 Tejun Heo         2013-11-28  283  }
414985ae23c031 Tejun Heo         2013-11-28  284  

-- 
0-DAY CI Kernel Test Service
https://01.org/lkp

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2022-05-16 11:44 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-11  9:51 [PATCH v3 0/4] kernfs: make ->attr.open RCU protected Imran Khan
2022-05-11  9:51 ` [PATCH v3 1/4] " Imran Khan
2022-05-11  9:51 ` [PATCH v3 2/4] kernfs: Change kernfs_notify_list to llist Imran Khan
2022-05-11  9:51 ` [PATCH v3 3/4] kernfs: Introduce interface to access global kernfs_open_file_mutex Imran Khan
2022-05-11  9:51 ` [PATCH v3 4/4] kernfs: Replace global kernfs_open_file_mutex with hashed mutexes Imran Khan
2022-05-14  9:30 [PATCH v3 1/4] kernfs: make ->attr.open RCU protected kernel test robot
2022-05-16 11:44 ` Dan Carpenter

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.