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.2 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY,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 1507BC432C0 for ; Thu, 21 Nov 2019 13:03:49 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 95C372089D for ; Thu, 21 Nov 2019 13:03:48 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 95C372089D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.alibaba.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 4624A6B031F; Thu, 21 Nov 2019 08:03:48 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 414116B0320; Thu, 21 Nov 2019 08:03:48 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 351A76B0321; Thu, 21 Nov 2019 08:03:48 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0239.hostedemail.com [216.40.44.239]) by kanga.kvack.org (Postfix) with ESMTP id 1DDD36B031F for ; Thu, 21 Nov 2019 08:03:48 -0500 (EST) Received: from smtpin24.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with SMTP id D30F0181AEF21 for ; Thu, 21 Nov 2019 13:03:47 +0000 (UTC) X-FDA: 76180301694.24.sugar16_3dfc29560c91a X-HE-Tag: sugar16_3dfc29560c91a X-Filterd-Recvd-Size: 2994 Received: from out30-44.freemail.mail.aliyun.com (out30-44.freemail.mail.aliyun.com [115.124.30.44]) by imf45.hostedemail.com (Postfix) with ESMTP for ; Thu, 21 Nov 2019 13:03:45 +0000 (UTC) X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R211e4;CH=green;DM=||false|;DS=|;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e07487;MF=alex.shi@linux.alibaba.com;NM=1;PH=DS;RN=10;SR=0;TI=SMTPD_---0Tij7W01_1574341419; Received: from IT-FVFX43SYHV2H.local(mailfrom:alex.shi@linux.alibaba.com fp:SMTPD_---0Tij7W01_1574341419) by smtp.aliyun-inc.com(127.0.0.1); Thu, 21 Nov 2019 21:03:39 +0800 Subject: Re: [PATCH] mm: fix unsafe page -> lruvec lookups with cgroup charge migration To: Hugh Dickins , Johannes Weiner Cc: Andrew Morton , Shakeel Butt , Michal Hocko , Roman Gushchin , linux-mm@kvack.org, cgroups@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-team@fb.com References: <20191120165847.423540-1-hannes@cmpxchg.org> From: Alex Shi Message-ID: <14b15e52-9fff-5497-d30c-2c7c4b99c35a@linux.alibaba.com> Date: Thu, 21 Nov 2019 21:03:36 +0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:60.0) Gecko/20100101 Thunderbird/60.9.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=gbk Content-Transfer-Encoding: 7bit X-Bogosity: Ham, tests=bogofilter, spamicity=0.000203, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: > It like the way you've rearranged isolate_lru_page() there, but I > don't think it amounts to more than a cleanup. Very good thinking > about the odd "lruvec->pgdat = pgdat" case tucked away inside > mem_cgroup_page_lruvec(), but actually, what harm does it do, if > mem_cgroup_move_account() changes page->mem_cgroup concurrently? Maybe the page could be added to root_mem_cgroup? > > You say use-after-free, but we have spin_lock_irq here, and the > struct mem_cgroup (and its lruvecs) cannot be freed until an RCU > grace period expires, which we rely upon in many places, and which > cannot happen until after the spin_unlock_irq. > > And the same applies in the pagevec_lru_move functions, doesn't it? > > I think now is not the time for such cleanups. If this fits well > with Alex's per-lruvec locking (or represents an initial direction > that you think he should follow), fine, but better to let him take it > into his patchset in that case, than change the base unnecessarily > underneath him. > > (It happens to go against my own direction, since it separates the > locking from the determination of lruvec, which I insist must be > kept together; but perhaps that won't be quite the same for Alex.) > It looks like we share the same base. Before this patch, root memcg's lruvc lock could guards !PageLRU and it followings, But now, there are much holes in the wall. :) Thanks Alex