Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp830361pxb; Tue, 3 Nov 2020 13:47:02 -0800 (PST) X-Google-Smtp-Source: ABdhPJz1qyDkm8+OnkO9mpquLueW9mWrHK3ZF4In6sXcWNchEjt9Eti5Ct2Z6+c90gbmdXqHp86c X-Received: by 2002:a17:906:1989:: with SMTP id g9mr20854162ejd.62.1604440022699; Tue, 03 Nov 2020 13:47:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604440022; cv=none; d=google.com; s=arc-20160816; b=q+Fg2egpPxZChoMj+rLI+QR2IlxBH9z3EtJl72NrWAg41YDQ9nDXHz/qOoYwXfgrGR aTFeFwv6uDM7mY/05dmGC5XN8YvBHhUqVGGmhfAxfJ0FlHLvqEoBWPV15Pulgl9dWVA0 GhpA4HuMEqTq9BtRUzB2gOrZVAK2zUgftpu++qHwPXKzpzqBx3awOIpJXggk5EdBU2zx GSr9MKobCoqHnKTS1DI1P26ZZ9UOMB+OEtha0GN0DjgT0lMpgX51A721OGUHSsIHgJWd 5CuMS5w5MVeavfgUnYZbIHB6quhSilSoqMtKpVTad2HMOBV4U+awjshyrJulgBvUkLBQ Xztg== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=vvmgw+xTQB5ScuwJ60jeBdkB3y2V9BDFXB4PUbfWra0=; b=ov4dmFm67RekOQW1EacJ6EpywoimmRJ6ehwp6s64SN0NWY790t6o5OKZYaVknnnrih K/rx/Pks+FS0b3smXB5P2oWPn4V8i7OK/ECYAQumlOPBdlRRMSLNWCn+BV6fNGyaRcL9 UyncOppcEc4sQUHOD8+w3+qGIy7gC/fRdTqXVuvKcZPVeUbceTS+6GyOoF5QsM+Npq9V gI9gT2W7NSGwpdBMIEjm/NDRIvT4Q37PJc8Sgx11jSf1sMgQpJuPyWZ1BYNiqZSPwZay RbKNLUsgICKSz105AOYr4f+Sd6rrJaElUDgDjAwb0f08eKETnf0ifCHgWu7oxVoxaRUo FUgA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=a5dsg6Df; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i14si43851eje.464.2020.11.03.13.46.39; Tue, 03 Nov 2020 13:47:02 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-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=@kernel.org header.s=default header.b=a5dsg6Df; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730043AbgKCUyH (ORCPT + 99 others); Tue, 3 Nov 2020 15:54:07 -0500 Received: from mail.kernel.org ([198.145.29.99]:52554 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732500AbgKCUx5 (ORCPT ); Tue, 3 Nov 2020 15:53:57 -0500 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 4A95B22226; Tue, 3 Nov 2020 20:53:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604436836; bh=Zm9qkC2dHdQaGhe1HFL456FzcRb3htH+NmybWllhnUA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=a5dsg6DfpCmDRVN76zZiGZgP5d4UPnZ+Rxi+hT1vw5VdKwfHCyZ7YJWsyHzDDRfB/ z5v3BQJheB8G7F9Q73l9gNFTAvraFuY6WmerRtjdNUFisLnQL03w/giJVBx4R0XxY9 z4LoV2TOtOUfFo7D101uE0qvmArtsZlQCT7Qlr3o= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Julien Grall , Juergen Gross , Jan Beulich , Wei Liu Subject: [PATCH 5.4 005/214] xen/blkback: use lateeoi irq binding Date: Tue, 3 Nov 2020 21:34:13 +0100 Message-Id: <20201103203250.053115009@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201103203249.448706377@linuxfoundation.org> References: <20201103203249.448706377@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Juergen Gross commit 01263a1fabe30b4d542f34c7e2364a22587ddaf2 upstream. In order to reduce the chance for the system becoming unresponsive due to event storms triggered by a misbehaving blkfront use the lateeoi irq binding for blkback and unmask the event channel only after processing all pending requests. As the thread processing requests is used to do purging work in regular intervals an EOI may be sent only after having received an event. If there was no pending I/O request flag the EOI as spurious. This is part of XSA-332. Cc: stable@vger.kernel.org Reported-by: Julien Grall Signed-off-by: Juergen Gross Reviewed-by: Jan Beulich Reviewed-by: Wei Liu Signed-off-by: Greg Kroah-Hartman --- drivers/block/xen-blkback/blkback.c | 22 +++++++++++++++++----- drivers/block/xen-blkback/xenbus.c | 5 ++--- 2 files changed, 19 insertions(+), 8 deletions(-) --- a/drivers/block/xen-blkback/blkback.c +++ b/drivers/block/xen-blkback/blkback.c @@ -202,7 +202,7 @@ static inline void shrink_free_pagepool( #define vaddr(page) ((unsigned long)pfn_to_kaddr(page_to_pfn(page))) -static int do_block_io_op(struct xen_blkif_ring *ring); +static int do_block_io_op(struct xen_blkif_ring *ring, unsigned int *eoi_flags); static int dispatch_rw_block_io(struct xen_blkif_ring *ring, struct blkif_request *req, struct pending_req *pending_req); @@ -615,6 +615,8 @@ int xen_blkif_schedule(void *arg) struct xen_vbd *vbd = &blkif->vbd; unsigned long timeout; int ret; + bool do_eoi; + unsigned int eoi_flags = XEN_EOI_FLAG_SPURIOUS; set_freezable(); while (!kthread_should_stop()) { @@ -639,16 +641,23 @@ int xen_blkif_schedule(void *arg) if (timeout == 0) goto purge_gnt_list; + do_eoi = ring->waiting_reqs; + ring->waiting_reqs = 0; smp_mb(); /* clear flag *before* checking for work */ - ret = do_block_io_op(ring); + ret = do_block_io_op(ring, &eoi_flags); if (ret > 0) ring->waiting_reqs = 1; if (ret == -EACCES) wait_event_interruptible(ring->shutdown_wq, kthread_should_stop()); + if (do_eoi && !ring->waiting_reqs) { + xen_irq_lateeoi(ring->irq, eoi_flags); + eoi_flags |= XEN_EOI_FLAG_SPURIOUS; + } + purge_gnt_list: if (blkif->vbd.feature_gnt_persistent && time_after(jiffies, ring->next_lru)) { @@ -1121,7 +1130,7 @@ static void end_block_io_op(struct bio * * and transmute it to the block API to hand it over to the proper block disk. */ static int -__do_block_io_op(struct xen_blkif_ring *ring) +__do_block_io_op(struct xen_blkif_ring *ring, unsigned int *eoi_flags) { union blkif_back_rings *blk_rings = &ring->blk_rings; struct blkif_request req; @@ -1144,6 +1153,9 @@ __do_block_io_op(struct xen_blkif_ring * if (RING_REQUEST_CONS_OVERFLOW(&blk_rings->common, rc)) break; + /* We've seen a request, so clear spurious eoi flag. */ + *eoi_flags &= ~XEN_EOI_FLAG_SPURIOUS; + if (kthread_should_stop()) { more_to_do = 1; break; @@ -1202,13 +1214,13 @@ done: } static int -do_block_io_op(struct xen_blkif_ring *ring) +do_block_io_op(struct xen_blkif_ring *ring, unsigned int *eoi_flags) { union blkif_back_rings *blk_rings = &ring->blk_rings; int more_to_do; do { - more_to_do = __do_block_io_op(ring); + more_to_do = __do_block_io_op(ring, eoi_flags); if (more_to_do) break; --- a/drivers/block/xen-blkback/xenbus.c +++ b/drivers/block/xen-blkback/xenbus.c @@ -229,9 +229,8 @@ static int xen_blkif_map(struct xen_blki BUG(); } - err = bind_interdomain_evtchn_to_irqhandler(blkif->domid, evtchn, - xen_blkif_be_int, 0, - "blkif-backend", ring); + err = bind_interdomain_evtchn_to_irqhandler_lateeoi(blkif->domid, + evtchn, xen_blkif_be_int, 0, "blkif-backend", ring); if (err < 0) { xenbus_unmap_ring_vfree(blkif->be->dev, ring->blk_ring); ring->blk_rings.common.sring = NULL;