Received: by 2002:a25:86ce:0:0:0:0:0 with SMTP id y14csp2139631ybm; Thu, 23 May 2019 12:02:01 -0700 (PDT) X-Google-Smtp-Source: APXvYqxRmelkkRFqVaz2WDLOerAh3ygsNpY0caAzKUWmf2ft0Fpibu46K/ds9d3vIa5OiPmaN0rF X-Received: by 2002:a63:eb0d:: with SMTP id t13mr2282086pgh.37.1558638121898; Thu, 23 May 2019 12:02:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558638121; cv=none; d=google.com; s=arc-20160816; b=p5vHjCj31CB4ge/qPZNoXnT2V3bQyPiTBuHQT9T9IPAAMJ+JfByk7llCEtTzzVD0Jl DkfV3J7CqRN0gWZEHtnu3wqHzc212FdTXRlw4uFPq1B5ZymvcNy+eUwTQ4OyECE65Ojb CnZgo3pdaVUv646NEjteBz1jOXR68u+pwa97D+WrgQXeat+IxOe9vmMBgoLsC9DyW6DJ m7y93HKIDp4kcFro1utHB43fpCCi85r7EJ7BIS+s/4ETAMS7CpaANXFNx/LAcD6f1coF +peAvtUM3aS7FWEgXvWgscQmGGo2CMX32/0uX3QgycularI8wH94gqFz4g/greYd6UFq 8kvw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=/CV1FhBU6ocaD5fOePWATFvyxYduYyIfBpfvSQwN/B8=; b=nw7xV6xXTn9YXNGyNGaShTDvIUuWwB9o9M3jx7O2JIsY//CvkQGJggMeJ4aRkKwrVt eMFt4lSrZxhoPTZkKjxQNUcbYQss9Sf16PfQE0K6X3n735Zs5Xgc/yXWWssbROWAJrR7 UPgHrvm5X2DnRCtRLJkIvKsHvmR0P1AxgH8Hap8fCHeHGuX2fTGgS3c5OmbVBuqG+Eic VZPaPG5eV70HbxP7rg8wDdd58ramIhj4NXOBE3amBMUixulo3gjsBcxHtllHAndzPucf sx4dPQedZwiOVODkMR+wxnfTOW/qOs/QjYdoL3QH6/tlkONVRoywwPD4aQMXCP08sg74 40+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=Miz1U9o2; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v19si441612plo.413.2019.05.23.12.01.44; Thu, 23 May 2019 12:02:01 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=Miz1U9o2; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731556AbfEWTAf (ORCPT + 99 others); Thu, 23 May 2019 15:00:35 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:59642 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731261AbfEWTAf (ORCPT ); Thu, 23 May 2019 15:00:35 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=/CV1FhBU6ocaD5fOePWATFvyxYduYyIfBpfvSQwN/B8=; b=Miz1U9o2wXcym4Jtn1wzy+VUn 4BJDF2kiponhBBRN/KFC/M/0I/Qr5ov6lMO9Mf5Zm7DnA/drcPmOna2euyKCsqRj/bZL9uIvcPKhY xRqkO46Ak525MvJjJSV98ayqh2zv2tkbQvjt+Oz8ptIzGb2UICnoz/YNjZPrKZFdhOqkwlo9hz5Ag V7bHvynIZUjN91dxR3oaRTqX6JHTfWbptGKyB5J28TfrS/yCOgTXrBmitaAhzM+KrELPYl1vC+100 i4YZjccf377zAwdOuTpxCZufHXIPfo9aPCLr53mVS5BW7O7U0YOVAu4c0RyKUDxyyRjrF3347VNLB ImPknIcRg==; Received: from willy by bombadil.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1hTsx7-0004yj-2H; Thu, 23 May 2019 19:00:33 +0000 Date: Thu, 23 May 2019 12:00:32 -0700 From: Matthew Wilcox To: Shakeel Butt Cc: Johannes Weiner , Andrew Morton , Linux MM , linux-fsdevel , LKML , Kernel Team Subject: Re: xarray breaks thrashing detection and cgroup isolation Message-ID: <20190523190032.GA7873@bombadil.infradead.org> References: <20190523174349.GA10939@cmpxchg.org> <20190523183713.GA14517@bombadil.infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.2 (2017-12-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, May 23, 2019 at 11:49:41AM -0700, Shakeel Butt wrote: > On Thu, May 23, 2019 at 11:37 AM Matthew Wilcox wrote: > > > > On Thu, May 23, 2019 at 01:43:49PM -0400, Johannes Weiner wrote: > > > I noticed that recent upstream kernels don't account the xarray nodes > > > of the page cache to the allocating cgroup, like we used to do for the > > > radix tree nodes. > > > > > > This results in broken isolation for cgrouped apps, allowing them to > > > escape their containment and harm other cgroups and the system with an > > > excessive build-up of nonresident information. > > > > > > It also breaks thrashing/refault detection because the page cache > > > lives in a different domain than the xarray nodes, and so the shadow > > > shrinker can reclaim nonresident information way too early when there > > > isn't much cache in the root cgroup. > > > > > > I'm not quite sure how to fix this, since the xarray code doesn't seem > > > to have per-tree gfp flags anymore like the radix tree did. We cannot > > > add SLAB_ACCOUNT to the radix_tree_node_cachep slab cache. And the > > > xarray api doesn't seem to really support gfp flags, either (xas_nomem > > > does, but the optimistic internal allocations have fixed gfp flags). > > > > Would it be a problem to always add __GFP_ACCOUNT to the fixed flags? > > I don't really understand cgroups. > > Does xarray cache allocated nodes, something like radix tree's: > > static DEFINE_PER_CPU(struct radix_tree_preload, radix_tree_preloads) = { 0, }; > > For the cached one, no __GFP_ACCOUNT flag. No. That was the point of the XArray conversion; no cached nodes. > Also some users of xarray may not want __GFP_ACCOUNT. That's the > reason we had __GFP_ACCOUNT for page cache instead of hard coding it > in radix tree. This is what I don't understand -- why would someone not want __GFP_ACCOUNT? For a shared resource? But the page cache is a shared resource. So what is a good example of a time when an allocation should _not_ be accounted to the cgroup?