Received: by 10.223.164.202 with SMTP id h10csp464017wrb; Thu, 30 Nov 2017 13:22:16 -0800 (PST) X-Google-Smtp-Source: AGs4zMZ3R/bMnc664LWicQCInaNmTTiEVVzs3Nh5/X5Kh5TpIJRaI2uRoAsFFBM3jJIJEeC8pKlG X-Received: by 10.101.74.8 with SMTP id s8mr3568214pgq.259.1512076935994; Thu, 30 Nov 2017 13:22:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1512076935; cv=none; d=google.com; s=arc-20160816; b=DzQ149y8gVV9wn3ghjLSn093z0AN2hn80WM0R/HYgTLayKaCHx15jXT85SocjntOD8 sfNZBlHi6Nmmhr0Uq8jplqMIt56f4278yhIgHwCOv/ZUTdWth1rsXrT0Xa2ZAqlxqnia 7lE371nP9uIbpYTiH6TlirCCxnhVT9/Mu/8LL75gwKO2CBWqoI8k4LrTzD8nq+57CETf u9S7XD5yZGTbWaeNPtMTxd3cKzYtu0u2JHS/hSzx5oC9iQTmrQ//fo8KQ86EiCtv70vc 4wCpMA3M01t8GgQtQA/AKbApyxX4qlICwFJuDGVFrF/k6uIAZ+I7wcR2BoIxI99IuTU2 e0QQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature :arc-authentication-results; bh=/V1+v5ZPJAb6wGMdEkFnJML8lGqv7xJoFZ3w6ztIfwk=; b=sWl7Hoqcj6+XZxbuCKM4ejuDgs//6mxSVvy9ZcHTuN9Spe1DW0JZSdTNGoXMEFHjH5 R6iu7c5TiRAIZipJtft2Q92A4cJSfkgqVyFDrW/b+FD7fPGO+a4xuiFGFQcgZnxNCXlI t8T0tvC4FndT2UHoKz4y80qde+rHBynny4UEpa9H/5GGsgpvDdZQiPCenSbIGM8MV0Ns 2J1DJiVjL9J9mJWxru8z+I0GilojQLlhokC2lvvvFmeRIBcUs6kMjwCVJJUyzr4awV6e 8Z/L5mRhWKqjmPHWBQqFhqJrp58s4PL3cjifMzR7g2KZuem6MmNMVLDwIsXuPnWrwej5 GMmw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel-dk.20150623.gappssmtp.com header.s=20150623 header.b=jrJPDTH0; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 1si3743720plb.315.2017.11.30.13.22.01; Thu, 30 Nov 2017 13:22:15 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel-dk.20150623.gappssmtp.com header.s=20150623 header.b=jrJPDTH0; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751023AbdK3VVt (ORCPT + 99 others); Thu, 30 Nov 2017 16:21:49 -0500 Received: from mail-io0-f193.google.com ([209.85.223.193]:39995 "EHLO mail-io0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750760AbdK3VVr (ORCPT ); Thu, 30 Nov 2017 16:21:47 -0500 Received: by mail-io0-f193.google.com with SMTP id d21so9067131ioe.7 for ; Thu, 30 Nov 2017 13:21:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20150623.gappssmtp.com; s=20150623; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=/V1+v5ZPJAb6wGMdEkFnJML8lGqv7xJoFZ3w6ztIfwk=; b=jrJPDTH0RJm+1CfIDgTUl0JoeWO5kHwg/St8za7cQPebSti+afFgBbYKmge51o6UOh eBxtzmPjsdkUpq8N5XHcFuYdHdJIqTaem4a6y8gbjCSCLvCx1V0c2CorIHd7WScpDfA/ PW1JMvxqSNw6AefvN5kC6/gKpXc/GZ1BOYPTH23fEcIyAHljaIOZwT/LjERCKNnAk4zL P4kb/lsOOqELhmSawDcFe+P7Xoib3XGU3aWZRasH7hmplGWUFoJCXuf1uzK0TsGmJKGB cAMZn29UiipEn60hwlkfA5wpwPNQGvbJTmpQQJ22M/ENSaqXGwJI9x0IXQ39k2lTahKg /t2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=/V1+v5ZPJAb6wGMdEkFnJML8lGqv7xJoFZ3w6ztIfwk=; b=cqKESRZ0QzaKONo9kW4/XhOMKN1ggh21fyXdvED/EbViskl9YZq8sFLbSk9jq9K8aX P4U/XAzme3opNp5YwY+bmWpu7isEiqQXEY1z2eoh6+Z0qwU8vt1izJRDqJBu6SUw6oz9 3ankpaWYJKdNfP1XWQECNHY2NODFX8BmWyx6djczyQx9HzdMFtMuOmFFAYNRSqOcXEji ncqxqOpgnDlr40tmsVeFgQ7uKnB/PphlKjRU0gceSB5J8ASQ/2B8XeHUFS4Thz9YNSQq YL0GQxLn26Kktt4sKASi11PNDxMD0LV2++dbqw2QeEQ3LGTAWuqTdemdAuWYktlJlSTn QYfg== X-Gm-Message-State: AJaThX5qq7cV6zRlLTk5WIt6adLokP3yBiStbkhhoDFhG7riVzUJ4hkE juJmwm848K+2+i56agU6EmWk86T3Z2g= X-Received: by 10.107.46.169 with SMTP id u41mr9933653iou.303.1512076906692; Thu, 30 Nov 2017 13:21:46 -0800 (PST) Received: from [192.168.1.154] ([216.160.245.98]) by smtp.gmail.com with ESMTPSA id d186sm2751522itd.22.2017.11.30.13.21.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 30 Nov 2017 13:21:45 -0800 (PST) Subject: Re: [PATCH] block, bfq: remove batches of confusing ifdefs To: Paolo Valente Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, ulf.hansson@linaro.org, broonie@kernel.org, linus.walleij@linaro.org, lucmiccio@gmail.com, bfq-iosched@googlegroups.com References: <20171128093734.1918-1-paolo.valente@linaro.org> From: Jens Axboe Message-ID: <5892a41d-4677-937a-a56e-5d4554724dd6@kernel.dk> Date: Thu, 30 Nov 2017 14:21:45 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 In-Reply-To: <20171128093734.1918-1-paolo.valente@linaro.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 11/28/2017 02:37 AM, Paolo Valente wrote: > Commit a33801e8b473 ("block, bfq: move debug blkio stats behind > CONFIG_DEBUG_BLK_CGROUP") introduced two batches of confusing ifdefs: > one reported in [1], plus a similar one in another function. This > commit removes both batches, in the way suggested in [1]. Some comments below. > +static inline void bfq_update_dispatch_stats(struct request *rq, > + spinlock_t *queue_lock, > + struct bfq_queue *in_serv_queue, > + bool idle_timer_disabled) > +{ Don't pass in the queue lock. The normal convention is to pass in the queue, thus making this: static void bfq_update_dispatch_stats(struct request_queue *q, struct request *rq, struct bfq_queue *in_serv_queue, bool idle_timer_disabled) which also gets rid of the inline. In general, never inline anything. The compiler should figure it out for you. This function is way too big to inline, plus the cost of what it's doing completely dwarfes function call overhead. > > + struct bfq_queue *bfqq = rq ? RQ_BFQQ(rq) : NULL; > > -#if defined(CONFIG_BFQ_GROUP_IOSCHED) && defined(CONFIG_DEBUG_BLK_CGROUP) > - bfqq = rq ? RQ_BFQQ(rq) : NULL; > if (!idle_timer_disabled && !bfqq) > - return rq; > + return; > > /* > * rq and bfqq are guaranteed to exist until this function > @@ -3732,7 +3713,7 @@ static struct request *bfq_dispatch_request(struct blk_mq_hw_ctx *hctx) > * In addition, the following queue lock guarantees that > * bfqq_group(bfqq) exists as well. > */ > - spin_lock_irq(hctx->queue->queue_lock); > + spin_lock_irq(queue_lock); > if (idle_timer_disabled) > /* > * Since the idle timer has been disabled, > @@ -3751,9 +3732,37 @@ static struct request *bfq_dispatch_request(struct blk_mq_hw_ctx *hctx) > bfqg_stats_set_start_empty_time(bfqg); > bfqg_stats_update_io_remove(bfqg, rq->cmd_flags); > } > - spin_unlock_irq(hctx->queue->queue_lock); > + spin_unlock_irq(queue_lock); > +} > +#else > +static inline void bfq_update_dispatch_stats(struct request *rq, > + spinlock_t *queue_lock, > + struct bfq_queue *in_serv_queue, > + bool idle_timer_disabled) {} > #endif > > +static struct request *bfq_dispatch_request(struct blk_mq_hw_ctx *hctx) > +{ > + struct bfq_data *bfqd = hctx->queue->elevator->elevator_data; > + struct request *rq; > + struct bfq_queue *in_serv_queue; > + bool waiting_rq, idle_timer_disabled; > + > + spin_lock_irq(&bfqd->lock); > + > + in_serv_queue = bfqd->in_service_queue; > + waiting_rq = in_serv_queue && bfq_bfqq_wait_request(in_serv_queue); > + > + rq = __bfq_dispatch_request(hctx); > + > + idle_timer_disabled = > + waiting_rq && !bfq_bfqq_wait_request(in_serv_queue); > + > + spin_unlock_irq(&bfqd->lock); > + > + bfq_update_dispatch_stats(rq, hctx->queue->queue_lock, in_serv_queue, > + idle_timer_disabled); > + > return rq; > } > > @@ -4276,16 +4285,46 @@ static bool __bfq_insert_request(struct bfq_data *bfqd, struct request *rq) > return idle_timer_disabled; > } > > +#if defined(CONFIG_BFQ_GROUP_IOSCHED) && defined(CONFIG_DEBUG_BLK_CGROUP) > +static inline void bfq_update_insert_stats(struct bfq_queue *bfqq, > + spinlock_t *queue_lock, > + bool idle_timer_disabled, > + unsigned int cmd_flags) > +{ > + if (!bfqq) > + return; > + > + /* > + * bfqq still exists, because it can disappear only after > + * either it is merged with another queue, or the process it > + * is associated with exits. But both actions must be taken by > + * the same process currently executing this flow of > + * instructions. > + * > + * In addition, the following queue lock guarantees that > + * bfqq_group(bfqq) exists as well. > + */ > + spin_lock_irq(queue_lock); > + bfqg_stats_update_io_add(bfqq_group(bfqq), bfqq, cmd_flags); > + if (idle_timer_disabled) > + bfqg_stats_update_idle_time(bfqq_group(bfqq)); > + spin_unlock_irq(queue_lock); > +} > +#else > +static inline void bfq_update_insert_stats(struct bfq_queue *bfqq, > + spinlock_t *queue_lock, > + bool idle_timer_disabled, > + unsigned int cmd_flags) {} > +#endif Ditto here, kill the inlines. In general though, good improvement. -- Jens Axboe From 1585306041113092891@xxx Tue Nov 28 10:40:55 +0000 2017 X-GM-THRID: 1585302238869781550 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread