All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mikulas Patocka <mpatocka@redhat.com>
To: Mike Snitzer <msnitzer@redhat.com>
Cc: dm-devel@redhat.com, Mikulas Patocka <mpatocka@redhat.com>
Subject: [patch 1/3] dm-writecache: convert swait_queues to wait_queues
Date: Wed, 06 Jun 2018 17:31:43 +0200	[thread overview]
Message-ID: <20180606153200.530119259@debian.vm> (raw)

[-- Attachment #1: dm-writecache-wait.patch --]
[-- Type: text/plain, Size: 3385 bytes --]

Convert swait_queues to wait_queues, because there may be multiple
processes waiting on the queue and swait_queues are inefficient in that
case (and the code incorrectly uses swake_up where it intends to wake all
the waiters).

Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>

---
 drivers/md/dm-writecache.c |   26 +++++++++++++-------------
 1 file changed, 13 insertions(+), 13 deletions(-)

Index: linux-2.6/drivers/md/dm-writecache.c
===================================================================
--- linux-2.6.orig/drivers/md/dm-writecache.c	2018-06-04 21:45:35.000000000 +0200
+++ linux-2.6/drivers/md/dm-writecache.c	2018-06-04 22:10:35.000000000 +0200
@@ -129,10 +129,10 @@ struct dm_writecache {
 
 	unsigned long autocommit_jiffies;
 	struct timer_list autocommit_timer;
-	struct swait_queue_head freelist_wait;
+	struct wait_queue_head freelist_wait;
 
 	atomic_t bio_in_progress[2];
-	struct swait_queue_head bio_in_progress_wait[2];
+	struct wait_queue_head bio_in_progress_wait[2];
 
 	struct dm_target *ti;
 	struct dm_dev *dev;
@@ -408,7 +408,7 @@ static void write_original_sector_seq_co
 do {									\
 	if (!cmpxchg(&(wc)->error, 0, err))				\
 		DMERR(msg, ##arg);					\
-	swake_up(&(wc)->freelist_wait);					\
+	wake_up(&(wc)->freelist_wait);					\
 } while (0)
 
 #define writecache_has_error(wc)	(unlikely(READ_ONCE((wc)->error)))
@@ -526,7 +526,7 @@ static void writecache_disk_flush(struct
 
 static void writecache_wait_for_ios(struct dm_writecache *wc, int direction)
 {
-	swait_event(wc->bio_in_progress_wait[direction],
+	wait_event(wc->bio_in_progress_wait[direction],
 		   !atomic_read(&wc->bio_in_progress[direction]));
 }
 
@@ -658,18 +658,18 @@ static void writecache_free_entry(struct
 	writecache_add_to_freelist(wc, e);
 	clear_seq_count(wc, e);
 	writecache_flush_region(wc, memory_entry(wc, e), sizeof(struct wc_memory_entry));
-	if (unlikely(swait_active(&wc->freelist_wait)))
-		swake_up(&wc->freelist_wait);
+	if (unlikely(waitqueue_active(&wc->freelist_wait)))
+		wake_up(&wc->freelist_wait);
 }
 
 static void writecache_wait_on_freelist(struct dm_writecache *wc)
 {
-	DECLARE_SWAITQUEUE(wait);
+	DEFINE_WAIT(wait);
 
-	prepare_to_swait(&wc->freelist_wait, &wait, TASK_UNINTERRUPTIBLE);
+	prepare_to_wait(&wc->freelist_wait, &wait, TASK_UNINTERRUPTIBLE);
 	wc_unlock(wc);
 	io_schedule();
-	finish_swait(&wc->freelist_wait, &wait);
+	finish_wait(&wc->freelist_wait, &wait);
 	wc_lock(wc);
 }
 
@@ -1238,8 +1238,8 @@ static int writecache_end_io(struct dm_t
 	if (bio->bi_private != NULL) {
 		int dir = bio_data_dir(bio);
 		if (atomic_dec_and_test(&wc->bio_in_progress[dir]))
-			if (unlikely(swait_active(&wc->bio_in_progress_wait[dir])))
-				swake_up(&wc->bio_in_progress_wait[dir]);
+			if (unlikely(waitqueue_active(&wc->bio_in_progress_wait[dir])))
+				wake_up(&wc->bio_in_progress_wait[dir]);
 	}
 	return 0;
 }
@@ -1823,12 +1823,12 @@ static int writecache_ctr(struct dm_targ
 
 	mutex_init(&wc->lock);
 	writecache_poison_lists(wc);
-	init_swait_queue_head(&wc->freelist_wait);
+	init_waitqueue_head(&wc->freelist_wait);
 	timer_setup(&wc->autocommit_timer, writecache_autocommit_timer, 0);
 
 	for (i = 0; i < 2; i++) {
 		atomic_set(&wc->bio_in_progress[i], 0);
-		init_swait_queue_head(&wc->bio_in_progress_wait[i]);
+		init_waitqueue_head(&wc->bio_in_progress_wait[i]);
 	}
 
 	wc->dm_io = dm_io_client_create();

                 reply	other threads:[~2018-06-06 15:31 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20180606153200.530119259@debian.vm \
    --to=mpatocka@redhat.com \
    --cc=dm-devel@redhat.com \
    --cc=msnitzer@redhat.com \
    /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 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.