Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755956AbbBFXne (ORCPT ); Fri, 6 Feb 2015 18:43:34 -0500 Received: from mail-vc0-f172.google.com ([209.85.220.172]:52059 "EHLO mail-vc0-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752687AbbBFXnc (ORCPT ); Fri, 6 Feb 2015 18:43:32 -0500 MIME-Version: 1.0 In-Reply-To: <20150206141746.GB10580@htj.dyndns.org> References: <20150130160722.GA26111@htj.dyndns.org> <54CFCF74.6090400@yandex-team.ru> <20150202194608.GA8169@htj.dyndns.org> <20150204170656.GA18858@htj.dyndns.org> <20150205131514.GD25736@htj.dyndns.org> <20150205222522.GA10580@htj.dyndns.org> <20150206141746.GB10580@htj.dyndns.org> From: Greg Thelen Date: Fri, 6 Feb 2015 15:43:11 -0800 Message-ID: Subject: Re: [RFC] Making memcg track ownership per address_space or anon_vma To: Tejun Heo Cc: Konstantin Khlebnikov , Johannes Weiner , Michal Hocko , Cgroups , "linux-mm@kvack.org" , "linux-kernel@vger.kernel.org" , Jan Kara , Dave Chinner , Jens Axboe , Christoph Hellwig , Li Zefan , Hugh Dickins Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3370 Lines: 68 On Fri, Feb 6, 2015 at 6:17 AM, Tejun Heo wrote: > Hello, Greg. > > On Thu, Feb 05, 2015 at 04:03:34PM -0800, Greg Thelen wrote: >> So this is a system which charges all cgroups using a shared inode >> (recharge on read) for all resident pages of that shared inode. There's >> only one copy of the page in memory on just one LRU, but the page may be >> charged to multiple container's (shared_)usage. > > Yeap. > >> Perhaps I missed it, but what happens when a child's limit is >> insufficient to accept all pages shared by its siblings? Example >> starting with 2M cached of a shared file: >> >> A >> +-B (usage=2M lim=3M hosted_usage=2M) >> +-C (usage=0 lim=2M shared_usage=2M) >> +-D (usage=0 lim=2M shared_usage=2M) >> \-E (usage=0 lim=1M shared_usage=0) >> >> If E faults in a new 4K page within the shared file, then E is a sharing >> participant so it'd be charged the 2M+4K, which pushes E over it's >> limit. > > OOM? It shouldn't be participating in sharing of an inode if it can't > match others' protection on the inode, I think. What we're doing now > w/ page based charging is kinda unfair because in the situations like > above the one under pressure can end up siphoning off of the larger > cgroups' protection if they actually use overlapping areas; however, > for disjoint areas, per-page charging would behave correctly. > > So, this part comes down to the same question - whether multiple > cgroups accessing disjoint areas of a single inode is an important > enough use case. If we say yes to that, we better make writeback > support that too. If cgroups are about isolation then writing to shared files should be rare, so I'm willing to say that we don't need to handle shared writers well. Shared readers seem like a more valuable use cases (thin provisioning). I'm getting overwhelmed with the thought exercise of automatically moving inodes to common ancestors and back charging the sharers for shared_usage. I haven't wrapped my head around how these shared data pages will get protected. It seems like they'd no longer be protected by child min watermarks. So I know this thread opened with the claim "both memcg and blkcg must be looking at the same picture. Deviating them is highly likely to lead to long-term issues forcing us to look at this again anyway, only with far more baggage." But I'm still wondering if the following is simpler: (1) leave memcg as a per page controller. (2) maintain a per inode i_memcg which is set to the common dirtying ancestor. If not shared then it'll point to the memcg that the page was charged to. (3) when memcg dirtying page pressure is seen, walk up the cgroup tree writing dirty inodes, this will write shared inodes using blkcg priority of the respective levels. (4) background limit wb_check_background_flush() and time based wb_check_old_data_flush() can feel free to attack shared inodes to hopefully restore them to non-shared state. For non-shared inodes, this should behave the same. For shared inodes it should only affect those in the hierarchy which is sharing. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/