Page MenuHomeFreeBSD

D45381.diff
No OneTemporary

D45381.diff

diff --git a/share/man/man4/xen.4 b/share/man/man4/xen.4
--- a/share/man/man4/xen.4
+++ b/share/man/man4/xen.4
@@ -73,6 +73,14 @@
Exports local block devices or files to other Xen domains where they can
then be imported via
.Nm blkfront .
+Loader tunable and
+.Xr sysctl 3
+entry
+.Va hw.xbd.xbb_reserved_new_bios
+configures the number of the
+.Vt bio
+items preallocated and reserved for
+.Nm blkback .
.It Nm blkfront
Import block devices from other Xen domains as local block devices, to be
used for file systems, swap, etc.
diff --git a/sys/dev/xen/blkback/blkback.c b/sys/dev/xen/blkback/blkback.c
--- a/sys/dev/xen/blkback/blkback.c
+++ b/sys/dev/xen/blkback/blkback.c
@@ -72,6 +72,7 @@
#include <vm/vm.h>
#include <vm/vm_extern.h>
#include <vm/vm_kern.h>
+#include <vm/uma.h>
#include <xen/xen-os.h>
#include <xen/blkif.h>
@@ -753,8 +754,20 @@
/** Got the needed data from hotplug scripts? */
bool hotplug_done;
+
+ /** Uma(9) zone for the bio */
+ uma_zone_t zone;
};
+/*---------------------------- Global Static Data ----------------------------*/
+SYSCTL_DECL(_hw_xbd);
+
+int __read_mostly xbb_reserved_new_bios = 65536;
+
+SYSCTL_INT(_hw_xbd, OID_AUTO, xbb_reserved_new_bios, CTLFLAG_RWTUN,
+ &xbb_reserved_new_bios, 0,
+ "Number of reserved new xen blkback bios for non-blocking allocation");
+
/*---------------------------- Request Processing ----------------------------*/
/**
* Allocate an internal transaction tracking structure from the free pool.
@@ -1986,7 +1999,7 @@
bio_idx = 0;
if (operation == BIO_FLUSH) {
- bio = g_new_bio();
+ bio = g_new_bio_uz(xbb->zone);
if (__predict_false(bio == NULL)) {
DPRINTF("Unable to allocate bio for BIO_FLUSH\n");
error = ENOMEM;
@@ -2047,7 +2060,7 @@
goto fail_free_bios;
}
- bio = bios[nbio++] = g_new_bio();
+ bio = bios[nbio++] = g_new_bio_uz(xbb->zone);
if (__predict_false(bio == NULL)) {
error = ENOMEM;
goto fail_free_bios;
@@ -3627,6 +3640,13 @@
return (error);
}
+ if (xbb_reserved_new_bios > 0) {
+ xbb->zone = g_io_new_uz("xen_blkback");
+ uma_prealloc(xbb->zone, xbb_reserved_new_bios);
+ uma_zone_reserve(xbb->zone, xbb_reserved_new_bios);
+ } else
+ xbb->zone = NULL;
+
return (0);
}
@@ -3686,6 +3706,11 @@
xbb->dev_name = NULL;
}
+ if (xbb->zone != NULL) {
+ uma_zdestroy(xbb->zone);
+ xbb->zone = NULL;
+ }
+
mtx_destroy(&xbb->lock);
return (0);
}

File Metadata

Mime Type
text/plain
Expires
Fri, Jan 31, 9:59 AM (4 h, 5 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
16360208
Default Alt Text
D45381.diff (2 KB)

Event Timeline