Skip to content

Commit

Permalink
Use dedicated lock name for pbufs
Browse files Browse the repository at this point in the history
(cherry picked from commit 531f8cf)
  • Loading branch information
kostikbel committed Feb 7, 2022
1 parent 6939af9 commit 78d27f2
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
14 changes: 7 additions & 7 deletions sys/kern/vfs_bio.c
Original file line number Diff line number Diff line change
Expand Up @@ -400,12 +400,6 @@ struct bufqueue __exclusive_cache_line bqempty;
*/
uma_zone_t buf_zone;

/*
* Single global constant for BUF_WMESG, to avoid getting multiple references.
* buf_wmesg is referred from macros.
*/
const char *buf_wmesg = BUF_WMESG;

static int
sysctl_runningspace(SYSCTL_HANDLER_ARGS)
{
Expand Down Expand Up @@ -1175,6 +1169,12 @@ kern_vfs_bio_buffer_alloc(caddr_t v, long physmem_est)
return (v);
}

/*
* Single global constant for BUF_WMESG, to avoid getting multiple
* references.
*/
static const char buf_wmesg[] = "bufwait";

/* Initialize the buffer subsystem. Called before use of any buffers. */
void
bufinit(void)
Expand Down Expand Up @@ -1205,7 +1205,7 @@ bufinit(void)
bp->b_xflags = 0;
bp->b_data = bp->b_kvabase = unmapped_buf;
LIST_INIT(&bp->b_dep);
BUF_LOCKINIT(bp);
BUF_LOCKINIT(bp, buf_wmesg);
bq_insert(&bqempty, bp, false);
}

Expand Down
6 changes: 2 additions & 4 deletions sys/sys/buf.h
Original file line number Diff line number Diff line change
Expand Up @@ -291,16 +291,14 @@ struct buf {
/*
* Buffer locking
*/
extern const char *buf_wmesg; /* Default buffer lock message */
#define BUF_WMESG "bufwait"
#include <sys/proc.h> /* XXX for curthread */
#include <sys/mutex.h>

/*
* Initialize a lock.
*/
#define BUF_LOCKINIT(bp) \
lockinit(&(bp)->b_lock, PRIBIO + 4, buf_wmesg, 0, LK_NEW)
#define BUF_LOCKINIT(bp, wmesg) \
lockinit(&(bp)->b_lock, PRIBIO + 4, wmesg, 0, LK_NEW)
/*
*
* Get a lock sleeping non-interruptably until it becomes available.
Expand Down
4 changes: 3 additions & 1 deletion sys/vm/vm_pager.c
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,8 @@ pbuf_dtor(void *mem, int size, void *arg)
BUF_UNLOCK(bp);
}

static const char pbuf_wmesg[] = "pbufwait";

static int
pbuf_init(void *mem, int size, int flags)
{
Expand All @@ -489,7 +491,7 @@ pbuf_init(void *mem, int size, int flags)
if (bp->b_kvabase == NULL)
return (ENOMEM);
bp->b_kvasize = ptoa(PBUF_PAGES);
BUF_LOCKINIT(bp);
BUF_LOCKINIT(bp, pbuf_wmesg);
LIST_INIT(&bp->b_dep);
bp->b_rcred = bp->b_wcred = NOCRED;
bp->b_xflags = 0;
Expand Down

0 comments on commit 78d27f2

Please sign in to comment.