Re: Query on per app memory cgroup

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 2/20/2017 5:59 PM, Bob Liu wrote:
> On Mon, Feb 20, 2017 at 1:22 PM, Vinayak Menon <vinmenon@xxxxxxxxxxxxxx> wrote:
>>
>> On 2/17/2017 6:47 PM, Bob Liu wrote:
>>> On Thu, Feb 9, 2017 at 7:16 PM, Vinayak Menon <vinmenon@xxxxxxxxxxxxxx> wrote:
>>>> Hi,
>>>>
>>>> We were trying to implement the per app memory cgroup that Johannes
>>>> suggested (https://lkml.org/lkml/2014/12/19/358) and later discussed during
>>>> Minchan's proposal of per process reclaim
>>>> (https://lkml.org/lkml/2016/6/13/570). The test was done on Android target
>>>> with 2GB of RAM and cgroupv1. The first test done was to just create per
>>>> app cgroups without modifying any cgroup controls. 2 kinds of tests were
>>>> done which gives similar kind of observation. One was to just open
>>>> applications in sequence and repeat this N times (20 apps, so around 20
>>>> memcgs max at a time). Another test was to create around 20 cgroups and
>>>> perform a make (not kernel, another less heavy source) in each of them.
>>>>
>>>> It is observed that because of the creation of memcgs per app, the per
>>>> memcg LRU size is so low and results in kswapd priority drop. This results
>>> How did you confirm that? Traced the get_scan_count() function?
>>> You may hack this function for more verification.
>> This was confirmed by adding some VM event counters in get_scan_count.
> Would you mind attach your modification?
> That would be helpful for people to make fix patches.

Sure. The entire set of debug changes is quite big with stuff not relevant for this issue.
Adding here only the relevant part related to priority drop. Let me know if this is not useful,
I can clean up the debug path and share it.
Note that the test is done on 4.4 kernel.
To get the number of pages chosen by get_scan_count for each LRU vm event was added
like this. Showing only a part of it.

+       if (current_is_kswapd()) {
+               switch (sc->priority) {
+                       case 0:
+                       count_vm_events(SCAN_ACTIVE_ANON0, nr[LRU_ACTIVE_ANON]);
+                       count_vm_events(SCAN_INACTIVE_ANON0, nr[LRU_INACTIVE_ANON]);
+                       count_vm_events(SCAN_ACTIVE_FILE0, nr[LRU_ACTIVE_FILE]);
+                       count_vm_events(SCAN_INACTIVE_FILE0, nr[LRU_INACTIVE_FILE]);
+                       break;
+                       case 1:
....

Similarly just after the shrink_list in shrink_lruvec

+     if ((lru == LRU_INACTIVE_ANON) && current_is_kswapd()) {
+     	count_vm_events(RECLAIM_INACTIVE_ANON, ret);
...

The results from above counters show the scanned and reclaimed at each priority and with
the per app memcg it can be seen that the scanned and reclaimed are less at lower priorities
(because of small LRU) and suddenly increases at higher priorities (because of scanning most
of the LRUs of all the memcgs).

A check like this was added in get_scan_count to get a comparative data on times we hit !scan
case.

+                       if (!scan && pass && force_scan) {
+                               count_vm_event(GSC_6);
                                scan = min(size, SWAP_CLUSTER_MAX);
+                       }
+
+                       if (!scan) {
+                               if (lru == 0)
+                                       count_vm_event(GSC_7_0);
+                               else if (lru == 1)
+                                       count_vm_event(GSC_7_1);
+                               else if (lru == 2)
+                                       count_vm_event(GSC_7_2);
+                               else if (lru == 3)
+                                       count_vm_event(GSC_7_3);
+                       }

And to get the actual scanned and reclaimed pages at each priority, events were added in shrink_zone
after the shrink_lruvec call

+if (current_is_kswapd()) {
+       switch (sc->priority) {
+               case 0:
+                       count_vm_events(KSWAPD_S_AT_0, sc->nr_scanned - nr_scanned);
+                       count_vm_events(KSWAPD_R_AT_0, sc->nr_reclaimed - nr_reclaimed);
+                       break;
+               case 1:
+                       count_vm_events(KSWAPD_S_AT_1, sc->nr_scanned - nr_scanned);
+                       count_vm_events(KSWAPD_R_AT_1, sc->nr_reclaimed - nr_reclaimed);
+                       break;
...

The below count was added to find the number of times kswapd_shrink_zone had run at different priorities.
+       switch (sc->priority) {
+               case 0:
+                       count_vm_event(KSWAPD_AT_0);
+                       break;
+               case 1:
...

Thanks,
Vinayak

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



[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]
  Powered by Linux