Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1481195 > unrolled thread
| Started by | Michal Hocko <mhocko@kernel.org> |
|---|---|
| First post | 2016-09-12 14:10 +0200 |
| Last post | 2016-09-20 02:40 +0200 |
| Articles | 13 — 4 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 v5 0/3] mm, proc: Implement /proc/<pid>/totmaps Michal Hocko <mhocko@kernel.org> - 2016-09-12 14:10 +0200
Re: [PATCH v5 0/3] mm, proc: Implement /proc/<pid>/totmaps Sonny Rao <sonnyrao@chromium.org> - 2016-09-12 17:50 +0200
Re: [PATCH v5 0/3] mm, proc: Implement /proc/<pid>/totmaps Michal Hocko <mhocko@kernel.org> - 2016-09-12 19:20 +0200
Re: [PATCH v5 0/3] mm, proc: Implement /proc/<pid>/totmaps Sonny Rao <sonnyrao@chromium.org> - 2016-09-12 19:30 +0200
Re: [PATCH v5 0/3] mm, proc: Implement /proc/<pid>/totmaps Michal Hocko <mhocko@kernel.org> - 2016-09-13 09:20 +0200
Re: [PATCH v5 0/3] mm, proc: Implement /proc/<pid>/totmaps Sonny Rao <sonnyrao@chromium.org> - 2016-09-13 22:30 +0200
Re: [PATCH v5 0/3] mm, proc: Implement /proc/<pid>/totmaps Michal Hocko <mhocko@kernel.org> - 2016-09-14 11:20 +0200
Re: [PATCH v5 0/3] mm, proc: Implement /proc/<pid>/totmaps Robert Foss <robert.foss@collabora.com> - 2016-09-19 17:20 +0200
Re: [PATCH v5 0/3] mm, proc: Implement /proc/<pid>/totmaps Michal Hocko <mhocko@kernel.org> - 2016-09-19 21:40 +0200
Re: [PATCH v5 0/3] mm, proc: Implement /proc/<pid>/totmaps Jann Horn <jann@thejh.net> - 2016-09-19 22:00 +0200
Re: [PATCH v5 0/3] mm, proc: Implement /proc/<pid>/totmaps Sonny Rao <sonnyrao@chromium.org> - 2016-09-19 22:20 +0200
Re: [PATCH v5 0/3] mm, proc: Implement /proc/<pid>/totmaps Robert Foss <robert.foss@collabora.com> - 2016-09-20 02:30 +0200
Re: [PATCH v5 0/3] mm, proc: Implement /proc/<pid>/totmaps Sonny Rao <sonnyrao@chromium.org> - 2016-09-20 02:40 +0200
| From | Michal Hocko <mhocko@kernel.org> |
|---|---|
| Date | 2016-09-12 14:10 +0200 |
| Subject | Re: [PATCH v5 0/3] mm, proc: Implement /proc/<pid>/totmaps |
| Message-ID | <sgydI-35W-37@gated-at.bofh.it> |
On Mon 05-09-16 16:14:06, robert.foss@collabora.com wrote: > From: Robert Foss <robert.foss@collabora.com> > > This series provides the /proc/PID/totmaps feature, which > summarizes the information provided by /proc/PID/smaps for > improved performance and usability reasons. > > A use case is to speed up monitoring of memory consumption in > environments where RSS isn't precise. > > For example Chrome tends to many processes which have hundreds of VMAs > with a substantial amount of shared memory, and the error of using > RSS rather than PSS tends to be very large when looking at overall > memory consumption. PSS isn't kept as a single number that's exported > like RSS, so to calculate PSS means having to parse a very large smaps > file. > > This process is slow and has to be repeated for many processes, and we > found that the just act of doing the parsing was taking up a > significant amount of CPU time, so this patch is an attempt to make > that process cheaper. I still maintain my concerns about a single pss value. It might work in a very specific situations where the consumer knows what is shared but other than that the value can be more misleading than helpful. So a NACK from me until I am shown that this is usable in general and still helpful. -- Michal Hocko SUSE Labs
[toc] | [next] | [standalone]
| From | Sonny Rao <sonnyrao@chromium.org> |
|---|---|
| Date | 2016-09-12 17:50 +0200 |
| Message-ID | <sgBEC-5cu-39@gated-at.bofh.it> |
| In reply to | #1481195 |
On Mon, Sep 12, 2016 at 5:02 AM, Michal Hocko <mhocko@kernel.org> wrote: > On Mon 05-09-16 16:14:06, robert.foss@collabora.com wrote: >> From: Robert Foss <robert.foss@collabora.com> >> >> This series provides the /proc/PID/totmaps feature, which >> summarizes the information provided by /proc/PID/smaps for >> improved performance and usability reasons. >> >> A use case is to speed up monitoring of memory consumption in >> environments where RSS isn't precise. >> >> For example Chrome tends to many processes which have hundreds of VMAs >> with a substantial amount of shared memory, and the error of using >> RSS rather than PSS tends to be very large when looking at overall >> memory consumption. PSS isn't kept as a single number that's exported >> like RSS, so to calculate PSS means having to parse a very large smaps >> file. >> >> This process is slow and has to be repeated for many processes, and we >> found that the just act of doing the parsing was taking up a >> significant amount of CPU time, so this patch is an attempt to make >> that process cheaper. > > I still maintain my concerns about a single pss value. It might work in > a very specific situations where the consumer knows what is shared but > other than that the value can be more misleading than helpful. So a NACK > from me until I am shown that this is usable in general and still > helpful. I know you think Pss isn't useful in general (though I'll point out two other independent people said they found it useful) but how about the other fields like Swap, Private_Dirty and Private_Shared? If we removed Pss would you still NACK it? > > -- > Michal Hocko > SUSE Labs
[toc] | [prev] | [next] | [standalone]
| From | Michal Hocko <mhocko@kernel.org> |
|---|---|
| Date | 2016-09-12 19:20 +0200 |
| Message-ID | <sgD3J-6fr-61@gated-at.bofh.it> |
| In reply to | #1481501 |
On Mon 12-09-16 08:31:36, Sonny Rao wrote: > On Mon, Sep 12, 2016 at 5:02 AM, Michal Hocko <mhocko@kernel.org> wrote: > > On Mon 05-09-16 16:14:06, robert.foss@collabora.com wrote: > >> From: Robert Foss <robert.foss@collabora.com> > >> > >> This series provides the /proc/PID/totmaps feature, which > >> summarizes the information provided by /proc/PID/smaps for > >> improved performance and usability reasons. > >> > >> A use case is to speed up monitoring of memory consumption in > >> environments where RSS isn't precise. > >> > >> For example Chrome tends to many processes which have hundreds of VMAs > >> with a substantial amount of shared memory, and the error of using > >> RSS rather than PSS tends to be very large when looking at overall > >> memory consumption. PSS isn't kept as a single number that's exported > >> like RSS, so to calculate PSS means having to parse a very large smaps > >> file. > >> > >> This process is slow and has to be repeated for many processes, and we > >> found that the just act of doing the parsing was taking up a > >> significant amount of CPU time, so this patch is an attempt to make > >> that process cheaper. > > > > I still maintain my concerns about a single pss value. It might work in > > a very specific situations where the consumer knows what is shared but > > other than that the value can be more misleading than helpful. So a NACK > > from me until I am shown that this is usable in general and still > > helpful. > > I know you think Pss isn't useful in general (though I'll point out > two other independent people said they found it useful) sure, and one of them admitted that the value is useful because they _know_ the resource. The other was quite vague for me to understand all the details. Please, try to understand that once you provide a user API then it will carved in stone. If the interface is poor and ambigous it will bite us later. One very specific usecase doesn't justify something that might be really misleading for 90% of cases. > but how about the other fields like Swap, Private_Dirty and > Private_Shared? Private_Shared can be pretty confusing as well without the whole context as well see my other emails in the original thread (just to remind shmem/tmpfs makes all this really confusing). -- Michal Hocko SUSE Labs
[toc] | [prev] | [next] | [standalone]
| From | Sonny Rao <sonnyrao@chromium.org> |
|---|---|
| Date | 2016-09-12 19:30 +0200 |
| Message-ID | <sgDdp-6jb-61@gated-at.bofh.it> |
| In reply to | #1481629 |
On Mon, Sep 12, 2016 at 10:15 AM, Michal Hocko <mhocko@kernel.org> wrote: > On Mon 12-09-16 08:31:36, Sonny Rao wrote: >> On Mon, Sep 12, 2016 at 5:02 AM, Michal Hocko <mhocko@kernel.org> wrote: >> > On Mon 05-09-16 16:14:06, robert.foss@collabora.com wrote: >> >> From: Robert Foss <robert.foss@collabora.com> >> >> >> >> This series provides the /proc/PID/totmaps feature, which >> >> summarizes the information provided by /proc/PID/smaps for >> >> improved performance and usability reasons. >> >> >> >> A use case is to speed up monitoring of memory consumption in >> >> environments where RSS isn't precise. >> >> >> >> For example Chrome tends to many processes which have hundreds of VMAs >> >> with a substantial amount of shared memory, and the error of using >> >> RSS rather than PSS tends to be very large when looking at overall >> >> memory consumption. PSS isn't kept as a single number that's exported >> >> like RSS, so to calculate PSS means having to parse a very large smaps >> >> file. >> >> >> >> This process is slow and has to be repeated for many processes, and we >> >> found that the just act of doing the parsing was taking up a >> >> significant amount of CPU time, so this patch is an attempt to make >> >> that process cheaper. >> > >> > I still maintain my concerns about a single pss value. It might work in >> > a very specific situations where the consumer knows what is shared but >> > other than that the value can be more misleading than helpful. So a NACK >> > from me until I am shown that this is usable in general and still >> > helpful. >> >> I know you think Pss isn't useful in general (though I'll point out >> two other independent people said they found it useful) > > sure, and one of them admitted that the value is useful because they > _know_ the resource. The other was quite vague for me to understand > all the details. Please, try to understand that once you provide a user > API then it will carved in stone. If the interface is poor and ambigous > it will bite us later. One very specific usecase doesn't justify > something that might be really misleading for 90% of cases. > >> but how about the other fields like Swap, Private_Dirty and >> Private_Shared? > > Private_Shared can be pretty confusing as well without the whole context > as well see my other emails in the original thread (just to remind > shmem/tmpfs makes all this really confusing). But this is exactly the issue -- RSS is can be just as confusing if you don't know something about the application. I think the issue is how common that situation is, and you seem to believe that it's so uncommon that it's actually better to keep the information more difficult to get for those of us who know something about our systems. That's fine, I guess we just have to disagree here, thanks for look at this. > > -- > Michal Hocko > SUSE Labs
[toc] | [prev] | [next] | [standalone]
| From | Michal Hocko <mhocko@kernel.org> |
|---|---|
| Date | 2016-09-13 09:20 +0200 |
| Message-ID | <sgQaC-72V-15@gated-at.bofh.it> |
| In reply to | #1481697 |
On Mon 12-09-16 10:28:53, Sonny Rao wrote: > On Mon, Sep 12, 2016 at 10:15 AM, Michal Hocko <mhocko@kernel.org> wrote: > > On Mon 12-09-16 08:31:36, Sonny Rao wrote: [...] > >> but how about the other fields like Swap, Private_Dirty and > >> Private_Shared? > > > > Private_Shared can be pretty confusing as well without the whole context > > as well see my other emails in the original thread (just to remind > > shmem/tmpfs makes all this really confusing). > > But this is exactly the issue -- RSS is can be just as confusing if > you don't know something about the application. I agree that rss can be confusing but we will not make the situation any better if we add yet another confusing metric. > I think the issue is > how common that situation is, and you seem to believe that it's so > uncommon that it's actually better to keep the information more > difficult to get for those of us who know something about our systems. > > That's fine, I guess we just have to disagree here, thanks for look at this. I think you should just step back and think more about what exactly you expect from the counter(s). I believe what you want is an estimate of a freeable memory when the particular process dies or is killed. That would mean resident single mapped private anonymous memory + unlinked single mapped shareable mappings + single mapped swapped out memory. Maybe I've missed something but it should be something along those lines. Definitely something that the current smaps infrastructure doesn't give you, though. -- Michal Hocko SUSE Labs
[toc] | [prev] | [next] | [standalone]
| From | Sonny Rao <sonnyrao@chromium.org> |
|---|---|
| Date | 2016-09-13 22:30 +0200 |
| Message-ID | <sh2v8-6Mr-3@gated-at.bofh.it> |
| In reply to | #1482196 |
On Tue, Sep 13, 2016 at 12:12 AM, Michal Hocko <mhocko@kernel.org> wrote: > On Mon 12-09-16 10:28:53, Sonny Rao wrote: >> On Mon, Sep 12, 2016 at 10:15 AM, Michal Hocko <mhocko@kernel.org> wrote: >> > On Mon 12-09-16 08:31:36, Sonny Rao wrote: > [...] >> >> but how about the other fields like Swap, Private_Dirty and >> >> Private_Shared? >> > >> > Private_Shared can be pretty confusing as well without the whole context >> > as well see my other emails in the original thread (just to remind >> > shmem/tmpfs makes all this really confusing). >> >> But this is exactly the issue -- RSS is can be just as confusing if >> you don't know something about the application. > > I agree that rss can be confusing but we will not make the situation any > better if we add yet another confusing metric. > >> I think the issue is >> how common that situation is, and you seem to believe that it's so >> uncommon that it's actually better to keep the information more >> difficult to get for those of us who know something about our systems. >> >> That's fine, I guess we just have to disagree here, thanks for look at this. > > I think you should just step back and think more about what exactly > you expect from the counter(s). I believe what you want is an > estimate of a freeable memory when the particular process dies or is > killed. That would mean resident single mapped private anonymous memory > + unlinked single mapped shareable mappings + single mapped swapped out > memory. Maybe I've missed something but it should be something along > those lines. Definitely something that the current smaps infrastructure > doesn't give you, though. Yes your description of what we want is pretty good. Having a reasonable lower bound on the estimate is fine, though we probably want to break out swapped out memory separately. Given that smaps doesn't provide this in a straightforward way, what do you think is the right way to provide this information? > -- > Michal Hocko > SUSE Labs
[toc] | [prev] | [next] | [standalone]
| From | Michal Hocko <mhocko@kernel.org> |
|---|---|
| Date | 2016-09-14 11:20 +0200 |
| Message-ID | <shewh-7tn-5@gated-at.bofh.it> |
| In reply to | #1482752 |
On Tue 13-09-16 13:27:39, Sonny Rao wrote: > On Tue, Sep 13, 2016 at 12:12 AM, Michal Hocko <mhocko@kernel.org> wrote: > > On Mon 12-09-16 10:28:53, Sonny Rao wrote: > >> On Mon, Sep 12, 2016 at 10:15 AM, Michal Hocko <mhocko@kernel.org> wrote: > >> > On Mon 12-09-16 08:31:36, Sonny Rao wrote: > > [...] > >> >> but how about the other fields like Swap, Private_Dirty and > >> >> Private_Shared? > >> > > >> > Private_Shared can be pretty confusing as well without the whole context > >> > as well see my other emails in the original thread (just to remind > >> > shmem/tmpfs makes all this really confusing). > >> > >> But this is exactly the issue -- RSS is can be just as confusing if > >> you don't know something about the application. > > > > I agree that rss can be confusing but we will not make the situation any > > better if we add yet another confusing metric. > > > >> I think the issue is > >> how common that situation is, and you seem to believe that it's so > >> uncommon that it's actually better to keep the information more > >> difficult to get for those of us who know something about our systems. > >> > >> That's fine, I guess we just have to disagree here, thanks for look at this. > > > > I think you should just step back and think more about what exactly > > you expect from the counter(s). I believe what you want is an > > estimate of a freeable memory when the particular process dies or is > > killed. That would mean resident single mapped private anonymous memory > > + unlinked single mapped shareable mappings + single mapped swapped out > > memory. Maybe I've missed something but it should be something along > > those lines. Definitely something that the current smaps infrastructure > > doesn't give you, though. > > Yes your description of what we want is pretty good. Having a > reasonable lower bound on the estimate is fine, though we probably > want to break out swapped out memory separately. Why would you want to separate that? > Given that smaps > doesn't provide this in a straightforward way, what do you think is > the right way to provide this information? I would be tempted to sneak it into /proc/<pid>/statm because that looks like a proper place but getting this information is not for free performance wise so I am not really sure something that relies on this file would see unexpected stalls. Maybe this could be worked around by some caching... I would suggest to check who is actually using this file (top/ps etc...) If this would be unacceptable then a new file could be considered. -- Michal Hocko SUSE Labs
[toc] | [prev] | [next] | [standalone]
| From | Robert Foss <robert.foss@collabora.com> |
|---|---|
| Date | 2016-09-19 17:20 +0200 |
| Message-ID | <sj8wq-74K-17@gated-at.bofh.it> |
| In reply to | #1483118 |
On 2016-09-14 05:12 AM, Michal Hocko wrote: > On Tue 13-09-16 13:27:39, Sonny Rao wrote: >> On Tue, Sep 13, 2016 at 12:12 AM, Michal Hocko <mhocko@kernel.org> wrote: >>> On Mon 12-09-16 10:28:53, Sonny Rao wrote: >>>> On Mon, Sep 12, 2016 at 10:15 AM, Michal Hocko <mhocko@kernel.org> wrote: >>>>> On Mon 12-09-16 08:31:36, Sonny Rao wrote: >>> [...] >>>>>> but how about the other fields like Swap, Private_Dirty and >>>>>> Private_Shared? >>>>> >>>>> Private_Shared can be pretty confusing as well without the whole context >>>>> as well see my other emails in the original thread (just to remind >>>>> shmem/tmpfs makes all this really confusing). >>>> >>>> But this is exactly the issue -- RSS is can be just as confusing if >>>> you don't know something about the application. >>> >>> I agree that rss can be confusing but we will not make the situation any >>> better if we add yet another confusing metric. >>> >>>> I think the issue is >>>> how common that situation is, and you seem to believe that it's so >>>> uncommon that it's actually better to keep the information more >>>> difficult to get for those of us who know something about our systems. >>>> >>>> That's fine, I guess we just have to disagree here, thanks for look at this. >>> >>> I think you should just step back and think more about what exactly >>> you expect from the counter(s). I believe what you want is an >>> estimate of a freeable memory when the particular process dies or is >>> killed. That would mean resident single mapped private anonymous memory >>> + unlinked single mapped shareable mappings + single mapped swapped out >>> memory. Maybe I've missed something but it should be something along >>> those lines. Definitely something that the current smaps infrastructure >>> doesn't give you, though. >> >> Yes your description of what we want is pretty good. Having a >> reasonable lower bound on the estimate is fine, though we probably >> want to break out swapped out memory separately. > > Why would you want to separate that? > >> Given that smaps >> doesn't provide this in a straightforward way, what do you think is >> the right way to provide this information? > > I would be tempted to sneak it into /proc/<pid>/statm because that looks > like a proper place but getting this information is not for free > performance wise so I am not really sure something that relies on this > file would see unexpected stalls. Maybe this could be worked around by > some caching... I would suggest to check who is actually using this file > (top/ps etc...) What would this caching look like? Can any information be re-used between vma walks? > > If this would be unacceptable then a new file could be considered. >
[toc] | [prev] | [next] | [standalone]
| From | Michal Hocko <mhocko@kernel.org> |
|---|---|
| Date | 2016-09-19 21:40 +0200 |
| Message-ID | <sjcA1-17g-7@gated-at.bofh.it> |
| In reply to | #1486586 |
On Mon 19-09-16 11:16:31, Robert Foss wrote: > On 2016-09-14 05:12 AM, Michal Hocko wrote: > > On Tue 13-09-16 13:27:39, Sonny Rao wrote: [...] > > > Given that smaps > > > doesn't provide this in a straightforward way, what do you think is > > > the right way to provide this information? > > > > I would be tempted to sneak it into /proc/<pid>/statm because that looks > > like a proper place but getting this information is not for free > > performance wise so I am not really sure something that relies on this > > file would see unexpected stalls. Maybe this could be worked around by > > some caching... I would suggest to check who is actually using this file > > (top/ps etc...) > > What would this caching look like? Can any information be re-used between > vma walks? yes basically return the same value if called within HZ or something similar. But that assumes that statm latency really matters and it is called often enough. -- Michal Hocko SUSE Labs
[toc] | [prev] | [next] | [standalone]
| From | Jann Horn <jann@thejh.net> |
|---|---|
| Date | 2016-09-19 22:00 +0200 |
| Message-ID | <sjcTp-1ej-53@gated-at.bofh.it> |
| In reply to | #1486795 |
[Multipart message — attachments visible in raw view] — view raw
On Mon, Sep 19, 2016 at 09:51:13PM +0200, Michal Hocko wrote: > [not sure why the CC list was trimmed - do no do that please unless you > have a strong reason for that - if this was not intentional please > restpre it] Ah, sorry, pressed the wrong key. > On Mon 19-09-16 21:40:01, Jann Horn wrote: > > On Mon, Sep 19, 2016 at 09:32:38PM +0200, Michal Hocko wrote: > > > On Mon 19-09-16 11:16:31, Robert Foss wrote: > > > > On 2016-09-14 05:12 AM, Michal Hocko wrote: > > > > > On Tue 13-09-16 13:27:39, Sonny Rao wrote: > > > [...] > > > > > > Given that smaps > > > > > > doesn't provide this in a straightforward way, what do you think is > > > > > > the right way to provide this information? > > > > > > > > > > I would be tempted to sneak it into /proc/<pid>/statm because that looks > > > > > like a proper place but getting this information is not for free > > > > > performance wise so I am not really sure something that relies on this > > > > > file would see unexpected stalls. Maybe this could be worked around by > > > > > some caching... I would suggest to check who is actually using this file > > > > > (top/ps etc...) > > > > > > > > What would this caching look like? Can any information be re-used between > > > > vma walks? > > > > > > yes basically return the same value if called within HZ or something > > > similar. But that assumes that statm latency really matters and it is > > > called often enough. > > > > That sounds horrible. If some application decides that they want to check > > statm directly after some action or so (like after program startup), this is > > going to give them a very bad time. That probably doesn't happen > > often - but still. > > > > I can already imagine some developer going "yeah, that usleep()... that's > > because the kernel API returns stale information for a couple milliseconds > > after we do something *shrug*". > > > > What are you trying to optimize for? Ten users on the same machine, each of > > which is running "top" because it looks so great? > > Please try to read what I wrote again. I didn't say this would be > needed. The idea was that _if_ /proc/<pid>/statm is used very _often_ > than some caching might help to reduce the overhead. Especially when you > consider that the information is not precise anyway. It can change > anytime while you are doing the address space walk.
[toc] | [prev] | [next] | [standalone]
| From | Sonny Rao <sonnyrao@chromium.org> |
|---|---|
| Date | 2016-09-19 22:20 +0200 |
| Message-ID | <sjdcK-1DF-15@gated-at.bofh.it> |
| In reply to | #1486822 |
On Mon, Sep 19, 2016 at 12:56 PM, Jann Horn <jann@thejh.net> wrote: > On Mon, Sep 19, 2016 at 09:51:13PM +0200, Michal Hocko wrote: >> [not sure why the CC list was trimmed - do no do that please unless you >> have a strong reason for that - if this was not intentional please >> restpre it] > > Ah, sorry, pressed the wrong key. > > >> On Mon 19-09-16 21:40:01, Jann Horn wrote: >> > On Mon, Sep 19, 2016 at 09:32:38PM +0200, Michal Hocko wrote: >> > > On Mon 19-09-16 11:16:31, Robert Foss wrote: >> > > > On 2016-09-14 05:12 AM, Michal Hocko wrote: >> > > > > On Tue 13-09-16 13:27:39, Sonny Rao wrote: >> > > [...] >> > > > > > Given that smaps >> > > > > > doesn't provide this in a straightforward way, what do you think is >> > > > > > the right way to provide this information? >> > > > > >> > > > > I would be tempted to sneak it into /proc/<pid>/statm because that looks >> > > > > like a proper place but getting this information is not for free >> > > > > performance wise so I am not really sure something that relies on this >> > > > > file would see unexpected stalls. Maybe this could be worked around by >> > > > > some caching... I would suggest to check who is actually using this file >> > > > > (top/ps etc...) >> > > > >> > > > What would this caching look like? Can any information be re-used between >> > > > vma walks? >> > > >> > > yes basically return the same value if called within HZ or something >> > > similar. But that assumes that statm latency really matters and it is >> > > called often enough. >> > >> > That sounds horrible. If some application decides that they want to check >> > statm directly after some action or so (like after program startup), this is >> > going to give them a very bad time. That probably doesn't happen >> > often - but still. >> > >> > I can already imagine some developer going "yeah, that usleep()... that's >> > because the kernel API returns stale information for a couple milliseconds >> > after we do something *shrug*". >> > >> > What are you trying to optimize for? Ten users on the same machine, each of >> > which is running "top" because it looks so great? >> >> Please try to read what I wrote again. I didn't say this would be >> needed. The idea was that _if_ /proc/<pid>/statm is used very _often_ >> than some caching might help to reduce the overhead. Especially when you >> consider that the information is not precise anyway. It can change >> anytime while you are doing the address space walk. Just thinking out loud here -- I haven't looked closely at the code so please bear with me :-) Instead of checking when the last read was and returning old data, what about a scheme where we still have a timestamp for last stat read on and any changes to that address space invalidate the timestamp. The invalidation could be racy because we're not too concerned about immediate accuracy -- so just a write. The main issue I could see which this is that it could cause the cacheline holding this timestamp to bounce around a lot? Maybe there's an existing solution in the page table locking that could be leveraged here to at least maintain whatever scalability enhancements are present for this type of situation where there are many updates happening in parallel.
[toc] | [prev] | [next] | [standalone]
| From | Robert Foss <robert.foss@collabora.com> |
|---|---|
| Date | 2016-09-20 02:30 +0200 |
| Message-ID | <sjh6F-4dN-5@gated-at.bofh.it> |
| In reply to | #1486795 |
On 2016-09-19 03:32 PM, Michal Hocko wrote: > On Mon 19-09-16 11:16:31, Robert Foss wrote: >> On 2016-09-14 05:12 AM, Michal Hocko wrote: >>> On Tue 13-09-16 13:27:39, Sonny Rao wrote: > [...] >>>> Given that smaps >>>> doesn't provide this in a straightforward way, what do you think is >>>> the right way to provide this information? >>> >>> I would be tempted to sneak it into /proc/<pid>/statm because that looks >>> like a proper place but getting this information is not for free >>> performance wise so I am not really sure something that relies on this >>> file would see unexpected stalls. Maybe this could be worked around by >>> some caching... I would suggest to check who is actually using this file >>> (top/ps etc...) >> >> What would this caching look like? Can any information be re-used between >> vma walks? > > yes basically return the same value if called within HZ or something > similar. But that assumes that statm latency really matters and it is > called often enough. Any single application querying more often than HZ, would presumably do so for accuracy reasons. However for multiple applications that combined query more often than HZ, this would most definitely be halpful in terms of performance. @Sonny, does chromiumos fall into the first or second category?
[toc] | [prev] | [next] | [standalone]
| From | Sonny Rao <sonnyrao@chromium.org> |
|---|---|
| Date | 2016-09-20 02:40 +0200 |
| Message-ID | <sjhgl-4gO-3@gated-at.bofh.it> |
| In reply to | #1486973 |
On Mon, Sep 19, 2016 at 5:27 PM, Robert Foss <robert.foss@collabora.com> wrote: > > > On 2016-09-19 03:32 PM, Michal Hocko wrote: >> >> On Mon 19-09-16 11:16:31, Robert Foss wrote: >>> >>> On 2016-09-14 05:12 AM, Michal Hocko wrote: >>>> >>>> On Tue 13-09-16 13:27:39, Sonny Rao wrote: >> >> [...] >>>>> >>>>> Given that smaps >>>>> doesn't provide this in a straightforward way, what do you think is >>>>> the right way to provide this information? >>>> >>>> >>>> I would be tempted to sneak it into /proc/<pid>/statm because that looks >>>> like a proper place but getting this information is not for free >>>> performance wise so I am not really sure something that relies on this >>>> file would see unexpected stalls. Maybe this could be worked around by >>>> some caching... I would suggest to check who is actually using this file >>>> (top/ps etc...) >>> >>> >>> What would this caching look like? Can any information be re-used between >>> vma walks? >> >> >> yes basically return the same value if called within HZ or something >> similar. But that assumes that statm latency really matters and it is >> called often enough. > > > Any single application querying more often than HZ, would presumably do so > for accuracy reasons. > However for multiple applications that combined query more often than HZ, > this would most definitely be halpful in terms of performance. > > @Sonny, does chromiumos fall into the first or second category? It's a single application -- and it definitely doesn't query at HZ -- especially given how long it takes to gather the data :-)
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web