mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Petr Mladek <pmladek@suse.com>
To: wen.yang99@zte.com.cn
Cc: sergey.senozhatsky.work@gmail.com, jejb@linux.vnet.ibm.com,
	martin.petersen@oracle.com, linux-scsi@vger.kernel.org,
	linux-kernel@vger.kernel.org, Bart.VanAssche@wdc.com,
	tj@kernel.org, jiang.biao2@zte.com.cn, zhong.weidong@zte.com.cn,
	tan.hu@zte.com.cn
Subject: Re: 答复: Re: [PATCH v2] scsi: Introduce sdev_printk_ratelimited to throttlefrequent printk
Date: Fri, 6 Apr 2018 10:30:16 +0200	[thread overview]
Message-ID: <20180406083016.weuoemmcgvgxlcxy@pathway.suse.cz> (raw)
In-Reply-To: <201804031419435288297@zte.com.cn>

On Tue 2018-04-03 14:19:43, wen.yang99@zte.com.cn wrote:
> On the other hand,queue_lock is big, looping doing something under spinlock 
> 
> may locked many things and taking a long time, may cause some problems.
> 
> So This code needs to be optimized later:
> 
> scsi_request_fn()
> {
> 	for (;;) {
> 		int rtn;
> 		/*
> 		 * get next queueable request.  We do this early to make sure
> 		 * that the request is fully prepared even if we cannot
> 		 * accept it.
> 		 */
> 
> 		req = blk_peek_request(q);
> 
> 		if (!req)
> 			break;
> 
> 		if (unlikely(!scsi_device_online(sdev))) {
> 			sdev_printk(KERN_ERR, sdev,
> 				    "rejected I/O to offline device\n");
> 			scsi_kill_request(req, q);
> 			continue;
> 
> 			^^^^^^^^^ still under spinlock
> 		}

I wonder if the following might be the best solution after all:

		if (unlikely(!scsi_device_online(sdev))) {
			scsi_kill_request(req, q);

			/*
			 * printk() might take a while on slow consoles.
			 * Prevent solftlockups by releasing the lock.
			 */
			spin_unlock_irq(q->queue_lock);
			sdev_printk(KERN_ERR, sdev,
				    "rejecting I/O to offline device\n");
			spin_lock_irq(q->queue_lock);
			continue;
		}

I see that the lock is released also in several other situations.
Therefore it looks safe. Also handling too many requests without
releasing the lock seems to be a bad idea in general. I think
that this solution was already suggested earlier.

Please, note that I moved scsi_kill_request() up. It looks natural
to remove it from the queue before we release the queue lock.

Best Regards,
Petr

BTW: Your mail had strange formatting. Please, try to avoid using
html.

  parent reply	other threads:[~2018-04-06  8:30 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-02  1:58 [PATCH v2] scsi: Introduce sdev_printk_ratelimited to throttle frequent printk Wen Yang
2018-04-02  2:10 ` Sergey Senozhatsky
     [not found]   ` <201804031419435288297@zte.com.cn>
2018-04-06  8:30     ` Petr Mladek [this message]
2018-04-06  8:49       ` 答复: Re: [PATCH v2] scsi: Introduce sdev_printk_ratelimited to throttlefrequent printk Petr Mladek
     [not found]         ` <201804091013439214247@zte.com.cn>
2018-04-09  8:59           ` 答复: Re: 答复: Re: [PATCH v2] scsi: Introduce sdev_printk_ratelimited tothrottlefrequent printk Petr Mladek
2018-04-02  2:37 ` [PATCH v2] scsi: Introduce sdev_printk_ratelimited to throttle frequent printk Jason Yan
     [not found]   ` <201804021314481872986@zte.com.cn>
2018-04-02  5:29     ` 答复: Re: [PATCH v2] scsi: Introduce sdev_printk_ratelimited to throttlefrequent printk Sergey Senozhatsky
2018-04-02  6:07       ` Jason Yan
2018-04-02  6:06     ` Jason Yan

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=20180406083016.weuoemmcgvgxlcxy@pathway.suse.cz \
    --to=pmladek@suse.com \
    --cc=Bart.VanAssche@wdc.com \
    --cc=jejb@linux.vnet.ibm.com \
    --cc=jiang.biao2@zte.com.cn \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=sergey.senozhatsky.work@gmail.com \
    --cc=tan.hu@zte.com.cn \
    --cc=tj@kernel.org \
    --cc=wen.yang99@zte.com.cn \
    --cc=zhong.weidong@zte.com.cn \
    /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

all inboxes | Powered by JetHome®