diff options
author | Jacob Wen <jian.w.wen@oracle.com> | 2019-01-06 20:59:59 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2019-01-07 10:22:36 -0500 |
commit | eeb2c4fb6a3d0ebed35fbc13a255f691c8b8d7e5 (patch) | |
tree | a6a3fd94a38cd29cddb7b6ce6cf3f90fbf45f3ba | |
parent | 10262b0b53666cbc506989b17a3ead1e9c3b43b4 (diff) |
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>
-rw-r--r-- | net/rds/ib_send.c | 4 | ||||
-rw-r--r-- | net/rds/message.c | 4 | ||||
-rw-r--r-- | net/rds/rds.h | 4 | ||||
-rw-r--r-- | net/rds/send.c | 2 |
4 files changed, 5 insertions, 9 deletions
diff --git a/net/rds/ib_send.c b/net/rds/ib_send.c index 2dcb555e6350..4e0c36acf866 100644 --- a/net/rds/ib_send.c +++ b/net/rds/ib_send.c | |||
@@ -522,7 +522,7 @@ int rds_ib_xmit(struct rds_connection *conn, struct rds_message *rm, | |||
522 | if (be32_to_cpu(rm->m_inc.i_hdr.h_len) == 0) | 522 | if (be32_to_cpu(rm->m_inc.i_hdr.h_len) == 0) |
523 | i = 1; | 523 | i = 1; |
524 | else | 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 | work_alloc = rds_ib_ring_alloc(&ic->i_send_ring, i, &pos); | 527 | work_alloc = rds_ib_ring_alloc(&ic->i_send_ring, i, &pos); |
528 | if (work_alloc == 0) { | 528 | if (work_alloc == 0) { |
@@ -879,7 +879,7 @@ int rds_ib_xmit_rdma(struct rds_connection *conn, struct rm_rdma_op *op) | |||
879 | * Instead of knowing how to return a partial rdma read/write we insist that there | 879 | * Instead of knowing how to return a partial rdma read/write we insist that there |
880 | * be enough work requests to send the entire message. | 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 | work_alloc = rds_ib_ring_alloc(&ic->i_send_ring, i, &pos); | 884 | work_alloc = rds_ib_ring_alloc(&ic->i_send_ring, i, &pos); |
885 | if (work_alloc != i) { | 885 | if (work_alloc != i) { |
diff --git a/net/rds/message.c b/net/rds/message.c index f139420ba1f6..50f13f1d4ae0 100644 --- a/net/rds/message.c +++ b/net/rds/message.c | |||
@@ -341,7 +341,7 @@ struct rds_message *rds_message_map_pages(unsigned long *page_addrs, unsigned in | |||
341 | { | 341 | { |
342 | struct rds_message *rm; | 342 | struct rds_message *rm; |
343 | unsigned int i; | 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 | int extra_bytes = num_sgs * sizeof(struct scatterlist); | 345 | int extra_bytes = num_sgs * sizeof(struct scatterlist); |
346 | int ret; | 346 | int ret; |
347 | 347 | ||
@@ -351,7 +351,7 @@ struct rds_message *rds_message_map_pages(unsigned long *page_addrs, unsigned in | |||
351 | 351 | ||
352 | set_bit(RDS_MSG_PAGEVEC, &rm->m_flags); | 352 | set_bit(RDS_MSG_PAGEVEC, &rm->m_flags); |
353 | rm->m_inc.i_hdr.h_len = cpu_to_be32(total_len); | 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 | rm->data.op_sg = rds_message_alloc_sgs(rm, num_sgs, &ret); | 355 | rm->data.op_sg = rds_message_alloc_sgs(rm, num_sgs, &ret); |
356 | if (!rm->data.op_sg) { | 356 | if (!rm->data.op_sg) { |
357 | rds_message_put(rm); | 357 | rds_message_put(rm); |
diff --git a/net/rds/rds.h b/net/rds/rds.h index 02ec4a3b2799..4ffe100ff5e6 100644 --- a/net/rds/rds.h +++ b/net/rds/rds.h | |||
@@ -48,10 +48,6 @@ void rdsdebug(char *fmt, ...) | |||
48 | } | 48 | } |
49 | #endif | 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 | #define RDS_FRAG_SHIFT 12 | 51 | #define RDS_FRAG_SHIFT 12 |
56 | #define RDS_FRAG_SIZE ((unsigned int)(1 << RDS_FRAG_SHIFT)) | 52 | #define RDS_FRAG_SIZE ((unsigned int)(1 << RDS_FRAG_SHIFT)) |
57 | 53 | ||
diff --git a/net/rds/send.c b/net/rds/send.c index 3d822bad7de9..fd8b687d5c05 100644 --- a/net/rds/send.c +++ b/net/rds/send.c | |||
@@ -1107,7 +1107,7 @@ int rds_sendmsg(struct socket *sock, struct msghdr *msg, size_t payload_len) | |||
1107 | size_t total_payload_len = payload_len, rdma_payload_len = 0; | 1107 | size_t total_payload_len = payload_len, rdma_payload_len = 0; |
1108 | bool zcopy = ((msg->msg_flags & MSG_ZEROCOPY) && | 1108 | bool zcopy = ((msg->msg_flags & MSG_ZEROCOPY) && |
1109 | sock_flag(rds_rs_to_sk(rs), SOCK_ZEROCOPY)); | 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 | int namelen; | 1111 | int namelen; |
1112 | struct rds_iov_vector_arr vct; | 1112 | struct rds_iov_vector_arr vct; |
1113 | int ind; | 1113 | int ind; |