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

rds: use DIV_ROUND_UP instead of ceil

Yes indeed, DIV_ROUND_UP is in kernel.h.

Signed-off-by: Jacob Wen <jian.w.wen@oracle.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Jacob Wen and committed by
David S. Miller
eeb2c4fb 10262b0b

+5 -9
+2 -2
net/rds/ib_send.c
··· 522 522 if (be32_to_cpu(rm->m_inc.i_hdr.h_len) == 0) 523 523 i = 1; 524 524 else 525 - i = ceil(be32_to_cpu(rm->m_inc.i_hdr.h_len), RDS_FRAG_SIZE); 525 + i = DIV_ROUND_UP(be32_to_cpu(rm->m_inc.i_hdr.h_len), RDS_FRAG_SIZE); 526 526 527 527 work_alloc = rds_ib_ring_alloc(&ic->i_send_ring, i, &pos); 528 528 if (work_alloc == 0) { ··· 879 879 * Instead of knowing how to return a partial rdma read/write we insist that there 880 880 * be enough work requests to send the entire message. 881 881 */ 882 - i = ceil(op->op_count, max_sge); 882 + i = DIV_ROUND_UP(op->op_count, max_sge); 883 883 884 884 work_alloc = rds_ib_ring_alloc(&ic->i_send_ring, i, &pos); 885 885 if (work_alloc != i) {
+2 -2
net/rds/message.c
··· 341 341 { 342 342 struct rds_message *rm; 343 343 unsigned int i; 344 - int num_sgs = ceil(total_len, PAGE_SIZE); 344 + int num_sgs = DIV_ROUND_UP(total_len, PAGE_SIZE); 345 345 int extra_bytes = num_sgs * sizeof(struct scatterlist); 346 346 int ret; 347 347 ··· 351 351 352 352 set_bit(RDS_MSG_PAGEVEC, &rm->m_flags); 353 353 rm->m_inc.i_hdr.h_len = cpu_to_be32(total_len); 354 - rm->data.op_nents = ceil(total_len, PAGE_SIZE); 354 + rm->data.op_nents = DIV_ROUND_UP(total_len, PAGE_SIZE); 355 355 rm->data.op_sg = rds_message_alloc_sgs(rm, num_sgs, &ret); 356 356 if (!rm->data.op_sg) { 357 357 rds_message_put(rm);
-4
net/rds/rds.h
··· 48 48 } 49 49 #endif 50 50 51 - /* XXX is there one of these somewhere? */ 52 - #define ceil(x, y) \ 53 - ({ unsigned long __x = (x), __y = (y); (__x + __y - 1) / __y; }) 54 - 55 51 #define RDS_FRAG_SHIFT 12 56 52 #define RDS_FRAG_SIZE ((unsigned int)(1 << RDS_FRAG_SHIFT)) 57 53
+1 -1
net/rds/send.c
··· 1107 1107 size_t total_payload_len = payload_len, rdma_payload_len = 0; 1108 1108 bool zcopy = ((msg->msg_flags & MSG_ZEROCOPY) && 1109 1109 sock_flag(rds_rs_to_sk(rs), SOCK_ZEROCOPY)); 1110 - int num_sgs = ceil(payload_len, PAGE_SIZE); 1110 + int num_sgs = DIV_ROUND_UP(payload_len, PAGE_SIZE); 1111 1111 int namelen; 1112 1112 struct rds_iov_vector_arr vct; 1113 1113 int ind;