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 DE07AC47409 for ; Fri, 17 Jan 2020 09:42:23 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id ABCDD2082F for ; Fri, 17 Jan 2020 09:42:23 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org ABCDD2082F Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=virtuozzo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 5254E6B0346; Fri, 17 Jan 2020 04:42:23 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 4D5A26B0347; Fri, 17 Jan 2020 04:42:23 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3ECEE6B0348; Fri, 17 Jan 2020 04:42:23 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0009.hostedemail.com [216.40.44.9]) by kanga.kvack.org (Postfix) with ESMTP id 284186B0346 for ; Fri, 17 Jan 2020 04:42:23 -0500 (EST) Received: from smtpin23.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with SMTP id E553A8248076 for ; Fri, 17 Jan 2020 09:42:22 +0000 (UTC) X-FDA: 76386635724.23.sock97_14b80476daf05 X-HE-Tag: sock97_14b80476daf05 X-Filterd-Recvd-Size: 3278 Received: from relay.sw.ru (relay.sw.ru [185.231.240.75]) by imf38.hostedemail.com (Postfix) with ESMTP for ; Fri, 17 Jan 2020 09:42:22 +0000 (UTC) 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 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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?