Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp207722pxb; Mon, 2 Nov 2020 19:09:19 -0800 (PST) X-Google-Smtp-Source: ABdhPJzxl71TnMv/yGjW2GTVZceuhqQGxdpc34uPyP4Fj9lT/rpnsyRJMzNh2MNTFN870aYKgOXg X-Received: by 2002:aa7:da0a:: with SMTP id r10mr4665030eds.102.1604372959422; Mon, 02 Nov 2020 19:09:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604372959; cv=none; d=google.com; s=arc-20160816; b=IBtAhqOwvvqKwYs2oh5oHBDCccKVmG/27RCocU7akscwv5zpLxbnZMwVa8yNhB/mQ4 mhNVRblTaGZoJy7VoFuzZV67V0xmgyvVXmrRm0zVkhLqzMvj9NPoVADyiKeeqKSlJl0I Bx53GnYKegBar4UuzKFuV3vP9No9shQGXW5abp7WxqbOTNi/TivLi5hH8uVlMTM75asI ODxPkwJas0qgpfdn6ZpbsP4+dl1afQLQG7oRPOrM4Lfomb110RR4yjEZDrbiVGjmzGHY VOOjbZxSMCVmGBgmUa79vZ9Xrfrppe7Wb+w1HCQOQ2oVPbvlNkHoingipuMuGhXg7VOR gksg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to :mime-version:user-agent:date:message-id:from:references:cc:to :subject; bh=FyiIWJES8mjPchcfRTwrbsgct3KLQDnuzuvfyj50YuI=; b=ymXjYMBfZBSCUsovbNPXrtdeVdG9iqHBeI8OQd/FiWVa9tnS5hB9UDg4YnCC6dm+ya qqL3pvDfM4iYMdQqEPfULL/f+R902riy/PWjdsU9pav1MaU+Rki5PpRcFzSx0uv6FVWz Hhjgj6WK8fBqzDyUZEgRc3qol+bIaOEHc+UAocW1ZCYBw1zDu7of8nGxmcuAAzUrItfW 75U0KSJvTILZY8gjnstgbKUSWApNIAWcGLvdhWxxPu4qdvr+4dkLXH1d5ttYZLJQr5Kr 52QaErCfI/emCrYsc0Yms1jLXj2DP8/325EQWho/mv2THIpsw3sF5V6l0n51Ux1e0JBw Rqpw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id n24si3983570ejb.608.2020.11.02.19.08.55; Mon, 02 Nov 2020 19:09:19 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1725997AbgKCDEz (ORCPT + 99 others); Mon, 2 Nov 2020 22:04:55 -0500 Received: from out30-45.freemail.mail.aliyun.com ([115.124.30.45]:54223 "EHLO out30-45.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725913AbgKCDEz (ORCPT ); Mon, 2 Nov 2020 22:04:55 -0500 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R201e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e04357;MF=alex.shi@linux.alibaba.com;NM=1;PH=DS;RN=22;SR=0;TI=SMTPD_---0UE2aS-g_1604372689; Received: from IT-FVFX43SYHV2H.local(mailfrom:alex.shi@linux.alibaba.com fp:SMTPD_---0UE2aS-g_1604372689) by smtp.aliyun-inc.com(127.0.0.1); Tue, 03 Nov 2020 11:04:49 +0800 Subject: Re: [PATCH v20 15/20] mm/lru: introduce TestClearPageLRU To: Johannes Weiner Cc: akpm@linux-foundation.org, mgorman@techsingularity.net, tj@kernel.org, hughd@google.com, khlebnikov@yandex-team.ru, daniel.m.jordan@oracle.com, willy@infradead.org, lkp@intel.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, cgroups@vger.kernel.org, shakeelb@google.com, iamjoonsoo.kim@lge.com, richard.weiyang@gmail.com, kirill@shutemov.name, alexander.duyck@gmail.com, rong.a.chen@intel.com, mhocko@suse.com, vdavydov.dev@gmail.com, shy828301@gmail.com, Michal Hocko References: <1603968305-8026-1-git-send-email-alex.shi@linux.alibaba.com> <1603968305-8026-16-git-send-email-alex.shi@linux.alibaba.com> <20201102151008.GH724984@cmpxchg.org> From: Alex Shi Message-ID: Date: Tue, 3 Nov 2020 11:02:15 +0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:68.0) Gecko/20100101 Thunderbird/68.12.0 MIME-Version: 1.0 In-Reply-To: <20201102151008.GH724984@cmpxchg.org> Content-Type: text/plain; charset=gbk Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org ?? 2020/11/2 ????11:10, Johannes Weiner ะด??: > On Thu, Oct 29, 2020 at 06:45:00PM +0800, Alex Shi wrote: >> Currently lru_lock still guards both lru list and page's lru bit, that's >> ok. but if we want to use specific lruvec lock on the page, we need to >> pin down the page's lruvec/memcg during locking. Just taking lruvec >> lock first may be undermined by the page's memcg charge/migration. To >> fix this problem, we could clear the lru bit out of locking and use >> it as pin down action to block the page isolation in memcg changing. > > Small nit, but the use of "could" in this sentence sounds like you're > describing one possible solution that isn't being taken, when in fact > you are describing the chosen locking mechanism. > > Replacing "could" with "will" would make things a bit clearer IMO. > Yes, 'will' is better here. Thanks! >> So now a standard steps of page isolation is following: >> 1, get_page(); #pin the page avoid to be free >> 2, TestClearPageLRU(); #block other isolation like memcg change >> 3, spin_lock on lru_lock; #serialize lru list access >> 4, delete page from lru list; >> The step 2 could be optimzed/replaced in scenarios which page is >> unlikely be accessed or be moved between memcgs. > > This is a bit ominous. I'd either elaborate / provide an example / > clarify why some sites can deal with races - or just remove that > sentence altogether from this part of the changelog. > A few scenarios here, so examples looks verbose or cann't describe whole. Maybe removing above 2 lines "The step 2 could be optimzed/replaced in scenarios which page is unlikely be accessed or be moved between memcgs." is better. Thanks! >> This patch start with the first part: TestClearPageLRU, which combines >> PageLRU check and ClearPageLRU into a macro func TestClearPageLRU. This >> function will be used as page isolation precondition to prevent other >> isolations some where else. Then there are may !PageLRU page on lru >> list, need to remove BUG() checking accordingly. >> >> There 2 rules for lru bit now: >> 1, the lru bit still indicate if a page on lru list, just in some >> temporary moment(isolating), the page may have no lru bit when >> it's on lru list. but the page still must be on lru list when the >> lru bit set. >> 2, have to remove lru bit before delete it from lru list. >> >> As Andrew Morton mentioned this change would dirty cacheline for page >> isn't on LRU. But the lost would be acceptable in Rong Chen >> report: >> https://lore.kernel.org/lkml/20200304090301.GB5972@shao2-debian/ >> >> Suggested-by: Johannes Weiner >> Signed-off-by: Alex Shi >> Acked-by: Hugh Dickins >> Cc: Hugh Dickins >> Cc: Johannes Weiner >> Cc: Michal Hocko >> Cc: Vladimir Davydov >> Cc: Andrew Morton >> Cc: linux-kernel@vger.kernel.org >> Cc: cgroups@vger.kernel.org >> Cc: linux-mm@kvack.org > > Acked-by: Johannes Weiner > Thanks! Alex