Skip to content
This repository has been archived by the owner on May 12, 2021. It is now read-only.

Commit

Permalink
config: Add scsi_mod.scan=none for virtio-scsi
Browse files Browse the repository at this point in the history
As per [1], the default scan mode of scsi is sync.
kata-agent already scans the SCSI buses [2], changing it to none
can reduce the guest boot time.

=Before this patch=
[    0.113828] [    T1] scsi host0: Virtio SCSI HBA
[    0.134006] [    T1] tun: Universal TUN/TAP device driver, 1.6

=After this patch=
[    0.105891] [    T1] scsi host0: Virtio SCSI HBA
[    0.107868] [    T1] tun: Universal TUN/TAP device driver, 1.6

It reduces about 17ms on arm64 for virtio-scsi.

This patch changes the default kernel parameter:
1. If user specifies the scan mode, use that
2. If user doesn't specify it, and the block device is virtio-scsi, use
   "none" by default

[1] https://lwn.net/Articles/201898/
[2] https://github.com/kata-containers/agent/blob/649d44117a/device.go#L322

Fixes: #2560
Signed-off-by: Jia He <[email protected]
  • Loading branch information
justin-he committed Apr 15, 2020
1 parent af24829 commit 8c850d9
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
18 changes: 14 additions & 4 deletions pkg/katautils/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -977,7 +977,6 @@ func SetKernelParams(runtimeConfig *oci.RuntimeConfig) error {
if runtimeConfig.HypervisorConfig.Debug {
strParams := vc.SerializeParams(defaultKernelParams, "=")
formatted := strings.Join(strParams, " ")

kataUtilsLogger.WithField("default-kernel-parameters", formatted).Debug()
}

Expand All @@ -989,7 +988,18 @@ func SetKernelParams(runtimeConfig *oci.RuntimeConfig) error {

// first, add default values
for _, p := range defaultKernelParams {
if err := (runtimeConfig).AddKernelParam(p); err != nil {
if err := runtimeConfig.AddKernelParam(p); err != nil {
return err
}
}

// set the scsi scan mode to none for virtio-scsi
if runtimeConfig.HypervisorConfig.BlockDeviceDriver == config.VirtioSCSI {
p := vc.Param{
Key: "scsi_mod.scan",
Value: "none",
}
if err := runtimeConfig.AddKernelParam(p); err != nil {
return err
}
}
Expand All @@ -1004,15 +1014,15 @@ func SetKernelParams(runtimeConfig *oci.RuntimeConfig) error {
params := vc.KataAgentKernelParams(agentConfig)

for _, p := range params {
if err := (runtimeConfig).AddKernelParam(p); err != nil {
if err := runtimeConfig.AddKernelParam(p); err != nil {
return err
}
}
}

// now re-add the user-specified values so that they take priority.
for _, p := range userKernelParams {
if err := (runtimeConfig).AddKernelParam(p); err != nil {
if err := runtimeConfig.AddKernelParam(p); err != nil {
return err
}
}
Expand Down
4 changes: 4 additions & 0 deletions pkg/katautils/create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,10 @@ func TestSetKernelParams(t *testing.T) {
err := SetKernelParams(&config)
assert.NoError(err)

config.HypervisorConfig.BlockDeviceDriver = "virtio-scsi"
err = SetKernelParams(&config)
assert.NoError(err)

if needSystemd(config.HypervisorConfig) {
assert.NotEmpty(config.HypervisorConfig.KernelParams)
}
Expand Down

0 comments on commit 8c850d9

Please sign in to comment.