Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit baff465f authored by Ganesh Mahendran's avatar Ganesh Mahendran
Browse files

continue read file when returned count > 0

In android, we met a lot of watchdog timeout which
caused by read file "/d/wakeup_sources".

The root cause is that in kernel side wakeup.c, it uses single_open()
interface to show the stats. But single_open() interface
requires that the whole output must fit into a single
buffer(physical continuous). This will lead to timeout when system
memory is not in a good situation.

Problem in kenrel side has been merged in [1]. Then kernel will return
max a page bytes to user space. So in KernelWakelockReader, we
need to read again when returned count > 0.

[1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?h=v5.0-rc4&id=00ee22c28915d111ba415750a3311d7678fd1206



Change-Id: If7886514c609c8d6338532c67c1cee79f2754ab1
Signed-off-by: default avatarGanesh Mahendran <opensource.ganesh@gmail.com>
parent fad9571d
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -66,7 +66,7 @@ public class KernelWakelockReader {
     */
    public final KernelWakelockStats readKernelWakelockStats(KernelWakelockStats staleStats) {
        byte[] buffer = new byte[32*1024];
        int len;
        int len = 0;
        boolean wakeup_sources;
        final long startTime = SystemClock.uptimeMillis();

@@ -87,7 +87,11 @@ public class KernelWakelockReader {
                }
            }

            len = is.read(buffer);
            int cnt;
            while ((cnt = is.read(buffer, len, buffer.length - len)) > 0) {
                len += cnt;
            }

            is.close();
        } catch (java.io.IOException e) {
            Slog.wtf(TAG, "failed to read kernel wakelocks", e);