From: Paul Jackson <pj@sgi.com>
To: "Paul Menage" <menage@google.com>
Cc: bunk@kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [2.6 patch] kernel/cgroup.c: remove dead code
Date: Thu, 25 Oct 2007 18:37:21 -0700 [thread overview]
Message-ID: <20071025183721.705c13d0.pj@sgi.com> (raw)
In-Reply-To: <6599ad830710251826g5669a4cw3696ad500ff90bb4@mail.gmail.com>
pj wrote:
> Check out the assembly code generated by:
>
> BUG_ON(sizeof(cgrp->root->release_agent_path) < PATH_MAX));
>
> (Hint: you can't find it ;)
>
> It -is- compile time!
To be clear, BUG_ON() in general is a runtime check.
But the compiler can optimize out constant expressions,
and code conditionally executed in the case of a constant
that can never be true.
Adrian wrote:
> > It -is- compile time!
>
> But when the condition is fulfilled, you get a runtime error, not a
> compile error.
Correct you are. And when I advocated BUG_ON in this role, I did
two things:
1) I was blissfully ignorant of BUILD_BUG_ON(), which would be
better here, for the reasons you state, and
2) I did a silent calculation in my head, noticing that if the
constants ever changed so as to trigger this check, it would
show up really quickly in testing, because it was on code path
that would be hard to miss. Because of this, the delay until
runtime of this check was less of a disaster than it would
have been on a rarely traveled code path.
In sum - Adrian is right - use BUILD_BUG_ON() here.
Thanks, Adrian.
--
I won't rest till it's the best ...
Programmer, Linux Scalability
Paul Jackson <pj@sgi.com> 1.925.600.0401
next prev parent reply other threads:[~2007-10-26 1:37 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-10-24 16:25 [2.6 patch] kernel/cgroup.c: remove dead code Adrian Bunk
2007-10-24 16:30 ` Paul Menage
2007-10-24 17:07 ` Adrian Bunk
2007-10-24 17:13 ` Paul Menage
2007-10-24 17:34 ` Paul Jackson
2007-10-26 1:10 ` Paul Menage
2007-10-26 1:19 ` Adrian Bunk
2007-10-26 1:24 ` Paul Jackson
2007-10-26 1:26 ` Paul Menage
2007-10-26 1:37 ` Paul Jackson [this message]
2007-10-26 1:30 ` Adrian Bunk
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=20071025183721.705c13d0.pj@sgi.com \
--to=pj@sgi.com \
--cc=bunk@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=menage@google.com \
/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