linux-mmc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Rafael J. Wysocki" <rjw@sisk.pl>
To: Alan Stern <stern@rowland.harvard.edu>
Cc: Jens Axboe <axboe@kernel.dk>, Tejun Heo <tj@kernel.org>,
	Steve French <sfrench@samba.org>, Chris Ball <cjb@laptop.org>,
	Jeff Layton <jlayton@poochiereds.net>,
	David Airlie <airlied@linux.ie>,
	David Howells <dhowells@redhat.com>,
	Linux-pm mailing list <linux-pm@vger.kernel.org>,
	linux-cifs@vger.kernel.org, linux-mmc@vger.kernel.org,
	dri-devel@lists.freedesktop.org, keyrings@linux-nfs.org
Subject: Re: [PATCH] Block: use a freezable workqueue for disk-event polling
Date: Fri, 17 Feb 2012 23:11:05 +0100	[thread overview]
Message-ID: <201202172311.06246.rjw@sisk.pl> (raw)
In-Reply-To: <Pine.LNX.4.44L0.1202171615550.1194-100000@iolanthe.rowland.org>

On Friday, February 17, 2012, Alan Stern wrote:
> This patch (as1519) fixes a bug in the block layer's disk-events
> polling.  The polling is done by a work routine queued on the
> system_nrt_wq workqueue.  Since that workqueue isn't freezable, the
> polling continues even in the middle of a system sleep transition.
> 
> Obviously, polling a suspended drive for media changes and such isn't
> a good thing to do; in the case of USB mass-storage devices it can
> lead to real problems requiring device resets and even re-enumeration.
> 
> The patch fixes things by creating a new system-wide, non-reentrant,
> freezable workqueue and using it for disk-events polling.
> 
> Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
> CC: Tejun Heo <tj@kernel.org>
> CC: <stable@kernel.org>

Acked-by: Rafael J. Wysocki <rjw@sisk.pl>

Thanks,
Rafael


> ---
> 
> I'm not sure who to send this patch to, since it is relevant to both
> the block and PM subsystems.  Jens, is it okay if Rafael takes it?
> 
> 
> 
>  block/genhd.c             |   10 +++++-----
>  include/linux/workqueue.h |    4 ++++
>  kernel/workqueue.c        |    7 ++++++-
>  3 files changed, 15 insertions(+), 6 deletions(-)
> 
> Index: usb-3.3/block/genhd.c
> ===================================================================
> --- usb-3.3.orig/block/genhd.c
> +++ usb-3.3/block/genhd.c
> @@ -1475,9 +1475,9 @@ static void __disk_unblock_events(struct
>  	intv = disk_events_poll_jiffies(disk);
>  	set_timer_slack(&ev->dwork.timer, intv / 4);
>  	if (check_now)
> -		queue_delayed_work(system_nrt_wq, &ev->dwork, 0);
> +		queue_delayed_work(system_nrt_freezable_wq, &ev->dwork, 0);
>  	else if (intv)
> -		queue_delayed_work(system_nrt_wq, &ev->dwork, intv);
> +		queue_delayed_work(system_nrt_freezable_wq, &ev->dwork, intv);
>  out_unlock:
>  	spin_unlock_irqrestore(&ev->lock, flags);
>  }
> @@ -1521,7 +1521,7 @@ void disk_flush_events(struct gendisk *d
>  	ev->clearing |= mask;
>  	if (!ev->block) {
>  		cancel_delayed_work(&ev->dwork);
> -		queue_delayed_work(system_nrt_wq, &ev->dwork, 0);
> +		queue_delayed_work(system_nrt_freezable_wq, &ev->dwork, 0);
>  	}
>  	spin_unlock_irq(&ev->lock);
>  }
> @@ -1558,7 +1558,7 @@ unsigned int disk_clear_events(struct ge
>  
>  	/* uncondtionally schedule event check and wait for it to finish */
>  	disk_block_events(disk);
> -	queue_delayed_work(system_nrt_wq, &ev->dwork, 0);
> +	queue_delayed_work(system_nrt_freezable_wq, &ev->dwork, 0);
>  	flush_delayed_work(&ev->dwork);
>  	__disk_unblock_events(disk, false);
>  
> @@ -1595,7 +1595,7 @@ static void disk_events_workfn(struct wo
>  
>  	intv = disk_events_poll_jiffies(disk);
>  	if (!ev->block && intv)
> -		queue_delayed_work(system_nrt_wq, &ev->dwork, intv);
> +		queue_delayed_work(system_nrt_freezable_wq, &ev->dwork, intv);
>  
>  	spin_unlock_irq(&ev->lock);
>  
> Index: usb-3.3/include/linux/workqueue.h
> ===================================================================
> --- usb-3.3.orig/include/linux/workqueue.h
> +++ usb-3.3/include/linux/workqueue.h
> @@ -289,12 +289,16 @@ enum {
>   *
>   * system_freezable_wq is equivalent to system_wq except that it's
>   * freezable.
> + *
> + * system_nrt_freezable_wq is equivalent to system_nrt_wq except that
> + * it's freezable.
>   */
>  extern struct workqueue_struct *system_wq;
>  extern struct workqueue_struct *system_long_wq;
>  extern struct workqueue_struct *system_nrt_wq;
>  extern struct workqueue_struct *system_unbound_wq;
>  extern struct workqueue_struct *system_freezable_wq;
> +extern struct workqueue_struct *system_nrt_freezable_wq;
>  
>  extern struct workqueue_struct *
>  __alloc_workqueue_key(const char *fmt, unsigned int flags, int max_active,
> Index: usb-3.3/kernel/workqueue.c
> ===================================================================
> --- usb-3.3.orig/kernel/workqueue.c
> +++ usb-3.3/kernel/workqueue.c
> @@ -253,11 +253,13 @@ struct workqueue_struct *system_long_wq
>  struct workqueue_struct *system_nrt_wq __read_mostly;
>  struct workqueue_struct *system_unbound_wq __read_mostly;
>  struct workqueue_struct *system_freezable_wq __read_mostly;
> +struct workqueue_struct *system_nrt_freezable_wq __read_mostly;
>  EXPORT_SYMBOL_GPL(system_wq);
>  EXPORT_SYMBOL_GPL(system_long_wq);
>  EXPORT_SYMBOL_GPL(system_nrt_wq);
>  EXPORT_SYMBOL_GPL(system_unbound_wq);
>  EXPORT_SYMBOL_GPL(system_freezable_wq);
> +EXPORT_SYMBOL_GPL(system_nrt_freezable_wq);
>  
>  #define CREATE_TRACE_POINTS
>  #include <trace/events/workqueue.h>
> @@ -3833,8 +3835,11 @@ static int __init init_workqueues(void)
>  					    WQ_UNBOUND_MAX_ACTIVE);
>  	system_freezable_wq = alloc_workqueue("events_freezable",
>  					      WQ_FREEZABLE, 0);
> +	system_nrt_freezable_wq = alloc_workqueue("events_nrt_freezable",
> +			WQ_NON_REENTRANT | WQ_FREEZABLE, 0);
>  	BUG_ON(!system_wq || !system_long_wq || !system_nrt_wq ||
> -	       !system_unbound_wq || !system_freezable_wq);
> +	       !system_unbound_wq || !system_freezable_wq ||
> +		!system_nrt_freezable_wq);
>  	return 0;
>  }
>  early_initcall(init_workqueues);
> 
> 
> 


  parent reply	other threads:[~2012-02-17 22:07 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-16 14:41 system_nrt_wq, system suspend, and the freezer Alan Stern
     [not found] ` <Pine.LNX.4.44L0.1202160930010.1268-100000-IYeN2dnnYyZXsRXLowluHWD2FQJk+8+b@public.gmane.org>
2012-02-16 15:22   ` David Howells
     [not found]     ` <32626.1329405744-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2012-02-16 16:26       ` Tejun Heo
     [not found]     ` <20120216162634.GE24986-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>
2012-02-16 16:35       ` David Howells
2012-02-16 16:37         ` Tejun Heo
2012-02-16 15:27 ` Jeff Layton
     [not found]   ` <20120216102728.230b99ba-vpEMnDpepFuMZCB2o+C8xQ@public.gmane.org>
2012-02-16 16:29     ` Tejun Heo
     [not found]       ` <20120216162951.GF24986-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>
2012-02-16 16:42         ` Alan Stern
2012-02-16 18:59       ` Jeff Layton
     [not found]         ` <20120216135945.3dd3893a-eUNUBHrolfbYtjvyW6yDsg@public.gmane.org>
2012-02-16 19:01           ` Tejun Heo
2012-02-17 21:22   ` [PATCH] Block: use a freezable workqueue for disk-event polling Alan Stern
2012-02-17 21:52     ` Tejun Heo
2012-02-17 22:11     ` Rafael J. Wysocki [this message]
2012-03-02  9:51     ` Jens Axboe
2012-02-16 16:25 ` system_nrt_wq, system suspend, and the freezer Tejun Heo
     [not found]   ` <20120216162529.GD24986-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>
2012-02-16 16:37     ` Alan Stern
     [not found]       ` <Pine.LNX.4.44L0.1202161131420.1268-100000-IYeN2dnnYyZXsRXLowluHWD2FQJk+8+b@public.gmane.org>
2012-02-16 16:45         ` Tejun Heo
2012-02-16 16:58           ` Alan Stern

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=201202172311.06246.rjw@sisk.pl \
    --to=rjw@sisk.pl \
    --cc=airlied@linux.ie \
    --cc=axboe@kernel.dk \
    --cc=cjb@laptop.org \
    --cc=dhowells@redhat.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=jlayton@poochiereds.net \
    --cc=keyrings@linux-nfs.org \
    --cc=linux-cifs@vger.kernel.org \
    --cc=linux-mmc@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=sfrench@samba.org \
    --cc=stern@rowland.harvard.edu \
    --cc=tj@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).