@@ -24,8 +24,13 @@ void initialize()
2424
2525// PDA keeps a handle to buffers that are registered to it.
2626// This exists as a file "/sys/bus/pci/drivers/uio_pci_dma/[PCI address]/dma/[some number]/map"
27+ // This can be problematic when a readout process crashes without giving the driver the chance to deregister DMA buffer,
28+ // because then even if the readout's handle to the buffer is manually deleted, PDA's handle stays.
29+ // And if there's not enough memory to create a new buffer, we are stuck.
30+ //
31+ // But there's a way out.
2732// If you echo that [some number] into "/sys/bus/pci/drivers/uio_pci_dma/[PCI address]/dma/free" it will be freed.
28- // Not sure what happens if you do this while it's in use by a readout process...
33+ // Not sure what happens if you do this while it's in use by a readout process... But we check if it's in use.
2934void freeUnusedChannelBuffers ()
3035{
3136 namespace bfs = boost::filesystem;
@@ -48,11 +53,13 @@ void freeUnusedChannelBuffers()
4853 if (bfs::is_directory (entry)) {
4954 std::string mapPath = dmaPath + " /" + bufferId + " /map" ;
5055 std::string freePath = dmaPath + " /free" ;
51- auto fuserResult = AliceO2::Common::System::executeCommand (" fuser " + mapPath);
56+ auto fuserResult = AliceO2::Common::System::executeCommand (" fuser " + mapPath + " 2>&1 " );
5257 if (fuserResult.empty ()) {
5358 // No process is using it, we can free the buffer!
5459 logger << " Freeing PDA buffer '" + mapPath + " '" << InfoLogger::InfoLogger::endm;
55- auto fuserResult = AliceO2::Common::System::executeCommand (" echo " + bufferId + " > " + freePath);
60+ AliceO2::Common::System::executeCommand (" echo " + bufferId + " > " + freePath);
61+ } else {
62+ logger << " Not freeing PDA buffer '" + mapPath + " ', fuser: '" + fuserResult + " '" << InfoLogger::InfoLogger::endm;
5663 }
5764 }
5865 }
0 commit comments