Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp628009pxk; Thu, 17 Sep 2020 11:43:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw0s6aSXrBskD5CzQo3OAlpyx+BDgRO+/4Xw4H7ekCm+pwC+V620RK847Pl0n6MlfvNHQTX X-Received: by 2002:a17:906:ce3b:: with SMTP id sd27mr32299280ejb.433.1600368215531; Thu, 17 Sep 2020 11:43:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600368215; cv=none; d=google.com; s=arc-20160816; b=F3ijfLoSlLqbpjoFA1gb2sSTcPF3F53eSqWdSuYy9JT4YxURcnX2PNrPPH1P+gtXAi Lg8GR4yUQN3WhkkiKBQ5J6ECPfwiMw/92jJZGFXnemiq923AQwi1Kv/+fblgnJFd0ckb KljHpWQHEWw97LPzx9ibJ97y3HDnzTqOZYL9+o9iEdXE1anOlFKwNYWxPrZ/IPcr9wmr H4PgEgmy/mMS8CxVuOfr/lt6dhsMjPWtyvDBw+NjpFog/nke7B9/I4RF25xpALv3SlMB VbeLOMtsCZTYXx0dnmmP0p9c6N3TL3uM/Og17UMJenlT9e7+SetD/vdt1aHe94Cnf1Jj tVjg== 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 :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=UQBnVsJr02uLFsIfBbHQQ9qq8JxaQke2v+9Qgjupbgo=; b=HYo5dSOHexlvGpLUfaYZLn/zVKKO4jKBrjT/z0vUayh/ibwUftWazFCYu8kn8ZyUhp hofjyuxWi7iejZgzEVykUgcSvXg27Lek4APLuNk5Jxmx7UIogjjphN4Nvqu9/COpvo/p utG+f9TM9FBv9G1x93IOennsba6eiz5tfohpREmvbjdYiPPzOuJUw+oyDAkuTUnCDLUZ 3A4T24ZS+EKJBHtpCw4c9RuBu34kXMGKHBil0eIEKb+m+QjtxPUMPHSK2U0/AqLKjvZa juJAnD+JsDR1fRp2hNIKz7FD0CKATh6xIAgiXx8kmP04dyEneB0cRYTbH6gnOmURQ9Mt ONSA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=pWc2jfeN; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id fi13si488911ejb.490.2020.09.17.11.43.12; Thu, 17 Sep 2020 11:43:35 -0700 (PDT) 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=pWc2jfeN; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726635AbgIQSj4 (ORCPT + 99 others); Thu, 17 Sep 2020 14:39:56 -0400 Received: from mail.kernel.org ([198.145.29.99]:32772 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726250AbgIQRTs (ORCPT ); Thu, 17 Sep 2020 13:19:48 -0400 Received: from archlinux (cpc149474-cmbg20-2-0-cust94.5-4.cable.virginm.net [82.4.196.95]) (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 145A8221E3; Thu, 17 Sep 2020 17:19:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600363187; bh=21Q34AOs8zDD3/feAv29bl5fXW+Jkv/vzpLdXHQugjU=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=pWc2jfeNPJrr5Y0o2P93Y7tbpoCAOwUOSngPay4RQ1bh4VbLgLYwTxs2VTes6qsse 0kC0jMMhFaZJaDcxS8xWsfOt/w/Bg+bTLPxehAh8ZqjIxxkEACqV/m6/nRBpRhgdsU Xoq8pBaePp6h9+Jo4nd9vif/0G6P+qCZEzmyt0eQ= Date: Thu, 17 Sep 2020 18:19:42 +0100 From: Jonathan Cameron To: Christian Eggers Cc: Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald-Stadler , , , Subject: Re: [PATCH v2] iio: trigger: Don't use RT priority Message-ID: <20200917181942.0d5db535@archlinux> In-Reply-To: <20200917120333.2337-1-ceggers@arri.de> References: <20200917120333.2337-1-ceggers@arri.de> X-Mailer: Claws Mail 3.17.6 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 17 Sep 2020 14:03:33 +0200 Christian Eggers wrote: > Triggers may raise transactions on slow busses like I2C. Using the > original RT priority of a threaded IRQ may prevent other important IRQ > handlers from being run. > > Signed-off-by: Christian Eggers > Cc: stable@vger.kernel.org > --- > In my particular case (on a RT kernel), the RT priority of the sysfstrig > threaded IRQ handler caused (temporarily) raising the prio of a user > space process which was holding the I2C bus mutex. > > Due to a bug in the i2c-imx driver, this process spent 500 ms in a busy-wait > loop and prevented all threaded IRQ handlers from being run during this > time. I'm not sure I fully understand the impacts of this yet. What is the impact on cases where we don't have any nasty side affects due to users of the trigger? I presume reducing the priority will cause some reduction in performance? If so is there any chance that would count as a regression? Jonathan > > v2: > - Use sched_set_normal() instead of sched_setscheduler_nocheck() > > drivers/iio/industrialio-trigger.c | 10 ++++++++++ > 1 file changed, 10 insertions(+) > > diff --git a/drivers/iio/industrialio-trigger.c b/drivers/iio/industrialio-trigger.c > index 6f16357fd732..7ed00ad695c7 100644 > --- a/drivers/iio/industrialio-trigger.c > +++ b/drivers/iio/industrialio-trigger.c > @@ -9,7 +9,10 @@ > #include > #include > #include > +#include > +#include > #include > +#include > #include > > #include > @@ -245,6 +248,7 @@ int iio_trigger_attach_poll_func(struct iio_trigger *trig, > int ret = 0; > bool notinuse > = bitmap_empty(trig->pool, CONFIG_IIO_CONSUMERS_PER_TRIGGER); > + struct irq_desc *irq_desc; > > /* Prevent the module from being removed whilst attached to a trigger */ > __module_get(pf->indio_dev->driver_module); > @@ -264,6 +268,12 @@ int iio_trigger_attach_poll_func(struct iio_trigger *trig, > if (ret < 0) > goto out_put_irq; > > + /* Triggers may raise transactions on slow busses like I2C. Using the original RT priority > + * of a threaded IRQ may prevent other threaded IRQ handlers from being run. > + */ > + irq_desc = irq_to_desc(pf->irq); > + sched_set_normal(irq_desc->action->thread, 0); > + > /* Enable trigger in driver */ > if (trig->ops && trig->ops->set_trigger_state && notinuse) { > ret = trig->ops->set_trigger_state(trig, true);