Manage the PMU in VMs

This document explains how to change the performance monitoring unit (PMU) typeenabled in a virtual machine (VM) instance, or disable it. To learn more aboutthe PMU, seePMU overview.

After you've enabled the PMU in a VM and run performance-monitoring software onthe VM, you can do the following:

  • Change the PMU type enabled in the VM. This change is useful when youwant to track different types of low-level CPU events.

  • Disable the PMU in the VM. This action is useful when you no longer needto access the performance counters in the PMU.

Before you begin

Required roles

To get the permissions that you need to change the PMU type enabled in a VM or disable it, ask your administrator to grant you theCompute Instance Admin (v1) (roles/compute.instanceAdmin.v1) IAM role on your project. For more information about granting roles, seeManage access to projects, folders, and organizations.

This predefined role contains the permissions required to change the PMU type enabled in a VM or disable it. To see the exact permissions that are required, expand theRequired permissions section:

Required permissions

The following permissions are required to change the PMU type enabled in a VM or disable it:

  • To update a VM:compute.instances.update on the VM

You might also be able to get these permissions withcustom roles or otherpredefined roles.

Change the PMU type in a VM

Before changing the PMU type enabled in an existing C4A or C4 VM,view the details of the VM using theGoogle Cloud CLI or REST API. In the output from the command or APIrequest, verify the following:

  1. To verify the PMU type enabled in the VM, check the value of theperformanceMonitoringUnit field. If the field is missing, then the PMU isdisabled.

  2. If you want to enable the Enhanced PMU type, then make sure that the VM isusing a C4 machine type with 96 or 192 vCPUs by checking the value of themachineType field. If not, thenchange the machine type of the VM.

You don't have to stop the VM to change the PMU type enabled in it. However, tomake the change effective, you must restart the VM as described in this section.

To change the PMU type enabled in an existing VM, select one of the followingoptions:

gcloud

  1. Create an empty YAML file.

  2. To export the properties of a VM into the YAML file that you've justcreated, use thegcloud compute instances export command:

    gcloud compute instances exportVM_NAME \    --destination=YAML_FILE \    --zone=ZONE

    Replace the following:

    • VM_NAME: the name of the VM.

    • YAML_FILE: the path to the YAML file that youcreated in the previous step.

    • ZONE: the zone where the VM is located.

  3. In the YAML configuration file, locate theperformanceMonitoringUnitfield and change its value to specify a different PMU type:

    advancedMachineFeatures:  performanceMonitoringUnit:PMU_TYPE

    ReplacePMU_TYPE with one of the following values:

    • Architectural PMU type:ARCHITECTURAL

    • Standard PMU type:STANDARD

    • Enhanced PMU type:ENHANCED

    Tip: To avoid getting an error such as"ERROR: (gcloud.compute.instances.update-from-file) Cannot parse YAML: [Expected type for field value, found True (type)]", add quotes (' ') around any label values ofyes orno in the exported instance configuration file. This indicates the values are strings, not Boolean values.
  4. To update the VM and restart it, use thegcloud compute instances update-from-file commandwith the--most-disruptive-allowed-action flag set toRESTART:

    gcloud compute instances update-from-fileVM_NAME \    --most-disruptive-allowed-action=RESTART \    --source=YAML_FILE \    --zone=ZONE

    Replace the following:

    • VM_NAME: the name of the VM.

    • YAML_FILE: the path to the YAML file with theconfiguration data that you modified in the previous step.

    • ZONE: the zone where the VM is located.

REST

  1. Create an empty JSON file.

  2. To view the properties of an existing VM, make aGET request to theinstances.get method:

    GET https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/zones/ZONE/instances/VM_NAME

    Replace the following:

    • PROJECT_ID: the ID of the project where the VM islocated.

    • ZONE: the zone where the VM is located.

    • VM_NAME: the name of an existing VM.

  3. In the empty JSON file that you created in the previous steps, do thefollowing:

    1. Enter the VM properties from theGET request output.

    2. Locate theperformanceMonitoringUnit field, and then change itsvalue to specify a different PMU type:

      "advancedMachineFeatures": {  "performanceMonitoringUnit": "PMU_TYPE"}

      ReplacePMU_TYPE with one of the followingvalues:

      • Architectural PMU type:ARCHITECTURAL

      • Standard PMU type:STANDARD

      • Enhanced PMU type:ENHANCED

  4. To update the VM and restart it, make aPUT request to theinstances.update method.In the request, do the following:

    • In the request URL, include themostDisruptiveAllowedAction queryparameter set toRESTART.

    • For the request body, use the VM properties from the JSON file thatyou created and updated in the previous steps.

    The request is similar to the following:

    PUT https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/zones/ZONE/instances/VM_NAME?mostDisruptiveAllowedAction=RESTART{  "advancedMachineFeatures": {    "performanceMonitoringUnit": "PMU_TYPE"  },  ...}

For more information about updating the properties of a VM, seeUpdate VM properties.

Disable the PMU in a VM

You don't have to stop the VM to disable the PMU. However, to make the changeeffective, you must restart the VM as described in this section.

To disable the PMU in an existing VM, select one of the following options:

gcloud

  1. Create an empty YAML file.

  2. To export the properties of a VM into the YAML file that you've justcreated, use thegcloud compute instances export command:

    gcloud compute instances exportVM_NAME \    --destination=YAML_FILE \    --zone=ZONE

    Replace the following:

    • VM_NAME: the name of the VM.

    • YAML_FILE: the path to the YAML file that youcreated in the previous step.

    • ZONE: the zone where the VM is located.

  3. In the YAML configuration file, locate theperformanceMonitoringUnitfield and set its value toNONE:

    advancedMachineFeatures:  performanceMonitoringUnit: NONE
    Tip: To avoid getting an error such as"ERROR: (gcloud.compute.instances.update-from-file) Cannot parse YAML: [Expected type for field value, found True (type)]", add quotes (' ') around any label values ofyes orno in the exported instance configuration file. This indicates the values are strings, not Boolean values.
  4. To update the VM and restart it, use thegcloud compute instances update-from-file commandwith the--most-disruptive-allowed-action flag set toRESTART:

    gcloud compute instances update-from-fileVM_NAME \    --most-disruptive-allowed-action=RESTART \    --source=YAML_FILE \    --zone=ZONE

    Replace the following:

    • VM_NAME: the name of the VM.

    • YAML_FILE: the path to the YAML file with theconfiguration data that you modified in the previous step.

    • ZONE: the zone where the VM is located.

REST

  1. Create an empty JSON file.

  2. To view the properties of an existing VM, make aGET request to theinstances.get method:

    GET https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/zones/ZONE/instances/VM_NAME

    Replace the following:

    • PROJECT_ID: the ID of the project where the VM islocated.

    • ZONE: the zone where the VM is located.

    • VM_NAME: the name of an existing VM.

  3. In the empty JSON file that you created in the previous steps, do thefollowing:

    1. Enter the VM properties from theGET request output.

    2. Locate theperformanceMonitoringUnit field, and then change itsvalue toNONE:

      "advancedMachineFeatures": {  "performanceMonitoringUnit": "NONE"}
  4. To update the VM and restart it, make aPUT request to theinstances.update method.In the request, do the following:

    • In the request URL, include themostDisruptiveAllowedAction queryparameter set toRESTART.

    • For the request body, use the VM properties from the JSON file thatyou created and updated in the previous steps.

    The request is similar to the following:

    PUT https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/zones/ZONE/instances/VM_NAME?mostDisruptiveAllowedAction=RESTART{  "advancedMachineFeatures": {    "performanceMonitoringUnit": "NONE"  },  ...}

For more information about updating the properties of a VM, seeUpdate VM properties.

What's next

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-12-15 UTC.