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

Commit

Permalink
runtime: clh: disable virtiofs DAX when FS cache size is 0
Browse files Browse the repository at this point in the history
Guest consumes 120Mb more of memory when DAX is enabled and the default
FS cache size (8G) is used. Disable dax when it is not required
reducing guest's memory footprint.

Without this patch:

```
7fdea4000000-7fdee4000000 rw-s 18850589 /memfd:ch_ram (deleted)
Size:            1048576 kB
KernelPageSize:        4 kB
MMUPageSize:           4 kB
Rss:              187876 kB
```

With this patch:

```
7fa970000000-7fa9b0000000 rw-s 612001  /memfd:ch_ram (deleted)
Size:            1048576 kB
KernelPageSize:        4 kB
MMUPageSize:           4 kB
Rss:               57308 kB
Pss:               56722 kB
```

fixes #3072

Signed-off-by: Julio Montes <[email protected]>
  • Loading branch information
Julio Montes committed Nov 13, 2020
1 parent 4ec184a commit 02af5c9
Showing 1 changed file with 17 additions and 16 deletions.
33 changes: 17 additions & 16 deletions virtcontainers/clh.go
Original file line number Diff line number Diff line change
Expand Up @@ -1209,22 +1209,23 @@ func (clh *cloudHypervisor) addVolume(volume types.Volume) error {
return err
}

if clh.config.VirtioFSCache == virtioFsCacheAlways {
clh.vmconfig.Fs = []chclient.FsConfig{
{
Tag: volume.MountTag,
CacheSize: int64(clh.config.VirtioFSCacheSize << 20),
Socket: vfsdSockPath,
},
}
} else {
clh.vmconfig.Fs = []chclient.FsConfig{
{
Tag: volume.MountTag,
Socket: vfsdSockPath,
},
}

// disable DAX if VirtioFSCacheSize is 0
dax := clh.config.VirtioFSCacheSize != 0

// numQueues and queueSize are required, let's use the
// default values defined by cloud-hypervisor
numQueues := int32(1)
queueSize := int32(1024)

clh.vmconfig.Fs = []chclient.FsConfig{
{
Tag: volume.MountTag,
Socket: vfsdSockPath,
Dax: dax,
CacheSize: int64(clh.config.VirtioFSCacheSize << 20),
NumQueues: numQueues,
QueueSize: queueSize,
},
}

clh.Logger().Debug("Adding share volume to hypervisor: ", volume.MountTag)
Expand Down

0 comments on commit 02af5c9

Please sign in to comment.