Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp8828162ybl; Fri, 17 Jan 2020 01:43:32 -0800 (PST) X-Google-Smtp-Source: APXvYqzuniaYPV1koNgK8t0JYRtVEmiulU5agwVFY7e/rpZ3vH/jkpX6+uBosPyLz4qZ29h4Q/In X-Received: by 2002:aca:1b08:: with SMTP id b8mr2841741oib.62.1579254212817; Fri, 17 Jan 2020 01:43:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579254212; cv=none; d=google.com; s=arc-20160816; b=tE12WWtkAH9daYztgUsE6kr6DnWnqhLDCFoDzHVWwXqHW0ze2sHWTvUUpG2O6k46Rp 18+UeWW0LNOl7pQgI7E7UaqRvkdA6MDIcM/nBTbECWTr5GQqMZdG6fF2y7AkvXKJImWJ lNF+jST5Wz5QbR0XGQi5YtdmtTBXmHdefRJiKt10Du73P7MbxnayUOBXM/j68eMh/UtN VWrQlMknaNf7ZenuDY36A18zwZ8JCL19YrhC3XIoBWSCJ0grkve32w2YGJON0g+8ckEJ WjtYhPj50rbA+7OVChK5bZY0u3KXTIObbuB8A7hmk4rz8hAmwg5du2tBDRVwuNgHUwP8 9uQA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=1AkgE9WcyU2oM0FsTsz06uu4RiPkyJr2f8qfJLOpjao=; b=Do0QzaSsoqcM6ayOVSpQ472v/dMjrtw0vkW15WE/fiQNenplNackNUAUkFdpxXLdF/ Hz1f5obHtahMC7O68Vdl2yv8oeQukyLNQI53GRU95pmGFF0XZ9h5D2YQrwVVqZcTGue3 HfwbxuGvxWwKIbbuJnAh0BG347IlblpjvPbjss3n6Mxq5gpqFLfYNqp3Ftpx1wCn9hQ0 wU+Mp68OU4R564M0YOKwpHbURe80KsUrlEmXorgo3gHQWZO9xrWDVRtB4f04f3kzKgu1 L6vLufMqCRCczQI0FwT+eY68s8ueJOs1lC6cbN3cshEpvgXPNwffo0V3dm9q08QnuSlT 0Sig== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=virtuozzo.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 185si12960805oie.52.2020.01.17.01.43.20; Fri, 17 Jan 2020 01:43:32 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=virtuozzo.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729030AbgAQJmX (ORCPT + 99 others); Fri, 17 Jan 2020 04:42:23 -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?