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: 9560735 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 733E76047A for ; Tue, 7 Feb 2017 17:25:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6653F28420 for ; Tue, 7 Feb 2017 17:25:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5B0252842C; Tue, 7 Feb 2017 17:25:30 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1024128420 for ; Tue, 7 Feb 2017 17:25:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755380AbdBGRZ2 (ORCPT ); Tue, 7 Feb 2017 12:25:28 -0500 Received: from mail-wm0-f48.google.com ([74.125.82.48]:36723 "EHLO mail-wm0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755484AbdBGRZ0 (ORCPT ); Tue, 7 Feb 2017 12:25:26 -0500 Received: by mail-wm0-f48.google.com with SMTP id c85so170328960wmi.1 for ; Tue, 07 Feb 2017 09:25:24 -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=o+ND/fgmvp4eaNmyKlNQ24nhz2G7kkuoIiyVfFg7U5rZjwqUtUEEQoSREX7HPskAjx YLMoFpmvdk3f9VfpBlBpoJPtxT1GbpTAL6xRryDu+ZvLrXAQ46dO2gP2xmcqhcsa+evW UoNcFNbaLLTp9qPMKNvEnjb9B6mtwGkeSngCuPaIlrxdUgYOgrAJfJ30sUwP/i5mwU1/ bJPluD2ApPd+22tu7c20RZMT1M+6dFiSOCpCbSd2FO9JHcP2dE3+QSfwRrw68URvWsfZ t1P3NpReSdyoyWpuKmr1YNh7ivoB8lrApPEUrK9QIXyZgThlIyKmSuFCsK6RB1LUWFI/ QJPQ== X-Gm-Message-State: AMke39mdzsUYMq7IBURFW1p0Ymser+ygoc3tWb+ku4aha1WMBrgPwuTXLEuGLKT5Uut063IU 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-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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(-) 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;