From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 57398C433E0 for ; Wed, 22 Jul 2020 08:34:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 330E7207BB for ; Wed, 22 Jul 2020 08:34:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1595406875; bh=bBhVauzcDv+gdi7HS/M9GiiTKSQl50htelXyJHZUl4E=; h=Date:From:To:Cc:Subject:References:In-Reply-To:List-ID:From; b=1/HnCRUqg08obAznC2GjMGykHt+hpmXIPm9QU5mSIFP9GLCRrYgfDc5oBcq3s82nC uP0VIAjckzAnl9NkrTkK/rnpJwcyLTmf2QSxOqebTWpqmxPqVfzRrv3rOYr8cd1ZNo 54RbL5YAMyy9WS8Ct8w+jI/zmJWv5o/Q/S2dmmwI= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727826AbgGVIee (ORCPT ); Wed, 22 Jul 2020 04:34:34 -0400 Received: from mail-lj1-f194.google.com ([209.85.208.194]:46944 "EHLO mail-lj1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726573AbgGVIed (ORCPT ); Wed, 22 Jul 2020 04:34:33 -0400 Received: by mail-lj1-f194.google.com with SMTP id h19so1543930ljg.13; Wed, 22 Jul 2020 01:34:31 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=a320Kl5LlLOAYjeoIoCSr52bpOgO1xg6oWW0y+XyzMw=; b=RW1QO2AgljyDHzHWSrSy+PzOsrEwS//NpMR/UWp20giKm3iN/75GmdEpAtwGJg0GV2 uHoabgJtLA9ajOttFxUoPv9BtSAoHDJE/RdjEPvT29Qj23c1/9Q63cbSMabCg620zvM6 rOtq+mp7+o5pqVX9AehRGhxtuF8cEVZp5qSLy/yWilBTLxrhDQe9W8Xi6ACUOx2olD5k kVicebcX1KEuXl9uWsjHSq7PWOReXlbfmgufXQk4C6c8PZtGFq0zVlUH6xgWajZLrjyZ 5pOoUV6UDPTzXUqvoxoBuynPaZv57p6CdxNqiwEeCSI9fHLax87pL1vlLWjcsUaKSgLp v8zw== X-Gm-Message-State: AOAM531BK8oQ2k7QGi8tzYUK3w2O88X+Lz7tJMBc5BDlwE1jGnGYf4rw TV8iYuV3hunhpqzh01hcRbRSBwZY X-Google-Smtp-Source: ABdhPJyZVBEFI0bvjliXucRioA69zALGxm9a2TuCL16DZpKu64loQwYwFw8ndfYgVc8LlaM47TwOeA== X-Received: by 2002:a2e:9d86:: with SMTP id c6mr14184500ljj.418.1595406870872; Wed, 22 Jul 2020 01:34:30 -0700 (PDT) Received: from xi.terra (c-beaee455.07-184-6d6c6d4.bbcust.telenor.se. [85.228.174.190]) by smtp.gmail.com with ESMTPSA id c27sm7530646lfm.56.2020.07.22.01.34.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Jul 2020 01:34:29 -0700 (PDT) Received: from johan by xi.terra with local (Exim 4.93.0.4) (envelope-from ) id 1jyACn-0005S2-4r; Wed, 22 Jul 2020 10:34:25 +0200 Date: Wed, 22 Jul 2020 10:34:25 +0200 From: Johan Hovold To: Uwe =?iso-8859-1?Q?Kleine-K=F6nig?= Cc: Johan Hovold , Pavel Machek , linux-serial@vger.kernel.org, Greg Kroah-Hartman , linux-kernel@vger.kernel.org, Jacek Anaszewski , kernel@pengutronix.de, Jiri Slaby , linux-leds@vger.kernel.org, Dan Murphy Subject: Re: [PATCH v7 3/3] leds: trigger: implement a tty trigger Message-ID: <20200722083425.GF3634@localhost> References: <20200707165958.16522-1-u.kleine-koenig@pengutronix.de> <20200707165958.16522-4-u.kleine-koenig@pengutronix.de> <20200714071355.GY3453@localhost> <20200721194815.mmkqccrkbgrly4xz@pengutronix.de> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="CblX+4bnyfN0pR09" Content-Disposition: inline In-Reply-To: <20200721194815.mmkqccrkbgrly4xz@pengutronix.de> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --CblX+4bnyfN0pR09 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Jul 21, 2020 at 09:48:15PM +0200, Uwe Kleine-K=F6nig wrote: > Hello Johan, >=20 > On Tue, Jul 14, 2020 at 09:13:55AM +0200, Johan Hovold wrote: > > On Tue, Jul 07, 2020 at 06:59:58PM +0200, Uwe Kleine-K=F6nig wrote: > > > + while (firstrun || > > > + icount.rx !=3D trigger_data->rx || > > > + icount.tx !=3D trigger_data->tx) { > > > + > > > + led_set_brightness(trigger_data->led_cdev, LED_ON); > > > + > > > + msleep(100); > > > + > > > + led_set_brightness(trigger_data->led_cdev, LED_OFF); > > > + > > > + trigger_data->rx =3D icount.rx; > > > + trigger_data->tx =3D icount.tx; > > > + firstrun =3D false; > > > + > > > + ret =3D tty_get_icount(trigger_data->tty, &icount); > > > + if (ret) > > > + return; > > > + } > >=20 > > Haven't looked at the latest proposal in detail, but this looks broken > > as you can potentially loop indefinitely in a worker thread, and with no > > way to stop the trigger (delayed work). >=20 > I don't think that potentially looping indefinitely is a problem, but > indeed it should drop the lock during each iteration. Will think about > how to adapt. You musn't queue work that can run for long on the global shared workqueue as it affects flushing: * system_wq is the one used by schedule[_delayed]_work[_on](). * Multi-CPU multi-threaded. There are users which expect relatively * short queue flush time. Don't queue works which can run for too * long. Work that potentially run indefinitely is an absolute no-no. :) Johan --CblX+4bnyfN0pR09 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iHUEABYIAB0WIQQHbPq+cpGvN/peuzMLxc3C7H1lCAUCXxf6DgAKCRALxc3C7H1l CAKdAPwMLuzL36R91UerEvnH4zUtKfNS5jRfm18tpgXYHJMHygEArxfQACvPs6nx njUDzVBzoW1/YxY47dCsqRZ4zne/JAQ= =E/KR -----END PGP SIGNATURE----- --CblX+4bnyfN0pR09--