public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jean Delvare <jdelvare@suse.de>
To: Peter Zijlstra <peterz@infradead.org>
Cc: Ingo Molnar <mingo@kernel.org>,
	LKML <linux-kernel@vger.kernel.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	"H. Peter Anvin" <hpa@zytor.com>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [PATCH] firmware: dmi_scan: Drop dmi_initialized
Date: Wed, 27 Sep 2017 10:56:17 +0200	[thread overview]
Message-ID: <20170927105617.40d20827@endymion> (raw)
In-Reply-To: <20170925092644.7teso4xhkjw2hksl@hirez.programming.kicks-ass.net>

Hi Peter,

On Mon, 25 Sep 2017 11:26:44 +0200, Peter Zijlstra wrote:
> On Mon, Sep 25, 2017 at 11:00:11AM +0200, Jean Delvare wrote:
> > Then we have that in common. While reading the code and its history, I
> > was worried that the justification to add this warning in the first
> > place was technically weak. Not every coding error must automatically
> > translate to a patch to make the code robust against said error.
> > Sometimes you just have to admit that you did not pay attention as you
> > should have, fix your mistake, possibly document it for others, and
> > move on. Otherwise we end up with slow bloated code.  
> 
> That WARN_ON() is a form of documentation.

Sort of, but not the best form in my opinion. I mean, if a WARN
triggers, you'll have to spot it in the kernel log, and then figure out
why the condition which triggered it was evaluated to false. In this
specific case, this means grepping the code for "dmi_initialized" to
figure out where it should have been set. The error string ("dmi check:
not initialized yet") helps a bit, but that's still not as clear and
immediate as an explicit "dmi_scan_machine must be called before this
function is called" in the function description.

> And if you care about performance for your code path, hide it under some
> CONFIG_*_DEBUG,

I'd love to, but I couldn't find a generic one which would actually be
disabled on production kernels, and introducing a configuration option
for just this seems overkill.

> (...) but in general WARN_ON() isn't terribly expensive
> (depending entirely on the complexity of the condition of course).

The condition is pretty trivial here, so it should indeed be fairly
cheap. However you have to multiply it by the number of times it is
called. When this WARN was introduced, there were 61 calls to
dmi_check_system() in the whole kernel tree. Today we have 164 and the
count keeps increasing. And some of them in common paths which get
called repeatedly. I just instrumented the function to see how many
times it was called on my x86_64 workstation and the answer is 110.
That's not a one-time thing.

-- 
Jean Delvare
SUSE L3 Support

      reply	other threads:[~2017-09-27  8:56 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-18  8:05 [PATCH] firmware: dmi_scan: Drop dmi_initialized Jean Delvare
2017-09-23 10:50 ` Ingo Molnar
2017-09-23 15:29   ` Jean Delvare
2017-09-24  9:16     ` Ingo Molnar
2017-09-25  9:00       ` Jean Delvare
2017-09-25  9:24         ` Peter Zijlstra
2017-09-25  9:26         ` Peter Zijlstra
2017-09-27  8:56           ` Jean Delvare [this message]

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=20170927105617.40d20827@endymion \
    --to=jdelvare@suse.de \
    --cc=akpm@linux-foundation.org \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    --cc=torvalds@linux-foundation.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox