API for cacheline write trylock

Signed-off-by: Michal Mielewczyk <michal.mielewczyk@intel.com>
This commit is contained in:
Michal Mielewczyk 2021-01-14 23:48:08 -05:00
parent bd20d6119b
commit 6d962b38e9
2 changed files with 33 additions and 0 deletions

View File

@ -1157,3 +1157,17 @@ void ocf_cache_line_unlock_rd(struct ocf_cache *cache, ocf_cache_line_t line)
__unlock_cache_line_rd(c, line);
}
bool ocf_cache_line_try_lock_wr(struct ocf_cache *cache, ocf_cache_line_t line)
{
struct ocf_cache_line_concurrency *c = cache->device->concurrency.cache_line;
return __lock_cache_line_wr(c, line, NULL, NULL, 0);
}
void ocf_cache_line_unlock_wr(struct ocf_cache *cache, ocf_cache_line_t line)
{
struct ocf_cache_line_concurrency *c = cache->device->concurrency.cache_line;
OCF_DEBUG_RQ(cache, "Cache line = %u", line);
__unlock_cache_line_wr(c, line);
}

View File

@ -161,4 +161,23 @@ void ocf_cache_line_unlock_rd(struct ocf_cache *cache, ocf_cache_line_t line);
*/
bool ocf_cache_line_try_lock_rd(struct ocf_cache *cache, ocf_cache_line_t line);
/**
* @brief Release cache line write lock
*
* @param cache - OCF cache instance
* @param line - Cache line to be unlocked
*/
void ocf_cache_line_unlock_wr(struct ocf_cache *cache, ocf_cache_line_t line);
/**
* @brief Attempt to lock cache line for write
*
* @param cache - OCF cache instance
* @param line - Cache line to be checked for waiters
*
* @retval true - write lock successfully acquired
* @retval false - failed to acquire write lock
*/
bool ocf_cache_line_try_lock_wr(struct ocf_cache *cache, ocf_cache_line_t line);
#endif /* OCF_CONCURRENCY_H_ */