Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp3848985pxb; Tue, 17 Nov 2020 05:20:02 -0800 (PST) X-Google-Smtp-Source: ABdhPJzwfhCpVOvX0lupROre2gXVOCmsmAiU/18L5gbWr7v6Nxwyv/JF9G0VL0KvRtrLraKRfQ5E X-Received: by 2002:a17:906:cb2:: with SMTP id k18mr20850197ejh.71.1605619202298; Tue, 17 Nov 2020 05:20:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605619202; cv=none; d=google.com; s=arc-20160816; b=mN92wwRJj8FWe33WB9CZVvEetJhFVVtG2RY9M7AV1DW0I0qvIlOfgGrnK6ZGUyoj7r bvaqORL8i2tz3bwDrKoSzHzHVRbfmcMIyCluI8SYhh58AlgMVgjLgown/B2XP5RUNq+e DwSd5O2aL/o+T1poPFNSrJ3dUjPTP0TsbH/0LqeZnaXbYWLN7d6nHiBg/aE7RJDDOph0 UeHPxhRJuQCYr7VJQPBOfbFeyUtELZTxvameqVLVnn7XmijgiR8rc32ZmOqNTGjm4YRE k8NqesG5mZxwG9lRdN41D923ACEOaumgtYkl8CjOXBV9TXbj/6zy2ch+oEmX68EZ3Uxw Ujgg== 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=zMuPmuh3qVPEyPFLJW0c7LIphT84wIA7Wc2W/xhACCI=; b=ozfhCorTVJCeDuRFiqGyu7X3tVlj6+xGE36UdtLMCgXhvfmZSsRUe923nQX+VSR1CB +jWLqJUnm49GezGcRF3XqozjZ5NfQ6H8mUdWcJKwh5yer4t0JJHzK/STz4aY9dSPvgWs /55jwidV0Lh7vFZOkq88XCuKVEd4pygOz2f3jc8zkhED1XHvgVM65H2N5BTDeQyKakAS scPuKfmCJy4wM/RcIRe82DCQTOWpQYqpcrgFWUe14yavTVaYSSqjeddVWef8xX0iifZd 7W5sQoxe1rkp5AczL7BkAx6I3mYd+O9Cksoaxtk0ihjIh4sCZRh4P7Mg3ygUSD3EUk2g M4/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=1ewpEWFT; 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 s20si16449922eji.711.2020.11.17.05.19.38; Tue, 17 Nov 2020 05:20: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=1ewpEWFT; 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 S1730563AbgKQNR2 (ORCPT + 99 others); Tue, 17 Nov 2020 08:17:28 -0500 Received: from mail.kernel.org ([198.145.29.99]:49382 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730529AbgKQNRP (ORCPT ); Tue, 17 Nov 2020 08:17:15 -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 2ABBF241A5; Tue, 17 Nov 2020 13:17:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1605619034; bh=MMnO4sjRiKkTxWezw4rX+lA7iqfPOga9KpZqGnhN6KY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1ewpEWFTJ+bnQSKkDwmBTmY0J+rnas9whQb04OjJb7dbfW/7a2DFC7ioYpJPfjogr L6q6jI2Mr6PQ+IwEkP8s63uIYcaqvPcsy2Wi6JUhuKdZQ5YeDuHQ7rvMeLYPWwCPUe zTuUmNWjLHpSY32/PmZgIpjGe2DDTtWI21TA3a84= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Greg Kroah-Hartman , Julien Grall , Juergen Gross , Jan Beulich , Wei Liu Subject: [PATCH 4.14 73/85] xen/blkback: use lateeoi irq binding Date: Tue, 17 Nov 2020 14:05:42 +0100 Message-Id: <20201117122114.618028230@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201117122111.018425544@linuxfoundation.org> References: <20201117122111.018425544@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 @@ -183,7 +183,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); @@ -608,6 +608,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()) { @@ -632,16 +634,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)) { @@ -1114,7 +1123,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; @@ -1137,6 +1146,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; @@ -1195,13 +1207,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 @@ -236,9 +236,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;