Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp5465208imm; Tue, 12 Jun 2018 08:13:20 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJu2wT5C0SOXfQY2eNc5Y1dLvjY9ghjpEOYjc+0BVn9Y3Y/h2T2Qh6MwahemT6Qpo/c+Mcx X-Received: by 2002:a63:6dce:: with SMTP id i197-v6mr672945pgc.215.1528816400858; Tue, 12 Jun 2018 08:13:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528816400; cv=none; d=google.com; s=arc-20160816; b=ZmbQDzJCxnAk6VnL4LF89CymwxQV1QmZkXZ7jyXwAsDmoxa+QBDcyZHkuCe0okCrLk C0YNvchxJTs5EWdcW0qp1mokaIzdAqPbyASz+bXWn8Bx4RRKyxsOJBxu2i08Y81rve8w 6AxvINnxgUtEqn+yM9IVaQWsNspng9gJS8rZyL3xIVyf4JNTtsvbgIzc+P45eTbYMBO3 S/GswXxQfzy3v8e9aeVe4nYorL4oPica2vNnuz8AmE8WhT3Y+0OikGmdBdnr3gnMm2D2 yDq89birdfSrt8pedB7kjAKzkuR1XjNGTx1DNojgY6NHRJGOIeM+BlRqep2Ygke/zLc3 1C+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:in-reply-to :subject:cc:to:from:date:arc-authentication-results; bh=EmGG5Rv7xbyDPqIroHAGURuwHWltQ0YKC4zwIem0CLc=; b=geaxXPeNCCThcDCkrwOvzNOVbENs0GG4n+u0EORJ2r0ei/LMcTmuHxHixEpLipRDak XbuodLN+O+bwyaCJjhLYrAz7uKNMCIQexELSIfOJ8xaK0QxtS2G25AJuoAP1OKKbv79m 4YBtlDra84ELM1pb9+nist+8jOZcYPiS2ZCWKLHaKDetgFUQfVoK6p2ivzIiDZzxxNba wy1RvD9zPbpap2E3oke2ID1NVOxW8zRyxgLx7qptV0h3QhLFmjPq/ajzcmBHMNnzbB0i zZs4SVN8PqX+RDZYkL34UMadNO83/yvcFRPrT0UPEoShExO4PmHJyo/8GcL+lZvMxIVY hWaw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y1-v6si230749pga.344.2018.06.12.08.13.06; Tue, 12 Jun 2018 08:13:20 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933970AbeFLPLd (ORCPT + 99 others); Tue, 12 Jun 2018 11:11:33 -0400 Received: from iolanthe.rowland.org ([192.131.102.54]:47118 "HELO iolanthe.rowland.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S932919AbeFLPLc (ORCPT ); Tue, 12 Jun 2018 11:11:32 -0400 Received: (qmail 3650 invoked by uid 2102); 12 Jun 2018 11:11:31 -0400 Received: from localhost (sendmail-bs@127.0.0.1) by localhost with SMTP; 12 Jun 2018 11:11:31 -0400 Date: Tue, 12 Jun 2018 11:11:31 -0400 (EDT) From: Alan Stern X-X-Sender: stern@iolanthe.rowland.org To: Mikulas Patocka cc: Greg Kroah-Hartman , Ming Lei , , Subject: Re: [PATCH] usb: don't offload isochronous urb completions to ksoftirq In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 12 Jun 2018, Mikulas Patocka wrote: > > > On Tue, 12 Jun 2018, Alan Stern wrote: > > > On Tue, 12 Jun 2018, Mikulas Patocka wrote: > > > > > I have a single-core machine with usb2 soundcard. When I increase mplayer > > > priority (to real-time or high non-realtime priority), the sound is > > > stuttering. The reason for the stuttering is that mplayer at high priority > > > preempts the softirq thread, preventing URBs from being completed. It was > > > caused by the patch 428aac8a81058 that offloads URB completion to softirq. > > > > > > This patch prevents offloading isochronous URBs to softirq to fix the > > > stuttering. > > > > How about just not running mplayer at such a high priority? > > I need to run mplayer at a high priority so that other work doesn't > preempt mplayer and cause stuttering. Think about this a little more... You _want_ the softirq thread to preempt mplayer. Or at least, you don't want mplayer to use so much CPU time that the softirq thread doesn't get a chance to run. > > Or raising the priority of the softirq thread? > > Do you want to coordinate that with the softirq maintainers? I don't know > if they would be happy to add an extra real-time softirq thread. How about making the softirq thread's priority adjustable? As for coordinating with the softirq maintainers -- whether I want to or not isn't the issue. Right now I don't have _time_ to do it. Alan Stern > > Alan Stern > > Mikulas > > > > Fixes: c04ee4b1136e ("Revert "Revert "USB: EHCI: support running URB giveback in tasklet context""") > > > Cc: stable@vger.kernel.org > > > > > > --- > > > drivers/usb/core/hcd.c | 10 ++++++++++ > > > drivers/usb/host/ehci-q.c | 11 ++++++++++- > > > include/linux/usb/hcd.h | 2 ++ > > > 3 files changed, 22 insertions(+), 1 deletion(-) > > > > > > Index: linux-4.17/drivers/usb/core/hcd.c > > > =================================================================== > > > --- linux-4.17.orig/drivers/usb/core/hcd.c 2018-06-12 16:06:23.000000000 +0200 > > > +++ linux-4.17/drivers/usb/core/hcd.c 2018-06-12 16:07:51.000000000 +0200 > > > @@ -1858,6 +1858,16 @@ void usb_hcd_giveback_urb(struct usb_hcd > > > } > > > EXPORT_SYMBOL_GPL(usb_hcd_giveback_urb); > > > > > > +void _usb_hcd_giveback_urb(struct usb_hcd *hcd, struct urb *urb, int status) > > > +{ > > > + /* pass status to tasklet via unlinked */ > > > + if (likely(!urb->unlinked)) > > > + urb->unlinked = status; > > > + > > > + __usb_hcd_giveback_urb(urb); > > > +} > > > +EXPORT_SYMBOL_GPL(_usb_hcd_giveback_urb); > > > + > > > /*-------------------------------------------------------------------------*/ > > > > > > /* Cancel all URBs pending on this endpoint and wait for the endpoint's > > > Index: linux-4.17/drivers/usb/host/ehci-q.c > > > =================================================================== > > > --- linux-4.17.orig/drivers/usb/host/ehci-q.c 2018-06-12 16:06:23.000000000 +0200 > > > +++ linux-4.17/drivers/usb/host/ehci-q.c 2018-06-12 16:09:28.000000000 +0200 > > > @@ -238,6 +238,8 @@ static int qtd_copy_status ( > > > > > > static void > > > ehci_urb_done(struct ehci_hcd *ehci, struct urb *urb, int status) > > > +__releases(ehci->lock) > > > +__acquires(ehci->lock) > > > { > > > if (usb_pipetype(urb->pipe) == PIPE_INTERRUPT) { > > > /* ... update hc-wide periodic stats */ > > > @@ -264,7 +266,14 @@ ehci_urb_done(struct ehci_hcd *ehci, str > > > #endif > > > > > > usb_hcd_unlink_urb_from_ep(ehci_to_hcd(ehci), urb); > > > - usb_hcd_giveback_urb(ehci_to_hcd(ehci), urb, status); > > > + if (usb_pipeisoc(urb->pipe)) { > > > + /* complete() can reenter this HCD */ > > > + spin_unlock(&ehci->lock); > > > + _usb_hcd_giveback_urb(ehci_to_hcd(ehci), urb, status); > > > + spin_lock(&ehci->lock); > > > + } else { > > > + usb_hcd_giveback_urb(ehci_to_hcd(ehci), urb, status); > > > + } > > > } > > > > > > static int qh_schedule (struct ehci_hcd *ehci, struct ehci_qh *qh); > > > Index: linux-4.17/include/linux/usb/hcd.h > > > =================================================================== > > > --- linux-4.17.orig/include/linux/usb/hcd.h 2018-06-05 21:07:27.000000000 +0200 > > > +++ linux-4.17/include/linux/usb/hcd.h 2018-06-12 16:07:11.000000000 +0200 > > > @@ -428,6 +428,8 @@ extern int usb_hcd_submit_urb(struct urb > > > extern int usb_hcd_unlink_urb(struct urb *urb, int status); > > > extern void usb_hcd_giveback_urb(struct usb_hcd *hcd, struct urb *urb, > > > int status); > > > +extern void _usb_hcd_giveback_urb(struct usb_hcd *hcd, struct urb *urb, > > > + int status); > > > extern int usb_hcd_map_urb_for_dma(struct usb_hcd *hcd, struct urb *urb, > > > gfp_t mem_flags); > > > extern void usb_hcd_unmap_urb_setup_for_dma(struct usb_hcd *, struct urb *); > > > -- > > > To unsubscribe from this list: send the line "unsubscribe linux-usb" in > > > the body of a message to majordomo@vger.kernel.org > > > More majordomo info at http://vger.kernel.org/majordomo-info.html > > > > > > > > > >