Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 11 Apr 2021 13:25:11 +0100
From:      Jessica Clarke <jrtc27@freebsd.org>
To:        Mateusz Guzik <mjg@FreeBSD.org>
Cc:        "src-committers@freebsd.org" <src-committers@FreeBSD.org>, "dev-commits-src-all@freebsd.org" <dev-commits-src-all@FreeBSD.org>, "dev-commits-src-main@freebsd.org" <dev-commits-src-main@FreeBSD.org>
Subject:   Re: git: 97ed4babb516 - main - zfs: avoid memory allocation in arc_prune_async
Message-ID:  <6F4745E7-CC46-4060-99A1-90C2A691EBC7@freebsd.org>
In-Reply-To: <202104110643.13B6h91E076304@gitrepo.freebsd.org>
References:  <202104110643.13B6h91E076304@gitrepo.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On 11 Apr 2021, at 07:43, Mateusz Guzik <mjg@FreeBSD.org> wrote:
>=20
> The branch main has been updated by mjg:
>=20
> URL: =
https://cgit.FreeBSD.org/src/commit/?id=3D97ed4babb51636d8a4b11bc7b207c321=
9ffcd0e3
>=20
> 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
>=20
>    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(-)
>=20
> 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 =3D *(int64_t *)arg;
> +#ifdef __LP64__
> +	int64_t nr_scan =3D (int64_t)arg;
> +#else
> +	int64_t nr_scan =3D (int32_t)arg;
> +#endif

int64_t nr_scan =3D (intptr_t)arg;?

> 	arc_reduce_target_size(ptob(nr_scan));
> -	free(arg, M_TEMP);
> #if __FreeBSD_version >=3D 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;
>=20
> -	if ((adjustptr =3D malloc(sizeof (int64_t), M_TEMP, M_NOWAIT)) =
=3D=3D NULL)
> -		return;
> +#ifndef __LP64__
> +	if (adjust > __LONG_MAX)
> +		adjust =3D __LONG_MAX;
> +#endif

The code is correct without the ifdef, is this just to suppress a =
tautological
condition warning? If so, be precise in your condition and use =
__INT64_MAX__ >
__LONG_MAX__? LP64 conflates a lot of things into one variable, and so =
isn=E2=80=99t
defined for CHERI, but IMO it=E2=80=99s better to be precise *anyway* =
because then it=E2=80=99s
more self-documenting why the #if is there.

Jess




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?6F4745E7-CC46-4060-99A1-90C2A691EBC7>