Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp4539753ybz; Tue, 21 Apr 2020 02:26:20 -0700 (PDT) X-Google-Smtp-Source: APiQypJutVwxcNhFgMOSeGqWH6pm0vUxUfLHUcjkn1v1iroEQT/vn2dLfoG/ATUZwN46dJ7mcYOn X-Received: by 2002:a17:906:400a:: with SMTP id v10mr19440944ejj.300.1587461180802; Tue, 21 Apr 2020 02:26:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587461180; cv=none; d=google.com; s=arc-20160816; b=LrgouvBZaxWHyj4EpYqFfbT0RTDQd4w7sf9S6YAnXCzwgcnUkA7sON5LhmYDYBLIPk 6BNjtwic9945UtnUwb4YbSIeFstkeqUjmFEvfiRlymtk60akxNDaAYGnD2UpdOkWSw56 D0v+2xRz/+wK7iKN8MwKODksQPdW4ZaJJ6q4zpnVO9npw40eaQiXNzRqmgZ0ksw9nO8W HziMzVbECMe7unv2SjTjEiauj3EmKHqwgdRwzlXUQOGZbn7ZzZf3yRVJqwtOYDS8cxru wkD464xFUuabdBFuYIJF5MidVNuhMBzL35mq97FAi6sgNG/tAqCmYivJGDqHMvRtLN+M qNNA== 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=MJTsCWupT8w6roYl3qJ8zvAfWMm6gh/To0UFwRw38Pw=; b=p4R8Wb4uu6KoQP9sXAlS6BsTkgIpKH84WJyaYBhHCr6FEJSozI2sgfHYv9T9RDc8yT aEszrVF5FFjOJLK4Sky4uQEpdBGBEmTZO+cxI5w1q57/BWykVH4pBfEGMtc1dDG66qZv xNMq/xk1sDuby7zezshzbhe0DUIurp20IYTat9CvNDc0XE/rutGt305iXImHJu7WI+kz TFDETvN5HsSZqGA/Jbkoo90yppD49RRWyn1qgx61/rWcy/lNlo0mo+1QE4QBFistWr/E Ng6B2QKTvuylyfXbb3PfgR13TUUti8bX0LMJydD8mLIYWWhd70Chnd6pD0vokn3bY5nK y/jg== 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 mj2si1135058ejb.279.2020.04.21.02.25.56; Tue, 21 Apr 2020 02:26:20 -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 S1727911AbgDUJWh (ORCPT + 99 others); Tue, 21 Apr 2020 05:22:37 -0400 Received: from out30-131.freemail.mail.aliyun.com ([115.124.30.131]:47543 "EHLO out30-131.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725920AbgDUJWg (ORCPT ); Tue, 21 Apr 2020 05:22:36 -0400 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R461e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01f04397;MF=alex.shi@linux.alibaba.com;NM=1;PH=DS;RN=11;SR=0;TI=SMTPD_---0TwDn81a_1587460953; Received: from IT-FVFX43SYHV2H.local(mailfrom:alex.shi@linux.alibaba.com fp:SMTPD_---0TwDn81a_1587460953) by smtp.aliyun-inc.com(127.0.0.1); Tue, 21 Apr 2020 17:22:34 +0800 Subject: Re: [PATCH 16/18] mm: memcontrol: charge swapin pages on instantiation 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-17-hannes@cmpxchg.org> From: Alex Shi Message-ID: <6f03ed4e-f917-2ccc-26c0-c438c84d3d97@linux.alibaba.com> Date: Tue, 21 Apr 2020 17:21:26 +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-17-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 ะด??: > Right now, users that are otherwise memory controlled can easily > escape their containment and allocate significant amounts of memory > that they're not being charged for. That's because swap readahead > pages are not being charged until somebody actually faults them into > their page table. This can be exploited with MADV_WILLNEED, which > triggers arbitrary readahead allocations without charging the pages. > > There are additional problems with the delayed charging of swap pages: > > 1. To implement refault/workingset detection for anonymous pages, we > need to have a target LRU available at swapin time, but the LRU is > not determinable until the page has been charged. > > 2. To implement per-cgroup LRU locking, we need page->mem_cgroup to be > stable when the page is isolated from the LRU; otherwise, the locks > change under us. But swapcache gets charged after it's already on > the LRU, and even if we cannot isolate it ourselves (since charging > is not exactly optional). > > The previous patch ensured we always maintain cgroup ownership records > for swap pages. This patch moves the swapcache charging point from the > fault handler to swapin time to fix all of the above problems. > > Signed-off-by: Johannes Weiner Reviewed-by: Alex Shi