Spinlocks in StorPort and virtual miniport?

Hi All,

According to the Storport’s docs for virtual miniports - no spinlocks are гіув during a call to StartIo.

But under high load with DiskSpd.exe I can see with performance analyzer that spinlocks are constantly used in storport.sys!RaidStartIoPacket. And this seems to be a bottle neck for the miniport’s throughput when multiple threads doing I/O simultaneously. The cores are 100% busy trying to acquire the spinlocks.

Is it normal behavior when Storport calls a virtual miniport’s StartIo?

The miniport sets adapter’s parameters as follows:

pPortInfo->MaximumTransferLength = 0x10000;
pPortInfo->NumberOfPhysicalBreaks = 0x11;
pPortInfo->AlignmentMask = FILE_LONG_ALIGNMENT;
pPortInfo->NumberOfBuses = 1;
pPortInfo->InitiatorBusId[ 0 ] = 0x3F;
pPortInfo->MaximumNumberOfTargets = 64;
pPortInfo->MaximumNumberOfLogicalUnits = 8;

pPortInfo->SynchronizationModel = StorSynchronizeFullDuplex;
pPortInfo->VirtualDevice = TRUE;
pPortInfo->ScatterGather = TRUE;
pPortInfo->CachesData = FALSE;
pPortInfo->NeedPhysicalAddresses = TRUE;
pPortInfo->Master = TRUE;

pPortInfo->MaxIOsPerLun = 2048;
pPortInfo->InitialLunQueueDepth = 2048;
pPortInfo->MaxNumberOfIO = pPortInfo->MaxIOsPerLun * pPortInfo->MaximumNumberOfTargets * pPortInfo->MaximumNumberOfLogicalUnits;
pPortInfo->Dma64BitAddresses = SCSI_DMA64_MINIPORT_FULL64BIT_NO_BOUNDARY_REQ_SUPPORTED;

StorPortSetAdapterBusType(pDeviceExtension, 0xA);

and HW_INITIALIZATION_DATA setting are:

InitData.MapBuffers = STOR_MAP_NON_READ_WRITE_BUFFERS;
InitData.TaggedQueuing = TRUE; 
InitData.AutoRequestSense = TRUE; 
InitData.MultipleRequestPerLu = TRUE;
InitData.NeedPhysicalAddresses = TRUE; 

InitData.FeatureSupport |= STOR_FEATURE_VIRTUAL_MINIPORT 
	| STOR_FEATURE_DEVICE_NAME_NO_SUFFIX 
	| STOR_FEATURE_FULL_PNP_DEVICE_CAPABILITIES
	| STOR_FEATURE_ADAPTER_NOT_REQUIRE_IO_PORT;

InitData.SrbTypeFlags = SRB_TYPE_FLAG_STORAGE_REQUEST_BLOCK | SRB_TYPE_FLAG_SCSI_REQUEST_BLOCK;
InitData.AddressTypeFlags = ADDRESS_TYPE_FLAG_BTL8;

BuildIo is not locked, startio is locked. Do your setup work in BuildIo and
just commit the request in startio.

Mark Roddy

@Mark_Roddy said:
BuildIo is not locked, startio is locked. Do your setup work in BuildIo and
just commit the request in startio.
Hi Mark,
Thank you for your answer!

But it’s a virtual miniport, BuildIo is not used, only StartIo without holding any locks (according to the MSDN).
I’ve just rechecked it with my dummy BuildIo callback, but Storport doesn’t call it for the virtual miniport.

For more details here is a CPU Flame picture with function names for one of my performance tests with DiskSpd (with 24 threads) - https://drive.google.com/file/d/1tBSJjx07tQMbrpS6y6VsPAXeuGu7zKxN/view?usp=sharing

It looks like for me that Storport itself consumes much more CPU time than the StartIo callback, isn’t it?

Best regards,
Valeriy Glushkov