From patchwork Tue Feb 7 17:24:45 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Valente X-Patchwork-Id: 93573 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp2301640qgi; Tue, 7 Feb 2017 09:25:19 -0800 (PST) X-Received: by 10.98.38.130 with SMTP id m124mr21392749pfm.22.1486488319835; Tue, 07 Feb 2017 09:25:19 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t62si4659322pfg.41.2017.02.07.09.25.19; Tue, 07 Feb 2017 09:25:19 -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=@linaro.org; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755248AbdBGRZN (ORCPT + 25 others); Tue, 7 Feb 2017 12:25:13 -0500 Received: from mail-wm0-f52.google.com ([74.125.82.52]:37551 "EHLO mail-wm0-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754199AbdBGRZL (ORCPT ); Tue, 7 Feb 2017 12:25:11 -0500 Received: by mail-wm0-f52.google.com with SMTP id v77so164409960wmv.0 for ; Tue, 07 Feb 2017 09:25:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=EZIxCTdp2kdx/my81WUf99qXDl5dr6wza3V4uE4pJoY=; b=DvqpcFNPMHJm4yGQMKQryxMsazt5tEcJgSrNif9lOjIJJcUXp0oDBORgcE6paptCvJ mhrbTv4QZAssoIi/BdXU6NWufO0ZOb0kzbOnJXY8HSbye3eucAjhNmkUY5Ywf+JH802A NR1Et1SQIp8lTb89YzYbXHrdXeh7jWD+P5K8Y= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=EZIxCTdp2kdx/my81WUf99qXDl5dr6wza3V4uE4pJoY=; b=C3TBzGQCyxunzBflDS0tKd0ohYNh1Gwt1e9SbWPMgMHLIqqdyLx2ulZun+fkcraY31 C7n0gASWLvSqUaWOubmWjgmg6wDXOlp21dgBm9F+9uHWzdBrcWztFEF/qvqnXcDYcDGC oxsr7+I9V5iodVkHzlaXmdxpuII0BjHnS/2IYHPgZ3rSsSwgby501xlbzjP1b98QR3af mTn3mNRpkDDoCKi6YanQOklvi7tuZudXKBFWj4WACmzP5SwsE+sSDrzFcYJZrqo9Bjd/ MZpjjtDcuMFmoiBGpcsN+do2U/+kIf6aE8BiqmXA4ICj+kpVnRzdmP2UG0ZXQjan7fY9 4CZQ== X-Gm-Message-State: AMke39kBGRSeAy0zKEyLddu9gpBy9qa1/PiXBgNNdxQCyoHe5HKNtkPFqLaWrdY2+CWtI4dp X-Received: by 10.28.215.206 with SMTP id o197mr12944430wmg.31.1486488308710; Tue, 07 Feb 2017 09:25:08 -0800 (PST) Received: from localhost.localdomain ([185.14.11.102]) by smtp.gmail.com with ESMTPSA id p7sm8384228wrc.34.2017.02.07.09.25.04 (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 07 Feb 2017 09:25:07 -0800 (PST) From: Paolo Valente To: Jens Axboe , Tejun Heo Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, ulf.hansson@linaro.org, linus.walleij@linaro.org, broonie@kernel.org, Paolo Valente Subject: [WIP PATCHSET 3/4] Embed bfq-ioc.c and add locking on request queue Date: Tue, 7 Feb 2017 18:24:45 +0100 Message-Id: <20170207172446.4528-4-paolo.valente@linaro.org> X-Mailer: git-send-email 2.10.0 In-Reply-To: <20170207172446.4528-1-paolo.valente@linaro.org> References: <20170207172446.4528-1-paolo.valente@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The version of bfq-ioc.c for bfq-iosched.c is not correct any more for bfq-mq, because, in bfq-mq, the request queue lock is not being held when bfq_bic_lookup is invoked. That function must then take that look on its own. This commit removes the inclusion of bfq-ioc.c, copies the content of bfq-ioc.c into bfq-mq-iosched.c, and adds the grabbing of the lock. Signed-off-by: Paolo Valente --- block/bfq-mq-iosched.c | 39 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 36 insertions(+), 3 deletions(-) -- 2.10.0 diff --git a/block/bfq-mq-iosched.c b/block/bfq-mq-iosched.c index 7e3f429..a8679de 100644 --- a/block/bfq-mq-iosched.c +++ b/block/bfq-mq-iosched.c @@ -190,7 +190,39 @@ static int device_speed_thresh[2]; static void bfq_schedule_dispatch(struct bfq_data *bfqd); -#include "bfq-ioc.c" +/** + * icq_to_bic - convert iocontext queue structure to bfq_io_cq. + * @icq: the iocontext queue. + */ +static struct bfq_io_cq *icq_to_bic(struct io_cq *icq) +{ + /* bic->icq is the first member, %NULL will convert to %NULL */ + return container_of(icq, struct bfq_io_cq, icq); +} + +/** + * bfq_bic_lookup - search into @ioc a bic associated to @bfqd. + * @bfqd: the lookup key. + * @ioc: the io_context of the process doing I/O. + * @q: the request queue. + */ +static struct bfq_io_cq *bfq_bic_lookup(struct bfq_data *bfqd, + struct io_context *ioc, + struct request_queue *q) +{ + if (ioc) { + struct bfq_io_cq *icq; + + spin_lock_irq(q->queue_lock); + icq = icq_to_bic(ioc_lookup_icq(ioc, q)); + spin_unlock_irq(q->queue_lock); + + return icq; + } + + return NULL; +} + #include "bfq-sched.c" #include "bfq-cgroup.c" @@ -1480,13 +1512,14 @@ static void bfq_add_request(struct request *rq) } static struct request *bfq_find_rq_fmerge(struct bfq_data *bfqd, - struct bio *bio) + struct bio *bio, + struct request_queue *q) { struct task_struct *tsk = current; struct bfq_io_cq *bic; struct bfq_queue *bfqq; - bic = bfq_bic_lookup(bfqd, tsk->io_context); + bic = bfq_bic_lookup(bfqd, tsk->io_context, q); if (!bic) return NULL;