lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:   Tue, 3 Oct 2017 16:22:12 +0800
From:   Ming Lei <ming.lei@...hat.com>
To:     Christoph Hellwig <hch@...radead.org>
Cc:     Jens Axboe <axboe@...com>, linux-block@...r.kernel.org,
        linux-scsi@...r.kernel.org,
        "Martin K . Petersen" <martin.petersen@...cle.com>,
        "James E . J . Bottomley" <jejb@...ux.vnet.ibm.com>,
        Bart Van Assche <bart.vanassche@...disk.com>,
        Oleksandr Natalenko <oleksandr@...alenko.name>,
        Johannes Thumshirn <jthumshirn@...e.de>,
        Cathy Avery <cavery@...hat.com>,
        Martin Steigerwald <martin@...htvoll.de>,
        linux-kernel@...r.kernel.org, Hannes Reinecke <hare@...e.com>,
        Bart Van Assche <Bart.VanAssche@....com>
Subject: Re: [PATCH V7 5/6] block: support PREEMPT_ONLY

On Mon, Oct 02, 2017 at 06:50:24AM -0700, Christoph Hellwig wrote:
> > +void blk_set_preempt_only(struct request_queue *q, bool preempt_only)
> > +{
> > +	blk_mq_freeze_queue(q);
> > +	if (preempt_only)
> > +		queue_flag_set_unlocked(QUEUE_FLAG_PREEMPT_ONLY, q);
> > +	else
> > +		queue_flag_clear_unlocked(QUEUE_FLAG_PREEMPT_ONLY, q);
> > +	blk_mq_unfreeze_queue(q);
> > +}
> > +EXPORT_SYMBOL(blk_set_preempt_only);
> 
> What do you need the queue freeze for?

The main reason is for draining requests in queue before setting PREEMP_ONLY.

> 
> > +		/*
> > +		 * preempt_only flag has to be set after queue is frozen,
> > +		 * so it can be checked here lockless and safely
> > +		 */
> > +		if (blk_queue_preempt_only(q)) {
> 
> We can always check a single bit flag safely, so I really don't
> understand that comment.
> 
> > +			if (!(flags & BLK_REQ_PREEMPT))
> > +				goto slow_path;
> > +		}
> > +
> >  		if (percpu_ref_tryget_live(&q->q_usage_counter))
> >  			return 0;
> > -
> > + slow_path:
> 
> Also this looks a very spaghetti, why not:
> 
> 
> 	if (!blk_queue_preempt_only(q) || (flags & BLK_MQ_REQ_PREEMPT)) {
> 		if (percpu_ref_tryget_live(&q->q_usage_counter))
> 			return 0;
> 	}

Looks fine, will do it in next version.

-- 
Ming

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ