Skip to content

Commit c50d295

Browse files
Sebastian Andrzej SiewiorPaolo Abeni
authored andcommitted
rds: Use nested-BH locking for rds_page_remainder
rds_page_remainder is a per-CPU variable and relies on disabled BH for its locking. Without per-CPU locking in local_bh_disable() on PREEMPT_RT this data structure requires explicit locking. Add a local_lock_t to the data structure and use local_lock_nested_bh() for locking. This change adds only lockdep coverage and does not alter the functional behaviour for !PREEMPT_RT. Cc: Allison Henderson <[email protected]> Cc: [email protected] Signed-off-by: Sebastian Andrzej Siewior <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Paolo Abeni <[email protected]>
1 parent 0af5928 commit c50d295

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

net/rds/page.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,12 @@
4040
struct rds_page_remainder {
4141
struct page *r_page;
4242
unsigned long r_offset;
43+
local_lock_t bh_lock;
4344
};
4445

45-
static
46-
DEFINE_PER_CPU_SHARED_ALIGNED(struct rds_page_remainder, rds_page_remainders);
46+
static DEFINE_PER_CPU_SHARED_ALIGNED(struct rds_page_remainder, rds_page_remainders) = {
47+
.bh_lock = INIT_LOCAL_LOCK(bh_lock),
48+
};
4749

4850
/**
4951
* rds_page_remainder_alloc - build up regions of a message.
@@ -87,6 +89,7 @@ int rds_page_remainder_alloc(struct scatterlist *scat, unsigned long bytes,
8789
}
8890

8991
local_bh_disable();
92+
local_lock_nested_bh(&rds_page_remainders.bh_lock);
9093
rem = this_cpu_ptr(&rds_page_remainders);
9194

9295
while (1) {
@@ -115,11 +118,13 @@ int rds_page_remainder_alloc(struct scatterlist *scat, unsigned long bytes,
115118
}
116119

117120
/* alloc if there is nothing for us to use */
121+
local_unlock_nested_bh(&rds_page_remainders.bh_lock);
118122
local_bh_enable();
119123

120124
page = alloc_page(gfp);
121125

122126
local_bh_disable();
127+
local_lock_nested_bh(&rds_page_remainders.bh_lock);
123128
rem = this_cpu_ptr(&rds_page_remainders);
124129

125130
if (!page) {
@@ -138,6 +143,7 @@ int rds_page_remainder_alloc(struct scatterlist *scat, unsigned long bytes,
138143
rem->r_offset = 0;
139144
}
140145

146+
local_unlock_nested_bh(&rds_page_remainders.bh_lock);
141147
local_bh_enable();
142148
out:
143149
rdsdebug("bytes %lu ret %d %p %u %u\n", bytes, ret,

0 commit comments

Comments
 (0)