Skip to content

Commit

Permalink
Include other sources of freeable memory in the freemem calculation
Browse files Browse the repository at this point in the history
This prevents ARC collapse when non-ZFS filesystems, the block layer or
other consumers use a lot of reclaimable memory.
  • Loading branch information
dweeezil committed Aug 13, 2015
1 parent 8ac6ffe commit 08807f8
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion include/sys/vmsystm.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@

#define membar_producer() smp_wmb()
#define physmem totalram_pages
#define freemem nr_free_pages()
#define freemem (nr_free_pages() + \
global_page_state(NR_INACTIVE_FILE) + \
global_page_state(NR_INACTIVE_ANON) + \
global_page_state(NR_SLAB_RECLAIMABLE))

This comment has been minimized.

Copy link
@behlendorf

behlendorf Aug 18, 2015

This effectively changes the meaning of freemem but I admit it probably the cleanest way to solve this issue. We're going to need to remember to revisit this once the ARC is backed by the page cache and therefore is accounted for in NR_INACTIVE_FILE. But until that that time this seems little a pretty clean fix. Let me verify it doesn't cause build failures for older kernels and then I'll get it in. I'm glad this was caught.


#define xcopyin(from, to, size) copy_from_user(to, from, size)
#define xcopyout(from, to, size) copy_to_user(to, from, size)
Expand Down

1 comment on commit 08807f8

@dweeezil
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed. As has been discussed in the issue tracker, this is clearly a heuristic but that said, the idea of "free memory" is a bit wiggly to begin with. This seems to be the best solution for the time being so I'll add a pull request for it.

Please sign in to comment.