How to map translated CPU and group for newly added CPU?

my query is something similar: https://community.osr.com/discussion/157977.

  • Usually for active CPUs(KeQueryActiveProcessorCountEx), raw and translated resource are allocated in start device with cpu number and group, same are used for connecting interrupt for the CPU.

  • In Resource Requirement(IRP_MN_FILTER_RESOURCE_REQUIREMENTS), resource mapped only active cpus and group and index numbers queiried.

  • I have registered callback using KeRegisterProcessorChangeCallback, able to see callback called when CPU added.
    howeever how to get Raw and Translated resource for added CPU in runtime to map CPU number and group number for connecting Interrupt with CPU, group, vector etc.

What kind of resources are trying to get for a CPU? CPUs don’t have resources in the same way that other devices do.

@MBond2 tHank you for reply.
I need CmResourceTypeInterrupt(Interrupt) resource for available maximum cpus.
as per current logic, I am only able to map interrupt resource only active cpus.

For example server OS supports 64 Logical cpus, I need to initilize Interrupt resource for available maximum resource. So that if active CPUS are added i connect interrupt.

The linked thread appears to have the answer. from Jake Oshins, that you need to invalidate your device state to trigger a pnp resource rebalancing which in turn will re-run your device resource configuration pnp operations. You can only allocate resources to devices as part of pnp state processing.

Thanks @Mark_Roddy I will try that option and check rebalance can happen. I have query in that case currently processing data in other cpus will stop ? for example there 10 active CPUS where data is being processed, 11th CPU added and need to rebalance.

@Mark_Roddy I saw it but since i am doing hotplug in of CPU. I was expecting is there anything i can do rebalancing runtime and also the answer was given some years back.

Nope. You have to go through the PnP state machine, and yes it is disruptive.

@Mark_Roddy sure Mark will keep you update…

An interrupt is not a resource of the CPU - what you want is a new resource for your device that references this newly added CPU. The only way to get that is to trigger the arbitration process. The ‘hot’ version is called rebalance and it is disruptive by necessity

@MBond2 Thank you for response. what is meant by arbitration process ?

In mean time before trying rebalance, even though not recommended I tried allocate Interrupt resource with Interrupt.u.Interrupt.AffinityPolicy = IrqPolicyMachineDefault;
resource in driver start device recieved raw and translated resource. And tried to use the same resource for interrupt connect once CPU is available with specific number and group. However IoConnectInterruptEx returned C00000BB(The request is not supported) :slight_smile:

Resource arbitration is the process that the PNP manager goes through to decide which resources are assigned to each device.

On modern hardware resource conflicts are not common, but hardware resources are still finite and the resource that you want may not be available. You can’t just decide that you are going to use it. You have to wait for the PNP manager to decide that you can have it and allocates it to you. Once it does that, you can also be confident that someone else won’t decide that they can just use it

1 Like

@MBond2 thanks for reply. As process looks tedious so many requests are hitting for child devices and FDO of bus driver. However one query I have.

In Bus driver I have set following things:

KeProcessorAddCompleteNotify (CPU addition Register Callback)

  • IoInvalidateDeviceState(__FdoGetPhysicalDeviceObject(Fdo));

Recieved Following IRPs for Bus FDO

  • IRP_MN_QUERY_PNP_DEVICE_STATE (PNP_DEVICE_RESOURCE_REQUIREMENTS_CHANGED)
    IRP for STOP Query and STOP not received.
  • IRP_MN_QUERY_RESOURCE_REQUIREMENTS
  • IRP_MN_FILTER_RESOURCE_REQUIREMENTS
  • IRP_MN_START_DEVICE

Query:
Somehow I am not getting IRP_MN_QUERY_STOP_DEVICE, IRP_MN_STOP_DEVICE as per MSDN I should recieve, statemachine clean up is done here.

Additional Info:
For Child PDO, following IRPs recieved QUERY_STOP_DEVICE, STOP_DEVICE, START_DEVICE before bus FDO IRP_MN_QUERY_RESOURCE_REQUIREMENTS.

Nevermind above reply one of the child device stop/stop query not completed.