Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp5270819pxb; Mon, 15 Feb 2021 14:49:05 -0800 (PST) X-Google-Smtp-Source: ABdhPJw0WTmYQQMKuEBujrYjaUfEfzWoj2U1hCfc6iXdStUZ/T3jP4SuuR5j55ygDumO6DTP220f X-Received: by 2002:a05:6402:177b:: with SMTP id da27mr10101556edb.251.1613429344895; Mon, 15 Feb 2021 14:49:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613429344; cv=none; d=google.com; s=arc-20160816; b=EPmFuxKwidmdHiTiGW2wifE/wM84ItFLZ0lf8ZV0qkriwdyjvzvpRHwWuBW/flnWBP Uswg8u1N6D7sC5BnDj3S3msmu0Lxqa3uH6YgGi5Gd+Yw/sCIvlBswndL+2PJoAtmRucO V7E0hHkwJLVPbqIoTA6ECZTbC1tUXNI81TYJUklfdclTdHoJUFWtnKnCWkw92lEyNHPO 8dXUt6IflrTL4NIzISMyIEdOsK6L4TkvboB89yHNpQA80mZW+kj9cnHLLbexD763sGrG 0iL7TBbFQfgJvUw6nd/49xc1vPJqEgCrxzKlU17TnC33rZwz5VEA2godkKxxDHLk1POJ oaYQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:content-transfer-encoding :content-id:mime-version:from:subject:cc:to:references:in-reply-to :organization:dkim-signature; bh=siuHUtdQ6wlk6BrFE1gCfr6HqsnZ29fFXCRpUG5E5oE=; b=moxtUvZHyDp75Wty1Q/EBUa/rSKB67hzrDUNX4VV3StTPqswNcj6taZ9s9AzqMsnY/ NsfRvo4HPc14elDU99kGr+SrGspMsXTtnz+4cPj2wpY0yxvMF8nH0FpHWDmvZQOqgCjl 08w9VrI2OHBbBt2g9rFtUnsWJpTZlPqy24iLyK8LSyf+rTlaxK+GXJUQHaemv1sdPCNH yz2HwQjtv3/4On4absCENo616nrIPWf9Tg7/U4b0Jha9fsOCJPlAS3q+FWYrI3UGoGQt Nw2TvtWiCu7WRQW54H3YAaVRQcMyotfqdYdM1R3jzP5m5PRVkOEc7b4voegaV7W33iin j+0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="ityYQ/eO"; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y14si298898eds.573.2021.02.15.14.48.32; Mon, 15 Feb 2021 14:49:04 -0800 (PST) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="ityYQ/eO"; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229713AbhBOWsH (ORCPT + 99 others); Mon, 15 Feb 2021 17:48:07 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:45632 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229775AbhBOWsF (ORCPT ); Mon, 15 Feb 2021 17:48:05 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1613429198; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=siuHUtdQ6wlk6BrFE1gCfr6HqsnZ29fFXCRpUG5E5oE=; b=ityYQ/eOfIEQ9RMM3cqm9UL3DKROp0Sd1Znf1x08vb8zjtCjfhbTuQDYYMJ4SMfUKqiXTT MgcFBg9J1pdh0M+r7hBqoB0D7FNJ11SYYNO0tQpqgs0aFC6V/esB5JGpdiOUkxeSWtFWL5 J4tZ9eGOeyAPAzH7qDOje/esUcOvy3g= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-316-Wht9_IG0Ptu0_iui9ofi0w-1; Mon, 15 Feb 2021 17:46:34 -0500 X-MC-Unique: Wht9_IG0Ptu0_iui9ofi0w-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1F5B56DD22; Mon, 15 Feb 2021 22:46:32 +0000 (UTC) Received: from warthog.procyon.org.uk (ovpn-119-68.rdu2.redhat.com [10.10.119.68]) by smtp.corp.redhat.com (Postfix) with ESMTP id 187641F0; Mon, 15 Feb 2021 22:46:23 +0000 (UTC) Organization: Red Hat UK Ltd. Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SI4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 3798903 In-Reply-To: <161340385320.1303470.2392622971006879777.stgit@warthog.procyon.org.uk> References: <161340385320.1303470.2392622971006879777.stgit@warthog.procyon.org.uk> To: Trond Myklebust Cc: dhowells@redhat.com, Marc Dionne , Anna Schumaker , Steve French , Dominique Martinet , linux-cifs@vger.kernel.org, ceph-devel@vger.kernel.org, Jeff Layton , Matthew Wilcox , linux-cachefs@redhat.com, Alexander Viro , linux-mm@kvack.org, linux-afs@lists.infradead.org, v9fs-developer@lists.sourceforge.net, Christoph Hellwig , linux-fsdevel@vger.kernel.org, linux-nfs@vger.kernel.org, Jeff Layton , David Wysochanski , linux-kernel@vger.kernel.org Subject: [PATCH 34/33] netfs: Use in_interrupt() not in_softirq() From: David Howells MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1376937.1613429183.1@warthog.procyon.org.uk> Content-Transfer-Encoding: quoted-printable Date: Mon, 15 Feb 2021 22:46:23 +0000 Message-ID: <1376938.1613429183@warthog.procyon.org.uk> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org The in_softirq() in netfs_rreq_terminated() works fine for the cache being on a normal disk, as the completion handlers may get called in softirq context, but for an NVMe drive, the completion handler may get called in IRQ context. Fix to use in_interrupt() instead of in_softirq() throughout the read helpers, particularly when deciding whether to punt code that might sleep off to a worker thread. The symptom involves warnings like the following appearing and the kernel hanging: WARNING: CPU: 0 PID: 0 at kernel/softirq.c:175 __local_bh_enable_ip+0x35/= 0x50 ... RIP: 0010:__local_bh_enable_ip+0x35/0x50 ... Call Trace: rxrpc_kernel_begin_call+0x7d/0x1b0 [rxrpc] ? afs_rx_new_call+0x40/0x40 [kafs] ? afs_alloc_call+0x28/0x120 [kafs] afs_make_call+0x120/0x510 [kafs] ? afs_rx_new_call+0x40/0x40 [kafs] ? afs_alloc_flat_call+0xba/0x100 [kafs] ? __kmalloc+0x167/0x2f0 ? afs_alloc_flat_call+0x9b/0x100 [kafs] afs_wait_for_operation+0x2d/0x200 [kafs] afs_do_sync_operation+0x16/0x20 [kafs] afs_req_issue_op+0x8c/0xb0 [kafs] netfs_rreq_assess+0x125/0x7d0 [netfs] ? cachefiles_end_operation+0x40/0x40 [cachefiles] netfs_subreq_terminated+0x117/0x220 [netfs] cachefiles_read_complete+0x21/0x60 [cachefiles] iomap_dio_bio_end_io+0xdd/0x110 blk_update_request+0x20a/0x380 blk_mq_end_request+0x1c/0x120 nvme_process_cq+0x159/0x1f0 [nvme] nvme_irq+0x10/0x20 [nvme] __handle_irq_event_percpu+0x37/0x150 handle_irq_event+0x49/0xb0 handle_edge_irq+0x7c/0x200 asm_call_irq_on_stack+0xf/0x20 common_interrupt+0xad/0x120 asm_common_interrupt+0x1e/0x40 ... Reported-by: Marc Dionne Signed-off-by: David Howells cc: Matthew Wilcox cc: linux-mm@kvack.org cc: linux-cachefs@redhat.com cc: linux-afs@lists.infradead.org cc: linux-nfs@vger.kernel.org cc: linux-cifs@vger.kernel.org cc: ceph-devel@vger.kernel.org cc: v9fs-developer@lists.sourceforge.net cc: linux-fsdevel@vger.kernel.org --- read_helper.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/fs/netfs/read_helper.c b/fs/netfs/read_helper.c index 9191a3617d91..db582008b4bd 100644 --- a/fs/netfs/read_helper.c +++ b/fs/netfs/read_helper.c @@ -96,7 +96,7 @@ static void netfs_free_read_request(struct work_struct *= work) static void netfs_put_read_request(struct netfs_read_request *rreq) { if (refcount_dec_and_test(&rreq->usage)) { - if (in_softirq()) { + if (in_interrupt()) { rreq->work.func =3D netfs_free_read_request; if (!queue_work(system_unbound_wq, &rreq->work)) BUG(); @@ -353,7 +353,7 @@ static void netfs_rreq_write_to_cache_work(struct work= _struct *work) = static void netfs_rreq_write_to_cache(struct netfs_read_request *rreq) { - if (in_softirq()) { + if (in_interrupt()) { rreq->work.func =3D netfs_rreq_write_to_cache_work; if (!queue_work(system_unbound_wq, &rreq->work)) BUG(); @@ -479,7 +479,7 @@ static bool netfs_rreq_perform_resubmissions(struct ne= tfs_read_request *rreq) { struct netfs_read_subrequest *subreq; = - WARN_ON(in_softirq()); + WARN_ON(in_interrupt()); = trace_netfs_rreq(rreq, netfs_rreq_trace_resubmit); = @@ -577,7 +577,7 @@ static void netfs_rreq_work(struct work_struct *work) static void netfs_rreq_terminated(struct netfs_read_request *rreq) { if (test_bit(NETFS_RREQ_INCOMPLETE_IO, &rreq->flags) && - in_softirq()) { + in_interrupt()) { if (!queue_work(system_unbound_wq, &rreq->work)) BUG(); } else {