aboutsummaryrefslogtreecommitdiff
path: root/sys/sys/buf.h
diff options
context:
space:
mode:
authorGleb Smirnoff <glebius@FreeBSD.org>2019-01-15 01:02:16 +0000
committerGleb Smirnoff <glebius@FreeBSD.org>2019-01-15 01:02:16 +0000
commit756a5412798b7de1709bb1de2db5ba2a5908cba3 (patch)
tree90da29baacc3d3eccb4f10f6629ca9f3993be631 /sys/sys/buf.h
parent7c895edb6673b6cfe6ddcc024a5d2ab234bda7cc (diff)
downloadsrc-756a5412798b7de1709bb1de2db5ba2a5908cba3.tar.gz
src-756a5412798b7de1709bb1de2db5ba2a5908cba3.zip
Allocate pager bufs from UMA instead of 80-ish mutex protected linked list.
o In vm_pager_bufferinit() create pbuf_zone and start accounting on how many pbufs are we going to have set. In various subsystems that are going to utilize pbufs create private zones via call to pbuf_zsecond_create(). The latter calls uma_zsecond_create(), and sets a limit on created zone. After startup preallocate pbufs according to requirements of all pbuf zones. Subsystems that used to have a private limit with old allocator now have private pbuf zones: md(4), fusefs, NFS client, smbfs, VFS cluster, FFS, swap, vnode pager. The following subsystems use shared pbuf zone: cam(4), nvme(4), physio(9), aio(4). They should have their private limits, but changing that is out of scope of this commit. o Fetch tunable value of kern.nswbuf from init_param2() and while here move NSWBUF_MIN to opt_param.h and eliminate opt_swap.h, that was holding only this option. Default values aren't touched by this commit, but they probably should be reviewed wrt to modern hardware. This change removes a tight bottleneck from sendfile(2) operation, that uses pbufs in vnode pager. Other pagers also would benefit from faster allocation. Together with: gallatin Tested by: pho
Notes
Notes: svn path=/head/; revision=343030
Diffstat (limited to 'sys/sys/buf.h')
-rw-r--r--sys/sys/buf.h18
1 files changed, 10 insertions, 8 deletions
diff --git a/sys/sys/buf.h b/sys/sys/buf.h
index a099a972efc0..fe49224417d9 100644
--- a/sys/sys/buf.h
+++ b/sys/sys/buf.h
@@ -44,6 +44,7 @@
#include <sys/queue.h>
#include <sys/lock.h>
#include <sys/lockmgr.h>
+#include <vm/uma.h>
struct bio;
struct buf;
@@ -275,6 +276,11 @@ struct buf {
#define PRINT_BUF_VFLAGS "\20\4bkgrderr\3bkgrdwait\2bkgrdinprog\1scanned"
#ifdef _KERNEL
+
+#ifndef NSWBUF_MIN
+#define NSWBUF_MIN 16
+#endif
+
/*
* Buffer locking
*/
@@ -287,7 +293,7 @@ extern const char *buf_wmesg; /* Default buffer lock message */
* Initialize a lock.
*/
#define BUF_LOCKINIT(bp) \
- lockinit(&(bp)->b_lock, PRIBIO + 4, buf_wmesg, 0, 0)
+ lockinit(&(bp)->b_lock, PRIBIO + 4, buf_wmesg, 0, LK_NEW)
/*
*
* Get a lock sleeping non-interruptably until it becomes available.
@@ -493,10 +499,6 @@ extern int bdwriteskip;
extern int dirtybufferflushes;
extern int altbufferflushes;
extern int nswbuf; /* Number of swap I/O buffer headers. */
-extern int cluster_pbuf_freecnt; /* Number of pbufs for clusters */
-extern int vnode_pbuf_freecnt; /* Number of pbufs for vnode pager */
-extern int vnode_async_pbuf_freecnt; /* Number of pbufs for vnode pager,
- asynchronous reads */
extern caddr_t unmapped_buf; /* Data address for unmapped buffers. */
static inline int
@@ -537,7 +539,6 @@ void brelse(struct buf *);
void bqrelse(struct buf *);
int vfs_bio_awrite(struct buf *);
void vfs_drain_busy_pages(struct buf *bp);
-struct buf * getpbuf(int *);
struct buf *incore(struct bufobj *, daddr_t);
struct buf *gbincore(struct bufobj *, daddr_t);
struct buf *getblk(struct vnode *, daddr_t, int, int, int, int);
@@ -549,6 +550,9 @@ int bufwrite(struct buf *);
void bufdone(struct buf *);
void bd_speedup(void);
+extern uma_zone_t pbuf_zone;
+uma_zone_t pbuf_zsecond_create(char *name, int max);
+
int cluster_read(struct vnode *, u_quad_t, daddr_t, long,
struct ucred *, long, int, int, struct buf **);
int cluster_wbuild(struct vnode *, long, daddr_t, int, int);
@@ -562,7 +566,6 @@ void vfs_busy_pages(struct buf *, int clear_modify);
void vfs_unbusy_pages(struct buf *);
int vmapbuf(struct buf *, int);
void vunmapbuf(struct buf *);
-void relpbuf(struct buf *, int *);
void brelvp(struct buf *);
void bgetvp(struct vnode *, struct buf *);
void pbgetbo(struct bufobj *bo, struct buf *bp);
@@ -571,7 +574,6 @@ void pbrelbo(struct buf *);
void pbrelvp(struct buf *);
int allocbuf(struct buf *bp, int size);
void reassignbuf(struct buf *);
-struct buf *trypbuf(int *);
void bwait(struct buf *, u_char, const char *);
void bdone(struct buf *);