Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp4530451ybz; Tue, 21 Apr 2020 02:15:03 -0700 (PDT) X-Google-Smtp-Source: APiQypLMM13XjZwj6hkN4pG4fpverJxq4E4o7dl8Zz/gspgCU5Z6UfPZiUa6JsVgzJVy2EGhjJr9 X-Received: by 2002:a17:906:7f0c:: with SMTP id d12mr19867699ejr.40.1587460503296; Tue, 21 Apr 2020 02:15:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587460503; cv=none; d=google.com; s=arc-20160816; b=LYxlDDc/u8aoPWfm852u0d6pFXf/xmTbngR5Qhlz4h5iBjqSycHGVW1uo7WAVKufL6 AaZJF1EYQoSz5Tw3+3Ou53f9iCzMI3M6EyHXiKi9rbF+cEbCAyBleyeWkE12wVgeBkCg HiTdjn4BFYhDz59j52/BC2LKETRTh2PYH784LVNyz1GzxiphtnjrAFQXgrO41hi/gVvV mD1Brnzff6YE7Yn0gyMAOaQLsgKVpiwk9IwMWiSVx5a29YcFoNiPRnMo6WTWrjji+ujn 1fmAq87lkQ0pH6p7G8exOpbV69icq73hX/3pvRyQPAIWpCyon/2WbrnszBpaizbXAbfs 1WXw== 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:in-reply-to :mime-version:user-agent:date:message-id:from:references:cc:to :subject; bh=dCqrlyneSuY85QFMLHlVERddpeaHHQqiNOo94OCSgP0=; b=XUL5CbR5Wv36ncHLn6uXzPfV0raG3VcYggYyxBxPcuygHqfCxKzHXJVMpeQCrZdWjF rM8DsdIRAZ2ndLPp3p32G+aQwwdaXBMLl4+2WYi9mSkCBoMlAkCXePTSEgqOAIcVTC62 LTDmOl9FuOgIRxW1Us9Q6t/azUfEMTgjxs727mEsmBp1dseK8kEkNQjkloTDnSDj54Zq Od1C85uRGrJVmSM0UNGQK3ZEsSIPmRZRPL0HVsC6VCN2ks6s85dEF6lUq+ebs2xyhCz7 glyfFH+SI+Trp4jx3wxo6VNEAetywLFz525ppMnS3gUiKP1xo7kWHnrp15QCM0FtvglK eDzQ== 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 ov7si1201272ejb.489.2020.04.21.02.14.40; Tue, 21 Apr 2020 02:15:03 -0700 (PDT) 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 S1728414AbgDUJNX (ORCPT + 99 others); Tue, 21 Apr 2020 05:13:23 -0400 Received: from out30-54.freemail.mail.aliyun.com ([115.124.30.54]:52067 "EHLO out30-54.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726018AbgDUJNX (ORCPT ); Tue, 21 Apr 2020 05:13:23 -0400 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R161e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e01419;MF=alex.shi@linux.alibaba.com;NM=1;PH=DS;RN=11;SR=0;TI=SMTPD_---0TwDfDaE_1587460397; Received: from IT-FVFX43SYHV2H.local(mailfrom:alex.shi@linux.alibaba.com fp:SMTPD_---0TwDfDaE_1587460397) by smtp.aliyun-inc.com(127.0.0.1); Tue, 21 Apr 2020 17:13:18 +0800 Subject: Re: [PATCH 05/18] mm: memcontrol: convert page cache to a new mem_cgroup_charge() API To: Johannes Weiner , Joonsoo Kim Cc: Shakeel Butt , Hugh Dickins , Michal Hocko , "Kirill A. Shutemov" , Roman Gushchin , linux-mm@kvack.org, cgroups@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-team@fb.com References: <20200420221126.341272-1-hannes@cmpxchg.org> <20200420221126.341272-6-hannes@cmpxchg.org> From: Alex Shi Message-ID: Date: Tue, 21 Apr 2020 17:12:11 +0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:68.0) Gecko/20100101 Thunderbird/68.6.0 MIME-Version: 1.0 In-Reply-To: <20200420221126.341272-6-hannes@cmpxchg.org> Content-Type: text/plain; charset=gbk Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org ?? 2020/4/21 ????6:11, Johannes Weiner ะด??: > The try/commit/cancel protocol that memcg uses dates back to when > pages used to be uncharged upon removal from the page cache, and thus > couldn't be committed before the insertion had succeeded. Nowadays, > pages are uncharged when they are physically freed; it doesn't matter > whether the insertion was successful or not. For the page cache, the > transaction dance has become unnecessary. > > Introduce a mem_cgroup_charge() function that simply charges a newly > allocated page to a cgroup and sets up page->mem_cgroup in one single > step. If the insertion fails, the caller doesn't have to do anything > but free/put the page. > > Then switch the page cache over to this new API. > > Subsequent patches will also convert anon pages, but it needs a bit > more prep work. Right now, memcg depends on page->mapping being > already set up at the time of charging, so that it can maintain its > own MEMCG_CACHE and MEMCG_RSS counters. For anon, page->mapping is set > under the same pte lock under which the page is publishd, so a single > charge point that can block doesn't work there just yet. > > The following prep patches will replace the private memcg counters > with the generic vmstat counters, thus removing the page->mapping > dependency, then complete the transition to the new single-point > charge API and delete the old transactional scheme. > > Signed-off-by: Johannes Weiner > --- Reviewed-by: Alex Shi