Skip to content

[Coverity] Review kernel program cache locks #19495

@AlexeySachkov

Description

@AlexeySachkov

You can see Coverity issues at https://scan.coverity.com/projects/intel-llvm?tab=overview

This report is motivated by 512040 - from what I understand, Coverity's concern is that here we acquire multiple locks and it may lead to a deadlock if there is another place where the same set (or a subset bigger than 1 lock) is acquired as well, but in a different order.

I don't know if we have a precedent for this, but the comment around the function says that it should only be used in unit tests.
That makes me think that it may not be ready for a production usage in a multi-threaded environment.

/// Clears cache state.
///
/// This member function should only be used in unit tests.
void reset() {
std::lock_guard<std::mutex> EvictionListLock(MProgramEvictionListMutex);
std::lock_guard<std::mutex> L1(MProgramCacheMutex);
std::lock_guard<std::mutex> L2(MKernelsPerProgramCacheMutex);

However, it is used several times in the SYCL RT:

Context.getKernelProgramCache().reset();

ContextImpl.getKernelProgramCache().reset();

I think that we should clarify the comment and double-check if a deadlock Coverity is talking about is indeed possible or not

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions