Date: Mon, 29 Jun 2015 13:48:59 +0000 From: "emaste (Ed Maste)" <phabric-noreply@FreeBSD.org> To: freebsd-toolchain@freebsd.org Subject: [Differential] [Closed] D2933: Significantly speed up ar(1) on UFS file systems Message-ID: <59d242779a924a551c3b8c777e6f2f13@localhost.localdomain> In-Reply-To: <differential-rev-PHID-DREV-hkid5hylfsbts6yuvnph-req@FreeBSD.org> References: <differential-rev-PHID-DREV-hkid5hylfsbts6yuvnph-req@FreeBSD.org>
next in thread | previous in thread | raw e-mail | index | archive | help
--b1_59d242779a924a551c3b8c777e6f2f13 Content-Type: text/plain; charset = "utf-8" Content-Transfer-Encoding: 8bit This revision was automatically updated to reflect the committed changes. Closed by commit rS284928: speed up ar(1) on UFS file systems (authored by emaste). CHANGED PRIOR TO COMMIT https://reviews.freebsd.org/D2933?vs=6543&id=6545#toc REPOSITORY rS FreeBSD src repository CHANGES SINCE LAST UPDATE https://reviews.freebsd.org/D2933?vs=6543&id=6545 REVISION DETAIL https://reviews.freebsd.org/D2933 AFFECTED FILES head/usr.bin/ar/write.c CHANGE DETAILS diff --git a/head/usr.bin/ar/write.c b/head/usr.bin/ar/write.c --- a/head/usr.bin/ar/write.c +++ b/head/usr.bin/ar/write.c @@ -41,6 +41,7 @@ #include <stdlib.h> #include <string.h> #include <sysexits.h> +#include <unistd.h> #include "ar.h" @@ -61,6 +62,7 @@ static void free_obj(struct bsdar *bsdar, struct ar_obj *obj); static void insert_obj(struct bsdar *bsdar, struct ar_obj *obj, struct ar_obj *pos); +static void prefault_buffer(const char *buf, size_t s); static void read_objs(struct bsdar *bsdar, const char *archive, int checkargv); static void write_archive(struct bsdar *bsdar, char mode); @@ -551,11 +553,35 @@ } /* + * Fault in the buffer prior to writing as a workaround for poor performance + * due to interaction with kernel fs deadlock avoidance code. See the comment + * above vn_io_fault_doio() in sys/kern/vfs_vnops.c for details of the issue. + */ +static void +prefault_buffer(const char *buf, size_t s) +{ + volatile const char *p; + size_t page_size; + + if (s == 0) + return; + page_size = sysconf(_SC_PAGESIZE); + for (p = buf; p < buf + s; p += page_size) + *p; + /* + * Ensure we touch the last page as well, in case the buffer is not + * page-aligned. + */ + *(volatile const char *)(buf + s - 1); +} + +/* * Wrapper for archive_write_data(). */ static void write_data(struct bsdar *bsdar, struct archive *a, const void *buf, size_t s) { + prefault_buffer(buf, s); if (archive_write_data(a, buf, s) != (ssize_t)s) bsdar_errc(bsdar, EX_SOFTWARE, 0, "%s", archive_error_string(a)); EMAIL PREFERENCES https://reviews.freebsd.org/settings/panel/emailpreferences/ To: emaste, eadler, kib Cc: kib, freebsd-toolchain-list, dim, davide --b1_59d242779a924a551c3b8c777e6f2f13 Content-Type: text/x-patch; charset=utf-8; name="D2933.6545.patch" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="D2933.6545.patch" ZGlmZiAtLWdpdCBhL2hlYWQvdXNyLmJpbi9hci93cml0ZS5jIGIvaGVhZC91c3IuYmluL2FyL3dy aXRlLmMKLS0tIGEvaGVhZC91c3IuYmluL2FyL3dyaXRlLmMKKysrIGIvaGVhZC91c3IuYmluL2Fy L3dyaXRlLmMKQEAgLTQxLDYgKzQxLDcgQEAKICNpbmNsdWRlIDxzdGRsaWIuaD4KICNpbmNsdWRl IDxzdHJpbmcuaD4KICNpbmNsdWRlIDxzeXNleGl0cy5oPgorI2luY2x1ZGUgPHVuaXN0ZC5oPgog CiAjaW5jbHVkZSAiYXIuaCIKIApAQCAtNjEsNiArNjIsNyBAQAogc3RhdGljIHZvaWQJZnJlZV9v Ymooc3RydWN0IGJzZGFyICpic2Rhciwgc3RydWN0IGFyX29iaiAqb2JqKTsKIHN0YXRpYyB2b2lk CWluc2VydF9vYmooc3RydWN0IGJzZGFyICpic2Rhciwgc3RydWN0IGFyX29iaiAqb2JqLAogCQkg ICAgc3RydWN0IGFyX29iaiAqcG9zKTsKK3N0YXRpYyB2b2lkCXByZWZhdWx0X2J1ZmZlcihjb25z dCBjaGFyICpidWYsIHNpemVfdCBzKTsKIHN0Y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Vfd3JpdGVfZGF0YSgpLgog ICovCiBzdGF0aWMgdm9pZAogd3JpdGVfZGF0YShzdHJ1Y3QgYnNkYXIgKmJzZGFyLCBzdHJ1Y3Qg YXJjaGl2ZSAqYSwgY29uc3Qgdm9pZCAqYnVmLCBzaXplX3QgcykKIHsKKwlwcmVmYXVsdF9idWZm ZXIoYnVmLCBzKTsKIAlpZiAoYXJjaGl2ZV93cml0ZV9kYXRhKGEsIGJ1ZiwgcykgIT0gKHNzaXpl X3QpcykKIAkJYnNkYXJfZXJyYyhic2RhciwgRVhfU09GVFdBUkUsIDAsICIlcyIsCiAJCSAgICBh cmNoaXZlX2Vycm9yX3N0cmluZyhhKSk7Cgo= --b1_59d242779a924a551c3b8c777e6f2f13--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?59d242779a924a551c3b8c777e6f2f13>