Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <allison.henderson@oracle.com>
Cc: linux-rdma@vger.kernel.org
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Link: https://patch.msgid.link/20250512092736.229935-16-bigeasy@linutronix.de
Signed-off-by: Paolo Abeni <pabeni@redhat.com>

authored by

Sebastian Andrzej Siewior and committed by
Paolo Abeni
c50d295c 0af5928f

+8 -2
+8 -2
net/rds/page.c
··· 40 40 struct rds_page_remainder { 41 41 struct page *r_page; 42 42 unsigned long r_offset; 43 + local_lock_t bh_lock; 43 44 }; 44 45 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 + }; 47 49 48 50 /** 49 51 * rds_page_remainder_alloc - build up regions of a message. ··· 89 87 } 90 88 91 89 local_bh_disable(); 90 + local_lock_nested_bh(&rds_page_remainders.bh_lock); 92 91 rem = this_cpu_ptr(&rds_page_remainders); 93 92 94 93 while (1) { ··· 118 115 } 119 116 120 117 /* alloc if there is nothing for us to use */ 118 + local_unlock_nested_bh(&rds_page_remainders.bh_lock); 121 119 local_bh_enable(); 122 120 123 121 page = alloc_page(gfp); 124 122 125 123 local_bh_disable(); 124 + local_lock_nested_bh(&rds_page_remainders.bh_lock); 126 125 rem = this_cpu_ptr(&rds_page_remainders); 127 126 128 127 if (!page) { ··· 143 138 rem->r_offset = 0; 144 139 } 145 140 141 + local_unlock_nested_bh(&rds_page_remainders.bh_lock); 146 142 local_bh_enable(); 147 143 out: 148 144 rdsdebug("bytes %lu ret %d %p %u %u\n", bytes, ret,