From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934543Ab1JEMLg (ORCPT ); Wed, 5 Oct 2011 08:11:36 -0400 Received: from mx2.parallels.com ([64.131.90.16]:45385 "EHLO mx2.parallels.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934503Ab1JEMLf (ORCPT ); Wed, 5 Oct 2011 08:11:35 -0400 Message-ID: <4E8C494F.8020804@parallels.com> Date: Wed, 5 Oct 2011 16:10:55 +0400 From: Glauber Costa User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:6.0.2) Gecko/20110906 Thunderbird/6.0.2 MIME-Version: 1.0 To: Peter Zijlstra CC: , , , , Subject: Re: [PATCH 04/10] Display /proc/stat information per cgroup References: <1317583287-18300-1-git-send-email-glommer@parallels.com> <1317583287-18300-5-git-send-email-glommer@parallels.com> <1317804965.6766.2.camel@twins> In-Reply-To: <1317804965.6766.2.camel@twins> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 10/05/2011 12:56 PM, Peter Zijlstra wrote: > On Sun, 2011-10-02 at 23:21 +0400, Glauber Costa wrote: >> +struct kernel_stat *task_group_kstat(struct task_struct *p) >> +{ >> + struct task_group *tg; >> + struct kernel_stat *kstat; >> + >> + rcu_read_lock(); >> + tg = task_group(p); >> + kstat = tg->cpustat; >> + rcu_read_unlock(); >> + return kstat; >> +} > > Who keeps tg alive and kicking while you poke at its (cpustat) member? * All calls to this function currently pass current as a parameter (Okay, maybe it is too generic and we should pass nothing at all, and grab current within it) * rcu_read_lock() guarantees that current will exist during this call, and task_group won't change. (right?)