Date: Sun, 11 Apr 2021 06:43:09 GMT From: Mateusz Guzik <mjg@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Subject: git: 97ed4babb516 - main - zfs: avoid memory allocation in arc_prune_async Message-ID: <202104110643.13B6h91E076304@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch main has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=97ed4babb51636d8a4b11bc7b207c3219ffcd0e3 commit 97ed4babb51636d8a4b11bc7b207c3219ffcd0e3 Author: Mateusz Guzik <mjg@FreeBSD.org> AuthorDate: 2021-04-11 05:15:41 +0000 Commit: Mateusz Guzik <mjg@FreeBSD.org> CommitDate: 2021-04-11 05:19:56 +0000 zfs: avoid memory allocation in arc_prune_async --- sys/contrib/openzfs/module/os/freebsd/zfs/arc_os.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/sys/contrib/openzfs/module/os/freebsd/zfs/arc_os.c b/sys/contrib/openzfs/module/os/freebsd/zfs/arc_os.c index 201dbc423336..e73efd810e53 100644 --- a/sys/contrib/openzfs/module/os/freebsd/zfs/arc_os.c +++ b/sys/contrib/openzfs/module/os/freebsd/zfs/arc_os.c @@ -158,10 +158,13 @@ arc_default_max(uint64_t min, uint64_t allmem) static void arc_prune_task(void *arg) { - int64_t nr_scan = *(int64_t *)arg; +#ifdef __LP64__ + int64_t nr_scan = (int64_t)arg; +#else + int64_t nr_scan = (int32_t)arg; +#endif arc_reduce_target_size(ptob(nr_scan)); - free(arg, M_TEMP); #if __FreeBSD_version >= 1300139 sx_xlock(&arc_vnlru_lock); vnlru_free_vfsops(nr_scan, &zfs_vfsops, arc_vnlru_marker); @@ -185,13 +188,14 @@ arc_prune_task(void *arg) void arc_prune_async(int64_t adjust) { - int64_t *adjustptr; - if ((adjustptr = malloc(sizeof (int64_t), M_TEMP, M_NOWAIT)) == NULL) - return; +#ifndef __LP64__ + if (adjust > __LONG_MAX) + adjust = __LONG_MAX; +#endif - *adjustptr = adjust; + adjustptr = (void *)adjust; taskq_dispatch(arc_prune_taskq, arc_prune_task, adjustptr, TQ_SLEEP); ARCSTAT_BUMP(arcstat_prune); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202104110643.13B6h91E076304>