Skip to content

Commit 2557d0c

Browse files
Matthew WilcoxDominique Martinet
authored andcommitted
9p: Embed wait_queue_head into p9_req_t
On a 64-bit system, the wait_queue_head_t is 24 bytes while the pointer to it is 8 bytes. Growing the p9_req_t by 16 bytes is better than performing a 24-byte memory allocation. Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Matthew Wilcox <[email protected]> Reviewed-by: Greg Kurz <[email protected]> Cc: Eric Van Hensbergen <[email protected]> Cc: Ron Minnich <[email protected]> Cc: Latchesar Ionkov <[email protected]> Signed-off-by: Dominique Martinet <[email protected]>
1 parent f28cdf0 commit 2557d0c

File tree

3 files changed

+7
-16
lines changed

3 files changed

+7
-16
lines changed

include/net/9p/client.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ enum p9_req_status_t {
113113
struct p9_req_t {
114114
int status;
115115
int t_err;
116-
wait_queue_head_t *wq;
116+
wait_queue_head_t wq;
117117
struct p9_fcall *tc;
118118
struct p9_fcall *rc;
119119
void *aux;

net/9p/client.c

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -283,8 +283,9 @@ p9_tag_alloc(struct p9_client *c, u16 tag, unsigned int max_size)
283283
return ERR_PTR(-ENOMEM);
284284
}
285285
for (col = 0; col < P9_ROW_MAXTAG; col++) {
286-
c->reqs[row][col].status = REQ_STATUS_IDLE;
287-
c->reqs[row][col].tc = NULL;
286+
req = &c->reqs[row][col];
287+
req->status = REQ_STATUS_IDLE;
288+
init_waitqueue_head(&req->wq);
288289
}
289290
c->max_tag += P9_ROW_MAXTAG;
290291
}
@@ -294,13 +295,6 @@ p9_tag_alloc(struct p9_client *c, u16 tag, unsigned int max_size)
294295
col = tag % P9_ROW_MAXTAG;
295296

296297
req = &c->reqs[row][col];
297-
if (!req->wq) {
298-
req->wq = kmalloc(sizeof(wait_queue_head_t), GFP_NOFS);
299-
if (!req->wq)
300-
goto grow_failed;
301-
init_waitqueue_head(req->wq);
302-
}
303-
304298
if (!req->tc)
305299
req->tc = p9_fcall_alloc(alloc_msize);
306300
if (!req->rc)
@@ -320,9 +314,7 @@ p9_tag_alloc(struct p9_client *c, u16 tag, unsigned int max_size)
320314
pr_err("Couldn't grow tag array\n");
321315
kfree(req->tc);
322316
kfree(req->rc);
323-
kfree(req->wq);
324317
req->tc = req->rc = NULL;
325-
req->wq = NULL;
326318
return ERR_PTR(-ENOMEM);
327319
}
328320

@@ -410,7 +402,6 @@ static void p9_tag_cleanup(struct p9_client *c)
410402
/* free requests associated with tags */
411403
for (row = 0; row < (c->max_tag/P9_ROW_MAXTAG); row++) {
412404
for (col = 0; col < P9_ROW_MAXTAG; col++) {
413-
kfree(c->reqs[row][col].wq);
414405
kfree(c->reqs[row][col].tc);
415406
kfree(c->reqs[row][col].rc);
416407
}
@@ -453,7 +444,7 @@ void p9_client_cb(struct p9_client *c, struct p9_req_t *req, int status)
453444
smp_wmb();
454445
req->status = status;
455446

456-
wake_up(req->wq);
447+
wake_up(&req->wq);
457448
p9_debug(P9_DEBUG_MUX, "wakeup: %d\n", req->tc->tag);
458449
}
459450
EXPORT_SYMBOL(p9_client_cb);
@@ -774,7 +765,7 @@ p9_client_rpc(struct p9_client *c, int8_t type, const char *fmt, ...)
774765
}
775766
again:
776767
/* Wait for the response */
777-
err = wait_event_killable(*req->wq, req->status >= REQ_STATUS_RCVD);
768+
err = wait_event_killable(req->wq, req->status >= REQ_STATUS_RCVD);
778769

779770
/*
780771
* Make sure our req is coherent with regard to updates in other

net/9p/trans_virtio.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,7 @@ p9_virtio_zc_request(struct p9_client *client, struct p9_req_t *req,
490490
virtqueue_kick(chan->vq);
491491
spin_unlock_irqrestore(&chan->lock, flags);
492492
p9_debug(P9_DEBUG_TRANS, "virtio request kicked\n");
493-
err = wait_event_killable(*req->wq, req->status >= REQ_STATUS_RCVD);
493+
err = wait_event_killable(req->wq, req->status >= REQ_STATUS_RCVD);
494494
/*
495495
* Non kernel buffers are pinned, unpin them
496496
*/

0 commit comments

Comments
 (0)