From patchwork Mon Jan 25 11:58:33 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?UTF-8?q?Javier=20Gonz=C3=A1lez?= X-Patchwork-Id: 8107891 Return-Path: X-Original-To: patchwork-linux-block@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 3B1389F440 for ; Mon, 25 Jan 2016 11:59:06 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6FB2F201CE for ; Mon, 25 Jan 2016 11:59:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 962DE201B9 for ; Mon, 25 Jan 2016 11:59:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932203AbcAYL6o (ORCPT ); Mon, 25 Jan 2016 06:58:44 -0500 Received: from mail-wm0-f48.google.com ([74.125.82.48]:34084 "EHLO mail-wm0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932400AbcAYL6j (ORCPT ); Mon, 25 Jan 2016 06:58:39 -0500 Received: by mail-wm0-f48.google.com with SMTP id u188so62685570wmu.1 for ; Mon, 25 Jan 2016 03:58:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lightnvm-io.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:mime-version:content-type :content-transfer-encoding; bh=ayuVYuVvQjzGmQGywrZ7iVrVKbHpFXVSwp7jURhuDno=; b=GIrKQrLPoJqjiIUaCfFrVlaxSC30D7z1ehy/443aOT5HWTfPfLtbzWMV7E+OUkNyHO BPbgYhtUxZnIp1C5LgnUSixLOpSwsqczahhZTm4lwfFqzf9OiruDefcmAtJcHR65ww6a BmHMrg4aRdg3NQTYxBpWxSUYNwT/RgIYvASANZFeuFJ7bkTk1Q73EJ01rkWcQGOjM6aF 4lhXtI/B6+RG/+oNA34BHCr77nx1cbYsXLxoE8XoomkXilUMqru269W/ArTPNDY0FpKg gU1Vl4aHAg9NpOlmqrkIsWd+l43HL76vFY2R3Wnt8IE+vhaLaTGDiE12dqXDZ9f30lis SO8Q== 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:mime-version :content-type:content-transfer-encoding; bh=ayuVYuVvQjzGmQGywrZ7iVrVKbHpFXVSwp7jURhuDno=; b=QV17vxcuuUHPoU5Y7gGPOmuQDUrtNFd6HszgBw4UM+I3AVL/FTfOeKq/2ZvUiWBsds 7ko+e/G2rdRpXStsnk+nrlymIiO2mKZo5GRACzNkGh7UdN36RQukGVCXRSb0T6byPMlb xqax/RCcy9Tln1UK/Zyh25dl/j+sWwDVERjvzoQtxkVTS1Gmzi/+w8W/SiziC7DkwW9x W0vmv7wIYcNSuVoq18BbgsUDRcZpAm0s10QciWbEhnRl9l5612e6ZmpB0buGDib9x62Z XhJT46T+ggRyFzjV7YJO6ppsFQxieR4Eq+FnaTX5Yhnki/bznDvk1ley+LaYACIhau0o vDNw== X-Gm-Message-State: AG10YOTGZ85QhRhAyQs8qJWq6ekMS3825jW087QmrLqTORo1ZJhByc5pT47Ou1jHVsClrg== X-Received: by 10.194.250.39 with SMTP id yz7mr19036958wjc.92.1453723118591; Mon, 25 Jan 2016 03:58:38 -0800 (PST) Received: from localhost.localdomain (6164198-cl69.boa.fiberby.dk. [193.106.164.198]) by smtp.gmail.com with ESMTPSA id e198sm15987106wmd.0.2016.01.25.03.58.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 25 Jan 2016 03:58:38 -0800 (PST) From: "=?UTF-8?q?Javier=20Gonz=C3=A1lez?=" X-Google-Original-From: =?UTF-8?q?Javier=20Gonz=C3=A1lez?= To: mb@lightnvm.io Cc: linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, =?UTF-8?q?Javier=20Gonz=C3=A1lez?= Subject: [PATCH] lightnvm: update closed list out of interrupt context Date: Mon, 25 Jan 2016 12:58:33 +0100 Message-Id: <1453723113-30664-1-git-send-email-javier@javigon.com> X-Mailer: git-send-email 2.1.4 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 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 GC workqueue instead, thus avoiding holding a spinlock in an atomic context. Signed-off-by: Javier González --- 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 d8c7595..e2710da 100644 --- a/drivers/lightnvm/rrpc.c +++ b/drivers/lightnvm/rrpc.c @@ -497,12 +497,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); @@ -666,20 +675,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); - } } }