Skip to contentSkip to conversation

Fragmentation Avoidance V19

PATCH In review Andy Nelson 9 participants 15 messages Nov 4, 2005 – Nov 6, 2005 Memory management

lore
Share & tools
lore
#0 lore raw

cover Fragmentation Avoidance V19

Quoted 12 lines · Andy Nelson
Quoted 3 lines

My measurements of factors of 3-4 on more than one hw arch don't mean anything then?

When I _know_ that modern hardware does what you tested at least two orders of magnitude better than the hardware you tested?

Ok. In other posts you have skeptically accepted Power as a `modern' architecture. I have just now dug out some numbers of a slightly different problem running on a Power 5. Specifically a IBM p575 I think. These tests were done in June, while the others were done more than 2.5 years ago. In other words, there may be other small tuning optimizations that have gone in since then too.

The problem is a different configuration of particles, and about 2 times bigger (7Million) than the one in comp.arch (3million I think). I would estimate that the data set in this test spans something like 2-2.5GB or so.

Here are the results:

cpus    4k pages   16m pages
1       4888.74s   2399.36s
2       2447.68s   1202.71s
4       1225.98s    617.23s
6        790.05s    418.46s
8        592.26s    310.03s
12       398.46s    210.62s
16       296.19s    161.96s

These numbers were on a recent Linux. I don't know which one.

Now it looks like it is down to a factor 2 or slightly more. That is a totally different arch, that I think you have accepted as `modern', running the OS that you say doesn't need big page support.

Still a bit more than insignificant I would say.

Quoted 1 line

Think about it.

Likewise.

Andy

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#1 lore raw
Quoted 3 lines · Andy Nelson

Ok. In other posts you have skeptically accepted Power as a `modern' architecture.

Yes, sceptically.

I'd really like to hear what your numbers are on a modern x86. Any x86-64 is interesting, and I can't imagine that with a LANL address you can't find any.

I do believe that Power is within one order of magnitude of a modern x86 when it comes to TLB fill performance. That's much better than many others, but whether "almost as good" is within the error range, or whether it's "only five times worse", I don't know.

The thing is, there's a reason x86 machines kick ass. They are cheap, and they really _do_ outperform pretty much everything else out there.

Power 5 has a wonderful memory architecture, and those L3 caches kick ass. They probably don't help you as much as they help databases, though, and it's entirely possible that a small cheap Opteron with its integrated memory controller will outperform them on your load if you really don't have a lot of locality.

Linus

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#3 lore raw
In reply to Andy Nelson
Quoted 7 lines · Andy Nelson

The problem is a different configuration of particles, and about 2 times bigger (7Million) than the one in comp.arch (3million I think). I would estimate that the data set in this test spans something like 2-2.5GB or so.

Here are the results:

Quoted 8 lines
cpus    4k pages   16m pages
1       4888.74s   2399.36s
2       2447.68s   1202.71s
4       1225.98s    617.23s
6        790.05s    418.46s
8        592.26s    310.03s
12       398.46s    210.62s
16       296.19s    161.96s

interesting, and thanks for the numbers. Even if hugetlbs were only showing a 'mere' 5% improvement, a 5% _user-space improvement_ is still a considerable improvement that we should try to achieve, if possible cheaply.

the 'separate hugetlb zone' solution is cheap and simple, and i believe it should cover your needs of mixed hugetlb and smallpages workloads.

it would work like this: unlike the current hugepages=<nr> boot parameter, this zone would be useful for other (4K sized) allocations too. If an app requests a hugepage then we have the chance to allocate it from the hugetlb zone, in a guaranteed way [up to the point where the whole zone consists of hugepages only].

the architectural appeal in this solution is that no additional "fragmentation prevention" has to be done on this zone, because we only allow content into it that is "easy" to flush - this means that there is no complexity drag on the generic kernel VM.

can you think of any reason why the boot-time-configured hugetlb zone would be inadequate for your needs?

Ingo

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#4 lore raw

Hi,

Quoted 2 lines

can you think of any reason why the boot-time-configured hugetlb zone would be inadequate for your needs?

I am not enough of a kernel level person or sysadmin to know for certain, but I have still big worries about consecutive jobs that run on the same resources, but want extremely different page behavior. If what you are suggesting can cause all previous history on those resources to be forgotten and then reset to whatever it is that I want when I start my run, then yes. It would be fine for me. In some sense, this is perhaps what I was asking for in my original message when I was talking about using batch schedulers, cpusets and friends to encapsulate regions of resources, that could be reset to nice states at user specified intervals, like when the batch scheduler releases one job and another job starts.

The issues that I can still think of that hpc people will need are (some points here are clearly related to each other, but anyway).

1) how do zones play with numa? Does setting up resource management this way mean that various kernel things that help me access my memory (hellifino what I'm talking about here--things like tables and lists of pages that I own and how to access them etc I suppose--whatever it is that kernels don't get rid of when someone else's job ends and before mine starts) actually get allocated in some other zone half way across the machine? This is going to kill me on latency grounds. Can it be set up so that this reserved special kernel zone is somewhere close by? If it is bigger than the next guy to get my resources wants, can it be deleted and reset once my job is finished, so his job can run? This is what I would hope for and expect that something like cpuset/memsets would help to do.

2) How do zones play with merging small pages into big pages, splitting big pages into small, or deleting whatever page environment was there in favor of a reset of those resources to some initial state? If someone runs a small page job right after my big page job, will they get big pages? If I run a big page job right after their small page job, will I get small pages?

In each case, will it simply say 'no can do' and die? If this setup just means that some jobs can't be run or can't be run after something else, it will not fly.

3) How does any sort of fall back scheme work? If I can't have all of my big pages, maybe I'll settle for some small ones and some big ones. Can I have them? If I can't have them and die instead, zones like this will not fly.

Points 2 and 3 have mostly to do with the question Does the system performance degrade over time for different constituencies of users or can it stay up stably, serving everyone equally and well for a long time?

4) How does any of this stuff play with interactive management? It is not going to fly if sysadmins have to get involved on a daily/regular basis, or even at much more than a cursory level of turning something on once when the machine is purchased.

5) How does any of this stuff play with me having to rewrite my code to use nonstandard language features? If I can't run using standard fortran, standard C and maybe for some folks standard C++ or Java, it won't fly.

6) what about text vs data pages. I'm talking here about executable code vs whatever that code operates on. Do they get to have different sized pages? Do they get allocated from sensible places on the machine, as in reasonably separate from each other but not in some far away zone over the rainbow?

7) If OS's/HW ever get decent support for lots and lots of page sizes (like mips and sparc now) rather than a couple , will the infrastructure be able to give me whichever size I ask for, or will I only get to choose between a couple, even if perhaps settable at boot time? Extensibility like this will be a requirement long term of course.

8) What if I want 32 cpus and 64GB of memory on a machine, get it, finish using it, and then the next jobs in line request say 8 cpus and 16GB of memory, 4cpus and 16GB of memory, 20 cpus and 4GB of memory? Will the zone system be able to handle such dynamically changing things?

What I would need to see is that these sorts of issues can be handled gracefully by the OS, perhaps with the help of some user land or priveleged userland hints that would come from things like the batch scheduler or an env variable to set my prefered page size or other things about memory policy.

Thanks,

Andy

PS to Linus: I have secured access to an dual cpu dual core amd box. I have to talk to someone who is not here today to see about turning on large pages. We'll see how that goes probably some time next week. If it is possible, you'll see some benchmarks then.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#5 lore raw
Quoted 4 lines · Andy Nelson

5) How does any of this stuff play with me having to rewrite my code to use nonstandard language features? If I can't run using standard fortran, standard C and maybe for some folks standard C++ or Java, it won't fly.

it ought to be possible to get pretty much the same API as hugetlbfs via the 'hugetlb zone' approach too. It doesnt really change the API and FS side, it only impacts the allocator internally. So if you can utilize hugetlbfs, you should be able to utilize a 'special zone' approach pretty much the same way.

Ingo

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#6 lore raw
In reply to Andy Nelson
Quoted 7 lines · Andy Nelson

I am not enough of a kernel level person or sysadmin to know for certain, but I have still big worries about consecutive jobs that run on the same resources, but want extremely different page behavior. If what you are suggesting can cause all previous history on those resources to be forgotten and then reset to whatever it is that I want when I start my run, then yes.

That would largely be the behaviour.

When you use the hugetlb zone for big pages, nothing else would be there.

And when you don't use it, we'd be able to use those zones for at least page cache and user private pages - both of which are fairly easy to evict if required.

So the downside is that when the admin requests such a zone at boot-time, that will mean that the kernel will never be able to use it for its "normal" allocations. Not for inodes, not for directory name caching, not for page tables and not for process and file descriptors. Only a very certain class of allocations that we know how to evict easily could use them.

Now, for many loads, that's fine. User virtual pages and page cache pages are often a big part (in fact, often a huge majority) of the memory use.

Not always, though. Some loads really want lots of metadata caching, and if you make too much of memory be in the largepage zones, performance would suffer badly on such loads.

But the point is that this is easy(ish) to do, and would likely work wonderfully well for almost all loads. It does put a small onus on the maintainer of the machine to give a hint, but it's possible that normal loads won't mind the limitation and that we could even have a few hugepage zones by default (limit things to 25% of total memory or something). In fact, we would almost have to do so initially just to get better test coverage.

Now, if you want _most_ of memory to be available for hugepages, you really will always require a special boot option, and a friendly machine maintainer. Limiting things like inodes, process descriptors etc to a smallish percentage of memory would not be acceptable in general.

Something like 25% "big page zones" probably is fine even in normal use, and 50% might be an acceptable compromise even for machines that see a mixture of pretty regular use and some specialized use. But a machine that only cares about certain loads might boot up with 75% set aside in the large-page zones, and that almost certainly would _not_ be a good setup for random other usage.

IOW, we want a hit up-front about how important huge pages would be. Because it's practically impossible to free pages later, because they _will_ become fragmented with stuff that we definitely do not want to teach the VM how to handle.

But the hint can be pretty friendly. Especially if it's an option to just load a lot of memory into the boxes, and none of the loads are expected to want to really be excessively close to memory limits (ie you could just buy an extra 16GB to allow for "slop").

Linus

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#10 lore raw
In reply to Andy Nelson
Quoted 3 lines · Andy Nelson

I am not enough of a kernel level person or sysadmin to know for certain, but I have still big worries about consecutive jobs that run on the same resources, but want extremely different page behavior. I

Thats the idea. The 'hugetlb zone' will only be usable for allocations which are guaranteed reclaimable. Reclaimable includes userspace usage (since at worst an in use userspace page can be swapped out then paged back into another physical location).

For your sort of mixed use this should be a fine solution. However there are mixed use cases that that this will not solve, for example if the system usage is split between HPC uses and kernel allocation heavy workloads (say forking 10quintillion java processes) then the hugetlb zone will need to be made small to keep the kernel allocation heavy workload happy.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#7 lore raw
In reply to Linus Torvalds
Quoted 5 lines · Linus Torvalds

But the hint can be pretty friendly. Especially if it's an option to just load a lot of memory into the boxes, and none of the loads are expected to want to really be excessively close to memory limits (ie you could just buy an extra 16GB to allow for "slop").

One of the issues _will_ be how to allocate things on NUMA. Right now "hugetlb" only allows us to say "this much memory for hugetlb", and it probably needs to be per-zone.

Some uses might want to allocate all of the local memory on one node to huge-page usage (and specialized programs would then also like to run pinned to that node), others migth want to spread it out. So the maintenance would need to decide that.

The good news is that you can boot up with almost all zones being "big page" zones, and you could turn them into "normal zones" dynamically. It's only going the other way that is hard.

So from a maintenance standpoint if you manage lots of machines, you could have them all uniformly boot up with lots of memory set aside for large pages, and then use user-space tools to individually turn the zones into regular allocation zones.

Linus

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#11 lore raw
In reply to Gregory Maxwell
Quoted 9 lines · Gregory Maxwell
Quoted 3 lines · Andy Nelson

I am not enough of a kernel level person or sysadmin to know for certain, but I have still big worries about consecutive jobs that run on the same resources, but want extremely different page behavior. I

Thats the idea. The 'hugetlb zone' will only be usable for allocations which are guaranteed reclaimable. Reclaimable includes userspace usage (since at worst an in use userspace page can be swapped out then paged back into another physical location).

I don't like it very much. You have two choices if a workload runs out of the kernel allocatable pages. Either you spill into the reclaimable zone or you fail the allocation. The first means that the huge pages thing is unreliable, the second would mean that all the many problems of limited lowmem would be back.

None of this is very attractive.

-Andi

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#12 lore raw
Quoted 9 lines · Andi Kleen
Quoted 5 lines · Gregory Maxwell

Thats the idea. The 'hugetlb zone' will only be usable for allocations which are guaranteed reclaimable. Reclaimable includes userspace usage (since at worst an in use userspace page can be swapped out then paged back into another physical location).

Quoted 6 lines

I don't like it very much. You have two choices if a workload runs out of the kernel allocatable pages. Either you spill into the reclaimable zone or you fail the allocation. The first means that the huge pages thing is unreliable, the second would mean that all the many problems of limited lowmem would be back.

These are essentially the same problems that the frag patches face as well.

Quoted 2 lines

None of this is very attractive.

Though it is simple and I expect it should actually do a really good job for the non-kernel-intensive HPC group, and the highly tuned database group.

Nick

Signature · 3 lines
SUSE Labs, Novell Inc.

Send instant messages to your online friends http://au.messenger.yahoo.com 
#8 lore raw
In reply to Linus Torvalds
Quoted 4 lines · Linus Torvalds

Now, if you want _most_ of memory to be available for hugepages, you really will always require a special boot option, and a friendly machine maintainer. Limiting things like inodes, process descriptors etc to a smallish percentage of memory would not be acceptable in general.

But it might make it a lot easier for User Mode Linux to give unused memory back to the host system via madvise(DONT_NEED).

(Assuming there's some way to beat the page cache into submission and actually free up space. If there was an option to tell the page cache to stay the heck out of the hugepage zone, it would be just about perfect...)

Rob

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#13 lore raw
In reply to Andi Kleen
Quoted 8 lines · Andi Kleen

I don't like it very much. You have two choices if a workload runs out of the kernel allocatable pages. Either you spill into the reclaimable zone or you fail the allocation. The first means that the huge pages thing is unreliable, the second would mean that all the many problems of limited lowmem would be back.

None of this is very attractive.

You could allow the 'hugetlb zone' to shrink, allowing more kernel allocations. User pages at the boundary would be moved to make room.

This would at least keep the 'hugetlb zone' pure and not create holes in it.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#14 lore raw
Quoted 4 lines · Zan Lynx
Quoted 1 line

None of this is very attractive.

You could allow the 'hugetlb zone' to shrink, allowing more kernel allocations. User pages at the boundary would be moved to make room.

Please make that optional if you do. In my potential use case, an OOM kill lets the administrator know they've got things configure wrong so they can can fix it and try again. Containing and viciously reaping things like dentries is the behavior I want out of it.

Also, if you do shrink the hugetlb zone it might be possible to opportunistically expand it back to its original size. There's no guarantee that a given kernel allocation will ever go away, but if it _does_ go away then the hugetlb zone should be able to expand to the next blocking allocation or the maximum size, whichever comes first. (Given that my understanding of the layout may not match reality at all; don't ask me how the discontiguous memory stuff would work in here...)

Rob

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#9 lore raw
In reply to Linus Torvalds

How would this hugetlb zone be placed - on which nodes in a NUMA system?

My understanding is that you are thinking to specify it as a proportion or amount of total memory, with no particular placement.

I'd rather see it as a subset of the nodes on a system being marked for use, as much as practical, for easily reclaimed memory (page cache and user).

My HPC customers normally try to isolate the 'classic Unix load' on a few nodes that they call the bootcpuset, and keep the other nodes as unused as practical, except when allocated for dedicated use by a particular job. These other nodes need to run with a maximum amount of easily reclaimed memory, while the bootcpuset nodes have no such need.

They don't just want easily reclaimable memory in order to get hugetlb pages. They also want it so that the memory available for use as ordinary sized pages by one job will not be unduly reduced by the hard to reclaim pages left over from some previous job.

This would be easy to do with cpusets, adding a second per-cpuset nodemask that specified where not easily reclaimed kernel allocations should come from. The typical HPC user would set that second mask to their bootcpuset. The few kmalloc calls in the kernel (page cache and user space) deemed to be easily reclaimable would have a __GFP_EASYRCLM flag added, and the cpuset hook in the __alloc_pages code path would put requests -not- marked __GFP_EASYRCLM on this second set of nodes.

No changes to hugetlbs or to the kernel code that runs at boot, prior to starting init, would be required at all. The bootcpuset stuff is setup by a pre-init program (specified using the kernels "init=..." boot option.) This makes all the configuration of this entirely a user space problem.

Cpuset nodes, not zone sizes, are the proper way to manage this, in my view.

If you ask what this means for small (1 or 2 node) systems, then I would first ask you what we are trying to do on those systems. I suspect that that would involve other classes of users, with different needs, than what Andy or I can speak to.

Signature · 9 lines
                  I won't rest till it's the best ...
                  Programmer, Linux Scalability
                  Paul Jackson <[email protected]> 1.925.600.0401

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>