All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Theodore Ts'o" <tytso@mit.edu>
To: jwbda <jwbda@proton.me>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: How to quick test/debug in linux kernel?
Date: Sun, 18 Aug 2024 23:50:49 -0400	[thread overview]
Message-ID: <20240819035049.GA9627@mit.edu> (raw)
In-Reply-To: <MvEVlTCbeP8Fr6I7mi3pGDQuv7_Yc7CB2OITb8_7IOgJvxmHxXKeIv8XTzTBfazMnyWs6SlMqcM4hAd_TKiRKL9TXppOEFEzbtrZ93Y9Jqc=@proton.me>

On Fri, Aug 16, 2024 at 11:05:31AM +0000, jwbda wrote:
> 
> Hi guys, would you mind help me with this:
> How to quick test/debug in linux kernel?
> 
> Here is my method: 
> Make some changes to the source code, add this line of code `printk(KERN_INFO ">>> run in kernel!\n");`
> 
> Then compile and run
> 
> ```sh
> make -j12
> sudo qemu-system-x86_64 -hda ./mybuild/mylinux.img -m 4096 --enable-kvm -kernel ./linux/arch/x86_64/boot/bzImage -append "root=/dev/sda rw console=ttyS0" -nographic
> ```
> Then check the results in the console. But I think this method is still a bit cumbersome. May I ask how do you quickly test/debug in linux kernel?

Since I'm file system developer, I have my own test appliance which is
optimized for running test kernels via KVM and on GCE.  For more
information, see:

    https://thunk.org/gce-xfstests
    https://github.com/tytso/xfstests-bld/blob/master/Documentation/kvm-quickstart.md
    https://github.com/tytso/xfstests-bld/blob/master/Documentation/kvm-xfstests.md

The quick version: after installing xfstest-bld, I just run these commands:

   # This will install kernel config that is suitable for use with
   # kvm-xfstests or gce-xfstests
   install-kconfig
   # This is a convenience script that will build the kernel, with
   # some options if you are using a separate build directores, which
   # is handy if you are building for multiple CPU architectures, i.e.,
   #x86_64, i386, and/or arm64
   kbuild
   # This will launch a VM using qemu/kvm using the just-built kernel.
   kvm-xfstest shell

(Note: "kvm-xfstests shell" is morally equivalent to your
qemu-system-x86_64 command.  For example, if you run "kvm-fstests
shell --noaction" you'll see that it runs a *very* long command that
begins "ionice -n 5 qemu-system-x86_64 -boot order=c -net none ...")

If you are testing a file system change, you can kick off a file
system smoke test via:

   kvm-xfstests smoke

And if you have gce-xfstests set up, I will run multiple VM's for
different file sytem configurations using a command such as:

   gce-xfstest ltm -c ext4/all -g auto

The above command will create 12 Cloud VM's using Google Compute
Engine, run them in parallel, and then coalesce the result into a
single test report, and e-mail it to me.  It takes a little over two
hours of wall clock time, but it runs about 24 hours worth of tests.
So while I *could* run:

   kvm-xfstests -c ext4/all -g auto

... I'm too impatient, and using Google Cloud costs about two
dollars (USD), and saves me more than 10x the test time.

The whole system system is set up for development velocity; in
general, you only need to run install-kconfig once, unless you are
moving to a new kernel version, or you want to use different build
options ---- such as "install-kconfig --lockdep", or "install-kconfig
--kasan", etc.  And as I mentioned you can build for different
architectures if you have cross-build compilers installed, via
commands such as "install-kconfig --arch arm66" and "install-kconfig
--arch arm64".  Both kvm-xfstests and gce-xfstests support using
alternate architectures; using kvm-xfstest it will use qemu to run
with CPU emulation, and with gce-xfstests, Google Cloud supports arm64
VM's, so you can build an arm64 binary, and then gce-xfstests will
launch an arm VM and boot the kernel in that VM.

In general, my development workflow is:

1)  Hack the kernel, or apply patches sent by ext4 developers for review
2)  Run kbuild
3)  Run "kvm-xfstests shell" or "kvm-xfstests smoke"

And after applying a number of patches, I'll kick off a full
regression test build via "gce-xfstests ltm -c ext4/all -g auto" and
then come back after lunch or dinner and check for any new test
failures.

Cheers,

					- Ted


      reply	other threads:[~2024-08-19  3:51 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-16 11:05 How to quick test/debug in linux kernel? jwbda
2024-08-19  3:50 ` Theodore Ts'o [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240819035049.GA9627@mit.edu \
    --to=tytso@mit.edu \
    --cc=jwbda@proton.me \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.