Received: by 2002:a17:90a:8582:0:0:0:0 with SMTP id m2csp2333160pjn; Tue, 2 Apr 2019 14:34:02 -0700 (PDT) X-Google-Smtp-Source: APXvYqwYIkT+TO2YJPIMBL/I5u7yjzvWIctlczToQLnNz/rQ+PDI3GrpRWzpthdOqDGW1kCHlnBX X-Received: by 2002:a65:6645:: with SMTP id z5mr70128574pgv.251.1554240842488; Tue, 02 Apr 2019 14:34:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554240842; cv=none; d=google.com; s=arc-20160816; b=lQ58Wq83D+KRme2cBGp4q540Kt6Qp2eCOTjxpg4neiPsOPOAkH0/OGc8USRDPg++3S jnWuxIslgSLzsXtDxczRUqLgifeXkO2nCJav5bfQWqyyJyHwKJcT7+0FxB7zqQAbWNV6 ITI4a8tS4EYZbblEWqpOgzv25sptOAudGR7WhENSwQYSUgWXTgrHUCV1PkBOJf55bTXm MZsU5l3K5vzeWrzb+lr+GJiadQ63DMYlsdXyN6+eCiThHQS4K0qG9NP/Ui9NQ9iDusoz qAreIr1ypLQJaxmN6YbvUR5nu6LbgOcpp2V2e5FvL8Ik3gAYYhap4XSetYFBZxzB8Czm X2uw== 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:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date; bh=r1TqTzAnofVWov8Ckjl4rpwMXRjJzcR/zbtqSMMZ1V0=; b=Q6FNBovfvnhlkiu/vZVoRVUmqg+3jN4nMFuGrmbGzIACM6A7aIw0dirwZJpihL7iq9 bZ+C/C1oxVBBlh+Ad3QoRuMkA3cKaNWDkdMBtWTnQiv36zfx5g4jZwCUKXCn84Sfag1E dxhwquS1ia82unqApUDwusr3KbqV9yS9n2QxyAJMqeGSD7k/gFGt6lqbcC3uTtskOVFy LByrQkhhLr7QF5kXM5xeZtkIDML3GQwezOZWVTt0XS2T4Zma3WOJuspRL+DgQXppK6JC +G9os61NPnJaYvPn0YncuurZobUyD5O3RMYxarJQH8Mcz4fUdYL7Tl1eyA4ZOoDOeA7e mx+g== ARC-Authentication-Results: i=1; mx.google.com; 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 t17si10811884pgv.493.2019.04.02.14.33.46; Tue, 02 Apr 2019 14:34:02 -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; 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 S1726580AbfDBVcd (ORCPT + 99 others); Tue, 2 Apr 2019 17:32:33 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:47992 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725956AbfDBVcd (ORCPT ); Tue, 2 Apr 2019 17:32:33 -0400 Received: from akpm3.svl.corp.google.com (unknown [104.133.8.65]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id E45E3D88; Tue, 2 Apr 2019 21:32:31 +0000 (UTC) Date: Tue, 2 Apr 2019 14:32:30 -0700 From: Andrew Morton To: Johannes Weiner Cc: Greg Thelen , Roman Gushchin , Michal Hocko , Vladimir Davydov , Tejun Heo , linux-mm@kvack.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: Re: [PATCH v2] writeback: use exact memcg dirty counts Message-Id: <20190402143230.3ea53a7d599b2d78c39b77b0@linux-foundation.org> In-Reply-To: <20190401182044.GA3694@cmpxchg.org> References: <20190329174609.164344-1-gthelen@google.com> <20190401182044.GA3694@cmpxchg.org> X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.31; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 1 Apr 2019 14:20:44 -0400 Johannes Weiner wrote: > On Fri, Mar 29, 2019 at 10:46:09AM -0700, Greg Thelen wrote: > > @@ -3907,10 +3923,10 @@ void mem_cgroup_wb_stats(struct bdi_writeback *wb, unsigned long *pfilepages, > > struct mem_cgroup *memcg = mem_cgroup_from_css(wb->memcg_css); > > struct mem_cgroup *parent; > > > > - *pdirty = memcg_page_state(memcg, NR_FILE_DIRTY); > > + *pdirty = memcg_exact_page_state(memcg, NR_FILE_DIRTY); > > > > /* this should eventually include NR_UNSTABLE_NFS */ > > - *pwriteback = memcg_page_state(memcg, NR_WRITEBACK); > > + *pwriteback = memcg_exact_page_state(memcg, NR_WRITEBACK); > > *pfilepages = mem_cgroup_nr_lru_pages(memcg, (1 << LRU_INACTIVE_FILE) | > > (1 << LRU_ACTIVE_FILE)); > > Andrew, > > just a head-up: -mm has that LRU stat cleanup series queued ("mm: > memcontrol: clean up the LRU counts tracking") that changes the > mem_cgroup_nr_lru_pages() call here to two memcg_page_state(). > > I'm assuming Greg's fix here will get merged before the cleanup. When > it gets picked up, it'll conflict with "mm: memcontrol: push down > mem_cgroup_nr_lru_pages()". > > "mm: memcontrol: push down mem_cgroup_nr_lru_pages()" will need to be > changed to use memcg_exact_page_state() calls instead of the plain > memcg_page_state() for *pfilepages. > Thanks. Like this? void mem_cgroup_wb_stats(struct bdi_writeback *wb, unsigned long *pfilepages, unsigned long *pheadroom, unsigned long *pdirty, unsigned long *pwriteback) { struct mem_cgroup *memcg = mem_cgroup_from_css(wb->memcg_css); struct mem_cgroup *parent; *pdirty = memcg_exact_page_state(memcg, NR_FILE_DIRTY); /* this should eventually include NR_UNSTABLE_NFS */ *pwriteback = memcg_exact_page_state(memcg, NR_WRITEBACK); *pfilepages = memcg_exact_page_state(memcg, NR_INACTIVE_FILE) + memcg_exact_page_state(memcg, NR_ACTIVE_FILE); *pheadroom = PAGE_COUNTER_MAX; while ((parent = parent_mem_cgroup(memcg))) { unsigned long ceiling = min(memcg->memory.max, memcg->high); unsigned long used = page_counter_read(&memcg->memory); *pheadroom = min(*pheadroom, ceiling - min(ceiling, used)); memcg = parent; } }