From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-oi0-f46.google.com (mail-oi0-f46.google.com [209.85.218.46]) by dpdk.org (Postfix) with ESMTP id 3330CC2FE for ; Wed, 22 Apr 2015 17:39:20 +0200 (CEST) Received: by oiko83 with SMTP id o83so182365347oik.1 for ; Wed, 22 Apr 2015 08:39:19 -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=SqbFhci2/W6U2QYhxXq8QHIf6Fm16lpzkVcSL7BehCE=; b=tcIKJSU9uAsXAHO+IAKtyGKfp4o2ZLvFXCLEeTeZ9Ulg09vo1kOH20wiCBU1Gz6z6U 463eLInppxKzAJvEznOPFrU02sFf0pDmTMl5of+0DkR6+413s15k21ATnROo3/7SHtXc V3PDzssz9xcGifchmU4Dap5yeFr4JRRHVcJoTyvOcDCZskxMjdpOU30+DaiXeHR8Bl79 iX6sT6BWNXaOFXY6HRzFidFpiY6D5cCl2cxGLLSNybQobQYLVhFtlL5XxXU4GzXHSewa irIGZcw9rpWJgWJWuSYMdB7knUn0j8M8op+LYtJGYT26ey/Uv4t470a+0cPQDe52fFCC Q+Cg== MIME-Version: 1.0 X-Received: by 10.182.153.101 with SMTP id vf5mr15161126obb.48.1429717159649; Wed, 22 Apr 2015 08:39:19 -0700 (PDT) Received: by 10.202.179.195 with HTTP; Wed, 22 Apr 2015 08:39:19 -0700 (PDT) In-Reply-To: <20150422090311.GA5652@bricha3-MOBL3> References: <1429386161-12490-1-git-send-email-rkerur@gmail.com> <1429386191-12537-1-git-send-email-rkerur@gmail.com> <20150421142535.GA11524@bricha3-MOBL3> <20150422090311.GA5652@bricha3-MOBL3> Date: Wed, 22 Apr 2015 08:39:19 -0700 Message-ID: From: Ravi Kerur To: Bruce Richardson Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Content-Filtered-By: Mailman/MimeDel 2.1.15 Cc: "dev@dpdk.org" Subject: Re: [dpdk-dev] [PATCH v6 1/6] Move common functions in eal_thread.c X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 22 Apr 2015 15:39:20 -0000 On Wed, Apr 22, 2015 at 2:03 AM, Bruce Richardson < bruce.richardson@intel.com> wrote: > On Tue, Apr 21, 2015 at 12:28:24PM -0700, Ravi Kerur wrote: > > On Tue, Apr 21, 2015 at 7:25 AM, Bruce Richardson < > > bruce.richardson@intel.com> wrote: > > > > > On Sat, Apr 18, 2015 at 12:43:06PM -0700, Ravi Kerur wrote: > > > > Changes in v6 > > > > Remove RTE_EXEC_ENV_BSDAPP from eal_common_thread.c file. > > > > Add pthread_setname_np/pthread_set_name_np for Linux/FreeBSD > > > > respectively. Plan to use _getname_ in RTE_LOG when available. > > > > Use existing rte_get_systid() in RTE_LOG to print thread_id. > > > > > > Hi Ravi > > > > > > I think the change to add names to the threads might be better in an > > > existing > > > patch as it is separate from the change of making the code common. > > > [The code changes for the names also seems to have issues with it, as > > > described in comments below] > > > > > > > Hi Bruce, > > > > Thanks for your comments. Linux/FreeBSD has different APIs > > > > pthread_setname_np and pthread_getname_np in Linux > > pthread_set_name_np in FreeBSD. FreeBSD has no "_get_name_" counterpart > API. > > > > API signatures are different as well. Current plan is to use > > "_setname_"/"_set_name_" appropriately and leave out "_getname_" until = it > > is available in FreeBSD. > > > > Are you suggesting to use separate patch for set/get pthread names? > > Yes, I think that would be better. Have one patch just for moving the cod= e > to a common location, then a second patch for adding in thread names sinc= e > its > really a discrete unit of work. Apart from the bug with Linux vfio thread= , > the > idea and implementation looks really good, and something we would like to > have. > Thanks Bruce. I will take care of removing it from EAL common patch series and send out a separate patch for this. > > /Bruce > > > > > More inline. > > > > > > > > > > > > Changes in v5 > > > > Rebase to latest code. > > > > > > > > Changes in v4 > > > > None > > > > > > > > Changes in v3 > > > > Changed subject to be more explicit on file name inclusion. > > > > > > > > Changes in v2 > > > > None > > > > > > > > Changes in v1 > > > > eal_thread.c has minor differences between Linux and BSD, move > > > > entire file into common directory. > > > > Use RTE_EXEC_ENV_BSDAPP to differentiate on minor differences. > > > > Rename eal_thread.c to eal_common_thread.c > > > > Makefile changes to reflect file move and name change. > > > > Fix checkpatch warnings. > > > > > > > > Signed-off-by: Ravi Kerur > > > > --- > > > > examples/vhost/main.c | 18 ++- > > > > examples/vhost_xen/main.c | 18 ++- > > > > lib/librte_eal/bsdapp/eal/Makefile | 2 +- > > > > lib/librte_eal/bsdapp/eal/eal.c | 7 + > > > > lib/librte_eal/bsdapp/eal/eal_thread.c | 152 > > > --------------------- > > > > lib/librte_eal/common/eal_common_thread.c | 147 > > > +++++++++++++++++++- > > > > lib/librte_eal/common/eal_thread.h | 5 + > > > > lib/librte_eal/linuxapp/eal/Makefile | 2 + > > > > lib/librte_eal/linuxapp/eal/eal.c | 10 ++ > > > > lib/librte_eal/linuxapp/eal/eal_interrupts.c | 11 ++ > > > > lib/librte_eal/linuxapp/eal/eal_pci_vfio_mp_sync.c | 22 ++- > > > > lib/librte_eal/linuxapp/eal/eal_thread.c | 152 > > > +-------------------- > > > > lib/librte_eal/linuxapp/eal/eal_timer.c | 15 +- > > > > 13 files changed, 250 insertions(+), 311 deletions(-) > > > > > > > > > > <<>> > > > > > > > --- a/lib/librte_eal/linuxapp/eal/eal_pci_vfio_mp_sync.c > > > > +++ b/lib/librte_eal/linuxapp/eal/eal_pci_vfio_mp_sync.c > > > > @@ -34,6 +34,7 @@ > > > > #include > > > > #include > > > > #include > > > > +#include > > > > > > > > /* sys/un.h with __USE_MISC uses strlen, which is unsafe */ > > > > #ifdef __USE_MISC > > > > @@ -54,6 +55,7 @@ > > > > > > > > #include "eal_filesystem.h" > > > > #include "eal_pci_init.h" > > > > +#include "eal_thread.h" > > > > > > > > /** > > > > * @file > > > > @@ -374,20 +376,36 @@ int > > > > pci_vfio_mp_sync_setup(void) > > > > { > > > > int ret; > > > > + char thread_name[RTE_THREAD_NAME_LEN]; > > > > > > > > if (vfio_mp_sync_socket_setup() < 0) { > > > > RTE_LOG(ERR, EAL, "Failed to set up local socket!\n")= ; > > > > return -1; > > > > } > > > > > > > > + snprintf(thread_name, RTE_THREAD_NAME_LEN, > > > > + "pci-vfio-mp-sync"); > > > > > > This string is too long. According to the man page (Fedora Linux): > > > "The thread name is a meaningful C language string, whose length is > > > restricted to 16 charac=E2=80=90 > > > ters, including the terminating null byte ('\0')." > > > I make the string 16+ null, i.e. 17 in total. > > > > > > > My mistake, will fix it. > > > > > > > > > + > > > > ret =3D pthread_create(&socket_thread, NULL, > > > > pci_vfio_mp_sync_thread, NULL); > > > > if (ret) { > > > > - RTE_LOG(ERR, EAL, "Failed to create thread for > > > communication with " > > > > - "secondary processes!\n"); > > > > + RTE_LOG(ERR, EAL, > > > > + "Failed to create thread for communication > with " > > > > + "secondary processes!\n"); > > > > > > Should not split the error message string across multiple lines as it > > > breaks > > > git grep searches for the error message. > > > > > > > Will fix it. > > > > > > > > > + close(mp_socket_fd); > > > > + return -1; > > > > + } > > > > + > > > > + ret =3D pthread_setname_np(socket_thread, thread_name); > > > > + > > > > + if (ret) { > > > > + RTE_LOG(ERR, EAL, > > > > + "Failed to set thread name for " > > > > + "secondary processes!\n"); > > > > close(mp_socket_fd); > > > > return -1; > > > > > > Do we really want to return with an error here. Right now I can't run > any > > > apps > > > since I get an error on init of PCI - due to the name string being to= o > > > long for > > > Linux. (Things seem fine on BSD). Failing to name a thread doesn't > seem to > > > be > > > a fatal error IMHO. > > > > > > > > When I coded understanding was that pthread _set_ APIs should not fail > > (excluding bugs whilst calling the API), since _get_ APIs will be calle= d > > subsequently for logging and debugging it will not be of any help if I > let > > program continue after _set_ failure. I will change the code to just lo= g > an > > error and return success. > > > > Thanks, > > Ravi > > > > > > > Regards, > > > /Bruce > > > > > > >