Skip to content

Commit

Permalink
FreeBSD: avoid memory allocation in arc_prune_async
Browse files Browse the repository at this point in the history
Reviewed-by: Ryan Moeller <[email protected]>
Reviewed-by: Brian Behlendorf <[email protected]>
Signed-off-by:	Alexander Motin <[email protected]>
Closes #12049
  • Loading branch information
amotin authored and behlendorf committed May 28, 2021
1 parent cc1c7b0 commit aa4a84e
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions module/os/freebsd/zfs/arc_os.c
Original file line number Diff line number Diff line change
Expand Up @@ -158,10 +158,9 @@ arc_default_max(uint64_t min, uint64_t allmem)
static void
arc_prune_task(void *arg)
{
int64_t nr_scan = *(int64_t *)arg;
int64_t nr_scan = (intptr_t)arg;

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);
Expand All @@ -186,13 +185,12 @@ void
arc_prune_async(int64_t adjust)
{

int64_t *adjustptr;

if ((adjustptr = malloc(sizeof (int64_t), M_TEMP, M_NOWAIT)) == NULL)
return;

*adjustptr = adjust;
taskq_dispatch(arc_prune_taskq, arc_prune_task, adjustptr, TQ_SLEEP);
#ifndef __LP64__
if (adjust > INTPTR_MAX)
adjust = INTPTR_MAX;
#endif
taskq_dispatch(arc_prune_taskq, arc_prune_task,
(void *)(intptr_t)adjust, TQ_SLEEP);
ARCSTAT_BUMP(arcstat_prune);
}

Expand Down

0 comments on commit aa4a84e

Please sign in to comment.