Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp182391ybl; Fri, 17 Jan 2020 21:32:12 -0800 (PST) X-Google-Smtp-Source: APXvYqwRdIQRtYlyPJwXx+gxjxkIXpP8k5T5AbmTLXEqhhFjPmd+tU1fnLET/Io9GP1rX0Rt2QtK X-Received: by 2002:a05:6830:1515:: with SMTP id k21mr8353067otp.177.1579325531911; Fri, 17 Jan 2020 21:32:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579325531; cv=none; d=google.com; s=arc-20160816; b=e5xrYhwR1Pw5Z0SvBnt0ldKd9a9R25FiSK+nhUzUq9WO7TnrVmZcXWpg4rmZtUi/cm hd0KxEKEtpXrsx8vgck16x92v7rnWRx0Z45XO/dLeug0faqBTdnNRjiNahFHZa20ZpgM SQ81wjKNAluUlqQJ6W85iVL/rGur2g/SH32Ae2jhvu185u1UvpuAIvLor+NsIBQOz5D0 ppO9Tg58Pu7NG1cxzZLbkKdI1Ymsgo4OO6r+MaSE2betgx3QxXtAQAj7fflEYb8DW2Y5 v39GEr+vEChIVwu6wy+DHunwAJB3NoOQHNWyRW+9kekApRBKZ5dwDjb8qtLZ2AN3EcHo 20ow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:references:cc:to:from:subject; bh=rX4yaFb9Ol8i7liNyobjWUz+II/9swOyAzc3mPxfahs=; b=ExBuTmEMIuqA1wde13uDwPUQ7E8OnxkV+EALPh8bZGb2O/juQMnJRHBOVZ8mlAs8e6 uNl1A7yQ6o8HdAS3cmqRIeIuq8Cc5hb1T91qpCZB6fZksPG1ACj3dCJP85XgI0ByegqV zOFKiDsh0Ypaf0dAM7RvRtR4IXew0ihMcJghQI3GzcHbGU96T+eU7UadspqODfEDSoOt 08AAkJgFOX24MC6iUHn0mDEEBT4IUuFvDu/iQQ2yI1t5qMYWnAABnHaCi0Jro02BTwdT w5YpaKxSz/TGD2ZFdZyzIHUGAGtvkG+2qBzfk++M2ryJiF+KvA6ybNTggU+iw8W9bIWN +OMQ== 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=alibaba.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t16si16785096otp.257.2020.01.17.21.31.59; Fri, 17 Jan 2020 21:32:11 -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=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726060AbgARFbF (ORCPT + 99 others); Sat, 18 Jan 2020 00:31:05 -0500 Received: from out30-45.freemail.mail.aliyun.com ([115.124.30.45]:60911 "EHLO out30-45.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725385AbgARFbF (ORCPT ); Sat, 18 Jan 2020 00:31:05 -0500 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R131e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e04407;MF=yang.shi@linux.alibaba.com;NM=1;PH=DS;RN=13;SR=0;TI=SMTPD_---0To.f-S7_1579325449; Received: from US-143344MP.local(mailfrom:yang.shi@linux.alibaba.com fp:SMTPD_---0To.f-S7_1579325449) by smtp.aliyun-inc.com(127.0.0.1); Sat, 18 Jan 2020 13:31:00 +0800 Subject: Re: [Patch v4] mm: thp: remove the defer list related code since this will not happen From: Yang Shi To: Wei Yang , hannes@cmpxchg.org, mhocko@kernel.org, vdavydov.dev@gmail.com, akpm@linux-foundation.org, ktkhai@virtuozzo.com, kirill.shutemov@linux.intel.com Cc: cgroups@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, alexander.duyck@gmail.com, rientjes@google.com, stable@vger.kernel.org References: <20200117233836.3434-1-richardw.yang@linux.intel.com> Message-ID: <25e1226a-9cce-6a75-f0e9-b42f5afa22da@linux.alibaba.com> Date: Fri, 17 Jan 2020 21:30:45 -0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 1/17/20 4:57 PM, Yang Shi wrote: > > > On 1/17/20 3:38 PM, Wei Yang wrote: >> If compound is true, this means it is a PMD mapped THP. Which implies >> the page is not linked to any defer list. So the first code chunk will >> not be executed. >> >> Also with this reason, it would not be proper to add this page to a >> defer list. So the second code chunk is not correct. >> >> Based on this, we should remove the defer list related code. >> >> Fixes: 87eaceb3faa5 ("mm: thp: make deferred split shrinker memcg >> aware") >> >> Signed-off-by: Wei Yang >> Suggested-by: Kirill A. Shutemov >> Cc:     [5.4+] >> >> --- >> v4: >>    * finally we identified the related code is not necessary and not >>      correct, just remove it >>    * thanks to Kirill T first spot some problem > > Thanks for debugging and figuring this out. Acked-by: Yang Shi > BTW, the patch itself is fine, but the subject looks really confusing. It sounds like we would remove all deferred list code. I'd suggest rephrase it to: mm: thp: don't need care deferred split queue in memcg charge move path > >> v3: >>    * remove all review/ack tag since rewrite the changelog >>    * use deferred_split_huge_page as the example of race >>    * add cc stable 5.4+ tag as suggested by David Rientjes >> >> v2: >>    * move check on compound outside suggested by Alexander >>    * an example of the race condition, suggested by Michal >> --- >>   mm/memcontrol.c | 18 ------------------ >>   1 file changed, 18 deletions(-) >> >> diff --git a/mm/memcontrol.c b/mm/memcontrol.c >> index 6c83cf4ed970..27c231bf4565 100644 >> --- a/mm/memcontrol.c >> +++ b/mm/memcontrol.c >> @@ -5340,14 +5340,6 @@ static int mem_cgroup_move_account(struct page >> *page, >>           __mod_lruvec_state(to_vec, NR_WRITEBACK, nr_pages); >>       } >>   -#ifdef CONFIG_TRANSPARENT_HUGEPAGE >> -    if (compound && !list_empty(page_deferred_list(page))) { >> - spin_lock(&from->deferred_split_queue.split_queue_lock); >> -        list_del_init(page_deferred_list(page)); >> -        from->deferred_split_queue.split_queue_len--; >> - spin_unlock(&from->deferred_split_queue.split_queue_lock); >> -    } >> -#endif >>       /* >>        * It is safe to change page->mem_cgroup here because the page >>        * is referenced, charged, and isolated - we can't race with >> @@ -5357,16 +5349,6 @@ static int mem_cgroup_move_account(struct page >> *page, >>       /* caller should have done css_get */ >>       page->mem_cgroup = to; >>   -#ifdef CONFIG_TRANSPARENT_HUGEPAGE >> -    if (compound && list_empty(page_deferred_list(page))) { >> - spin_lock(&to->deferred_split_queue.split_queue_lock); >> -        list_add_tail(page_deferred_list(page), >> - &to->deferred_split_queue.split_queue); >> -        to->deferred_split_queue.split_queue_len++; >> - spin_unlock(&to->deferred_split_queue.split_queue_lock); >> -    } >> -#endif >> - >>       spin_unlock_irqrestore(&from->move_lock, flags); >>         ret = 0; >