All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Marek Behún" <kabel@kernel.org>
To: Ben Whitten <ben.whitten@gmail.com>
Cc: linux-leds@vger.kernel.org
Subject: ledtrig netdev: what is the purpose of spinlock usage?
Date: Thu, 29 Oct 2020 07:00:00 +0100	[thread overview]
Message-ID: <20201029070000.15472666@kernel.org> (raw)

Hi Ben (or Pavel or whomever can explain this),

since you are the original author of netdev LED trigger, I guess this
question should go to you. Why are spinlocks used as locks in the
netdev trigger code? Is this for performance? Would it be a drastic
performance hit to use mutexes?

The reason why I am asking is that I am designing an API for transparent
HW offload of LED triggers. (Some LEDs, eg. LEDs on ethernet PHYs, can
blink on rx/tx activity themselves).

You can find this at
https://git.kernel.org/pub/scm/linux/kernel/git/kabel/linux.git/log/?h=leds-trigger-hw-offload

The current approach for the netdev trigger is that the
set_baseline_state function calls trigger_offload() method of the LED
classdev. But the whole set_baseline_state function is called from
within spinlock, and so when the trigger_offload method calls something
that can sleep (MDIO bus communication, for example), kernel complains:
  BUG: scheduling while atomic

Thanks.

Marek

             reply	other threads:[~2020-10-29  8:27 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-29  6:00 Marek Behún [this message]
2020-10-29 17:45 ` ledtrig netdev: what is the purpose of spinlock usage? Pavel Machek
2020-10-29 18:13   ` Marek Behún
2020-10-29 21:32     ` Ben Whitten
2020-10-29 22:49     ` Jacek Anaszewski
2020-10-29 23:14       ` Marek Behún

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=20201029070000.15472666@kernel.org \
    --to=kabel@kernel.org \
    --cc=ben.whitten@gmail.com \
    --cc=linux-leds@vger.kernel.org \
    /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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.