From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751200AbdJCIWZ (ORCPT ); Tue, 3 Oct 2017 04:22:25 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34836 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751111AbdJCIWX (ORCPT ); Tue, 3 Oct 2017 04:22:23 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 6AAD2C058ECD Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=ming.lei@redhat.com Date: Tue, 3 Oct 2017 16:22:12 +0800 From: Ming Lei To: Christoph Hellwig Cc: Jens Axboe , linux-block@vger.kernel.org, linux-scsi@vger.kernel.org, "Martin K . Petersen" , "James E . J . Bottomley" , Bart Van Assche , Oleksandr Natalenko , Johannes Thumshirn , Cathy Avery , Martin Steigerwald , linux-kernel@vger.kernel.org, Hannes Reinecke , Bart Van Assche Subject: Re: [PATCH V7 5/6] block: support PREEMPT_ONLY Message-ID: <20171003082211.GC23564@ming.t460p> References: <20170930061214.10622-1-ming.lei@redhat.com> <20170930061214.10622-6-ming.lei@redhat.com> <20171002135024.GE19119@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20171002135024.GE19119@infradead.org> User-Agent: Mutt/1.8.3 (2017-05-23) X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Tue, 03 Oct 2017 08:22:23 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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