Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1195219 > unrolled thread
| Started by | Vladimir Davydov <vdavydov@parallels.com> |
|---|---|
| First post | 2015-07-29 16:00 +0200 |
| Last post | 2015-07-29 16:50 +0200 |
| Articles | 7 — 3 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: [PATCH -mm v9 0/8] idle memory tracking Vladimir Davydov <vdavydov@parallels.com> - 2015-07-29 16:00 +0200
Re: [PATCH -mm v9 0/8] idle memory tracking Michel Lespinasse <walken@google.com> - 2015-07-29 16:20 +0200
Re: [PATCH -mm v9 0/8] idle memory tracking Michal Hocko <mhocko@kernel.org> - 2015-07-29 16:30 +0200
Re: [PATCH -mm v9 0/8] idle memory tracking Michal Hocko <mhocko@kernel.org> - 2015-07-30 11:10 +0200
Re: [PATCH -mm v9 0/8] idle memory tracking Vladimir Davydov <vdavydov@parallels.com> - 2015-07-30 11:40 +0200
Re: [PATCH -mm v9 0/8] idle memory tracking Vladimir Davydov <vdavydov@parallels.com> - 2015-07-30 11:20 +0200
Re: [PATCH -mm v9 0/8] idle memory tracking Vladimir Davydov <vdavydov@parallels.com> - 2015-07-29 16:50 +0200
| From | Vladimir Davydov <vdavydov@parallels.com> |
|---|---|
| Date | 2015-07-29 16:00 +0200 |
| Subject | Re: [PATCH -mm v9 0/8] idle memory tracking |
| Message-ID | <pRA3N-1sA-41@gated-at.bofh.it> |
On Wed, Jul 29, 2015 at 02:36:30PM +0200, Michal Hocko wrote: > On Sun 19-07-15 15:31:09, Vladimir Davydov wrote: > [...] > > ---- USER API ---- > > > > The user API consists of two new proc files: > > I was thinking about this for a while. I dislike the interface. It is > quite awkward to use - e.g. you have to read the full memory to check a > single memcg idleness. This might turn out being a problem especially on > large machines. Yes, with this API estimating the wss of a single memory cgroup will cost almost as much as doing this for the whole system. Come to think of it, does anyone really need to estimate idleness of one particular cgroup? If we are doing this for finding an optimal memcg limits configuration or while considering a load move within a cluster (which I think are the primary use cases for the feature), we must do it system-wide to see the whole picture. > It also provides a very low level information (per-pfn idleness) which > is inherently racy. Does anybody really require this level of detail? Well, one might want to do it per-process, obtaining PFNs from /proc/pid/pagemap. > > I would assume that most users are interested only in a single number > which tells the idleness of the system/memcg. Yes, that's what I need it for - estimating containers' wss for setting their limits accordingly. > Well, you have mentioned a per-process reclaim but I am quite > skeptical about this. This is what Minchan mentioned initially. Personally, I'm not going to use it per-process, but I wouldn't rule out this use case either. > > I guess the primary reason to rely on the pfn rather than the LRU walk, > which would be more targeted (especially for memcg cases), is that we > cannot hold lru lock for the whole LRU walk and we cannot continue > walking after the lock is dropped. Maybe we can try to address that > instead? I do not think this is easy to achieve but have you considered > that as an option? Yes, I have, and I've come to a conclusion it's not doable, because LRU lists can be constantly rotating at an arbitrary rate. If you have an idea in mind how this could be done, please share. Speaking of LRU-vs-PFN walk, iterating over PFNs has its own advantages: - You can distribute a walk in time to avoid CPU bursts. - You are free to parallelize the scanner as you wish to decrease the scan time. Thanks, Vladimir -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [next] | [standalone]
| From | Michel Lespinasse <walken@google.com> |
|---|---|
| Date | 2015-07-29 16:20 +0200 |
| Message-ID | <pRAn7-24H-9@gated-at.bofh.it> |
| In reply to | #1195219 |
(resending as text, sorry for previous post which didn't make it to the ML) On Wed, Jul 29, 2015 at 7:12 AM, Michel Lespinasse <walken@google.com> wrote: > > On Wed, Jul 29, 2015 at 6:59 AM, Vladimir Davydov <vdavydov@parallels.com> wrote: > >> I guess the primary reason to rely on the pfn rather than the LRU walk, > >> which would be more targeted (especially for memcg cases), is that we > >> cannot hold lru lock for the whole LRU walk and we cannot continue > >> walking after the lock is dropped. Maybe we can try to address that > >> instead? I do not think this is easy to achieve but have you considered > >> that as an option? > > > > Yes, I have, and I've come to a conclusion it's not doable, because LRU > > lists can be constantly rotating at an arbitrary rate. If you have an > > idea in mind how this could be done, please share. > > > > Speaking of LRU-vs-PFN walk, iterating over PFNs has its own advantages: > > - You can distribute a walk in time to avoid CPU bursts. > > - You are free to parallelize the scanner as you wish to decrease the > > scan time. > > There is a third way: one could go through every MM in the system and scan their page tables. Doing things that way turns out to be generally faster than scanning by physical address, because you don't have to go through RMAP for every page. But, you end up needing to take the mmap_sem lock of every MM (in turn) while scanning them, and that degrades quickly under memory load, which is exactly when you most need this feature. So, scan by address is still what we use here. > > My only concern about the interface is that it exposes the fact that the scan is done by address - if the interface only showed per-memcg totals, it would make it possible to change the implementation underneath if we somehow figure out how to work around the mmap_sem issue in the future. I don't think that is necessarily a blocker but this is something to keep in mind IMO. -- Michel "Walken" Lespinasse A program is never fully debugged until the last user dies. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Michal Hocko <mhocko@kernel.org> |
|---|---|
| Date | 2015-07-29 16:30 +0200 |
| Message-ID | <pRAwO-2g5-27@gated-at.bofh.it> |
| In reply to | #1195219 |
On Wed 29-07-15 16:59:07, Vladimir Davydov wrote: > On Wed, Jul 29, 2015 at 02:36:30PM +0200, Michal Hocko wrote: > > On Sun 19-07-15 15:31:09, Vladimir Davydov wrote: > > [...] > > > ---- USER API ---- > > > > > > The user API consists of two new proc files: > > > > I was thinking about this for a while. I dislike the interface. It is > > quite awkward to use - e.g. you have to read the full memory to check a > > single memcg idleness. This might turn out being a problem especially on > > large machines. > > Yes, with this API estimating the wss of a single memory cgroup will > cost almost as much as doing this for the whole system. > > Come to think of it, does anyone really need to estimate idleness of one > particular cgroup? It is certainly interesting for setting the low limit. > If we are doing this for finding an optimal memcg > limits configuration or while considering a load move within a cluster > (which I think are the primary use cases for the feature), we must do it > system-wide to see the whole picture. > > > It also provides a very low level information (per-pfn idleness) which > > is inherently racy. Does anybody really require this level of detail? > > Well, one might want to do it per-process, obtaining PFNs from > /proc/pid/pagemap. Sure once the interface is exported you can do whatever ;) But my question is whether any real usecase _requires_ it. > > I would assume that most users are interested only in a single number > > which tells the idleness of the system/memcg. > > Yes, that's what I need it for - estimating containers' wss for setting > their limits accordingly. So why don't we export the single per memcg and global knobs then? This would have few advantages. First of all it would be much easier to use, you wouldn't have to export memcg ids and finally the implementation could be changed without any user visible changes (e.g. lru vs. pfn walks), potential caching and who knows what. In other words. Michel had a single number interface AFAIR, what was the primary reason to move away from that API? > > Well, you have mentioned a per-process reclaim but I am quite > > skeptical about this. > > This is what Minchan mentioned initially. Personally, I'm not going to > use it per-process, but I wouldn't rule out this use case either. Considering how many times we have been bitten by too broad interfaces I would rather be conservative. > > I guess the primary reason to rely on the pfn rather than the LRU walk, > > which would be more targeted (especially for memcg cases), is that we > > cannot hold lru lock for the whole LRU walk and we cannot continue > > walking after the lock is dropped. Maybe we can try to address that > > instead? I do not think this is easy to achieve but have you considered > > that as an option? > > Yes, I have, and I've come to a conclusion it's not doable, because LRU > lists can be constantly rotating at an arbitrary rate. If you have an > idea in mind how this could be done, please share. Yes this is really tricky with the current LRU implementation. I was playing with some ideas (do some checkpoints on the way) but none of them was really working out on a busy systems. But the LRU implementation might change in the future. I didn't mean this as a hard requirement it just sounds that the current implementation restrictions shape the user visible API which is a good sign to think twice about it. > Speaking of LRU-vs-PFN walk, iterating over PFNs has its own advantages: > - You can distribute a walk in time to avoid CPU bursts. This would make the information even more volatile. I am not sure how helpful it would be in the end. > - You are free to parallelize the scanner as you wish to decrease the > scan time. This is true but you could argue similar with per-node/lru threads if this was implemented in the kernel and really needed. I am not sure it would be really needed though. I would expect this would be a low priority thing. -- Michal Hocko SUSE Labs -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Michal Hocko <mhocko@kernel.org> |
|---|---|
| Date | 2015-07-30 11:10 +0200 |
| Message-ID | <pRS0G-2ew-15@gated-at.bofh.it> |
| In reply to | #1195247 |
On Wed 29-07-15 19:29:08, Vladimir Davydov wrote: > On Wed, Jul 29, 2015 at 05:47:18PM +0200, Michal Hocko wrote: [...] > > If you use the low limit for isolating an important load then you do not > > have to care about the others that much. All you care about is to set > > the reasonable protection level and let others to compete for the rest. > > That's a use case, you're right. Well, it's a natural limitation of this > API - you just have to perform a full PFN scan then. You can avoid > costly rmap walks for the cgroups you are not interested in by filtering > them out using /proc/kpagecgroup though. You still have to read through the whole memory and that is inherent to the API and there no way for a better implementation later on other than a new exported file. [...] > > > Because there is too much to be taken care of in the kernel with such an > > > approach and chances are high that it won't satisfy everyone. What > > > should the scan period be equal too? > > > > No, just gather the data on the read request and let the userspace > > to decide when/how often etc. If we are clever enough we can cache > > the numbers and prevent from the walk. Write to the file and do the > > mark_idle stuff. > > Still, scan rate limiting would be an issue IMO. Not sure what you mean here. Scan rate would be defined by the userspace by reading/writing to the knob. No background kernel thread is really necessary. > > > Knob. How many kthreads do we want? > > > Knob. I want to keep history for last N intervals (this was a part of > > > Michel's implementation), what should N be equal to? Knob. > > > > This all relates to the kernel thread implementation which I wasn't > > suggesting. I was referring to Michel's work which might induce that. > > I was merely referring to a single number output. Sorry about the > > confusion. > > Still, what about idle stats history? I mean having info about how many > pages were idle for N scans. It might be useful for more robust/accurate > wss estimation. Why cannot userspace remember those numbers? > > > I want to be > > > able to choose between an instant scan and a scan distributed in time. > > > Knob. I want to see stats for anon/locked/file/dirty memory separately, > > > > Why is this useful for the memcg limits setting or the wss estimation? I > > can imagine that a further drop down numbers might be interesting > > from the debugging POV but I fail to see what kind of decisions from > > userspace you would do based on them. > > A couple examples that pop up in my mind: > > It's difficult to make wss estimation perfect. By mlocking pages, a > workload might give a hint to the system that it will be really unhappy > if they are evicted. > > One might want to consider anon pages and/or dirty pages as not idle in > order to protect them and hence avoid expensive pageout/swapout. I still seem to miss the point. How do you do that via the proposed interface which doesn't influence the reclaim AFAIU and you do not have means to achieve the above (except for swappiness). What am I missing? > > [...] > > > > Yes this is really tricky with the current LRU implementation. I > > > > was playing with some ideas (do some checkpoints on the way) but > > > > none of them was really working out on a busy systems. But the LRU > > > > implementation might change in the future. > > > > > > It might. Then we could come up with a new /proc or /sys file which > > > would do the same as /proc/kpageidle, but on per LRU^w whatever-it-is > > > basis, and give people a choice which one to use. > > > > This just leads to proc files count explosion we are seeing > > already... Proc ended up in dump ground for different things which > > didn't fit elsewhere and I am not very much happy about it to be honest. > > Moving the API to memcg is not a good idea either IMO, because the > feature can actually be useful with memcg disabled, e.g. it might help > estimate if the system is over- or underloaded. I agree and that's why I was referring to memcg/global knobs. -- Michal Hocko SUSE Labs -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Vladimir Davydov <vdavydov@parallels.com> |
|---|---|
| Date | 2015-07-30 11:40 +0200 |
| Message-ID | <pRStI-2Ml-11@gated-at.bofh.it> |
| In reply to | #1195830 |
On Thu, Jul 30, 2015 at 11:07:09AM +0200, Michal Hocko wrote: > On Wed 29-07-15 19:29:08, Vladimir Davydov wrote: > > On Wed, Jul 29, 2015 at 05:47:18PM +0200, Michal Hocko wrote: > [...] > > > If you use the low limit for isolating an important load then you do not > > > have to care about the others that much. All you care about is to set > > > the reasonable protection level and let others to compete for the rest. > > > > That's a use case, you're right. Well, it's a natural limitation of this > > API - you just have to perform a full PFN scan then. You can avoid > > costly rmap walks for the cgroups you are not interested in by filtering > > them out using /proc/kpagecgroup though. > > You still have to read through the whole memory and that is inherent to > the API and there no way for a better implementation later on other than > a new exported file. I don't deny that. Nevertheless, PFN-walk is something that will always be useful, simply because PFN-range is an invariant - it will always exist. If one day a better page iterator appear (e.g. LRU walk) and the need for it is justified well enough, we can add one more file. Note, it won't deprecate the original PFN map - they both can be used for different use cases then. If we move kpageidle to /sys/kernel/mm attr group, which I'm doing now, it will be trivial to do and won't pollute /proc. > > [...] > > > > > Because there is too much to be taken care of in the kernel with such an > > > > approach and chances are high that it won't satisfy everyone. What > > > > should the scan period be equal too? > > > > > > No, just gather the data on the read request and let the userspace > > > to decide when/how often etc. If we are clever enough we can cache > > > the numbers and prevent from the walk. Write to the file and do the > > > mark_idle stuff. > > > > Still, scan rate limiting would be an issue IMO. > > Not sure what you mean here. Scan rate would be defined by the userspace > by reading/writing to the knob. No background kernel thread is really > necessary. Nevertheless, it means more logic in the kernel (rate limiter) and a wider interface (+ rate limit value). > > > > > Knob. How many kthreads do we want? > > > > Knob. I want to keep history for last N intervals (this was a part of > > > > Michel's implementation), what should N be equal to? Knob. > > > > > > This all relates to the kernel thread implementation which I wasn't > > > suggesting. I was referring to Michel's work which might induce that. > > > I was merely referring to a single number output. Sorry about the > > > confusion. > > > > Still, what about idle stats history? I mean having info about how many > > pages were idle for N scans. It might be useful for more robust/accurate > > wss estimation. > > Why cannot userspace remember those numbers? Because they must be per-page - you have to remember for how many periods *each particular* page has been idle. To achieve this, Michel had to introduce a byte array referenced by PFN in his work. With kpageidle file one can store this array in the userspace. > > > > > I want to be > > > > able to choose between an instant scan and a scan distributed in time. > > > > Knob. I want to see stats for anon/locked/file/dirty memory separately, > > > > > > Why is this useful for the memcg limits setting or the wss estimation? I > > > can imagine that a further drop down numbers might be interesting > > > from the debugging POV but I fail to see what kind of decisions from > > > userspace you would do based on them. > > > > A couple examples that pop up in my mind: > > > > It's difficult to make wss estimation perfect. By mlocking pages, a > > workload might give a hint to the system that it will be really unhappy > > if they are evicted. > > > > One might want to consider anon pages and/or dirty pages as not idle in > > order to protect them and hence avoid expensive pageout/swapout. > > I still seem to miss the point. How do you do that via the proposed > interface which doesn't influence the reclaim AFAIU and you do not have > means to achieve the above (except for swappiness). What am I missing? You can consider idle only those pages that are clean, and then set the low limit appropriately for your workload. You can find out which pages are clean by reading /proc/kpageflags. Of course, this won't stop the reclaimer from evicting them, but it will make the reclaimer less aggressive with respect to your workload. Thanks, Vladimir -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Vladimir Davydov <vdavydov@parallels.com> |
|---|---|
| Date | 2015-07-30 11:20 +0200 |
| Message-ID | <pRSam-2pU-15@gated-at.bofh.it> |
| In reply to | #1195247 |
On Wed, Jul 29, 2015 at 02:30:15PM -0700, Andrew Morton wrote: > On Wed, 29 Jul 2015 19:29:08 +0300 Vladimir Davydov <vdavydov@parallels.com> wrote: > > > /proc/kpageidle should probably live somewhere in /sys/kernel/mm, but I > > added it where similar files are located (kpagecount, kpageflags) to > > keep things consistent. > > I think these files should be moved elsewhere. Consistency is good, > but not when we're being consistent with a bad thing. > > So let's place these in /sys/kernel/mm and then start being consistent > with that? I really don't think we should separate kpagecgroup from kpagecount and kpageflags, because they look very similar (each of them is read-only, contains an array of u64 values referenced by PFN). Scattering these files between different filesystems would look ugly IMO. However, kpageidle is somewhat different (it's read-write, contains a bitmap) so I think it's worth moving it to /sys/kernel/mm. We have to move the code from fs/proc to mm/something then to remove dependency from PROC_FS, which would be unnecessary. Let me give it a try. Thanks, Vladimir -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Vladimir Davydov <vdavydov@parallels.com> |
|---|---|
| Date | 2015-07-29 16:50 +0200 |
| Message-ID | <pRAQa-2CD-13@gated-at.bofh.it> |
| In reply to | #1195219 |
On Wed, Jul 29, 2015 at 07:12:13AM -0700, Michel Lespinasse wrote: > On Wed, Jul 29, 2015 at 6:59 AM, Vladimir Davydov <vdavydov@parallels.com> > wrote: > >> I guess the primary reason to rely on the pfn rather than the LRU walk, > >> which would be more targeted (especially for memcg cases), is that we > >> cannot hold lru lock for the whole LRU walk and we cannot continue > >> walking after the lock is dropped. Maybe we can try to address that > >> instead? I do not think this is easy to achieve but have you considered > >> that as an option? > > > > Yes, I have, and I've come to a conclusion it's not doable, because LRU > > lists can be constantly rotating at an arbitrary rate. If you have an > > idea in mind how this could be done, please share. > > > > Speaking of LRU-vs-PFN walk, iterating over PFNs has its own advantages: > > - You can distribute a walk in time to avoid CPU bursts. > > - You are free to parallelize the scanner as you wish to decrease the > > scan time. > > There is a third way: one could go through every MM in the system and scan > their page tables. Doing things that way turns out to be generally faster > than scanning by physical address, because you don't have to go through > RMAP for every page. But, you end up needing to take the mmap_sem lock of > every MM (in turn) while scanning them, and that degrades quickly under > memory load, which is exactly when you most need this feature. So, scan by > address is still what we use here. Page table scan approach has the inherent problem - it ignores unmapped page cache. If a workload does a lot of read/write or map-access-unmap operations, we won't be able to even roughly estimate its wss. Thanks, Vladimir -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web