From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.3 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 65376C33CB1 for ; Fri, 17 Jan 2020 09:42:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 44D2920730 for ; Fri, 17 Jan 2020 09:42:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729052AbgAQJmY (ORCPT ); Fri, 17 Jan 2020 04:42:24 -0500 Received: from relay.sw.ru ([185.231.240.75]:50194 "EHLO relay.sw.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726785AbgAQJmW (ORCPT ); Fri, 17 Jan 2020 04:42:22 -0500 Received: from dhcp-172-16-24-104.sw.ru ([172.16.24.104]) by relay.sw.ru with esmtp (Exim 4.92.3) (envelope-from ) id 1isO8k-0005zq-5i; Fri, 17 Jan 2020 12:42:06 +0300 Subject: Re: [Patch v3] mm: thp: grab the lock before manipulation defer list To: David Rientjes Cc: Michal Hocko , Wei Yang , hannes@cmpxchg.org, vdavydov.dev@gmail.com, akpm@linux-foundation.org, kirill.shutemov@linux.intel.com, yang.shi@linux.alibaba.com, cgroups@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, alexander.duyck@gmail.com, stable@vger.kernel.org References: <20200116013100.7679-1-richardw.yang@linux.intel.com> <0bb34c4a-97c7-0b3c-cf43-8af6cf9c4396@virtuozzo.com> <20200117091002.GM19428@dhcp22.suse.cz> From: Kirill Tkhai Message-ID: <11ba0af7-c2b2-83f9-ac55-7793cedb8028@virtuozzo.com> Date: Fri, 17 Jan 2020 12:42:05 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.4.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 17.01.2020 12:32, David Rientjes wrote: > On Fri, 17 Jan 2020, Kirill Tkhai wrote: > >>>> I think that's a good point, especially considering that the current code >>>> appears to unconditionally place any compound page on the deferred split >>>> queue of the destination memcg. The correct list that it should appear >>>> on, I believe, depends on whether the pmd has been split for the process >>>> being moved: note the MC_TARGET_PAGE caveat in >>>> mem_cgroup_move_charge_pte_range() that does not move the charge for >>>> compound pages with split pmds. So when mem_cgroup_move_account() is >>>> called with compound == true, we're moving the charge of the entire >>>> compound page: why would it appear on that memcg's deferred split queue? >>> >>> I believe Kirill asked how do we know that the page should be actually >>> added to the deferred list just from the list_empty check. In other >>> words what if the page hasn't been split at all? >> >> Yes, I'm talking about this. Function mem_cgroup_move_account() adds every >> huge page to the deferred list, while we need to do that only for pages, >> which are queued for splitting... >> > > Yup, and that appears broken before Wei's patch. Since we only migrate > charges of entire compound pages (we have a mapping pmd, the underlying > page cannot be split), it should not appear on the deferred split queue > for any memcg, right? Hm. Can't a huge page be mapped in two tasks: 1)the first task unmapped a part of page and initiated splitting, 2)the second task still refers the whole page, then we move account for the second task?