From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932774AbcIMXNI (ORCPT ); Tue, 13 Sep 2016 19:13:08 -0400 Received: from mga14.intel.com ([192.55.52.115]:8756 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932286AbcIMXNF (ORCPT ); Tue, 13 Sep 2016 19:13:05 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.30,330,1470726000"; d="scan'208";a="1049874972" Subject: Re: [PATCH v2 26/33] Task fork and exit for rdtgroup To: Fenghua Yu , Thomas Gleixner , "H. Peter Anvin" , Ingo Molnar , Tony Luck , Peter Zijlstra , Tejun Heo , Borislav Petkov , Stephane Eranian , Marcelo Tosatti , David Carrillo-Cisneros , Shaohua Li , Ravi V Shankar , Vikas Shivappa , Sai Prakhya References: <1473328647-33116-1-git-send-email-fenghua.yu@intel.com> <1473328647-33116-27-git-send-email-fenghua.yu@intel.com> Cc: linux-kernel , x86 From: Dave Hansen Message-ID: <57D88800.1090302@intel.com> Date: Tue, 13 Sep 2016 16:13:04 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.8.0 MIME-Version: 1.0 In-Reply-To: <1473328647-33116-27-git-send-email-fenghua.yu@intel.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 09/08/2016 02:57 AM, Fenghua Yu wrote: > +void rdtgroup_fork(struct task_struct *child) > +{ > + struct rdtgroup *rdtgrp; > + > + INIT_LIST_HEAD(&child->rg_list); > + if (!rdtgroup_mounted) > + return; > + > + mutex_lock(&rdtgroup_mutex); > + > + rdtgrp = current->rdtgroup; > + if (!rdtgrp) > + goto out; > + > + list_add_tail(&child->rg_list, &rdtgrp->pset.tasks); > + child->rdtgroup = rdtgrp; > + atomic_inc(&rdtgrp->refcount); > + > +out: > + mutex_unlock(&rdtgroup_mutex); > +} ... > diff --git a/kernel/fork.c b/kernel/fork.c > index beb3172..79bfc99 100644 > --- a/kernel/fork.c > +++ b/kernel/fork.c > @@ -76,6 +76,7 @@ > #include > #include > #include > +#include > > #include > #include > @@ -1426,6 +1427,7 @@ static struct task_struct *copy_process(unsigned long clone_flags, > p->io_context = NULL; > p->audit_context = NULL; > cgroup_fork(p); > + rdtgroup_fork(p); > #ifdef CONFIG_NUMA > p->mempolicy = mpol_dup(p->mempolicy); > if (IS_ERR(p->mempolicy)) { Yikes, is this a new global lock and possible atomic_inc() on a shared variable in the fork() path? Has there been any performance or scalability testing done on this code? That mutex could be a disaster for fork() once the filesystem is mounted. Even if it goes away, if you have a large number of processes in an rdtgroup and they are forking a lot, you're bound to see the rdtgrp->refcount get bounced around a lot.