From patchwork Sat Feb 20 07:52:40 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Matias_Bj=C3=B8rling?= X-Patchwork-Id: 8365921 Return-Path: X-Original-To: patchwork-linux-block@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 20CEEC0553 for ; Sat, 20 Feb 2016 07:54:44 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 39B2420513 for ; Sat, 20 Feb 2016 07:54:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4FB2120511 for ; Sat, 20 Feb 2016 07:54:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1947508AbcBTHyZ (ORCPT ); Sat, 20 Feb 2016 02:54:25 -0500 Received: from mail-wm0-f50.google.com ([74.125.82.50]:38573 "EHLO mail-wm0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758131AbcBTHwx (ORCPT ); Sat, 20 Feb 2016 02:52:53 -0500 Received: by mail-wm0-f50.google.com with SMTP id a4so99040859wme.1 for ; Fri, 19 Feb 2016 23:52:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bjorling.me; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-type:content-transfer-encoding; bh=B4vh7IFaiq1SzPksBuEINn5CZ83Oy5fuDs6zdf7Ss4c=; b=yeYhgYO0EopW9IJoqkci8UpxmUaqfDMwPFlkKYQwMrS3mu3krhJPtZZZ/wkxPm5Pk4 BUKo6caCzWPmHchbIhRdaZH6eh2nTwwknUDNpvgCzUoLD2RNpJcNJICmnrE1fv1KE+3F UAPwvcIF62cM5wACJgVG9R9EISyIuHs9nF5B0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-type:content-transfer-encoding; bh=B4vh7IFaiq1SzPksBuEINn5CZ83Oy5fuDs6zdf7Ss4c=; b=TXq/SnfRBk1FY/fzmKAXmMrfukdFgmuL0M4k1BivYRkl4V4aeu0N1v1mKE/oxEzW77 uaUVXAiRVtjoq6Tp9TXpKq0cTLMSO4JAoRkPgzY2iTfKgsxtotXbEWpXsk7qg4P+e24B hMR+yi2JkH3LN6gxge8YDY5XtEWJjhbVNPDZH1LfsXj3FEemcacX/3w4pIZ7DRrA9FAN h1eD0kNB/Lg1lG0vnvHEFKngiizOFXk6k7vCRSr21DlshwxU/7lsbnbKs3tiXbts2Z1E ZZv73G6w8YqhP4lgY7kMMeMImmcKSOkitVLLWErIhyqDXSd7INOFaIrfALQbzGnC8E2B 4WVg== X-Gm-Message-State: AG10YOQbvAw/iYvXeNwau9fGDRZOchu/1kdw6hTfv3EiYzzPBmLIpgfElZ165FQSDoostw== X-Received: by 10.194.85.193 with SMTP id j1mr17220962wjz.122.1455954772684; Fri, 19 Feb 2016 23:52:52 -0800 (PST) Received: from localhost.localdomain (6164198-cl69.boa.fiberby.dk. [193.106.164.198]) by smtp.gmail.com with ESMTPSA id h132sm10904633wmf.9.2016.02.19.23.52.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 19 Feb 2016 23:52:51 -0800 (PST) From: =?UTF-8?q?Matias=20Bj=C3=B8rling?= To: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, axboe@fb.com Cc: =?UTF-8?q?Javier=20Gonz=C3=A1lez?= , =?UTF-8?q?Matias=20Bj=C3=B8rling?= Subject: [PATCH 1/4] lightnvm: update closed list outside of intr context Date: Sat, 20 Feb 2016 08:52:40 +0100 Message-Id: <1455954763-7880-2-git-send-email-m@bjorling.me> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1455954763-7880-1-git-send-email-m@bjorling.me> References: <1455954763-7880-1-git-send-email-m@bjorling.me> MIME-Version: 1.0 Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Javier González When an I/O finishes, full blocks are moved from the open to the closed list - a lock is taken to protect the list. This happens at the moment in the interrupt context, which is not correct. This patch moves this logic to the block workqueue instead, avoiding holding a spinlock without interrupt save in an interrupt context. Signed-off-by: Javier González Fixes: ff0e498bfa18 ("lightnvm: manage open and closed blocks sepa...") Signed-off-by: Matias Bjørling --- drivers/lightnvm/rrpc.c | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/drivers/lightnvm/rrpc.c b/drivers/lightnvm/rrpc.c index 307db1e..b7ddfb3 100644 --- a/drivers/lightnvm/rrpc.c +++ b/drivers/lightnvm/rrpc.c @@ -499,12 +499,21 @@ static void rrpc_gc_queue(struct work_struct *work) struct rrpc *rrpc = gcb->rrpc; struct rrpc_block *rblk = gcb->rblk; struct nvm_lun *lun = rblk->parent->lun; + struct nvm_block *blk = rblk->parent; struct rrpc_lun *rlun = &rrpc->luns[lun->id - rrpc->lun_offset]; spin_lock(&rlun->lock); list_add_tail(&rblk->prio, &rlun->prio_list); spin_unlock(&rlun->lock); + spin_lock(&lun->lock); + lun->nr_open_blocks--; + lun->nr_closed_blocks++; + blk->state &= ~NVM_BLK_ST_OPEN; + blk->state |= NVM_BLK_ST_CLOSED; + list_move_tail(&rblk->list, &rlun->closed_list); + spin_unlock(&lun->lock); + mempool_free(gcb, rrpc->gcb_pool); pr_debug("nvm: block '%lu' is full, allow GC (sched)\n", rblk->parent->id); @@ -668,20 +677,8 @@ static void rrpc_end_io_write(struct rrpc *rrpc, struct rrpc_rq *rrqd, lun = rblk->parent->lun; cmnt_size = atomic_inc_return(&rblk->data_cmnt_size); - if (unlikely(cmnt_size == rrpc->dev->pgs_per_blk)) { - struct nvm_block *blk = rblk->parent; - struct rrpc_lun *rlun = rblk->rlun; - - spin_lock(&lun->lock); - lun->nr_open_blocks--; - lun->nr_closed_blocks++; - blk->state &= ~NVM_BLK_ST_OPEN; - blk->state |= NVM_BLK_ST_CLOSED; - list_move_tail(&rblk->list, &rlun->closed_list); - spin_unlock(&lun->lock); - + if (unlikely(cmnt_size == rrpc->dev->pgs_per_blk)) rrpc_run_gc(rrpc, rblk); - } } }