From owner-freebsd-current@freebsd.org Fri Dec 22 14:05:13 2017 Return-Path: Delivered-To: freebsd-current@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 8249FE9A5DD for ; Fri, 22 Dec 2017 14:05:13 +0000 (UTC) (envelope-from gurenchan@gmail.com) Received: from mail-it0-x241.google.com (mail-it0-x241.google.com [IPv6:2607:f8b0:4001:c0b::241]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 47DAD77D3D for ; Fri, 22 Dec 2017 14:05:13 +0000 (UTC) (envelope-from gurenchan@gmail.com) Received: by mail-it0-x241.google.com with SMTP id f143so14763255itb.0 for ; Fri, 22 Dec 2017 06:05:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=jYTehVeS83+GFWpeSyuDtg66L+rwOHAwe2kA3s4bqZ8=; b=I2m+W97YQogdCQnNUT7xbOoFEWYMt/Aeouin0yhgaiDm8rqEpEgzXRop13NnCFpytR 5/FsTe1kibnn5IcgcuRmVmcbAKUgCe+ZB4pvtgIX3YHYhJVlm7km0tQG1zWurgCfpwxV DvZ/vMI3MaZyRPc72qkZj2ift/xdeOfxDw9sC2QesliC5S2bCmSKcR9ImBIpRqbZLdnZ E/bo3GyUh78oBL7zzTqmyocrRpSUqxQ53dyMJ2bMPFnXv1NiOJ48kr6Ir3ogF/16GBZ4 wc/XwHS8lvwuZcLvtGkl+bgczYKJH3odXH4QDy4xcWV2PP9IQPsKi5k5/2rQjShtb7sh eX4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=jYTehVeS83+GFWpeSyuDtg66L+rwOHAwe2kA3s4bqZ8=; b=Pa3Grj0ZlycWDgzOxQQsV5ZAV3jB1ZM2+ghkdflPvGx4lyyyFPQBhfL/kEZaiYKgh5 p9/u8BdEk/P20QZcQMICHWQW4LiRc0wqOlM0X26J3/3buDiYGKWl/yWsXXFpK8NCRKFW 37tEIIkd4Qdfl4Kap16mSuXG+rSENAZr97i4xmdET4dWgYLkpmwsTGTLVxneF8oBrijZ 0D7lrUuqUugVqfnsh997l297AYWa160xKf1poonnIRYXh3d4HZ/6AswV1bx/Ea+5lXDA KFCTVmuTmJZwZpyjRvQfmdlGbhgASjbYIeKqkifPWEFgHwqvxqLrmTmmKV1+J431Arh/ TdjQ== X-Gm-Message-State: AKGB3mJgPDuwuSJKQCdHX72q2HASdYxikhRNen0GvRBdiE7bSq5VHCnI zRqWf9r5+g9yv2x0vW0PBah8ncxIrgeasqz8evQ= X-Google-Smtp-Source: ACJfBovc+tTMJvzqupGSNW7LAuEB/3/C+8fGqeLBigHTE+oFaLp++UWjeGgGkMlQXLFfyDkCjH7eCNVmmwb4Qo4Ty6A= X-Received: by 10.36.221.147 with SMTP id t141mr17723705itf.140.1513951512505; Fri, 22 Dec 2017 06:05:12 -0800 (PST) MIME-Version: 1.0 Received: by 10.107.164.203 with HTTP; Fri, 22 Dec 2017 06:05:11 -0800 (PST) In-Reply-To: <010001607d9c59d5-15b6b788-a7ea-4edf-96e4-1235dd1a5c26-000000@email.amazonses.com> References: <010001607d9c59d5-15b6b788-a7ea-4edf-96e4-1235dd1a5c26-000000@email.amazonses.com> From: blubee blubeeme Date: Fri, 22 Dec 2017 22:05:11 +0800 Message-ID: Subject: Re: [Request for review] Profiling the FreeBSD kernel boot To: Colin Percival Cc: "freebsd-current@freebsd.org" Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.25 X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 22 Dec 2017 14:05:13 -0000 On Fri, Dec 22, 2017 at 5:44 PM, Colin Percival wrote: > Hi everyone, > > For the past few months I've been working on code for profiling the FreeBSD > "kernel boot", i.e., everything between when kernel code starts running and > when we first enter userland as init(8). This is not trivial since it's > impossible to use tools like dtrace to monitor things prior to when said > tools are running. The goal of this exercise is to help me track down the > places where we're wasting time during the boot, and then to fix them. > > The approach I've taken is to add some macros -- most notably TSENTER() and > TSEXIT() -- which by default compile to nothing, but if the TSLOG kernel > option is enabled they compile to code which logs the cycle count (e.g., on > x86 the value from the RDTSC instruction) along with some other data (in > the > case of TSENTER and TSEXIT, the fact that we're entering/exiting a > function). > This can then be dumped via a sysctl (debug.tslog) and processed in > userland > to convert function entries/exits into stacks and to visualize the time > spent > in the boot process. > > Two examples: > > A flame chart of my laptop booting HEAD: > http://www.daemonology.net/timestamping/tslog-laptop.svg > > A flame chart of an EC2 c5.4xlarge instance booting 11.1-RELEASE: > http://www.daemonology.net/timestamping/tslog-c5.4xlarge.svg > > The patches (10 of them, to be applied in order), userland scripts, and > very > brief usage instructions are at: > http://www.daemonology.net/timestamping/tslog.tgz > > I hope to commit the patches in the next week, since I'm planning on > writing > a paper to submit to AsiaBSDCon (which has a deadline of December 31st); so > if anyone has interest/time to look at this in the near future (I mean, > it's > not like anyone is going to be busy this weekend, right?) I'd love to have > some feedback before it goes into the tree. > > -- > Colin Percival > Security Officer Emeritus, FreeBSD | The power to serve > Founder, Tarsnap | www.tarsnap.com | Online backups for the truly paranoid > _______________________________________________ > freebsd-current@freebsd.org mailing list > https://lists.freebsd.org/mailman/listinfo/freebsd-current > To unsubscribe, send any mail to "freebsd-current-unsubscribe@freebsd.org" > I've gotta say nice work with the tracing. Hopefully your talk gets accepted, i'd love to hear it.