Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp529030imm; Wed, 22 Aug 2018 08:15:11 -0700 (PDT) X-Google-Smtp-Source: AA+uWPywpevoQJTHmdhVXIXnG2tnC4aCCWKb1s1Lm8k1O3qlXK1nJfIyW890d+7gPqPnzc3esr1d X-Received: by 2002:a63:77ce:: with SMTP id s197-v6mr24497529pgc.172.1534950911644; Wed, 22 Aug 2018 08:15:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534950911; cv=none; d=google.com; s=arc-20160816; b=PsTBrSxz1/0VSIS7ddOYLtql2V/U1epIfJiEdHIGUSJeidmDQ+4qoteu/AIQYp/j2P RX50d+eGgARAi4m2pXfL69KGqGLr2J73y73uyXDUz/FTJJ2YYROxWdHTW2Hz64NFafoz h29dqFSFBQdkvhJZwWtCPnWcTOb3B8BxTd2p3I+mpDU797fLEGreT0uFwyiRAlBmYuCq lJ2V40pyrSme5c2tSTTVnBSj/HzF22ShLykuKG0+2Lm5B5XNXkX+PlxIr2f8WGWPAwjq Vl2JYT/T99b5Uy1R5ecjW04VtZ5SvBQBbn+nfnnp0/8hGO4dW3z7v9Fikfxw/uIlRuXX dEug== 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:arc-authentication-results; bh=9Z9ZfxIvUwL3fTrnXWg72P1xFzFw2cH2SiyagF+m3Ms=; b=s4gefpSOYCHJc+MkwmUnVg7AMOg8PaqnGaBJH/e99DJOHRY+/HyaegBhLLb1TGIF3a 3BuDX7vhkxkqepQScVOBn4hvEye9My37Z987gF6Qo/wwZGsZ6QnbDrby83OTpK76P8QJ EeKB2/uFgHRf3nRbBVl2AXdVWPHL6KJUPGQ65uBxzFNRjwzOXfSlAk82KpkA+lpJFnn2 yGK5xdg9OQ8BzcRDmx28k0b2HVJsx0NG29ybNfQGoshLdiwOkdxTHaLdnQSzG6c8wXub 0i/gw4f5hN2Gzu+Ix1eDS0WRvJ8smBwkbIMQROJWWTsOCgcSBg9OSY4abAr53E3m9nb6 /FHw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=cxLCjBAF; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d3-v6si1889075pgk.610.2018.08.22.08.14.55; Wed, 22 Aug 2018 08:15:11 -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=@gmail.com header.s=20161025 header.b=cxLCjBAF; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729306AbeHVSYE (ORCPT + 99 others); Wed, 22 Aug 2018 14:24:04 -0400 Received: from mail-yw1-f65.google.com ([209.85.161.65]:41684 "EHLO mail-yw1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729293AbeHVSYE (ORCPT ); Wed, 22 Aug 2018 14:24:04 -0400 Received: by mail-yw1-f65.google.com with SMTP id q129-v6so745911ywg.8; Wed, 22 Aug 2018 07:58:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=9Z9ZfxIvUwL3fTrnXWg72P1xFzFw2cH2SiyagF+m3Ms=; b=cxLCjBAFu7j/d2L0Tm6YIzL3cE2bztqZbmJR4SvwQ3gHVGDljOrSHO6Xni3bAUQVrM m4iub27LZ/QhR2ie5ktWFPELifPMo0GQ1G25G5Tbj3jRi8AkQU+KKGlYd/Q6u/rVeSgF G6fYjy3lHgw7Pey5/vTx3bUMTVqhlbwLSjn4pvbLveTgbwHdDT+2PxdIWk/DHwASAD9v svkpoMB6qxbrD60qRwLwcRmxjCmlfbXQ04JcDRMAamicEXm/yLwy5EqKhcglZDJCvtJg tYpYXxoHeXMbk61oVIRomfksz3nH5Bg6k9gD5pIl0a70VGr1AlUHGskCBRWX2lZbDmjh YfGQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to:user-agent; bh=9Z9ZfxIvUwL3fTrnXWg72P1xFzFw2cH2SiyagF+m3Ms=; b=QCh2XuOangzFhw++tZIGHus8UyFACK0/g2g7npfhQGoqCQ1NutW9MvgfBTtyn1Sono KDis0ZXGuAXiE/iqiSQYc+9NLF24TSL6E2m+/x87bO+qccbtF1BPiNCkypxqer8T0/fc U7cykCLhORQqAdtqI83zh83qrNq2rUj6aI/8TxLURasoRFnHK74N5i8IUljdr9JrYKgo Gn5/m2bvbdvpknRoADvzJ1psE5qMJq7MCAtKPCncTO9NuG1Z7wjkNCxBTyX0rrXBxSKP XSqke/NsKJXPKwJEqcftWG9ORjsu0yuTSm8+q1EG8dbHH8maxumsnGqlNvz/7GQs3v0U 0wsw== X-Gm-Message-State: APzg51DdSTJ3ugCsYFUu8NXogkUVDHLCDzJDQQ26Euy7WMxVaApq8iQF t4A5DkdUILRoXUOOWJOj67g= X-Received: by 2002:a81:6e07:: with SMTP id j7-v6mr174848ywc.495.1534949929896; Wed, 22 Aug 2018 07:58:49 -0700 (PDT) Received: from localhost ([2620:10d:c091:200::1dc9]) by smtp.gmail.com with ESMTPSA id 203-v6sm808027ywv.34.2018.08.22.07.58.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 22 Aug 2018 07:58:48 -0700 (PDT) Date: Wed, 22 Aug 2018 07:58:46 -0700 From: Tejun Heo To: Konstantin Khlebnikov Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, cgroups@vger.kernel.org, Michal Hocko , Vladimir Davydov , Roman Gushchin , Johannes Weiner Subject: Re: [PATCH RFC 2/3] proc/kpagecgroup: report also inode numbers of offline cgroups Message-ID: <20180822145846.GT3978217@devbig004.ftw2.facebook.com> References: <153414348591.737150.14229960913953276515.stgit@buzz> <153414348994.737150.10057219558779418929.stgit@buzz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <153414348994.737150.10057219558779418929.stgit@buzz> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello, On Mon, Aug 13, 2018 at 09:58:10AM +0300, Konstantin Khlebnikov wrote: > diff --git a/mm/memcontrol.c b/mm/memcontrol.c > index 19a4348974a4..7ef6ea9d5e4a 100644 > --- a/mm/memcontrol.c > +++ b/mm/memcontrol.c > @@ -333,6 +333,7 @@ struct cgroup_subsys_state *mem_cgroup_css_from_page(struct page *page) > /** > * page_cgroup_ino - return inode number of the memcg a page is charged to > * @page: the page > + * @online: return closest online ancestor > * > * Look up the closest online ancestor of the memory cgroup @page is charged to > * and return its inode number or 0 if @page is not charged to any cgroup. It > @@ -343,14 +344,14 @@ struct cgroup_subsys_state *mem_cgroup_css_from_page(struct page *page) > * after page_cgroup_ino() returns, so it only should be used by callers that > * do not care (such as procfs interfaces). > */ > -ino_t page_cgroup_ino(struct page *page) > +ino_t page_cgroup_ino(struct page *page, bool online) > { > struct mem_cgroup *memcg; > unsigned long ino = 0; > > rcu_read_lock(); > memcg = READ_ONCE(page->mem_cgroup); > - while (memcg && !(memcg->css.flags & CSS_ONLINE)) > + while (memcg && online && !(memcg->css.flags & CSS_ONLINE)) > memcg = parent_mem_cgroup(memcg); > if (memcg) > ino = cgroup_ino(memcg->css.cgroup); We pin the ino till the cgroup is actually released now but that's an implementation detail which may change in the future, so I'm not sure this is a good idea. Can you instead use the 64bit filehandle exposed by kernfs? That's currently also based on ino (+gen) but it's something guarnateed to stay unique per cgroup and you can easily get to the cgroup using the fh too. Thanks. -- tejun