mirror of
https://github.com/torvalds/linux.git
synced 2026-03-08 04:04:43 +01:00
rds: Acquire per-CPU pointer within BH disabled section
rds_page_remainder_alloc() obtains the current CPU with get_cpu() while disabling preemption. Then the CPU number is used to access the per-CPU data structure via per_cpu(). This can be optimized by relying on local_bh_disable() to provide a stable CPU number/ avoid migration and then using this_cpu_ptr() to retrieve the data structure. 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-15-bigeasy@linutronix.de Signed-off-by: Paolo Abeni <pabeni@redhat.com>
This commit is contained in:
parent
aaaaa6639c
commit
0af5928f35
1 changed files with 2 additions and 4 deletions
|
|
@ -86,8 +86,8 @@ int rds_page_remainder_alloc(struct scatterlist *scat, unsigned long bytes,
|
|||
goto out;
|
||||
}
|
||||
|
||||
rem = &per_cpu(rds_page_remainders, get_cpu());
|
||||
local_bh_disable();
|
||||
rem = this_cpu_ptr(&rds_page_remainders);
|
||||
|
||||
while (1) {
|
||||
/* avoid a tiny region getting stuck by tossing it */
|
||||
|
|
@ -116,12 +116,11 @@ int rds_page_remainder_alloc(struct scatterlist *scat, unsigned long bytes,
|
|||
|
||||
/* alloc if there is nothing for us to use */
|
||||
local_bh_enable();
|
||||
put_cpu();
|
||||
|
||||
page = alloc_page(gfp);
|
||||
|
||||
rem = &per_cpu(rds_page_remainders, get_cpu());
|
||||
local_bh_disable();
|
||||
rem = this_cpu_ptr(&rds_page_remainders);
|
||||
|
||||
if (!page) {
|
||||
ret = -ENOMEM;
|
||||
|
|
@ -140,7 +139,6 @@ int rds_page_remainder_alloc(struct scatterlist *scat, unsigned long bytes,
|
|||
}
|
||||
|
||||
local_bh_enable();
|
||||
put_cpu();
|
||||
out:
|
||||
rdsdebug("bytes %lu ret %d %p %u %u\n", bytes, ret,
|
||||
ret ? NULL : sg_page(scat), ret ? 0 : scat->offset,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue