config: Add scsi_mod.scan=none for virtio-scsi

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 <justin.he@arm.com
This commit is contained in:
Jia He 2020-03-23 13:20:00 +08:00
parent af24829c2a
commit 8c850d9e3a
2 changed files with 18 additions and 4 deletions

View File

@ -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()
}
@ -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
}
}
@ -1004,7 +1014,7 @@ 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
}
}
@ -1012,7 +1022,7 @@ func SetKernelParams(runtimeConfig *oci.RuntimeConfig) error {
// 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
}
}

View File

@ -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)
}