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

Commit 0f3f4f40 authored by Jooyung Han's avatar Jooyung Han Committed by Gerrit Code Review
Browse files

Merge changes I72a3720c,Idac0d0ef

* changes:
  Migrate compare-bootcharts.py to python3
  Unshare mount namespace in bootchart's thread
parents ebfdbc7a cee25aa9
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
@@ -140,6 +140,20 @@ static void log_processes(FILE* log) {
static void bootchart_thread_main() {
  LOG(INFO) << "Bootcharting started";

  // Unshare the mount namespace of this thread so that the init process itself can switch
  // the mount namespace later while this thread is still running.
  // Otherwise, setns() call invoked as part of `enter_default_mount_ns` fails with EINVAL.
  //
  // Note that after unshare()'ing the mount namespace from the main thread, this thread won't
  // receive mount/unmount events from the other mount namespace unless the events are happening
  // from under a sharable mount.
  //
  // The bootchart thread is safe to unshare the mount namespace because it only reads from /proc
  // and write to /data which are not private mounts.
  if (unshare(CLONE_NEWNS) == -1) {
      PLOG(ERROR) << "Cannot create mount namespace";
      return;
  }
  // Open log files.
  auto stat_log = fopen_unique("/data/bootchart/proc_stat.log", "we");
  if (!stat_log) return;
+9 −9
Original line number Diff line number Diff line
@@ -56,24 +56,24 @@ def analyze_process_maps(process_map1, process_map2, jiffy_record):
    ]

    jw = jiffy_record['jiffy_to_wallclock']
    print "process: baseline experiment (delta)"
    print " - Unit is ms (a jiffy is %d ms on the system)" % jw
    print "------------------------------------"
    print("process: baseline experiment (delta)")
    print(" - Unit is ms (a jiffy is %d ms on the system)" % jw)
    print("------------------------------------")
    for p in processes_of_interest:
        # e.g., 32-bit system doesn't have zygote64
        if p in process_map1 and p in process_map2:
            print "%s: %d %d (%+d)" % (
            print("%s: %d %d (%+d)" % (
                p, process_map1[p]['start_time'] * jw,
                process_map2[p]['start_time'] * jw,
                (process_map2[p]['start_time'] -
                 process_map1[p]['start_time']) * jw)
                 process_map1[p]['start_time']) * jw))

    # Print the last tick for the bootanimation process
    print "bootanimation ends at: %d %d (%+d)" % (
    print("bootanimation ends at: %d %d (%+d)" % (
        process_map1['/system/bin/bootanimation']['last_tick'] * jw,
        process_map2['/system/bin/bootanimation']['last_tick'] * jw,
        (process_map2['/system/bin/bootanimation']['last_tick'] -
            process_map1['/system/bin/bootanimation']['last_tick']) * jw)
            process_map1['/system/bin/bootanimation']['last_tick']) * jw))

def parse_proc_file(pathname, process_map, jiffy_record=None):
    # Uncompress bootchart.tgz
@@ -83,7 +83,7 @@ def parse_proc_file(pathname, process_map, jiffy_record=None):
            f = tf.extractfile('proc_ps.log')

            # Break proc_ps into chunks based on timestamps
            blocks = f.read().split('\n\n')
            blocks = f.read().decode('utf-8').split('\n\n')
            for b in blocks:
                lines = b.split('\n')
                if not lines[0]:
@@ -133,7 +133,7 @@ def parse_proc_file(pathname, process_map, jiffy_record=None):

def main():
    if len(sys.argv) != 3:
        print "Usage: %s base_bootchart_dir exp_bootchart_dir" % sys.argv[0]
        print("Usage: %s base_bootchart_dir exp_bootchart_dir" % sys.argv[0])
        sys.exit(1)

    process_map1 = {}