Re: [PATCH] dma-debug: dynamic allocation of hash table

From: Robin Murphy
Date: Fri Jan 31 2020 - 12:43:53 EST


On 31/01/2020 2:42 pm, Eric Dumazet wrote:
On Fri, Jan 31, 2020 at 4:30 AM Robin Murphy <robin.murphy@xxxxxxx> wrote:

...and when that represents ~5% of the total system RAM it is a *lot*
less reasonable than even 12KB. As I said, it's great to make a debug
option more efficient such that what it observes is more representative
of the non-debug behaviour, but it mustn't come at the cost of making
the entire option unworkable for other users.


Then I suggest you send a patch to reduce PREALLOC_DMA_DEBUG_ENTRIES
because having 65536 preallocated entries consume 4 MB of memory.

...unless it's overridden on the command-line ;)

Actually this whole attempt to re-implement slab allocations in this
file is suspect.

Again that's a matter of expected usage patterns - typically the "reasonable default" or user-defined preallocation should still be enough (as it *had* to be before), and the kind of systems that can sustain so many live mappings as to regularly hit the dynamic expansion path are also likely to have enough memory not to care that later-unused entries never get 'properly' freed back to the kernel (plus as you've observed, many workloads tend to reach a steady state where entries are mostly only transiently free anyway). The reasoning for the exact implementation details is there in the commit logs.

Do not get me wrong, but if you really want to run linux on a 16MB host,
I guess you need to add CONFIG_BASE_SMALL all over the places,
not only in this kernel/dma/debug.c file.

Right, nobody's suggesting that defconfig should "just work" on your router/watch/IoT shoelaces/whatever, I'm just saying that tuning any piece of common code for datacenter behemoths, for quality-of-life rather than functional necessity, and leaving no way to adjust it other than hacking the source, would represent an unnecessary degree of short-sightedness that we can and should avoid.

Taking a closer look at the code, it appears fairly straightforward to make the hash size variable, and in fact making it self-adjusting doesn't seem too big a jump from there. I'm happy to have a go at that myself if you like.

Robin.