From patchwork Thu Jun 24 22:45:51 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sridhar Samudrala X-Patchwork-Id: 56866 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 31C26B6F3E for ; Fri, 25 Jun 2010 08:46:38 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754753Ab0FXWqH (ORCPT ); Thu, 24 Jun 2010 18:46:07 -0400 Received: from e38.co.us.ibm.com ([32.97.110.159]:35875 "EHLO e38.co.us.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751266Ab0FXWqE (ORCPT ); Thu, 24 Jun 2010 18:46:04 -0400 Received: from d03relay03.boulder.ibm.com (d03relay03.boulder.ibm.com [9.17.195.228]) by e38.co.us.ibm.com (8.14.4/8.13.1) with ESMTP id o5OMdGLx021858; Thu, 24 Jun 2010 16:39:16 -0600 Received: from d03av02.boulder.ibm.com (d03av02.boulder.ibm.com [9.17.195.168]) by d03relay03.boulder.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id o5OMjs92085886; Thu, 24 Jun 2010 16:45:57 -0600 Received: from d03av02.boulder.ibm.com (loopback [127.0.0.1]) by d03av02.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id o5OMjqe2028425; Thu, 24 Jun 2010 16:45:54 -0600 Received: from [9.47.18.19] (w-sridhar.beaverton.ibm.com [9.47.18.19]) by d03av02.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id o5OMjpnB028391; Thu, 24 Jun 2010 16:45:51 -0600 Subject: Re: [PATCH 3/3] vhost: apply cpumask and cgroup to vhost pollers From: Sridhar Samudrala To: "Michael S. Tsirkin" Cc: Tejun Heo , Oleg Nesterov , netdev , lkml , "kvm@vger.kernel.org" , Andrew Morton , Dmitri Vorobiev , Jiri Kosina , Thomas Gleixner , Ingo Molnar , Andi Kleen In-Reply-To: <20100624081135.GA937@redhat.com> References: <20100527131254.GB7974@redhat.com> <4BFE9ABA.6030907@kernel.org> <20100527163954.GA21710@redhat.com> <4BFEA434.6080405@kernel.org> <20100527173207.GA21880@redhat.com> <4BFEE216.2070807@kernel.org> <20100528150830.GB21880@redhat.com> <4BFFE742.2060205@kernel.org> <20100530112925.GB27611@redhat.com> <4C02C99D.9070204@kernel.org> <20100624081135.GA937@redhat.com> Date: Thu, 24 Jun 2010 15:45:51 -0700 Message-Id: <1277419551.27868.27.camel@w-sridhar.beaverton.ibm.com> Mime-Version: 1.0 X-Mailer: Evolution 2.26.3 (2.26.3-1.fc11) Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On Thu, 2010-06-24 at 11:11 +0300, Michael S. Tsirkin wrote: > On Sun, May 30, 2010 at 10:25:01PM +0200, Tejun Heo wrote: > > Apply the cpumask and cgroup of the initializing task to the created > > vhost poller. > > > > Based on Sridhar Samudrala's patch. > > > > Cc: Michael S. Tsirkin > > Cc: Sridhar Samudrala > > > I wanted to apply this, but modpost fails: > ERROR: "sched_setaffinity" [drivers/vhost/vhost_net.ko] undefined! > ERROR: "sched_getaffinity" [drivers/vhost/vhost_net.ko] undefined! > > Did you try building as a module? In my original implementation, i had these calls in workqueue.c. Now that these are moved to vhost.c which can be built as a module, these symbols need to be exported. The following patch fixes the build issue with vhost as a module. Signed-off-by: Sridhar Samudrala struct cpumask *new_mask) @@ -4900,6 +4901,7 @@ out_unlock: return retval; } +EXPORT_SYMBOL_GPL(sched_getaffinity); /** * sys_sched_getaffinity - get the cpu affinity of a process > > --- > > drivers/vhost/vhost.c | 36 +++++++++++++++++++++++++++++++----- > > 1 file changed, 31 insertions(+), 5 deletions(-) > > > > Index: work/drivers/vhost/vhost.c > > =================================================================== > > --- work.orig/drivers/vhost/vhost.c > > +++ work/drivers/vhost/vhost.c > > @@ -23,6 +23,7 @@ > > #include > > #include > > #include > > +#include > > > > #include > > #include > > @@ -176,12 +177,30 @@ repeat: > > long vhost_dev_init(struct vhost_dev *dev, > > struct vhost_virtqueue *vqs, int nvqs) > > { > > - struct task_struct *poller; > > - int i; > > + struct task_struct *poller = NULL; > > + cpumask_var_t mask; > > + int i, ret = -ENOMEM; > > + > > + if (!alloc_cpumask_var(&mask, GFP_KERNEL)) > > + goto out; > > > > poller = kthread_create(vhost_poller, dev, "vhost-%d", current->pid); > > - if (IS_ERR(poller)) > > - return PTR_ERR(poller); > > + if (IS_ERR(poller)) { > > + ret = PTR_ERR(poller); > > + goto out; > > + } > > + > > + ret = sched_getaffinity(current->pid, mask); > > + if (ret) > > + goto out; > > + > > + ret = sched_setaffinity(poller->pid, mask); > > + if (ret) > > + goto out; > > + > > + ret = cgroup_attach_task_current_cg(poller); > > + if (ret) > > + goto out; > > > > dev->vqs = vqs; > > dev->nvqs = nvqs; > > @@ -202,7 +221,14 @@ long vhost_dev_init(struct vhost_dev *de > > vhost_poll_init(&dev->vqs[i].poll, > > dev->vqs[i].handle_kick, POLLIN, dev); > > } > > - return 0; > > + > > + wake_up_process(poller); /* avoid contributing to loadavg */ > > + ret = 0; > > +out: > > + if (ret) > > + kthread_stop(poller); > > + free_cpumask_var(mask); > > + return ret; > > } > > > > /* Caller should have device mutex */ > -- > To unsubscribe from this list: send the line "unsubscribe netdev" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html Signed-off-by: Michael S. Tsirkin --- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/kernel/sched.c b/kernel/sched.c index 3c2a54f..15a0c6f 100644 --- a/kernel/sched.c +++ b/kernel/sched.c @@ -4837,6 +4837,7 @@ out_put_task: put_online_cpus(); return retval; } +EXPORT_SYMBOL_GPL(sched_setaffinity); static int get_user_cpu_mask(unsigned long __user *user_mask_ptr, unsigned len,