LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Enric Balletbo i Serra <enric.balletbo@collabora.com>
To: Guenter Roeck <groeck@google.com>,
	Douglas Anderson <dianders@chromium.org>
Cc: Mark Brown <broonie@kernel.org>,
	Benson Leung <bleung@chromium.org>,
	"open list:ARM/Rockchip SoC..."
	<linux-rockchip@lists.infradead.org>,
	Nicolas Boichat <drinkcat@chromium.org>,
	Guenter Roeck <groeck@chromium.org>,
	Brian Norris <briannorris@chromium.org>,
	Matthias Kaehlcke <mka@chromium.org>,
	linux-kernel <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v4 1/3] platform/chrome: cros_ec_spi: Move to real time priority for transfers
Date: Tue, 21 May 2019 09:52:48 +0200	[thread overview]
Message-ID: <1ad86217-67b6-bb39-f4ea-ddefaa57c560@collabora.com> (raw)
In-Reply-To: <CABXOdTeCtwFSOvHbBTaSqjv0+rzfbc2mVm=PjtZgid_xRAwwtA@mail.gmail.com>

Hi,

On 15/5/19 19:02, Guenter Roeck wrote:
> On Wed, May 15, 2019 at 9:48 AM Douglas Anderson <dianders@chromium.org> wrote:
>>
>> In commit 37a186225a0c ("platform/chrome: cros_ec_spi: Transfer
>> messages at high priority") we moved transfers to a high priority
>> workqueue.  This helped make them much more reliable.
>>
>> ...but, we still saw failures.
>>
>> We were actually finding ourselves competing for time with dm-crypt
>> which also scheduled work on HIGHPRI workqueues.  While we can
>> consider reverting the change that made dm-crypt run its work at
>> HIGHPRI, the argument in commit a1b89132dc4f ("dm crypt: use
>> WQ_HIGHPRI for the IO and crypt workqueues") is somewhat compelling.
>> It does make sense for IO to be scheduled at a priority that's higher
>> than the default user priority.  It also turns out that dm-crypt isn't
>> alone in using high priority like this.  loop_prepare_queue() does
>> something similar for loopback devices.
>>
>> Looking in more detail, it can be seen that the high priority
>> workqueue isn't actually that high of a priority.  It runs at MIN_NICE
>> which is _fairly_ high priority but still below all real time
>> priority.
>>
>> Should we move cros_ec_spi to real time priority to fix our problems,
>> or is this just escalating a priority war?  I'll argue here that
>> cros_ec_spi _does_ belong at real time priority.  Specifically
>> cros_ec_spi actually needs to run quickly for correctness.  As I
>> understand this is exactly what real time priority is for.
>>
>> There currently doesn't appear to be any way to use the standard
>> workqueue APIs with a real time priority, so we'll switch over to
>> using using a kthread worker.  We'll match the priority that the SPI
>> core uses when it wants to do things on a realtime thread and just use
>> "MAX_RT_PRIO - 1".
>>
>> This commit plus the patch ("platform/chrome: cros_ec_spi: Request the
>> SPI thread be realtime") are enough to get communications very close
>> to 100% reliable (the only known problem left is when serial console
>> is turned on, which isn't something that happens in shipping devices).
>> Specifically this test case now passes (tested on rk3288-veyron-jerry):
>>
>>   dd if=/dev/zero of=/var/log/foo.txt bs=4M count=512&
>>   while true; do
>>     ectool version > /dev/null;
>>   done
>>
>> It should be noted that "/var/log" is encrypted (and goes through
>> dm-crypt) and also passes through a loopback device.
>>
>> Signed-off-by: Douglas Anderson <dianders@chromium.org>
> 
> Reviewed-by: Guenter Roeck <groeck@chromium.org>
> 

Added to the for-next branch for the autobuilders to play with, if all goes well
will be queued in chrome-platform-5.3

Thanks,
 Enric

  reply	other threads:[~2019-05-21  7:52 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-15 16:48 [PATCH v4 0/3] spi: A better solution for cros_ec_spi reliability Douglas Anderson
2019-05-15 16:48 ` [PATCH v4 1/3] platform/chrome: cros_ec_spi: Move to real time priority for transfers Douglas Anderson
2019-05-15 17:02   ` Guenter Roeck
2019-05-21  7:52     ` Enric Balletbo i Serra [this message]
2019-05-15 16:48 ` [PATCH v4 2/3] spi: Allow SPI devices to request the pumping thread be realtime Douglas Anderson
2019-05-21  7:49   ` Enric Balletbo i Serra
2019-05-23 13:46   ` Mark Brown
2019-05-23 13:49   ` Applied "spi: Allow SPI devices to request the pumping thread be realtime" to the spi tree Mark Brown
2019-05-15 16:48 ` [PATCH v4 3/3] platform/chrome: cros_ec_spi: Request the SPI thread be realtime Douglas Anderson
2019-05-21  7:50   ` Enric Balletbo i Serra
2019-05-24 10:26   ` Enric Balletbo i Serra

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1ad86217-67b6-bb39-f4ea-ddefaa57c560@collabora.com \
    --to=enric.balletbo@collabora.com \
    --cc=bleung@chromium.org \
    --cc=briannorris@chromium.org \
    --cc=broonie@kernel.org \
    --cc=dianders@chromium.org \
    --cc=drinkcat@chromium.org \
    --cc=groeck@chromium.org \
    --cc=groeck@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rockchip@lists.infradead.org \
    --cc=mka@chromium.org \
    --subject='Re: [PATCH v4 1/3] platform/chrome: cros_ec_spi: Move to real time priority for transfers' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).