Skip to contentSkip to conversation

RDMA/rxe: remove redundant assignment to variable page_offset

PATCH Applied Colin Ian King 3 participants 3 messages Oct 14, 2025 – Oct 19, 2025

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 RDMA/rxe: remove redundant assignment to variable page_offset

The variable page_offset is being assigned a value at the start of a loop and being redundantly zero'd at the end of the loop, there is no code that reads the zero'd value. The assignment is redundant and can be removed.

---
 drivers/infiniband/sw/rxe/rxe_mr.c  | 1 -
 drivers/infiniband/sw/rxe/rxe_odp.c | 1 -
 2 files changed, 2 deletions(-)
drivers/infiniband/sw/rxe/rxe_mr.c +0 -1
index bcb97b3ea58a..b1df05238848 100644
@@ -452,7 +452,6 @@ static int rxe_mr_flush_pmem_iova(struct rxe_mr *mr, u64 iova, unsigned int leng
 
 		length -= bytes;
 		iova += bytes;
-		page_offset = 0;
 	}
 
 	return 0;
drivers/infiniband/sw/rxe/rxe_odp.c +0 -1
index f58e3ec6252f..ae71812bea82 100644
@@ -358,7 +358,6 @@ int rxe_odp_flush_pmem_iova(struct rxe_mr *mr, u64 iova,
 
 		length -= bytes;
 		iova += bytes;
-		page_offset = 0;
 	}
 
 	mutex_unlock(&umem_odp->umem_mutex);
Signature · 1 line
2.51.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 16 lines · Colin Ian King

The variable page_offset is being assigned a value at the start of a loop and being redundantly zero'd at the end of the loop, there is no code that reads the zero'd value. The assignment is redundant and can be removed.

---
  drivers/infiniband/sw/rxe/rxe_mr.c  | 1 -
  drivers/infiniband/sw/rxe/rxe_odp.c | 1 -
  2 files changed, 2 deletions(-)
drivers/infiniband/sw/rxe/rxe_mr.c +0 -0
index bcb97b3ea58a..b1df05238848 100644

drivers/infiniband/sw/rxe/rxe_mr.c static int rxe_mr_flush_pmem_iova(struct rxe_mr *mr, u64 iova, unsigned int leng · line 455

Quoted 5 lines
drivers/infiniband/sw/rxe/rxe_mr.c +0 -1
@@ -452,7 +452,6 @@ static int rxe_mr_flush_pmem_iova(struct rxe_mr *mr, u64 iova, unsigned int leng
 
  		length -= bytes;
  		iova += bytes;
-		page_offset = 0;
  	}

static int rxe_mr_flush_pmem_iova(struct rxe_mr *mr, u64 iova, unsigned int length)

{
	unsigned int page_offset;
	...
	while (length > 0) {
		index = rxe_mr_iova_to_index(mr, iova);
		page = xa_load(&mr->page_list, index);
		page_offset = rxe_mr_iova_to_page_offset(mr, iova);
	...
		page_offset = 0;
	}

	return 0;
}>

drivers/infiniband/sw/rxe/rxe_odp.c int rxe_odp_flush_pmem_iova(struct rxe_mr *mr, u64 iova, · line 361

Quoted 11 lines
drivers/infiniband/sw/rxe/rxe_mr.c +0 -0
  	return 0;
drivers/infiniband/sw/rxe/rxe_odp.c +0 -1
index f58e3ec6252f..ae71812bea82 100644
@@ -358,7 +358,6 @@ int rxe_odp_flush_pmem_iova(struct rxe_mr *mr, u64 iova,
 
  		length -= bytes;
  		iova += bytes;
-		page_offset = 0;
  	}

int rxe_odp_flush_pmem_iova(struct rxe_mr *mr, u64 iova,
unsigned int length)

{
	unsigned int page_offset;
...
	while (length > 0) {
		index = rxe_odp_iova_to_index(umem_odp, iova);
		page_offset = rxe_odp_iova_to_page_offset(umem_odp, iova);
...
		page_offset = 0;
	}

	mutex_unlock(&umem_odp->umem_mutex);

	return 0;
}

From the above, in the functions rxe_mr_flush_pmem_iova and rxe_odp_flush_pmem_iova, within the while loop, the variable page_offset is assigned a value. At the end of the loop, page_offset is set to 0. However, this assignment at the end of the loop is actually unnecessary.

Thanks,

Zhu Yanjun

Quoted 2 lines
drivers/infiniband/sw/rxe/rxe_odp.c +0 -0
  	mutex_unlock(&umem_odp->umem_mutex);
#2 lore raw
In reply to Colin Ian King
Quoted 6 lines · Colin Ian King

The variable page_offset is being assigned a value at the start of a loop and being redundantly zero'd at the end of the loop, there is no code that reads the zero'd value. The assignment is redundant and can be removed.

Applied, thanks!

[1/1] RDMA/rxe: remove redundant assignment to variable page_offset

      https://git.kernel.org/rdma/rdma/c/1511efaca032ed

Best regards,

Signature · 1 line
Leon Romanovsky <[email protected]>