Received: by 2002:a05:6622:f08:0:0:0:0 with SMTP id l8csp4479159ivc; Tue, 3 Nov 2020 13:06:23 -0800 (PST) X-Google-Smtp-Source: ABdhPJwG1K+OQN+4iesG9ZhpzXSWTtcP9/3onCx06bLoMHTdI38Jlyh9StPLlE5kq4GoE46/kagC X-Received: by 2002:a17:907:2110:: with SMTP id qn16mr22614462ejb.133.1604437583031; Tue, 03 Nov 2020 13:06:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604437583; cv=none; d=google.com; s=arc-20160816; b=Pu+6cu6PFHYhYVqaxiHZwbVomXLv0tCCsYqgxHlEouNbwEies0WtLNfVO9C6g6huZP tsHrJR2Pcl72KE4N6bqypHQnW1orxgBOIxFonx6P4CchyGWCs6CxnBKq2eYJUDdwnC5b GY1SWUyU46nW0cIm8H1/IzdKxrOizSGbdvO1V3aEmeUgtTUcRevKRJ89Q02otp2lxsuf +RZEC0jhmcjlbRxizjFeZKKiELfAFN2ZBhB0o2hN+9fd1ROAwO2fVbuMBx3gI7/aQWwy txgvQNPyXqs2Kkj9FySBpsadMo9t8IgHh5KwC7omte/LHEZTbEEPVAdwjr+HfcHPMTGN wtNg== 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=ZqM7lU1GAvf90d8V2jqvKWqtxVlQvfGweR/I+HpEjmk=; b=TmsFaooG+At96L5oRtvAdkfI+LgfVSm+3RvigRBPYgdzLDPylIgMbxr9ty2WK/FO3F jbygZxQY4uIckVuuu9BU3T5pLardBOeeqXs9IoaM8zxRj5oxVgtAKT9IQyELEbFdSYSu dUdYaeW8eaFB7MKqZHrt2czee1QFGCSoss85pj0Idq9TR+7MdLJtTOgikjUr05EQejti PdzNrSiBw/EmMSDiVZni7OUlrm+tLnHMdebeDRNDq2+V5vF+P9XMN6jYcUMXXgBI4iMb vqs88vz9D3Qu86AL8nG6UsHDBp6NGrUCU54riArmb3AQPWRjOoJQl0ouKOfMVt1ElEB0 igxQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ViANxWue; 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 r10si12485422edm.139.2020.11.03.13.05.59; Tue, 03 Nov 2020 13:06:23 -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=ViANxWue; 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 S1731095AbgKCVCp (ORCPT + 99 others); Tue, 3 Nov 2020 16:02:45 -0500 Received: from mail.kernel.org ([198.145.29.99]:39806 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387653AbgKCVCj (ORCPT ); Tue, 3 Nov 2020 16:02:39 -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 D922D21534; Tue, 3 Nov 2020 21:02:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604437358; bh=T9+xxC5TCgyryiMAlfc6SyUDb0yWAdd9BZx29ZkOeW0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ViANxWueOIPXaSjpckYT9wb+GxSxOmMjtnX5vFX/8Bo6LCEEPzv8t+XLZwOW1BJRd 3srEZewm84SNgt0THlxLtUibnt5f0HXAojO1fpoEZL2qD0E4d+7NN27pFCBwx+xL+V akxqWBjscD6ofbhUhwOMNWUpL0jZpgUdSBw32b4M= 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 4.19 041/191] xen/blkback: use lateeoi irq binding Date: Tue, 3 Nov 2020 21:35:33 +0100 Message-Id: <20201103203238.025538834@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201103203232.656475008@linuxfoundation.org> References: <20201103203232.656475008@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 @@ -237,9 +237,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;