Linux-Fsdevel Archive mirror
 help / color / mirror / Atom feed
* [PATCH AUTOSEL 5.4 07/13] radix tree test suite: Fix compilation
       [not found] <20210405160459.268794-1-sashal@kernel.org>
@ 2021-04-05 16:04 ` Sasha Levin
  2021-04-05 16:04 ` [PATCH AUTOSEL 5.4 09/13] radix tree test suite: Register the main thread with the RCU library Sasha Levin
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 5+ messages in thread
From: Sasha Levin @ 2021-04-05 16:04 UTC (permalink / raw)
  To: linux-kernel, stable; +Cc: Matthew Wilcox (Oracle), Sasha Levin, linux-fsdevel

From: "Matthew Wilcox (Oracle)" <willy@infradead.org>

[ Upstream commit dd841a749d1ded8e2e5facc4242ee0b6779fc0cb ]

Introducing local_lock broke compilation; fix it all up.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 tools/testing/radix-tree/linux/compiler_types.h | 0
 1 file changed, 0 insertions(+), 0 deletions(-)
 delete mode 100644 tools/testing/radix-tree/linux/compiler_types.h

diff --git a/tools/testing/radix-tree/linux/compiler_types.h b/tools/testing/radix-tree/linux/compiler_types.h
deleted file mode 100644
index e69de29bb2d1..000000000000
-- 
2.30.2


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

* [PATCH AUTOSEL 5.4 09/13] radix tree test suite: Register the main thread with the RCU library
       [not found] <20210405160459.268794-1-sashal@kernel.org>
  2021-04-05 16:04 ` [PATCH AUTOSEL 5.4 07/13] radix tree test suite: Fix compilation Sasha Levin
@ 2021-04-05 16:04 ` Sasha Levin
  2021-04-05 16:04 ` [PATCH AUTOSEL 5.4 10/13] idr test suite: Take RCU read lock in idr_find_test_1 Sasha Levin
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 5+ messages in thread
From: Sasha Levin @ 2021-04-05 16:04 UTC (permalink / raw)
  To: linux-kernel, stable
  Cc: Matthew Wilcox (Oracle), Chris von Recklinghausen, Sasha Levin,
	linux-fsdevel

From: "Matthew Wilcox (Oracle)" <willy@infradead.org>

[ Upstream commit 1bb4bd266cf39fd2fa711f2d265c558b92df1119 ]

Several test runners register individual worker threads with the
RCU library, but neglect to register the main thread, which can lead
to objects being freed while the main thread is in what appears to be
an RCU critical section.

Reported-by: Chris von Recklinghausen <crecklin@redhat.com>
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 tools/testing/radix-tree/idr-test.c   | 2 ++
 tools/testing/radix-tree/multiorder.c | 2 ++
 tools/testing/radix-tree/xarray.c     | 2 ++
 3 files changed, 6 insertions(+)

diff --git a/tools/testing/radix-tree/idr-test.c b/tools/testing/radix-tree/idr-test.c
index 3b796dd5e577..44ceff95a9b3 100644
--- a/tools/testing/radix-tree/idr-test.c
+++ b/tools/testing/radix-tree/idr-test.c
@@ -577,6 +577,7 @@ void ida_tests(void)
 
 int __weak main(void)
 {
+	rcu_register_thread();
 	radix_tree_init();
 	idr_checks();
 	ida_tests();
@@ -584,5 +585,6 @@ int __weak main(void)
 	rcu_barrier();
 	if (nr_allocated)
 		printf("nr_allocated = %d\n", nr_allocated);
+	rcu_unregister_thread();
 	return 0;
 }
diff --git a/tools/testing/radix-tree/multiorder.c b/tools/testing/radix-tree/multiorder.c
index 9eae0fb5a67d..e00520cc6349 100644
--- a/tools/testing/radix-tree/multiorder.c
+++ b/tools/testing/radix-tree/multiorder.c
@@ -224,7 +224,9 @@ void multiorder_checks(void)
 
 int __weak main(void)
 {
+	rcu_register_thread();
 	radix_tree_init();
 	multiorder_checks();
+	rcu_unregister_thread();
 	return 0;
 }
diff --git a/tools/testing/radix-tree/xarray.c b/tools/testing/radix-tree/xarray.c
index e61e43efe463..f20e12cbbfd4 100644
--- a/tools/testing/radix-tree/xarray.c
+++ b/tools/testing/radix-tree/xarray.c
@@ -25,11 +25,13 @@ void xarray_tests(void)
 
 int __weak main(void)
 {
+	rcu_register_thread();
 	radix_tree_init();
 	xarray_tests();
 	radix_tree_cpu_dead(1);
 	rcu_barrier();
 	if (nr_allocated)
 		printf("nr_allocated = %d\n", nr_allocated);
+	rcu_unregister_thread();
 	return 0;
 }
-- 
2.30.2


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

* [PATCH AUTOSEL 5.4 10/13] idr test suite: Take RCU read lock in idr_find_test_1
       [not found] <20210405160459.268794-1-sashal@kernel.org>
  2021-04-05 16:04 ` [PATCH AUTOSEL 5.4 07/13] radix tree test suite: Fix compilation Sasha Levin
  2021-04-05 16:04 ` [PATCH AUTOSEL 5.4 09/13] radix tree test suite: Register the main thread with the RCU library Sasha Levin
@ 2021-04-05 16:04 ` Sasha Levin
  2021-04-05 16:04 ` [PATCH AUTOSEL 5.4 11/13] idr test suite: Create anchor before launching throbber Sasha Levin
  2021-04-05 16:04 ` [PATCH AUTOSEL 5.4 13/13] block: don't ignore REQ_NOWAIT for direct IO Sasha Levin
  4 siblings, 0 replies; 5+ messages in thread
From: Sasha Levin @ 2021-04-05 16:04 UTC (permalink / raw)
  To: linux-kernel, stable
  Cc: Matthew Wilcox (Oracle), Chris von Recklinghausen, Sasha Levin,
	linux-fsdevel

From: "Matthew Wilcox (Oracle)" <willy@infradead.org>

[ Upstream commit 703586410da69eb40062e64d413ca33bd735917a ]

When run on a single CPU, this test would frequently access already-freed
memory.  Due to timing, this bug never showed up on multi-CPU tests.

Reported-by: Chris von Recklinghausen <crecklin@redhat.com>
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 tools/testing/radix-tree/idr-test.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/tools/testing/radix-tree/idr-test.c b/tools/testing/radix-tree/idr-test.c
index 44ceff95a9b3..4a9b451b7ba0 100644
--- a/tools/testing/radix-tree/idr-test.c
+++ b/tools/testing/radix-tree/idr-test.c
@@ -306,11 +306,15 @@ void idr_find_test_1(int anchor_id, int throbber_id)
 	BUG_ON(idr_alloc(&find_idr, xa_mk_value(anchor_id), anchor_id,
 				anchor_id + 1, GFP_KERNEL) != anchor_id);
 
+	rcu_read_lock();
 	do {
 		int id = 0;
 		void *entry = idr_get_next(&find_idr, &id);
+		rcu_read_unlock();
 		BUG_ON(entry != xa_mk_value(id));
+		rcu_read_lock();
 	} while (time(NULL) < start + 11);
+	rcu_read_unlock();
 
 	pthread_join(throbber, NULL);
 
-- 
2.30.2


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

* [PATCH AUTOSEL 5.4 11/13] idr test suite: Create anchor before launching throbber
       [not found] <20210405160459.268794-1-sashal@kernel.org>
                   ` (2 preceding siblings ...)
  2021-04-05 16:04 ` [PATCH AUTOSEL 5.4 10/13] idr test suite: Take RCU read lock in idr_find_test_1 Sasha Levin
@ 2021-04-05 16:04 ` Sasha Levin
  2021-04-05 16:04 ` [PATCH AUTOSEL 5.4 13/13] block: don't ignore REQ_NOWAIT for direct IO Sasha Levin
  4 siblings, 0 replies; 5+ messages in thread
From: Sasha Levin @ 2021-04-05 16:04 UTC (permalink / raw)
  To: linux-kernel, stable; +Cc: Matthew Wilcox (Oracle), Sasha Levin, linux-fsdevel

From: "Matthew Wilcox (Oracle)" <willy@infradead.org>

[ Upstream commit 094ffbd1d8eaa27ed426feb8530cb1456348b018 ]

The throbber could race with creation of the anchor entry and cause the
IDR to have zero entries in it, which would cause the test to fail.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 tools/testing/radix-tree/idr-test.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/testing/radix-tree/idr-test.c b/tools/testing/radix-tree/idr-test.c
index 4a9b451b7ba0..6ce7460f3c7a 100644
--- a/tools/testing/radix-tree/idr-test.c
+++ b/tools/testing/radix-tree/idr-test.c
@@ -301,11 +301,11 @@ void idr_find_test_1(int anchor_id, int throbber_id)
 	pthread_t throbber;
 	time_t start = time(NULL);
 
-	pthread_create(&throbber, NULL, idr_throbber, &throbber_id);
-
 	BUG_ON(idr_alloc(&find_idr, xa_mk_value(anchor_id), anchor_id,
 				anchor_id + 1, GFP_KERNEL) != anchor_id);
 
+	pthread_create(&throbber, NULL, idr_throbber, &throbber_id);
+
 	rcu_read_lock();
 	do {
 		int id = 0;
-- 
2.30.2


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

* [PATCH AUTOSEL 5.4 13/13] block: don't ignore REQ_NOWAIT for direct IO
       [not found] <20210405160459.268794-1-sashal@kernel.org>
                   ` (3 preceding siblings ...)
  2021-04-05 16:04 ` [PATCH AUTOSEL 5.4 11/13] idr test suite: Create anchor before launching throbber Sasha Levin
@ 2021-04-05 16:04 ` Sasha Levin
  4 siblings, 0 replies; 5+ messages in thread
From: Sasha Levin @ 2021-04-05 16:04 UTC (permalink / raw)
  To: linux-kernel, stable
  Cc: Pavel Begunkov, Jens Axboe, Sasha Levin, linux-fsdevel,
	linux-block

From: Pavel Begunkov <asml.silence@gmail.com>

[ Upstream commit f8b78caf21d5bc3fcfc40c18898f9d52ed1451a5 ]

If IOCB_NOWAIT is set on submission, then that needs to get propagated to
REQ_NOWAIT on the block side. Otherwise we completely lose this
information, and any issuer of IOCB_NOWAIT IO will potentially end up
blocking on eg request allocation on the storage side.

Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 fs/block_dev.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/fs/block_dev.c b/fs/block_dev.c
index 79272cdbe827..bd93563477a4 100644
--- a/fs/block_dev.c
+++ b/fs/block_dev.c
@@ -246,6 +246,8 @@ __blkdev_direct_IO_simple(struct kiocb *iocb, struct iov_iter *iter,
 		bio.bi_opf = dio_bio_write_op(iocb);
 		task_io_account_write(ret);
 	}
+	if (iocb->ki_flags & IOCB_NOWAIT)
+		bio.bi_opf |= REQ_NOWAIT;
 	if (iocb->ki_flags & IOCB_HIPRI)
 		bio_set_polled(&bio, iocb);
 
@@ -399,6 +401,8 @@ __blkdev_direct_IO(struct kiocb *iocb, struct iov_iter *iter, int nr_pages)
 			bio->bi_opf = dio_bio_write_op(iocb);
 			task_io_account_write(bio->bi_iter.bi_size);
 		}
+		if (iocb->ki_flags & IOCB_NOWAIT)
+			bio->bi_opf |= REQ_NOWAIT;
 
 		dio->size += bio->bi_iter.bi_size;
 		pos += bio->bi_iter.bi_size;
-- 
2.30.2


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

end of thread, other threads:[~2021-04-05 16:05 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20210405160459.268794-1-sashal@kernel.org>
2021-04-05 16:04 ` [PATCH AUTOSEL 5.4 07/13] radix tree test suite: Fix compilation Sasha Levin
2021-04-05 16:04 ` [PATCH AUTOSEL 5.4 09/13] radix tree test suite: Register the main thread with the RCU library Sasha Levin
2021-04-05 16:04 ` [PATCH AUTOSEL 5.4 10/13] idr test suite: Take RCU read lock in idr_find_test_1 Sasha Levin
2021-04-05 16:04 ` [PATCH AUTOSEL 5.4 11/13] idr test suite: Create anchor before launching throbber Sasha Levin
2021-04-05 16:04 ` [PATCH AUTOSEL 5.4 13/13] block: don't ignore REQ_NOWAIT for direct IO Sasha Levin

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 read-only IMAP folder(s) and NNTP newsgroup(s).