All of lore.kernel.org
 help / color / mirror / Atom feed
* regarding synchronization code
@ 2010-09-24 22:56 Sri Ram Vemulpali
  2010-09-24 23:58 ` Gregory Haskins
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Sri Ram Vemulpali @ 2010-09-24 22:56 UTC (permalink / raw)
  To: Kernel-newbies, Linux-rt-users

Hi all,

  I am encountering alot macros in the code. I did not understand what
those macro means.

  Can anyone explain them and the use of them putting them like that.

   "unlikely"
   "always_inline"  -- defined at the signature of the function.
   "inline" -- I know inline keyword in compiler is used to place the
code in to the caller function at the time of compiler, but why
declared as macro

    Any help would be appreciated.

-- 
Regards,
Sri.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: regarding synchronization code
  2010-09-24 22:56 regarding synchronization code Sri Ram Vemulpali
@ 2010-09-24 23:58 ` Gregory Haskins
  2010-09-25  5:16 ` Dave Hylands
  2010-09-25  8:48 ` Michael Blizek
  2 siblings, 0 replies; 6+ messages in thread
From: Gregory Haskins @ 2010-09-24 23:58 UTC (permalink / raw)
  To: Sri Ram Vemulpali, Kernel-newbies, Linux-rt-users

>>> On 9/24/2010 at 06:56 PM, in message
<AANLkTikhWVuL18zRcPTu2TcEQrv8Bpr4O0eafNsPgNjt@mail.gmail.com>, Sri Ram
Vemulpali <sri.ram.gmu06@gmail.com> wrote: 
> Hi all,
> 
>   I am encountering alot macros in the code. I did not understand what
> those macro means.
> 
>   Can anyone explain them and the use of them putting them like that.
> 
>    "unlikely"

Related to gcc branch-prediction, iirc.

>    "always_inline"  -- defined at the signature of the function.
>    "inline" -- I know inline keyword in compiler is used to place the
> code in to the caller function at the time of compiler, but why
> declared as macro

Probably so it can be enabled/disabled as a .config option.

Kind Regards,
-Greg


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: regarding synchronization code
  2010-09-24 22:56 regarding synchronization code Sri Ram Vemulpali
  2010-09-24 23:58 ` Gregory Haskins
@ 2010-09-25  5:16 ` Dave Hylands
  2010-09-25  8:48 ` Michael Blizek
  2 siblings, 0 replies; 6+ messages in thread
From: Dave Hylands @ 2010-09-25  5:16 UTC (permalink / raw)
  To: Sri Ram Vemulpali; +Cc: Kernel-newbies, Linux-rt-users

Hi Sri,

On Fri, Sep 24, 2010 at 3:56 PM, Sri Ram Vemulpali wrote:
> Hi all,
>
>  I am encountering alot macros in the code. I did not understand what
> those macro means.
>
>  Can anyone explain them and the use of them putting them like that.
>
>   "unlikely"

This has to do with branch prediction. If the architecture that you're
building for supports branch prediction then this provides a hint to
say that the following test is unlikely to pass, so the branch
prediction will be setup to take the likely path.

>   "always_inline"  -- defined at the signature of the function.

Exactly what it says - always make the function an inline function.
The inline keyword is normally just a hint or suggestion to the
compiler, whereas the always_inline says that the function should
always be inlined, even if optimizations to perform function inlining
is disabled.
<http://gcc.gnu.org/onlinedocs/gcc-4.0.4/gcc/Function-Attributes.html>

>   "inline" -- I know inline keyword in compiler is used to place the
> code in to the caller function at the time of compiler, but why
> declared as macro

There are some CONFIG options which allow inline behaviour to be tweaked:
<http://cateee.net/lkddb/web-lkddb/OPTIMIZE_INLINING.html>

-- 
Dave Hylands
Shuswap, BC, Canada
http://www.DaveHylands.com/
--
To unsubscribe from this list: send the line "unsubscribe linux-rt-users" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: regarding synchronization code
  2010-09-24 22:56 regarding synchronization code Sri Ram Vemulpali
  2010-09-24 23:58 ` Gregory Haskins
  2010-09-25  5:16 ` Dave Hylands
@ 2010-09-25  8:48 ` Michael Blizek
  2010-09-25 17:04   ` Sri Ram Vemulpali
  2 siblings, 1 reply; 6+ messages in thread
From: Michael Blizek @ 2010-09-25  8:48 UTC (permalink / raw)
  To: Sri Ram Vemulpali; +Cc: Kernel-newbies, Linux-rt-users

Hi!

On 18:56 Fri 24 Sep     , Sri Ram Vemulpali wrote:
> Hi all,
> 
>   I am encountering alot macros in the code. I did not understand what
> those macro means.
> 
>   Can anyone explain them and the use of them putting them like that.
> 
>    "unlikely"

likely() and unlikely() are wrappers around gcc extensions to give hints about
whether a given branch will likely be taken or not. When done correctly, this
can improve performance.

>    "always_inline"  -- defined at the signature of the function.

This can be used because "inline" is not always inlined. There should be a gcc
option which causes all inline code to be not inlined.

>    "inline" -- I know inline keyword in compiler is used to place the
> code in to the caller function at the time of compiler, but why
> declared as macro

Where do you see inline declared as a macro?

	-Michi
-- 
programing a layer 3+4 network protocol for mesh networks
see http://michaelblizek.twilightparadox.com


--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecartis@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: regarding synchronization code
  2010-09-25  8:48 ` Michael Blizek
@ 2010-09-25 17:04   ` Sri Ram Vemulpali
  2010-09-26  6:52     ` Bond
  0 siblings, 1 reply; 6+ messages in thread
From: Sri Ram Vemulpali @ 2010-09-25 17:04 UTC (permalink / raw)
  To: Michael Blizek; +Cc: Kernel-newbies, Linux-rt-users

I am just saying I know inline keyword. But what is always_inline.

Thanks for replies and explanations. I got it now.

Regards,
Sri.

On Sat, Sep 25, 2010 at 4:48 AM, Michael Blizek
<michi1@michaelblizek.twilightparadox.com> wrote:
> Hi!
>
> On 18:56 Fri 24 Sep     , Sri Ram Vemulpali wrote:
>> Hi all,
>>
>>   I am encountering alot macros in the code. I did not understand what
>> those macro means.
>>
>>   Can anyone explain them and the use of them putting them like that.
>>
>>    "unlikely"
>
> likely() and unlikely() are wrappers around gcc extensions to give hints about
> whether a given branch will likely be taken or not. When done correctly, this
> can improve performance.
>
>>    "always_inline"  -- defined at the signature of the function.
>
> This can be used because "inline" is not always inlined. There should be a gcc
> option which causes all inline code to be not inlined.
>
>>    "inline" -- I know inline keyword in compiler is used to place the
>> code in to the caller function at the time of compiler, but why
>> declared as macro
>
> Where do you see inline declared as a macro?
>
>        -Michi
> --
> programing a layer 3+4 network protocol for mesh networks
> see http://michaelblizek.twilightparadox.com
>
>



-- 
Regards,
Sri.
--
To unsubscribe from this list: send the line "unsubscribe linux-rt-users" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: regarding synchronization code
  2010-09-25 17:04   ` Sri Ram Vemulpali
@ 2010-09-26  6:52     ` Bond
  0 siblings, 0 replies; 6+ messages in thread
From: Bond @ 2010-09-26  6:52 UTC (permalink / raw)
  To: Sri Ram Vemulpali; +Cc: Michael Blizek, Kernel-newbies, Linux-rt-users

[-- Attachment #1: Type: text/plain, Size: 247 bytes --]

On Sat, Sep 25, 2010 at 10:34 PM, Sri Ram Vemulpali <sri.ram.gmu06@gmail.com
> wrote:

> I am just saying I know inline keyword. But what is always_inline.
>

I wonder why you were not given any lecture to Google etc as I get in my
other threads.

[-- Attachment #2: Type: text/html, Size: 512 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2010-09-26  6:52 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-09-24 22:56 regarding synchronization code Sri Ram Vemulpali
2010-09-24 23:58 ` Gregory Haskins
2010-09-25  5:16 ` Dave Hylands
2010-09-25  8:48 ` Michael Blizek
2010-09-25 17:04   ` Sri Ram Vemulpali
2010-09-26  6:52     ` Bond

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.