NetworkStatsService - WakeLock

1,428 views
Skip to first unread message

Madhvapathi Sriram

unread,
May 2, 2012, 7:22:55 AM5/2/12
to android-...@googlegroups.com
Hi,

I am trying to put my android platform (panda) to sleep using, however it never does so because the NetworkStatsService WakeLock is always held. This happens with WiFi on.
However, with WiFi off this is no so and the platform performs sleep.

I just checked the NetworkStatsService and found that a a lot of places and especially in performPoll the wakelock is held. Any idea why this is so? Is it required? This leads to lo of battery drain.

Anybody seen this issue?

Thanks and regards,
Madhvapathi Sriram

Jeff Sharkey

unread,
May 2, 2012, 11:53:42 AM5/2/12
to android-...@googlegroups.com, jp abgrall
The NetworkStatsService wakelock is only held while collecting and
recording statistics from the kernel, and it should only be held for a
short period of time. Here's a typical example from a maguro device
on battery for a few hours:

Wake lock NetworkStats: 1s 57ms partial (27 times) realtime

Since all wakelock usage in NetworkStatsService is wrapped in
try/finally blocks, I'm wondering if one of the /proc files is
hanging.

To help investigate, could you pull stack traces when in this state by
running "systemstack" (defined in envsetup.sh). If those traces
confirm it's blocked on a read() for a long time, reboot and turn on
logging on the kernel side to investigate further:

adb shell "echo 8 > /sys/module/xt_qtaguid/parameters/debug_mask"
adb shell cat /proc/kmsg | grep "qtaguid"

j
> --
> You received this message because you are subscribed to the Google Groups
> "android-platform" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/android-platform/-/5biDGZyuSCsJ.
> To post to this group, send email to android-...@googlegroups.com.
> To unsubscribe from this group, send email to
> android-platfo...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/android-platform?hl=en.



--
Jeff Sharkey
jsha...@android.com

Madhvapathi Sriram

unread,
May 3, 2012, 10:06:56 AM5/3/12
to android-...@googlegroups.com, jp abgrall
Thanks for the reply Jeff.

So, I dug in a little deeper. Its something like this..

The Linux driver I am using handles the PM_SUSPEND_PREPARE. During this, the driver tears down the interface and thus signals a link state change to the applications (Tethering/ConnectivityService/NetworkStatsService et al).
Now these (NetworkStatsService specifically) hold the wakelock for stats collection and by the time it is released, the kernel progresses towards SUSPEND (this is pretty fast). Here it  sees that the PowerManagerService is locked and returns. And just then the lock is released by the app.

So, to prevent this we are trying to push the link state change to the SUSPEND call instead of the PM_SUSPEND_PREPARE.

Regards,
Madhvapathi Sriram
Reply all
Reply to author
Forward
0 new messages