Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757631AbbEVX2t (ORCPT ); Fri, 22 May 2015 19:28:49 -0400 Received: from gum.cmpxchg.org ([85.214.110.215]:49529 "EHLO gum.cmpxchg.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756983AbbEVX2q (ORCPT ); Fri, 22 May 2015 19:28:46 -0400 Date: Fri, 22 May 2015 19:28:31 -0400 From: Johannes Weiner To: Tejun Heo Cc: axboe@kernel.dk, linux-kernel@vger.kernel.org, jack@suse.cz, hch@infradead.org, linux-fsdevel@vger.kernel.org, vgoyal@redhat.com, lizefan@huawei.com, cgroups@vger.kernel.org, linux-mm@kvack.org, mhocko@suse.cz, clm@fb.com, fengguang.wu@intel.com, david@fromorbit.com, gthelen@google.com, khlebnikov@yandex-team.ru Subject: Re: [PATCH 11/51] memcg: implement mem_cgroup_css_from_page() Message-ID: <20150522232831.GB6485@cmpxchg.org> References: <1432329245-5844-1-git-send-email-tj@kernel.org> <1432329245-5844-12-git-send-email-tj@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1432329245-5844-12-git-send-email-tj@kernel.org> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1039 Lines: 26 On Fri, May 22, 2015 at 05:13:25PM -0400, Tejun Heo wrote: > +/** > + * mem_cgroup_css_from_page - css of the memcg associated with a page > + * @page: page of interest > + * > + * This function is guaranteed to return a valid cgroup_subsys_state and > + * the returned css remains accessible until @page is released. > + */ > +struct cgroup_subsys_state *mem_cgroup_css_from_page(struct page *page) > +{ > + if (page->mem_cgroup) > + return &page->mem_cgroup->css; > + return &root_mem_cgroup->css; > +} replace_page_cache() can clear page->mem_cgroup even when the page still has references, so unfortunately you must hold the page lock when calling this function. I haven't checked how you use this - chances are you always have the page locked anyways - but it probably needs a comment. -- 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/