Skip to content

Commit 398d932

Browse files
authored
Merge pull request #71325 from ousleyp/cnv-25663
CNV#25663: kernel samepage merging
2 parents deb2e0c + 67c175e commit 398d932

File tree

5 files changed

+173
-0
lines changed

5 files changed

+173
-0
lines changed

_topic_maps/_topic_map.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3998,6 +3998,8 @@ Topics:
39983998
File: virt-working-with-resource-quotas-for-vms
39993999
- Name: Specifying nodes for virtual machines
40004000
File: virt-specifying-nodes-for-vms
4001+
- Name: Activating kernel samepage merging (KSM)
4002+
File: virt-activating-ksm
40014003
- Name: Configuring certificate rotation
40024004
File: virt-configuring-certificate-rotation
40034005
- Name: Configuring the default CPU model

modules/virt-about-ksm.adoc

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
// Module included in the following assembly:
2+
//
3+
// * virt/virtual_machines/advanced_vm_management/virt-activating-ksm.adoc
4+
//
5+
6+
:_mod-docs-content-type: CONCEPT
7+
[id="virt-about-ksm_{context}"]
8+
= About using {VirtProductName} to activate KSM
9+
10+
You can configure {VirtProductName} to activate kernel samepage merging (KSM) when nodes experience memory overload.
11+
12+
[id="virt-ksm-configuration-methods"]
13+
== Configuration methods
14+
15+
You can enable or disable the KSM activation feature for all nodes by using the {product-title} web console or by editing the `HyperConverged` custom resource (CR). The `HyperConverged` CR supports more granular configuration.
16+
17+
[discrete]
18+
[id="virt-ksm-cr-configuration"]
19+
=== CR configuration
20+
21+
You can configure the KSM activation feature by editing the `spec.configuration.ksmConfiguration` stanza of the `HyperConverged` CR.
22+
23+
* You enable the feature and configure settings by editing the `ksmConfiguration` stanza.
24+
25+
* You disable the feature by deleting the `ksmConfiguration` stanza.
26+
27+
* You can allow {VirtProductName} to enable KSM on only a subset of nodes by adding node selection syntax to the `ksmConfiguration.nodeLabelSelector` field.
28+
29+
[NOTE]
30+
====
31+
Even if the KSM activation feature is disabled in {VirtProductName}, an administrator can still enable KSM on nodes that support it.
32+
====
33+
34+
[id="virt-ksm-node-labels"]
35+
== KSM node labels
36+
37+
{VirtProductName} identifies nodes that are configured to support KSM and applies the following node labels:
38+
39+
`kubevirt.io/ksm-handler-managed: "false"`:: This label is set to `"true"` when {VirtProductName} activates KSM on a node that is experiencing memory overload. This label is not set to `"true"` if an administrator activates KSM.
40+
41+
`kubevirt.io/ksm-enabled: "false"`:: This label is set to `"true"` when KSM is activated on a node, even if {VirtProductName} did not activate KSM.
42+
43+
These labels are not applied to nodes that do not support KSM.

modules/virt-configure-ksm-cli.adoc

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
// Module included in the following assembly:
2+
//
3+
// * virt/virtual_machines/advanced_vm_management/virt-activating-ksm.adoc
4+
//
5+
6+
:_mod-docs-content-type: PROCEDURE
7+
[id="virt-configure-ksm-cli_{context}"]
8+
= Configuring KSM activation by using the CLI
9+
10+
You can enable or disable {VirtProductName}'s kernel samepage merging (KSM) activation feature by editing the `HyperConverged` custom resource (CR). Use this method if you want {VirtProductName} to activate KSM on only a subset of nodes.
11+
12+
.Procedure
13+
14+
. Open the `HyperConverged` CR in your default editor by running the following command:
15+
+
16+
[source,terminal,subs="attributes+"]
17+
----
18+
$ oc edit hyperconverged kubevirt-hyperconverged -n {CNVNamespace}
19+
----
20+
21+
. Edit the `ksmConfiguration` stanza:
22+
* To enable the KSM activation feature for all nodes, set the `nodeLabelSelector` value to `{}`. For example:
23+
+
24+
[source,yaml,subs="attributes+"]
25+
----
26+
apiVersion: hco.kubevirt.io/v1beta1
27+
kind: HyperConverged
28+
metadata:
29+
name: kubevirt-hyperconverged
30+
namespace: {CNVNamespace}
31+
spec:
32+
configuration:
33+
ksmConfiguration:
34+
nodeLabelSelector: {}
35+
# ...
36+
----
37+
38+
* To enable the KSM activation feature on a subset of nodes, edit the `nodeLabelSelector` field. Add syntax that matches the nodes where you want {VirtProductName} to enable KSM. For example, the following configuration allows {VirtProductName} to enable KSM on nodes where both `<first_example_key>` and `<second_example_key>` are set to `"true"`:
39+
+
40+
[source,yaml,subs="attributes+"]
41+
----
42+
apiVersion: hco.kubevirt.io/v1beta1
43+
kind: HyperConverged
44+
metadata:
45+
name: kubevirt-hyperconverged
46+
namespace: {CNVNamespace}
47+
spec:
48+
configuration:
49+
ksmConfiguration:
50+
nodeLabelSelector:
51+
matchLabels:
52+
<first_example_key>: "true"
53+
<second_example_key>: "true"
54+
# ...
55+
----
56+
57+
* To disable the KSM activation feature, delete the `ksmConfiguration` stanza. For example:
58+
+
59+
[source,yaml,subs="attributes+"]
60+
----
61+
apiVersion: hco.kubevirt.io/v1beta1
62+
kind: HyperConverged
63+
metadata:
64+
name: kubevirt-hyperconverged
65+
namespace: {CNVNamespace}
66+
spec:
67+
configuration:
68+
# ...
69+
----
70+
71+
. Save the file.

modules/virt-configure-ksm-web.adoc

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// Module included in the following assembly:
2+
//
3+
// * virt/virtual_machines/advanced_vm_management/virt-activating-ksm.adoc
4+
//
5+
6+
:_mod-docs-content-type: PROCEDURE
7+
[id="virt-configure-ksm-web_{context}"]
8+
= Configuring KSM activation by using the web console
9+
10+
You can allow {VirtProductName} to activate kernel samepage merging (KSM) on all nodes in your cluster by using the {product-title} web console.
11+
12+
.Procedure
13+
14+
. From the side menu, click *Virtualization* -> *Overview*.
15+
16+
. Select the *Settings* tab.
17+
18+
. Select the *Cluster* tab.
19+
20+
. Expand *Resource management*.
21+
22+
. Enable or disable the feature for all nodes:
23+
* Set *Kernel Samepage Merging (KSM)* to on.
24+
* Set *Kernel Samepage Merging (KSM)* to off.
25+
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
:_mod-docs-content-type: ASSEMBLY
2+
[id="virt-activating-ksm"]
3+
= Activating kernel samepage merging (KSM)
4+
include::_attributes/common-attributes.adoc[]
5+
:context: virt-activating-ksm
6+
7+
toc::[]
8+
9+
{VirtProductName} can activate kernel samepage merging (KSM) when nodes are overloaded. KSM deduplicates identical data found in the memory pages of virtual machines (VMs). If you have very similar VMs, KSM can make it possible to schedule more VMs on a single node.
10+
11+
[IMPORTANT]
12+
====
13+
You must only use KSM with trusted workloads.
14+
====
15+
16+
[role="_prerequisites"]
17+
[id="prerequisites_{context}"]
18+
== Prerequisites
19+
* Ensure that an administrator has configured KSM support on any nodes where you want {VirtProductName} to activate KSM.
20+
21+
include::modules/virt-about-ksm.adoc[leveloffset=+1]
22+
23+
include::modules/virt-configure-ksm-web.adoc[leveloffset=+1]
24+
25+
include::modules/virt-configure-ksm-cli.adoc[leveloffset=+1]
26+
27+
[role="_additional-resources"]
28+
[id="additional-resources_{context}"]
29+
== Additional resources
30+
* xref:../../../virt/virtual_machines/advanced_vm_management/virt-specifying-nodes-for-vms.adoc#virt-specifying-nodes-for-vms[Specifying nodes for virtual machines]
31+
* xref:../../../nodes/scheduling/nodes-scheduler-node-selectors.adoc#nodes-scheduler-node-selectors[Placing pods on specific nodes using node selectors]
32+
* link:https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/9/html-single/configuring_and_managing_virtualization/index#proc_managing-ksm_optimizing-virtual-machine-cpu-performance[Managing kernel samepage merging] in the {op-system-base-full} documentation

0 commit comments

Comments
 (0)