some questions about kernel source

Rajat Jain rajatjain at juniper.net
Wed Feb 16 00:59:44 EST 2011


Hello loody,

> 1. in kernel/trace, I always see "__read_mostly" at the end of
> parameter is that a compiler optimization parameter?

Yes, it is a hint to the compiler that the parameter is mostly read, thus if the compiler has to make a decision between optimizing one of the read / write paths, it will optimize the read path even at the expense of write path.

> 2. what are below __releases and __acquires used for?
> ehci_urb_done(struct ehci_hcd *ehci, struct urb *urb, int status)
> __releases(ehci->lock)
> __acquires(ehci->lock)
> these 2 cmds are not in the {}, so I guess it will not compile out
> machine. If so, why we add them after function prototype?

I think it is some jugglery to aid the compiler and intelligent static code analysis tools to inform this function acquires and releases the said lock. This would help those tools in finding out potential synchronization issues, lockup scenarios.

Thanks,

Rajat


> -----Original Message-----
> From: kernelnewbies-bounces at kernelnewbies.org [mailto:kernelnewbies-
> bounces at kernelnewbies.org] On Behalf Of loody
> Sent: Wednesday, February 16, 2011 11:23 AM
> To: kernelnewbies at kernelnewbies.org
> Subject: some questions about kernel source
> 
> Dear all:
> I have some questions about kernel source code:
> 1. in kernel/trace, I always see "__read_mostly" at the end of
> parameter is that a compiler optimization parameter?
> 2. what are below __releases and __acquires used for?
> ehci_urb_done(struct ehci_hcd *ehci, struct urb *urb, int status)
> __releases(ehci->lock)
> __acquires(ehci->lock)
> these 2 cmds are not in the {}, so I guess it will not compile out
> machine. If so, why we add them after function prototype?
> 
> 
> --
> Regards,
> 
> _______________________________________________
> Kernelnewbies mailing list
> Kernelnewbies at kernelnewbies.org
> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies



More information about the Kernelnewbies mailing list