Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp1059010imm; Fri, 15 Jun 2018 10:29:39 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKya0tA0zAGbK4JN7N1Yqh1OjVutQOMlJo8ZCofkzHMe+Ltjk0GZ9DhcPZoj2dQYIFg7W0w X-Received: by 2002:a62:1013:: with SMTP id y19-v6mr2911848pfi.166.1529083779098; Fri, 15 Jun 2018 10:29:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529083779; cv=none; d=google.com; s=arc-20160816; b=ci2YqbHkIsZqmaVNQ+0Odv3G83lSSlh1KAaJlUc+shmKyoU9nbg+i/Y8Nuomxdcr53 eTiOEbdvCjT9h6E1F0pyVB7vyZ7dk/2al43sXgwZSqVBpj1heTdaN+mtaZFIwQocyIkG G44TyqSMvS5qE4eD2ezNsVBE6V0AT8JW3XxJSuIKDKUGKHu9fJP8PYZ2oBJvIRrrUEQ/ iKvY1kZMEkpY9uIgampE25dSLndOTTtG3wyYNLrnMZ0aGa1E1DvBK5W8fLHff2TY1qw2 5m3YwtRgKkPwkjzoHTMNxv5zuHDeDoKGruoIplinAr9Ut0Z2TQzGtZ/15c8+RpbBunG2 QeRg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date :arc-authentication-results; bh=TyXWcpLNGkeE5HogdbQ5iG1JND2K9cS5n2vwOKCfoj0=; b=omKBGas0FkcyAjI3I5uk6ME2NIOsbioavyNWhQaXvNDa6T/o9pecFkSeEQPDV1/4yX 3cZEqaiP2Bu+Jx6OlWjZsOdLQmZx00W2/zrJpV9GM04+uQ5Azd9TkI5PsJyvuR09bvdP 5oDpzL74/AOdVTfFDwL6T1fomLS4C57ZNJLdXPL24yHmhngDDxuErae5sMJlzfnvnJxh iO9rA42dCotNNUKGNRNylh0lxHxYxDMBYRbM0IUCUiISFXQ5guj+1hO0okcZrqLI1lAo y27zSsj7/gyDuUkLcu+yfbshuwixEmRtBR6Th6+0Oii5PfrJpjhtpeGM3qcZ2v8xwsWx LzrQ== 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 b12-v6si6714930pgn.308.2018.06.15.10.29.24; Fri, 15 Jun 2018 10:29:39 -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 S966059AbeFOR2m (ORCPT + 99 others); Fri, 15 Jun 2018 13:28:42 -0400 Received: from Galois.linutronix.de ([146.0.238.70]:51240 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S936136AbeFOR2l (ORCPT ); Fri, 15 Jun 2018 13:28:41 -0400 Received: from p4fea482e.dip0.t-ipconnect.de ([79.234.72.46] helo=nanos) by Galois.linutronix.de with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1fTsWY-0004iF-SO; Fri, 15 Jun 2018 19:28:35 +0200 Date: Fri, 15 Jun 2018 19:28:34 +0200 (CEST) From: Thomas Gleixner To: Alan Stern cc: Mikulas Patocka , Steven Rostedt , Ming Lei , Greg Kroah-Hartman , USB list , Kernel development list , Sebastian Sewior Subject: Re: High-priority softirqs [was: [PATCH] usb: don't offload isochronous urb completions to ksoftirq] In-Reply-To: Message-ID: References: User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 15 Jun 2018, Alan Stern wrote: > On Fri, 15 Jun 2018, Mikulas Patocka wrote: > > > I think the major problem (in the upstream kernel) with softirq latency is > > this: > > static inline void invoke_softirq(void) > > { > > if (ksoftirqd_running()) > > return; > > > > It means that if any piece of code kicks ksoftirq, no tasklets are > > processed in the irq context at all. > > > > So, the ehci callbacks will be offloaded to ksoftirqd (no matter how small > > they are) and this causes audio skipping. Could this be changed, so that > > it processes tasklets submitted with "tasklet_hi_schedule" in irq context > > even if ksoftirqd is running? > > That's a great question. Basically you're asking to have the HI > softirq always handled in the bottom half, never in ksoftirqd, right? > > Or maybe to have more than one softirq thread, to handle different > softirq levels, so that they can be assigned differing priorities. > > > It's not easy - __do_softirq lacks any locking - so it can't run > > concurrently in process context and in irq context. > > I have no idea. Maybe someone with a better understanding of this part > of the kernel can help. Well, yes. Similar issues have been discussed in the past, but softirqs and especially tasklets have horrible semantics. There was an attempt to deal with that, but that didn't end well. There is another even worse issue with USB/audio which I looked at a few days ago. Some USB hosts offload to kworkers, which has even worse behaviour than the ksoftirqd case. One solution to that is to avoid both tasklets and kworkers and change the USB code to make use of threaded interrupt handlers. I.e. handle the fast stuff in the primary (hardirq) handler and delegate the rest to the irq thread. That thread still can offload disk type stuff to a kworker if needed. But the irq thread allows to bring the stuff under scheduler control and experiments which I did a few years ago worked out pretty good. Thanks, tglx