mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-09 04:10:18 +09:00
UPSTREAM: dm bufio: introduce a global queue
Rename param_spinlock to global_spinlock and introduce a global queue of
all used buffers. The queue will be used in the following commits.
Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
(cherry picked from commit af53badc0c)
Bug: 136247322
Change-Id: I00fac757cdb8dadf23ed6140076dc5217468d137
Signed-off-by: Martijn Coenen <maco@android.com>
This commit is contained in:
committed by
Martijn Coenen
parent
c93619f6ab
commit
d4e9ac649b
@@ -132,6 +132,7 @@ enum data_mode {
|
||||
struct dm_buffer {
|
||||
struct rb_node node;
|
||||
struct list_head lru_list;
|
||||
struct list_head global_list;
|
||||
sector_t block;
|
||||
void *data;
|
||||
unsigned char data_mode; /* DATA_MODE_* */
|
||||
@@ -192,7 +193,9 @@ static unsigned long dm_bufio_cache_size;
|
||||
*/
|
||||
static unsigned long dm_bufio_cache_size_latch;
|
||||
|
||||
static DEFINE_SPINLOCK(param_spinlock);
|
||||
static DEFINE_SPINLOCK(global_spinlock);
|
||||
|
||||
static LIST_HEAD(global_queue);
|
||||
|
||||
/*
|
||||
* Buffers are freed after this timeout
|
||||
@@ -305,7 +308,7 @@ static void adjust_total_allocated(struct dm_buffer *b, bool unlink)
|
||||
if (unlink)
|
||||
diff = -diff;
|
||||
|
||||
spin_lock(¶m_spinlock);
|
||||
spin_lock(&global_spinlock);
|
||||
|
||||
*class_ptr[data_mode] += diff;
|
||||
|
||||
@@ -314,7 +317,13 @@ static void adjust_total_allocated(struct dm_buffer *b, bool unlink)
|
||||
if (dm_bufio_current_allocated > dm_bufio_peak_allocated)
|
||||
dm_bufio_peak_allocated = dm_bufio_current_allocated;
|
||||
|
||||
spin_unlock(¶m_spinlock);
|
||||
if (!unlink) {
|
||||
list_add(&b->global_list, &global_queue);
|
||||
} else {
|
||||
list_del(&b->global_list);
|
||||
}
|
||||
|
||||
spin_unlock(&global_spinlock);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user