From patchwork Tue Oct 3 13:48:44 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans Holmberg X-Patchwork-Id: 9982907 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 8A896602B8 for ; Tue, 3 Oct 2017 13:51:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7D7CB285CC for ; Tue, 3 Oct 2017 13:51:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7228A287BE; Tue, 3 Oct 2017 13:51:36 +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=-6.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,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 1FF1E285CC for ; Tue, 3 Oct 2017 13:51:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751987AbdJCNvV (ORCPT ); Tue, 3 Oct 2017 09:51:21 -0400 Received: from mail-wm0-f44.google.com ([74.125.82.44]:49561 "EHLO mail-wm0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751719AbdJCNvR (ORCPT ); Tue, 3 Oct 2017 09:51:17 -0400 Received: by mail-wm0-f44.google.com with SMTP id b189so12981769wmd.4 for ; Tue, 03 Oct 2017 06:51:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=owltronix-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=c97nOmI/7vPZFkdaXiBO5oZzrrzxOyAGaIvq0bf3uBQ=; b=0TCT2C7oPEqsSO7yZd/JziOluXrq40Mw//TdLTJizgX/pbZo9qe4woudyqVuyvw1Ug nwe5KR65siXcsY0ewQL6NRlOa28pkiHw3eR/jVv/pBYSPKj9+2tqpK26RcjXyVt2viQD efm1UwqXWrdkaKQ6xUTo9u7DJHMDCKS1wmdmbkPmtL0MieSH3CSkhcYQMwudDud2FH0J l3jPewbfs9/28+80sqM+aPHZbcC2hZIXRBYmljUEnxgoUgI+EgwuR1bNGNTjg/qh4ALK OYqkIsjIKuOu3uU9pnLWrcKsbhyNgyzl0GVmHoDDdZN0lmkvoWUpTotj06GQIDRbyZtD mnpQ== 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; bh=c97nOmI/7vPZFkdaXiBO5oZzrrzxOyAGaIvq0bf3uBQ=; b=lcyNYb+7wDmyxouv+oM7y8tlOGNNU2GHT/L+Pv3eRhznCk1hkCUPiMwUFB6Xo1/hw1 UHHpuOanmlVcVhT5CAvsrMvHyw9c88NELUdDEBr4X3lKAoohjVpzpOkRvqv4D+Uw2GtX 52g4pUNWmIliTkmOvzw/OQO1PmP0jzXcCK8nfmUmU5xZgHX+O8IFDDa+zfq4YQYJzWz/ CaFBPoMWS6iNC62T5PRum0Yuuu/1kJbTdziMaHEBXm7hEV1hNLEUKs5ZHCrsknv6mMs8 cwx6K6VpZFVJlMnzu3Xy6G+qPNE0kBi6gmimRxBwPfE6VH/VVF0Ci5c5weG6YpP2Sd3Q Lu6w== X-Gm-Message-State: AHPjjUiS/Mfd3pzTGF62rcmSF/biIpbWl9e2tCGdv02DWsyroR64sRFz 5oX3Nx3VJS/HLmecAiRWvvtzmg== X-Google-Smtp-Source: AOwi7QCq4xNnm5Xd5JD63ezc7SFYXE7bnma2g4TjaQiT6tssn798HVuZR4IXFm2Z7kNABl//k+JHLA== X-Received: by 10.80.208.208 with SMTP id g16mr24043403edf.246.1507038676045; Tue, 03 Oct 2017 06:51:16 -0700 (PDT) Received: from titan.cnexlabs.com (6164211-cl69.boa.fiberby.dk. [193.106.164.211]) by smtp.gmail.com with ESMTPSA id j6sm7435290edj.58.2017.10.03.06.51.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 03 Oct 2017 06:51:15 -0700 (PDT) From: Hans Holmberg To: Matias Bjorling Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, Javier Gonzales , Andrey Ryabinin , Christoph Hellwig , Hans Holmberg Subject: [PATCH] lightnvm: pblk: use vfree_atomic when freeing line metadata Date: Tue, 3 Oct 2017 15:48:44 +0200 Message-Id: <1507038524-24587-1-git-send-email-hans.ml.holmberg@owltronix.com> X-Mailer: git-send-email 2.7.4 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 From: Hans Holmberg The commit bf22e37a6413 ("mm: add vfree_atomic()") made vfree unsafe to call in atomic context (unless the call came from an interrupt) and introduced vfree_atomic that is safe to call in atomic context. So, since we're holding locks when freeing line metadata, we need to use the atomic version of vfree. Fix this by introducing an atomic variant of pblk_mfree and switching to that in pblk_line_meta_free. Signed-off-by: Hans Holmberg --- The patch is for: https://github.com/OpenChannelSSD/linux branch for-4.15/pblk drivers/lightnvm/pblk-init.c | 3 ++- drivers/lightnvm/pblk.h | 8 ++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/lightnvm/pblk-init.c b/drivers/lightnvm/pblk-init.c index c452478..3a191a6 100644 --- a/drivers/lightnvm/pblk-init.c +++ b/drivers/lightnvm/pblk-init.c @@ -396,7 +396,8 @@ static void pblk_line_meta_free(struct pblk *pblk) spin_lock(&l_mg->free_lock); for (i = 0; i < PBLK_DATA_LINES; i++) { kfree(l_mg->sline_meta[i]); - pblk_mfree(l_mg->eline_meta[i]->buf, l_mg->emeta_alloc_type); + pblk_mfree_atomic(l_mg->eline_meta[i]->buf, + l_mg->emeta_alloc_type); kfree(l_mg->eline_meta[i]); } spin_unlock(&l_mg->free_lock); diff --git a/drivers/lightnvm/pblk.h b/drivers/lightnvm/pblk.h index 03965da..93f98e3 100644 --- a/drivers/lightnvm/pblk.h +++ b/drivers/lightnvm/pblk.h @@ -881,6 +881,14 @@ static inline void pblk_mfree(void *ptr, int type) vfree(ptr); } +static inline void pblk_mfree_atomic(void *ptr, int type) +{ + if (type == PBLK_KMALLOC_META) + kfree(ptr); + else + vfree_atomic(ptr); +} + static inline struct nvm_rq *nvm_rq_from_c_ctx(void *c_ctx) { return c_ctx - sizeof(struct nvm_rq);