Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp2435687rdb; Tue, 12 Sep 2023 01:30:23 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEbvmiiaQTLyWbg0Zi4vnFBfluNDXlUgwXMwA3Oi+IgnLM10DHcCNp3RcDLCIlnf8nfRd4x X-Received: by 2002:a05:6102:1da:b0:44d:6256:ac8b with SMTP id s26-20020a05610201da00b0044d6256ac8bmr8898880vsq.4.1694507423062; Tue, 12 Sep 2023 01:30:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694507423; cv=none; d=google.com; s=arc-20160816; b=LL523j8RgKnc1AbLXrqPBUNwuj7Zr3TIrsZBd/l+0+Fa/y4bf5Nt8p4ubtvugG5RNT XTydayhqMuCiig8ySIe9RvjophBbpKTCkfikAC7Mag2FpIdDPzcipJg1KiGdrr29NZda 4qzCiqzJ8/o3xaGV/NUzybSytxrWytyCfpPwYBFQytHMxN89cSLpkO1c7c+drgqimPyU 2rH4DKwHSwiB48DSzqDtvgGnx/lq2ZY78KNmnF06bOIHR7YXGoP31AQkuzAj+pyVIZV/ C0g1D0qFBdFKCxPihR6mzmrybma3a5ogxdYQVJR+Ou5dpbLNDsJHCywDgdkrWCI0TEpj j0QA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=7OoZjagsnZWH9lLtWUfejMd3Drnt5mNbnUM5nMobZ74=; fh=zMG4p95IGnwGUrpzY0dmoP/eMLWdPHtGdTRDuF+jFtI=; b=OSA8yf34+ryR+S4EAEv5oWa99+Sf1i3El3HkRYNwpBrTqa3MHHf327JP0gFDcVWoBp VnCDRc2w2kBH1BYL6o2ODZqMEJ2+wkE5JzNiYPtieM5rxbhBUDy/1wAZdMuuLru/mgrU 98z5lm7cL2Ex5H59jE1HQc1PQFPxj4E+ZQ8xDbhTSSdDz7wmYWUwkphNywSfBdUkskNS 3G4NE+jmcG3P3j0WKiSiWFX2Zd3rWktxwoZvwkzoR8eMpoLNxk3jQBFZqohERM2twjND BtDLaLVTk+YTnQHM5sPCqW8MEjsslHrLPPi5TqRDR0vZWwuTfH0X39t/Qxz8mLqckvmT K/NA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id w29-20020a63161d000000b0056949ba3f3fsi5832033pgl.253.2023.09.12.01.30.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Sep 2023 01:30:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id E488E80D6A32; Tue, 12 Sep 2023 01:26:07 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.8 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232520AbjILIZy (ORCPT + 99 others); Tue, 12 Sep 2023 04:25:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33244 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231725AbjILIZv (ORCPT ); Tue, 12 Sep 2023 04:25:51 -0400 Received: from us-smtp-delivery-44.mimecast.com (unknown [207.211.30.44]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 0DC2BB9 for ; Tue, 12 Sep 2023 01:25:47 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-621-cWlgkLV_OwuGzDlYigOlnA-1; Tue, 12 Sep 2023 04:25:11 -0400 X-MC-Unique: cWlgkLV_OwuGzDlYigOlnA-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 05089101FAB0; Tue, 12 Sep 2023 08:25:11 +0000 (UTC) Received: from fedora.brq.redhat.com (unknown [10.43.17.54]) by smtp.corp.redhat.com (Postfix) with ESMTP id F02ED40C6EA8; Tue, 12 Sep 2023 08:25:09 +0000 (UTC) From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Glozar?= To: nvdimm@lists.linux.dev Cc: dan.j.williams@intel.com, vishal.l.verma@intel.com, dave.jiang@intel.com, ira.weiny@intel.com, linux-kernel@vger.kernel.org, Tomas Glozar Subject: [PATCH] nd_btt: Make BTT lanes preemptible Date: Tue, 12 Sep 2023 10:24:40 +0200 Message-ID: <20230912082440.325189-1-tglozar@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Tue, 12 Sep 2023 01:26:08 -0700 (PDT) X-Spam-Status: No, score=0.5 required=5.0 tests=DKIM_ADSP_CUSTOM_MED, FORGED_GMAIL_RCVD,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email From: Tomas Glozar nd_region_acquire_lane uses get_cpu, which disables preemption. This is an issue on PREEMPT_RT kernels, since btt_write_pg and also nd_region_acquire_lane itself take a spin lock, resulting in BUG: sleeping function called from invalid context. Fix the issue by replacing get_cpu with smp_process_id and migrate_disable when needed. This makes BTT operations preemptible, thus permitting the use of spin_lock. Fixes: 5212e11fde4d ("nd_btt: atomic sector updates") Signed-off-by: Tomas Glozar --- drivers/nvdimm/region_devs.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/nvdimm/region_devs.c b/drivers/nvdimm/region_devs.c index 0a81f87f6f6c..e2f1fb99707f 100644 --- a/drivers/nvdimm/region_devs.c +++ b/drivers/nvdimm/region_devs.c @@ -939,7 +939,8 @@ unsigned int nd_region_acquire_lane(struct nd_region *nd_region) { unsigned int cpu, lane; - cpu = get_cpu(); + migrate_disable(); + cpu = smp_processor_id(); if (nd_region->num_lanes < nr_cpu_ids) { struct nd_percpu_lane *ndl_lock, *ndl_count; @@ -958,16 +959,15 @@ EXPORT_SYMBOL(nd_region_acquire_lane); void nd_region_release_lane(struct nd_region *nd_region, unsigned int lane) { if (nd_region->num_lanes < nr_cpu_ids) { - unsigned int cpu = get_cpu(); + unsigned int cpu = smp_processor_id(); struct nd_percpu_lane *ndl_lock, *ndl_count; ndl_count = per_cpu_ptr(nd_region->lane, cpu); ndl_lock = per_cpu_ptr(nd_region->lane, lane); if (--ndl_count->count == 0) spin_unlock(&ndl_lock->lock); - put_cpu(); } - put_cpu(); + migrate_enable(); } EXPORT_SYMBOL(nd_region_release_lane); -- 2.39.3