Skip to content

Commit

Permalink
Fix style problems found by checkpatch
Browse files Browse the repository at this point in the history
  • Loading branch information
johnousterhout committed Sep 26, 2024
1 parent 5f7ed5d commit 17c1103
Show file tree
Hide file tree
Showing 25 changed files with 860 additions and 1,050 deletions.
18 changes: 8 additions & 10 deletions homa.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
/* Copyright (c) 2019-2022 Homa Developers
* SPDX-License-Identifier: BSD-1-Clause
*/
/* SPDX-License-Identifier: BSD-2-Clause */

/* This file defines the kernel call interface for the Homa
* transport protocol.
Expand Down Expand Up @@ -57,11 +55,11 @@ extern "C"
* Holds either an IPv4 or IPv6 address (smaller and easier to use than
* sockaddr_storage).
*/
typedef union sockaddr_in_union {
union sockaddr_in_union {
struct sockaddr sa;
struct sockaddr_in in4;
struct sockaddr_in6 in6;
} sockaddr_in_union;
};

/**
* struct homa_sendmsg_args - Provides information needed by Homa's
Expand Down Expand Up @@ -122,7 +120,7 @@ struct homa_recvmsg_args {
* always be set when peer information is available, which includes
* some error cases.
*/
sockaddr_in_union peer_addr;
union sockaddr_in_union peer_addr;

/**
* @num_bpages: (in/out) Number of valid entries in @bpage_offsets.
Expand Down Expand Up @@ -216,16 +214,16 @@ struct homa_set_buf_args {
extern int homa_abortp(int fd, struct homa_abort_args *args);

extern int homa_send(int sockfd, const void *message_buf,
size_t length, const sockaddr_in_union *dest_addr,
size_t length, const union sockaddr_in_union *dest_addr,
uint64_t *id, uint64_t completion_cookie);
extern int homa_sendv(int sockfd, const struct iovec *iov,
int iovcnt, const sockaddr_in_union *dest_addr,
int iovcnt, const union sockaddr_in_union *dest_addr,
uint64_t *id, uint64_t completion_cookie);
extern ssize_t homa_reply(int sockfd, const void *message_buf,
size_t length, const sockaddr_in_union *dest_addr,
size_t length, const union sockaddr_in_union *dest_addr,
uint64_t id);
extern ssize_t homa_replyv(int sockfd, const struct iovec *iov,
int iovcnt, const sockaddr_in_union *dest_addr,
int iovcnt, const union sockaddr_in_union *dest_addr,
uint64_t id);
extern int homa_abort(int sockfd, uint64_t id, int error);

Expand Down
5 changes: 2 additions & 3 deletions homa_api.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
/* Copyright (c) 2019-2022 Homa Developers
* SPDX-License-Identifier: BSD-1-Clause
*/
// SPDX-License-Identifier: BSD-2-Clause

/* This file contains functions that implement the Homa API visible to
* applications. It is intended to be part of the user-level run-time library.
Expand Down Expand Up @@ -204,5 +202,6 @@ int homa_sendv(int sockfd, const struct iovec *iov, int iovcnt,
int homa_abort(int sockfd, uint64_t id, int error)
{
struct homa_abort_args args = {id, error};

return ioctl(sockfd, HOMAIOCABORT, &args);
}
70 changes: 36 additions & 34 deletions homa_grant.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
/* Copyright (c) 2024 Homa Developers
* SPDX-License-Identifier: BSD-1-Clause
*/
// SPDX-License-Identifier: BSD-2-Clause

/* This file contains functions related to issuing grants for incoming
* messages.
Expand Down Expand Up @@ -39,14 +37,17 @@ inline int homa_grant_outranks(struct homa_rpc *rpc1, struct homa_rpc *rpc2)
* may be possible to send out additional grants to some RPCs (doing
* this is left to the caller).
*/
inline int homa_grant_update_incoming(struct homa_rpc *rpc, struct homa *homa) {
inline int homa_grant_update_incoming(struct homa_rpc *rpc, struct homa *homa)
{
int incoming = rpc->msgin.granted - (rpc->msgin.length
- rpc->msgin.bytes_remaining);

if (incoming < 0)
incoming = 0;
if (incoming != rpc->msgin.rec_incoming) {
int delta = incoming - rpc->msgin.rec_incoming;
int old = atomic_fetch_add(delta, &homa->total_incoming);

rpc->msgin.rec_incoming = incoming;
return ((old >= homa->max_incoming)
&& ((old + delta) < homa->max_incoming));
Expand Down Expand Up @@ -76,6 +77,7 @@ void homa_grant_add_rpc(struct homa_rpc *rpc)
* the peer's list.
*/
__u64 time = get_cycles();

INC_METRIC(grantable_rpcs_integral, homa->num_grantable_rpcs
* (time - homa->last_grantable_change));
homa->last_grantable_change = time;
Expand All @@ -94,20 +96,22 @@ void homa_grant_add_rpc(struct homa_rpc *rpc)
}
}
list_add_tail(&rpc->grantable_links, &peer->grantable_rpcs);
} else while (rpc != list_first_entry(&peer->grantable_rpcs,
struct homa_rpc, grantable_links)) {
/* Message is on the list, but its priority may have
* increased because of the recent packet arrival. If so,
* adjust its position in the list.
*/
candidate = list_prev_entry(rpc, grantable_links);
if (!homa_grant_outranks(rpc, candidate))
goto position_peer;
__list_del_entry(&candidate->grantable_links);
list_add(&candidate->grantable_links, &rpc->grantable_links);
} else {
while (rpc != list_first_entry(&peer->grantable_rpcs,
struct homa_rpc, grantable_links)) {
/* Message is on the list, but its priority may have
* increased because of the recent packet arrival. If
* so, adjust its position in the list.
*/
candidate = list_prev_entry(rpc, grantable_links);
if (!homa_grant_outranks(rpc, candidate))
goto position_peer;
__list_del_entry(&candidate->grantable_links);
list_add(&candidate->grantable_links, &rpc->grantable_links);
}
}

position_peer:
position_peer:
/* At this point rpc is positioned correctly on the list for its peer.
* However, the peer may need to be added to, or moved upward on,
* homa->grantable_peers.
Expand All @@ -127,8 +131,8 @@ void homa_grant_add_rpc(struct homa_rpc *rpc)
list_add_tail(&peer->grantable_links, &homa->grantable_peers);
goto done;
}
/* The peer is on Homa's list, but it may need to move upward. */
while (peer != list_first_entry(&homa->grantable_peers,
/* The peer is on Homa's list, but it may need to move upward. */
while (peer != list_first_entry(&homa->grantable_peers,
struct homa_peer, grantable_links)) {
struct homa_peer *prev_peer = list_prev_entry(
peer, grantable_links);
Expand All @@ -139,7 +143,7 @@ void homa_grant_add_rpc(struct homa_rpc *rpc)
__list_del_entry(&prev_peer->grantable_links);
list_add(&prev_peer->grantable_links, &peer->grantable_links);
}
done:
done:
}

/**
Expand Down Expand Up @@ -188,7 +192,7 @@ void homa_grant_remove_rpc(struct homa_rpc *rpc)
*/
head = list_first_entry(&peer->grantable_rpcs,
struct homa_rpc, grantable_links);
while (peer != list_last_entry(&homa->grantable_peers, struct homa_peer,
while (peer != list_last_entry(&homa->grantable_peers, struct homa_peer,
grantable_links)) {
struct homa_peer *next_peer = list_next_entry(
peer, grantable_links);
Expand Down Expand Up @@ -245,10 +249,10 @@ int homa_grant_send(struct homa_rpc *rpc, struct homa *homa)
grant.priority = rpc->msgin.priority;
grant.resend_all = rpc->msgin.resend_all;
rpc->msgin.resend_all = 0;
tt_record4("sending grant for id %llu, offset %d, priority %d, "
"increment %d", rpc->id, rpc->msgin.granted,
rpc->msgin.priority, increment);
homa_xmit_control(GRANT, &grant, sizeof(grant),rpc);
tt_record4("sending grant for id %llu, offset %d, priority %d, increment %d",
rpc->id, rpc->msgin.granted, rpc->msgin.priority,
increment);
homa_xmit_control(GRANT, &grant, sizeof(grant), rpc);
return 1;
}

Expand Down Expand Up @@ -286,20 +290,20 @@ void homa_grant_check_rpc(struct homa_rpc *rpc)
}

if (rpc->msgin.granted >= rpc->msgin.length) {
homa_grant_update_incoming(rpc,homa);
homa_grant_update_incoming(rpc, homa);
homa_rpc_unlock(rpc);
goto done;
}

tt_record4("homa_grant_check_rpc starting for id %d, granted %d, "
"recv_end %d, length %d", rpc->id, rpc->msgin.granted,
rpc->msgin.recv_end, rpc->msgin.length);
tt_record4("homa_grant_check_rpc starting for id %d, granted %d, recv_end %d, length %d",
rpc->id, rpc->msgin.granted, rpc->msgin.recv_end,
rpc->msgin.length);

/* This message requires grants; if it is a new message, set up
* granting.
*/
if (list_empty(&rpc->grantable_links)) {
homa_grant_update_incoming(rpc,homa);
homa_grant_update_incoming(rpc, homa);
homa_grantable_lock(homa, 0);
homa_grant_add_rpc(rpc);
recalc = ((homa->num_active_rpcs < homa->max_overcommit)
Expand Down Expand Up @@ -355,7 +359,7 @@ void homa_grant_check_rpc(struct homa_rpc *rpc)
homa_rpc_unlock(rpc);
if (recalc)
homa_grant_recalc(homa, 0);
done:
done:
tt_record1("homa_grant_check_rpc finished with id %d", rpc->id);
}

Expand Down Expand Up @@ -405,9 +409,8 @@ void homa_grant_recalc(struct homa *homa, int locked)
atomic_inc(&homa->grant_recalc_count);

/* Clear the existing grant calculation. */
for (i = 0; i < homa->num_active_rpcs; i++) {
for (i = 0; i < homa->num_active_rpcs; i++)
atomic_set(&homa->active_rpcs[i]->msgin.rank, -1);
}

/* Recompute which RPCs we'll grant to and initialize info
* about them.
Expand Down Expand Up @@ -653,8 +656,7 @@ int homa_grantable_lock_slow(struct homa *homa, int recalc)
}
if (recalc && atomic_read(&homa->grant_recalc_count)
!= starting_count) {
tt_record("skipping wait for grantable lock: recalc "
"elsewhere");
tt_record("skipping wait for grantable lock: recalc elsewhere");
break;
}
}
Expand Down
Loading

0 comments on commit 17c1103

Please sign in to comment.