Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754089AbbKWJhL (ORCPT ); Mon, 23 Nov 2015 04:37:11 -0500 Received: from mx2.parallels.com ([199.115.105.18]:47931 "EHLO mx2.parallels.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753903AbbKWJhI (ORCPT ); Mon, 23 Nov 2015 04:37:08 -0500 Date: Mon, 23 Nov 2015 12:36:46 +0300 From: Vladimir Davydov To: Johannes Weiner CC: David Miller , Andrew Morton , Tejun Heo , Michal Hocko , , , , , Subject: Re: [PATCH 09/14] net: tcp_memcontrol: simplify linkage between socket and page counter Message-ID: <20151123093646.GA29014@esperanza> References: <1447371693-25143-1-git-send-email-hannes@cmpxchg.org> <1447371693-25143-10-git-send-email-hannes@cmpxchg.org> <20151120124216.GD31308@esperanza> <20151120185648.GC5623@cmpxchg.org> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <20151120185648.GC5623@cmpxchg.org> X-ClientProxiedBy: US-EXCH2.sw.swsoft.com (10.255.249.46) To US-EXCH2.sw.swsoft.com (10.255.249.46) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3784 Lines: 73 On Fri, Nov 20, 2015 at 01:56:48PM -0500, Johannes Weiner wrote: > On Fri, Nov 20, 2015 at 03:42:16PM +0300, Vladimir Davydov wrote: > > On Thu, Nov 12, 2015 at 06:41:28PM -0500, Johannes Weiner wrote: > > > There won't be any separate counters for socket memory consumed by > > > protocols other than TCP in the future. Remove the indirection and > > > > I really want to believe you're right. And with vmpressure propagation > > implemented properly you are likely to be right. > > > > However, we might still want to account other socket protos to > > memcg->memory in the unified hierarchy, e.g. UDP, or SCTP, or whatever > > else. Adding new consumers should be trivial, but it will break the > > legacy usecase, where only TCP sockets are supposed to be accounted. > > What about adding a check to sock_update_memcg() so that it would enable > > accounting only for TCP sockets in case legacy hierarchy is used? > > Yup, I was thinking the same thing. But we can cross that bridge when > we come to it and are actually adding further packet types. Fair enough. > > > For the same reason, I think we'd better rename memcg->tcp_mem to > > something like memcg->sk_mem or we can even drop the cg_proto struct > > altogether embedding its fields directly to mem_cgroup struct. > > > > Also, I don't see any reason to have tcp_memcontrol.c file. It's tiny > > and with this patch it does not depend on tcp code any more. Let's move > > it to memcontrol.c? > > I actually had all this at first, but then wondered if it makes more > sense to keep the legacy code in isolation. Don't you think it would > be easier to keep track of what's v1 and what's v2 if we keep the > legacy stuff physically separate as much as possible? In particular I > found that 'tcp_mem.' marker really useful while working on the code. > > In the same vein, tcp_memcontrol.c doesn't really hurt anybody and I'd > expect it to remain mostly unopened and unchanged in the future. But > if we merge it into memcontrol.c, that code will likely be in the way > and we'd have to make it explicit somehow that this is not actually > part of the new memory controller anymore. > > What do you think? There isn't much code left in tcp_memcontrol.c, and not all of it is legacy. We still want to call tcp_init_cgroup and tcp_destroy_cgroup from memcontrol.c - in fact, it's the only call site, so I think we'd better keep these functions there. Apart from init/destroy, there is only stuff for handling legacy files, which is relatively small and isolated. We can just put it along with memsw and kmem legacy files in the end of memcontrol.c adding a comment that it's legacy. Personally, I'd find the code easier to follow then, because currently the logic behind the ACTIVE flag as well as memcg->tcp_mem init/use/destroy turns out to be scattered between two files in different subsystems for no apparent reason now, as it does not need tcp_prot any more. Besides, this would allow us to accurately reuse the ACTIVE flag in init/destroy for inc/dec static branch and probably in sock_update_memcg instead of sprinkling cgroup_subsys_on_dfl all over the place, which would make the code a bit cleaner IMO (in fact, that's why I proposed to drop ACTIVATED bit and replace cg_proto->flags with ->active bool). Regarding, tcp_mem marker, well, currently it's OK, because we don't account anything but TCP sockets, but when it changes (and I'm pretty sure it will), we'll have to rename it anyway. For now, I'm OK with leaving it as is though. Thanks, Vladimir -- 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/