From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Date: Fri, 29 Jun 2018 10:39:44 +0200 From: Christoph Hellwig To: Ming Lei Cc: Jens Axboe , linux-block@vger.kernel.org, Kashyap Desai , Laurence Oberman , Omar Sandoval , Christoph Hellwig , Bart Van Assche , Hannes Reinecke Subject: Re: [PATCH V2 3/3] blk-mq: dequeue request one by one from sw queue iff hctx is busy Message-ID: <20180629083944.GE15870@lst.de> References: <20180629081252.13836-1-ming.lei@redhat.com> <20180629081252.13836-4-ming.lei@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii In-Reply-To: <20180629081252.13836-4-ming.lei@redhat.com> List-ID: > +/* update queue busy with EWMA (7/8 * ewma(t) + 1/8 * busy(t + 1)) */ > +static void blk_mq_update_hctx_busy(struct blk_mq_hw_ctx *hctx, unsigned int busy) Overly long line. Also busy really is a bool, so I think we should pass it as such. Also I think this needs a much better comment describing why we are using this algorith. Also expanding the EWMA acronym would help, I had to look it up first. > + const unsigned weight = 8; > + const unsigned factor = 4; Where do these magic constants come from? > + unsigned int ewma; > + > + if (hctx->queue->elevator) > + return; > + > + ewma = READ_ONCE(hctx->busy); > + > + ewma *= weight - 1; > + ewma += busy << factor; With the bool parameter and expanding the "factor" which really is a shift value this would be: if (busy) ewma += 16; which at least is a little more understandable, although still not great.