From owner-freebsd-virtualization@FreeBSD.ORG Tue Apr 29 16:21:49 2014 Return-Path: Delivered-To: freebsd-virtualization@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id A4AF26F2; Tue, 29 Apr 2014 16:21:49 +0000 (UTC) Received: from mail-qc0-x22e.google.com (mail-qc0-x22e.google.com [IPv6:2607:f8b0:400d:c01::22e]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 5633519EC; Tue, 29 Apr 2014 16:21:49 +0000 (UTC) Received: by mail-qc0-f174.google.com with SMTP id c9so499804qcz.33 for ; Tue, 29 Apr 2014 09:21:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=5bAQ6sW1u4tExIq9dvabmJifrMdhE8b/12Zg4JDCEY8=; b=k+63GJrLAlsYOFPbKCb8Cb+gX3cGzHgnmVn+nW+uO3KmfqURWNv0CM3yM1w2og/o83 QND1DVKxGQm0RIHfliFPGoB0Rkcg7ookm3/k2zsjHd4vd6c6b3iDbPdanhTqAVR1eUOV ccGBbGQBTUp5Ox3IGTmj3w8jPFyfbkI0dj7mHRjrgaMtA6jaFwj2uG80j8FjqDAsK013 rBC7Zggyjkd+hw8avkjdLeSZej+KOMTd7Gu1OdVw1TYxmRdo/pcmZKQxYOPi3saiMgqQ H+7T3v+eVqWewYFKKwiwpQQPR6PvFehqG8fPZq0FaLhmdIpkk0q3kLhOkUuMsH1v6/LW w96Q== MIME-Version: 1.0 X-Received: by 10.140.101.201 with SMTP id u67mr196278qge.107.1398788508476; Tue, 29 Apr 2014 09:21:48 -0700 (PDT) Received: by 10.140.47.201 with HTTP; Tue, 29 Apr 2014 09:21:48 -0700 (PDT) In-Reply-To: <20140427104511.GA7804@kloomba> References: <20140427104511.GA7804@kloomba> Date: Tue, 29 Apr 2014 09:21:48 -0700 Message-ID: Subject: Re: [PATCH] Flexible vcpu pinning configuration From: Neel Natu To: Roman Bogorodskiy Content-Type: text/plain; charset=UTF-8 Cc: "freebsd-virtualization@freebsd.org" X-BeenThere: freebsd-virtualization@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: "Discussion of various virtualization techniques FreeBSD supports." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 29 Apr 2014 16:21:49 -0000 Hi Roman, On Sun, Apr 27, 2014 at 3:45 AM, Roman Bogorodskiy wrote: > I've created an initial version of the patch which allows more flexible > vcpu pinning configuration. > > Current schema is: > > bhyve -p N > > pins vcpu i to hostcpu N + i. > > The propsed extension is: > > bhyve -p N:M .... -p 0:1 -p 3:5 > > which pins vcpu N to host pcpu M. Option needs to be specified > individually for each vcpu. > > So it works like that for me: > > sudo /usr/sbin/bhyve -p 0:0 -p 1:3 -c 2 ... > > # sudo cpuset -g -t 100262 > tid 100262 mask: 0 > # sudo cpuset -g -t 100264 > tid 100264 mask: 3 > > PS I used cpumat_t* array to store these values instead of int, because > if the idea is OK, I'll extend it to support ranges like e.g. cpuset(1) > supports, e.g.: "1:2-5". > > The questions are: > > - Is it OK to chance '-p' arg syntax or it's better to introduce a new > one? > I think we can reuse the "-p" option unless anybody objects vociferously. > - Is the syntax OK (currently: 'vcpu:pcpu', later > 'vcpu:pcpuN-pcpuM,pcpuX")? Yup, I think that works fine. The patch looks good in general but I have a few comments: - Scope of 'vcpupmap[]' should be restricted to 'static'. - usage() and man page need to be updated. - pincpu_parse(): The option parsing can be made much easier by using: if (sscanf(str, "%d:%d", &vcpu, &pcpu) == 2) { /* success */ } else { return (-1); } If the same vcpu is specified multiple times then we should malloc(sizeof(cpuset_t)) only the first time: if (vcpumap[vcpu] != NULL) mask = vcpumap[vcpu]; else mask = malloc(sizeof(cpuset_t)); We need to range-check 'vcpu' before using it as an index into the 'vcpumap[]' array. best Neel > > Roman Bogorodskiy