From: Denys Vlasenko <dvlasenk@redhat.com>
To: Brian Norris <computersforpeace@gmail.com>
Cc: David Woodhouse <David.Woodhouse@intel.com>,
Dan Carpenter <dan.carpenter@oracle.com>,
Jingoo Han <jg1.han@samsung.com>,
Aaron Sierra <asierra@xes-inc.com>,
Artem Bityutskiy <Artem.Bityutskiy@linux.intel.com>,
linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] mtd: cfi: Deiline large functions
Date: Thu, 21 May 2015 12:13:10 +0200 [thread overview]
Message-ID: <555DAFB6.7080208@redhat.com> (raw)
In-Reply-To: <20150521083612.GH11112@norris-Latitude-E6410>
On 05/21/2015 10:36 AM, Brian Norris wrote:
> On Thu, May 21, 2015 at 09:50:38AM +0200, Denys Vlasenko wrote:
>>>> cfi_udelay(): 74 bytes, 26 callsites
>>>
>>> ^^ This is pretty dead-simple. If it's generating bad code, we might
>>> look at fixing it up instead. Almost all of its call sites are with
>>> constant input, so it *should* just become:
>>>
>>> udelay(1);
>>> cond_resched();
>>>
>>> in most cases. For the non-constant cases, we might still do an
>>> out-of-line implementation. Or maybe we just say it's all not worth it,
>>> and we just stick with what you have. But I'd like to consider
>>> alternatives to out-lining this one.
>>
>> You want to consider not-deinlining (IOW: speed-optimizing)
>
> Inlining isn't always about speed.
>
>> a *fixed time delay function*?
>>
>> Think about what delay functions do...
>
> I wasn't really looking at speed. Just memory usage.
I don't follow.
A single, not-inlined cfi_udelay(1) call is
a minimal possible code size. Even
udelay(1);
cond_resched();
ought to be bigger.
> And I was only pointing this out because udelay() has a different
> implementation for the __builtin_constant_p() case. You can't take
> advantage of that for non-inlined versions of cfi_udelay().
>
> But that may be irrelevant anyway, now that I think again. At best,
> you're trading one function call (arm_delay_ops.const_udelay() on ARM)
> for another (cfi_udelay()), since you can never completely optimize out
> the latter.
*delay() and *sleep() functions are special: they do NOT
want to be executed as fast as possible. They are *pausing*
execution. They are *intended* to be "slow".
You should not strive to optimize out function call overhead
when you call one of these. Otherwise, it would mean that you
essentially do this for e.g. udelay(NUM):
"I want to pause for NUM us, (which is about NUM*3000 CPU cycles),
let's optimize out call+ret so that we speed up execution
by 5 cycles".
Do you see why it does not make sense?
next prev parent reply other threads:[~2015-05-21 10:13 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-18 10:58 [PATCH] mtd: cfi: Deiline large functions Denys Vlasenko
2015-05-20 18:56 ` Brian Norris
2015-05-21 7:50 ` Denys Vlasenko
2015-05-21 8:36 ` Brian Norris
2015-05-21 10:13 ` Denys Vlasenko [this message]
2015-05-21 18:03 ` Brian Norris
2015-05-27 19:44 ` Brian Norris
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=555DAFB6.7080208@redhat.com \
--to=dvlasenk@redhat.com \
--cc=Artem.Bityutskiy@linux.intel.com \
--cc=David.Woodhouse@intel.com \
--cc=asierra@xes-inc.com \
--cc=computersforpeace@gmail.com \
--cc=dan.carpenter@oracle.com \
--cc=jg1.han@samsung.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mtd@lists.infradead.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