Real time kernel support in Android

1,572 views
Skip to first unread message

vamsi android

unread,
Oct 5, 2009, 2:47:03 AM10/5/09
to android...@googlegroups.com
Hi Android Team,

As the kernel is taken as it is and few additional enhancements are done on top of kernel, has Android team ever thought of making Android kernel real time? As with the existing kernel we cant achieve real time performance!

Is Android targeting to make Android kernel real time?  Are they trying to add any patches to make it real time or any modifications or groups already working on android kernel to make better scheduling, better latency, better boot up process, better performance compared to existing kernels?

Thanks,
Vamsi

vamsi android

unread,
Oct 8, 2009, 5:50:17 AM10/8/09
to android...@googlegroups.com
Hi Team,

I am not able to get any leads regarding real time support in Android. I also have a quick doubt regarding android kernel performance tools, are there any tools that android provides for testing time taken for scheduling a task, latency etc?

Thanks,
Vamsi

Greg KH

unread,
Oct 8, 2009, 2:54:38 PM10/8/09
to android...@googlegroups.com
On Thu, Oct 8, 2009 at 2:50 AM, vamsi android <vamsi....@gmail.com> wrote:
> Hi Team,
>
> I am not able to get any leads regarding real time support in Android.

It is no different from real time support in any Linux system, have you
looked into the real time patchset for the Linux kernel? It should
apply to the Android kernels with no problems.

> I also have a quick doubt regarding android kernel performance tools,
> are there any tools that android provides for testing time taken for
> scheduling a task, latency etc?

Again, see the real-time Linux project, they have these tools.

But most importantly, why do you want such a thing on Android? It will
reduce overall system performance, and you still have hardware latency
problems that can cause issues that are outside of the Linux kernel's
control. What are you trying to do here?

Are the current latencies that Linux has (lowest of any operating
system) somehow not sufficient for your needs? If so, where are you
seeing these latencies?

thanks,

greg k-h

gulshan karmani

unread,
Oct 8, 2009, 10:26:06 PM10/8/09
to android...@googlegroups.com
Yes, I agree with Greg, as 2.6 kernel versions are all Pre-emptible which makes it close to real time, is'nt it ?
Any performance tools will be useful to measure. Does Android CTS will cover some performance tests ?
 
We are not sure when we will get CTS in our hands also.
 
Rgds,
Gulshan

 

vamsi android

unread,
Oct 13, 2009, 3:42:30 AM10/13/09
to android...@googlegroups.com
Hi,

Regarding Realtime patches, I was successfully able to patch it on normal linux kernel, but was not successful when I integrate it with Android kernel. I was able to patch and compile it, but am facing while loading the android system. I get some errors while loading real time modules.

Regarding real time support in android, basically most of them are concentrating on Application base of Android, but as Android uses regular kernel, where it gives average performance and its not optimized for real time, we might see some performance issues on Android. Practically I have not checked any hand held devices which uses this Android and how it performs, but if Android kernel can be made real time to some extent, then we can atleast see better performance right?


"It will reduce overall system performance, and you still have hardware latency
problems that can cause issues that are outside of the Linux kernel's control.  What are you trying to do here?"

--> for this question, I did not get how it will reduce overall system performance? Can you give me some clues?

Whats my thinking is, if we can optimize android kernel for real time performance, then over all system performance will improve which can make android a better system/product. Any comments are welcome?

Thanks,
Vamsi

Dianne Hackborn

unread,
Oct 13, 2009, 2:14:55 PM10/13/09
to android...@googlegroups.com
"real time" != "better performance".  It is a different approach to scheduling work, which is not really appropriate for most uses of Android.
--
Dianne Hackborn
Android framework engineer
hac...@android.com

Note: please don't send private questions to me, as I don't have time to provide private support, and so won't reply to such e-mails.  All such questions should be posted on public forums, where I and others can see and answer them.

Greg KH

unread,
Oct 13, 2009, 6:11:24 PM10/13/09
to android...@googlegroups.com
On Tue, Oct 13, 2009 at 12:42 AM, vamsi android <vamsi....@gmail.com> wrote:
> Hi,
>
> Regarding Realtime patches, I was successfully able to patch it on normal
> linux kernel, but was not successful when I integrate it with Android
> kernel. I was able to patch and compile it, but am facing while loading the
> android system. I get some errors while loading real time modules.

What are these errors specifically?

> Regarding real time support in android, basically most of them are
> concentrating on Application base of Android, but as Android uses regular
> kernel, where it gives average performance and its not optimized for real
> time, we might see some performance issues on Android. Practically I have
> not checked any hand held devices which uses this Android and how it
> performs, but if Android kernel can be made real time to some extent, then
> we can atleast see better performance right?

No, not at all. A real-time system is slower performance than a non-realtime
one. Please read the documentation for what a real-time kernel means
for details on this.

Running the rt kernels will just slow down your android system, which is
not what I think you want it to do.

good luck,

greg k-h

vamsi android

unread,
Oct 15, 2009, 1:17:35 AM10/15/09
to android...@googlegroups.com
> Hi,
>
> Regarding Realtime patches, I was successfully able to patch it on normal
> linux kernel, but was not successful when I integrate it with Android
> kernel. I was able to patch and compile it, but am facing while loading the
> android system. I get some errors while loading real time modules.

What are these errors specifically?
       ---> I was trying to patch RTAI and patched successfully. When I tried to start android,  RTAI patch initialised successfully and it started its scheduler part, and when it was trying to load HAL module (RTAI mounts HAL module)  but was getting stuck there stating waiting for response and hence android is stuck.
 

> Regarding real time support in android, basically most of them are
> concentrating on Application base of Android, but as Android uses regular
> kernel, where it gives average performance and its not optimized for real
> time, we might see some performance issues on Android. Practically I have
> not checked any hand held devices which uses this Android and how it
> performs, but if Android kernel can be made real time to some extent, then
> we can atleast see better performance right?

No, not at all.  A real-time system is slower performance than a non-realtime
one.  Please read the documentation for what a real-time kernel means
for details on this.
    ---> I was doing research on real time kernels and what I found is
           - Linux scheduling algorithms are not designed for real-time tasks.
           - context switching is not predictable, it might take longer
           - Timer resolution - 10ms and low priorty tasks still runs and it will make
             wait a high priority task.
         So, there are few disadvantages of linux kernel which are made sure in Real time OS.
          with this tuning of kernel, atleast fault tollerance should improve and performance a little right?


Running the rt kernels will just slow down your android system, which is
not what I think you want it to do.
     --> Regarding Android system performance, at present when we compare iphone performance
          and G1 performance we can clearly see the difference. So, what I was thinking was to make
          android performance better and comatialble to iphone. The speed with which applications are loaded,
          and accessed are not matching with iphone!!
 

good luck,

greg k-h



Avtar Singh

unread,
Oct 15, 2009, 2:13:37 AM10/15/09
to android...@googlegroups.com

On Thu, Oct 15, 2009 at 10:47 AM, vamsi android <vamsi....@gmail.com> wrote:

Running the rt kernels will just slow down your android system, which is
not what I think you want it to do.
     --> Regarding Android system performance, at present when we compare iphone performance
          and G1 performance we can clearly see the difference. So, what I was thinking was to make
          android performance better and comatialble to iphone. The speed with which applications are loaded,
          and accessed are not matching with iphone!!

To improve performance of apps/system on Android, you have to figure out the use case scenarios and the points where the system is losing time. Unless you have that data, you may not do the right thing to improve performance. Making the kernel real-time might not fix that.

Abhinayak Mishra

unread,
Oct 15, 2009, 2:38:15 AM10/15/09
to android...@googlegroups.com
Running the rt kernels will just slow down your android system, which is
not what I think you want it to do.
     --> Regarding Android system performance, at present when we compare iphone performance
          and G1 performance we can clearly see the difference. So, what I was thinking was to make
          android performance better and comatialble to iphone. The speed with which applications are loaded,
          and accessed are not matching with iphone!!


>>> Iphone and G1 have different underlying hardware. Depending on the iphone generation, if you have a 3rd gene unit, you are looking at an arm Cortex A8 core while G1 is running an arm11 core at a much slower speed. A first gen iphone is probably going to be a more fair comparison.


Greg KH

unread,
Oct 15, 2009, 10:42:28 AM10/15/09
to android...@googlegroups.com
On Wed, Oct 14, 2009 at 10:17 PM, vamsi android <vamsi....@gmail.com> wrote:
>> > Hi,
>> >
>> > Regarding Realtime patches, I was successfully able to patch it on
>> > normal
>> > linux kernel, but was not successful when I integrate it with Android
>> > kernel. I was able to patch and compile it, but am facing while loading
>> > the
>> > android system. I get some errors while loading real time modules.
>>
>> What are these errors specifically?
>
>        ---> I was trying to patch RTAI and patched successfully. When I
> tried to start android,  RTAI patch initialised successfully and it started
> its scheduler part, and when it was trying to load HAL module (RTAI mounts
> HAL module)  but was getting stuck there stating waiting for response and
> hence android is stuck.

I suggest asking the rt kernel developers about this. But note that the
locking model in the Android core is much different than the rt kernel
patches are expecting, so problems might happen with the interaction.

>> No, not at all.  A real-time system is slower performance than a
>> non-realtime
>> one.  Please read the documentation for what a real-time kernel means
>> for details on this.
>
>     ---> I was doing research on real time kernels and what I found is
>            - Linux scheduling algorithms are not designed for real-time
> tasks.
>            - context switching is not predictable, it might take longer
>            - Timer resolution - 10ms and low priorty tasks still runs and it
> will make
>              wait a high priority task.
>          So, there are few disadvantages of linux kernel which are
> made sure in Real time OS.           with this tuning of kernel,
> atleast fault tollerance should improve and performance a little
> right?

No, not really. Please, run a "real-time" kernel and look at the
performance numbers. A real-time kernel is much slower overall. This
is exactly what you do not want to have happen for a system you want to
get the best performance out of the hardware.

>> Running the rt kernels will just slow down your android system, which is
>> not what I think you want it to do.
>
>      --> Regarding Android system performance, at present when we compare
> iphone performance           and G1 performance we can clearly see the
> difference. So, what I was thinking was to make           android
> performance better and comatialble to iphone. The speed with which
> applications are loaded,           and accessed are not matching with
> iphone!!

That is because the hardware is vastly different, you are comparing two
different things here. Why would you expect the performance to be the
same?

good luck,

greg k-h

Dianne Hackborn

unread,
Oct 15, 2009, 1:10:46 PM10/15/09
to android...@googlegroups.com
On Wed, Oct 14, 2009 at 10:17 PM, vamsi android <vamsi....@gmail.com> wrote:
Running the rt kernels will just slow down your android system, which is
not what I think you want it to do.
     --> Regarding Android system performance, at present when we compare iphone performance
          and G1 performance we can clearly see the difference. So, what I was thinking was to make
          android performance better and comatialble to iphone. The speed with which applications are loaded,
          and accessed are not matching with iphone!!

Comparing what vs. what?  Are you comparing them on the same hardware?  If not, this "observation" is useless, and I certainly I can't see how it brings you to jump to "oh we need a real time scheduler."  (Though that said, there is another non-realtime alternative scheduler that apparently may provide noticeable improvement over the stock one.)

vamsi android

unread,
Oct 16, 2009, 5:09:27 AM10/16/09
to android...@googlegroups.com
Hi Dianne,

Even though my observations were not on the same hardware (regardless of hardware we can make system better on sotware part to make it run better I guess), I wanted to make Android performance faster and for that I am trying to explore much on this Android kernel part. As kernel is taken as it is with few enhancements we can do optimisation for improving performance I guess apart from making it real time to some extent. For that I am exploring more on this android kernel and general improvements.

I dont have tools to check the performance of Android, if any of you can give me lead where Android currently needs improvement (apart from Hardware) in the kernel or middleware, then surely we can take up for making Android a better system.

Thanks,
Vamsi

Bateman

unread,
Oct 15, 2009, 4:23:34 PM10/15/09
to Android Linux Kernel Development
Real Time is NOT about making things "quicker". Its about reliability.
Its about providing guarantees that certain events will happen within
a particular time deadline no matter how the rest of the system is
behaving. For example, lets say there is a music application
playing..which in itself is a soft real time application as a certain
"frame" needs to be played within a particular time deadline. Now say
there is another application that runs a computationally intensive
task..or for that matter a while(1) loop!. Now this while(1) could
screw the music app. But with real-time support in place you can
provide "reservations" to the music app which will guarantee the music
to be played, in spite of some other application misbehaving.

The real-time patch in linux does provide cpu reservation budgets but
does not provide hard guarantees what so ever.

The g1 phone processor is definitely slower than new iphones. Hence by
providing rt-extensions one will not be able to the responses of the
applications quicker than iphone!

On Oct 15, 1:10 pm, Dianne Hackborn <hack...@android.com> wrote:
> On Wed, Oct 14, 2009 at 10:17 PM, vamsi android <vamsi.andr...@gmail.com>wrote:
>
> > Running the rt kernels will just slow down your android system, which is
>
> >  not what I think you want it to do.
>
> >      *--> Regarding Android system performance, at present when we compare
> > iphone performance
> >           and G1 performance we can clearly see the difference. So, what I
> > was thinking was to make
> >           android performance better and comatialble to iphone. The speed
> > with which applications are loaded,
> >           and accessed are not matching with iphone!!
> > *
>
> Comparing what vs. what?  Are you comparing them on the same hardware?  If
> not, this "observation" is useless, and I certainly I can't see how it
> brings you to jump to "oh we need a real time scheduler."  (Though that
> said, there is another non-realtime alternative scheduler that apparently
> may provide noticeable improvement over the stock one.)
>
> --
> Dianne Hackborn
> Android framework engineer
> hack...@android.com

Sean Kelley

unread,
Oct 19, 2009, 11:32:43 AM10/19/09
to android...@googlegroups.com
Are you specifically needing to work with RT patches and PI enabled
futexes for userspace?

Sean

Dianne Hackborn

unread,
Oct 19, 2009, 8:52:24 PM10/19/09
to android...@googlegroups.com
If it was as easy as pointing a finger and saying "here optimize that," then it probably would have already been done.  90% of the effort in optimization is figuring out exactly what is slow and can be improved.  So if you want to proceed into this -- pull out a profiler and start digging in.  For example, take a UI operation you think is too slow, figure out a way to profile what is going on during that time, then analyze the results to see what can be improved.

And I will say, the kernel is perhaps not the meatiest place to look at for this work.

XingChao Wang

unread,
Oct 19, 2009, 11:16:50 PM10/19/09
to android...@googlegroups.com
2009/10/9 gulshan karmani <gulshan...@gmail.com>:
> Yes, I agree with Greg, as 2.6 kernel versions are all Pre-emptible which
> makes it close to real time, is'nt it ?
I once enable kernel preempt feature,change cfs to real time schedule
class, i found the UI become freeze easily.

--wxc200

XingChao Wang

unread,
Oct 19, 2009, 11:24:52 PM10/19/09
to android...@googlegroups.com
2009/10/16 Bateman <7thha...@gmail.com>:
>
> Real Time is NOT about making things "quicker". Its about reliability.
> Its about providing guarantees that certain events will happen within
> a particular time deadline no matter how the rest of the system is
> behaving. For example, lets say there is a music application
> playing..which in itself is a soft real time application as a certain
> "frame" needs to be played within a particular time deadline. Now say
> there is another application that runs a computationally intensive
> task..or for that matter a while(1) loop!. Now this while(1) could
> screw the music app. But with real-time support in place you can
> provide "reservations" to the music app which will guarantee the music
> to be played, in spite of some other application misbehaving.
>
Good point!
In current Android Kernel environment(G1/Ophone),it's really safe and
simple weak. In above case,if other thread was blocked or busy
running, soft real time app will become abnormal.
Maybe try realtime patch will harm current weak kernel environment,
but it's really a good thing. I wish to see it. :-)


thanks
--wang xingchao

vamsi android

unread,
Oct 20, 2009, 12:40:05 AM10/20/09
to android...@googlegroups.com
This really helped to zero down my thinking between real time and performance.

As I did not use this G1 phone, I am not sure of Android phones reliability. May be once who used G1 phone/tested G1 phones can answer these questions better,
- How reliable are Android phones?
- Does it really need attention to make Android phone reliable? i.e., real time?
- Does android users really face reliability kind of issues in the existing phones in market, if yes then up to what extinct like 1/10 or 1/1000?

Thanks,
Vamsi

vamsi android

unread,
Oct 20, 2009, 12:58:09 AM10/20/09
to android...@googlegroups.com
> If it was as easy as pointing a finger and saying "here optimize that," then it probably would have already been done.  90% of the effort in optimization is
> figuring out exactly what is slow and can be improved.  So if you want to proceed into this -- pull out a profiler and start digging in.  For example, take a UI > operation you think is too slow, figure out a way to profile what is going on during that time, then analyze the results to see what can be improved.

> And I will say, the kernel is perhaps not the meatiest place to look at for this work.

Yes, you are right, I am spending lot of time to just identify, but not able to find the right place. I think I need to find a way to profile to find where we can optimise. Thanks for your suggestions.

Can we see some improvement in the android system if we can optimize kernel? Not only performance, consider over all improvement of Android system!

- vamsi
 

Greg KH

unread,
Oct 20, 2009, 1:41:40 AM10/20/09
to android...@googlegroups.com
On Mon, Oct 19, 2009 at 9:40 PM, vamsi android <vamsi....@gmail.com> wrote:
> This really helped to zero down my thinking between real time and
> performance.
>
> As I did not use this G1 phone, I am not sure of Android phones reliability.
> May be once who used G1 phone/tested G1 phones can answer these questions
> better,
> - How reliable are Android phones?

Very.

> - Does it really need attention to make Android phone reliable? i.e., real
> time?

Reliability has nothing to do with real time, please stop thinking that.

> - Does android users really face reliability kind of issues in the existing
> phones in market, if yes then up to what extinct like 1/10 or 1/1000?

Again, the real time changes have nothing to do with reliability.
This is making
less and less sense of a thread...

Please get a phone and test it out yourself if you are still curious.

good luck,

greg k-h

vamsi android

unread,
Oct 20, 2009, 2:48:19 AM10/20/09
to android...@googlegroups.com
See Greg, as stated in previous emails, if music application wont get scheduling time which is stuck up with non pre-emptable task then we can see music is not running cont. and this regards as phone gets stuck and this is just an example, like this there might be many other cases where we expect phone to behave one way but it might behave other ways where it hampers Androids reliability, So I wanted experts to share their info regarding these kinds of stuff. This can happen with any OS, and android is not that perfect I guess. No peice of software is 100% full proof and trying to identify gray areas and exploring new things will make sence of a thread I guess.

Greg KH

unread,
Oct 20, 2009, 10:49:12 AM10/20/09
to android...@googlegroups.com
On Mon, Oct 19, 2009 at 11:48 PM, vamsi android <vamsi....@gmail.com> wrote:
> See Greg, as stated in previous emails, if music application wont get
> scheduling time which is stuck up with non pre-emptable task then we can see
> music is not running cont.

The way the kernel works, I do not think you will ever see this happen
today. If it does, please let us know.

> and this regards as phone gets stuck and this is
> just an example, like this there might be many other cases where we expect
> phone to behave one way but it might behave other ways where it hampers
> Androids reliability,

Again, no, it does not. Please test this for yourself to prove it.

Good luck,

greg k-h

ranjith vk

unread,
Oct 20, 2009, 1:54:57 AM10/20/09
to Android Linux Kernel Development
>
> No, not at all.  A real-time system is slower performance than a non-realtime
> one.  Please read the documentation for what a real-time kernel means
> for details on this.
>
> Running the rt kernels will just slow down your android system, which is
> not what I think you want it to do.
>
> good luck,
>
> greg k-h

An ideal system is the one that gives real time guarantees and is also
fast.So im my opinion trying to
improve/add rt features in android is a valid thing . But just
saying that the system will slow down
because of rt features is not valid. There are systems that do use rt
features today,
extending android capabilities to support that would definitely be
desirable.

ranjith





in my opinion is not

Greg KH

unread,
Oct 20, 2009, 11:13:32 AM10/20/09
to android...@googlegroups.com
On Mon, Oct 19, 2009 at 10:54 PM, ranjith vk <ranjit...@gmail.com> wrote:
>
>>
>> No, not at all.  A real-time system is slower performance than a non-realtime
>> one.  Please read the documentation for what a real-time kernel means
>> for details on this.
>>
>> Running the rt kernels will just slow down your android system, which is
>> not what I think you want it to do.
>>
>> good luck,
>>
>> greg k-h
>
> An ideal system is the one that gives real time guarantees and is also
> fast.

Yes, that is ideal, for some workloads.

> So im my opinion trying to
> improve/add  rt features in android is  a valid thing.

Of course.

> But just saying that the system will slow down
> because of rt features is not valid.

Not true at all, adding rt features to the Linux kernel slows things down,
that is just the way real-time features work.

> There are systems that do use rt
> features today,

Yes, but they are slower than non-rt systems on the same hardware with
the same operating system, right?

> extending android capabilities to support that would definitely be
> desirable.

Then please join the main Real Time Linux kernel developer community
to work on resolving these issues. It is not an Android specific thing
at all.

Best of luck,

greg k-h

Dianne Hackborn

unread,
Oct 20, 2009, 2:37:27 PM10/20/09
to android...@googlegroups.com
On Mon, Oct 19, 2009 at 9:40 PM, vamsi android <vamsi....@gmail.com> wrote:
- How reliable are Android phones?

Not reliable at all.
 
- Does it really need attention to make Android phone reliable? i.e., real time?

We'll take all the attention we can get.
 
- Does android users really face reliability kind of issues in the existing phones in market, if yes then up to what extinct like 1/10 or 1/1000?

One one billionth!

Sorry I know that was uncalled for, I should not be posting when I am sick.  And even knowing that, I am going to post anyway, that is how sick I am. :/

--
Dianne Hackborn
Android framework engineer
hac...@android.com

Abhinayak Mishra

unread,
Oct 20, 2009, 3:25:05 PM10/20/09
to android...@googlegroups.com
ha ha :)
hope you get well soon!

Michael Trimarchi

unread,
Oct 29, 2009, 6:39:07 AM10/29/09
to android...@googlegroups.com
Hi,

Greg KH wrote:
> On Mon, Oct 19, 2009 at 10:54 PM, ranjith vk <ranjit...@gmail.com> wrote:
>
>>> No, not at all. A real-time system is slower performance than a non-realtime
>>> one. Please read the documentation for what a real-time kernel means
>>> for details on this.
>>>
>>> Running the rt kernels will just slow down your android system, which is
>>> not what I think you want it to do.
>>>
>>> good luck,
>>>
>>> greg k-h
>>>
>> An ideal system is the one that gives real time guarantees and is also
>> fast.
>>
>
> Yes, that is ideal, for some workloads.
>
>

You can try to wrap service or group (radio, media) in the cgroup
interface, just extending how the init parse the init.rc file and give
or garantee bandwith or share for a particular android subsystem.

Michael

Reply all
Reply to author
Forward
Message has been deleted
0 new messages