From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pd0-f176.google.com (mail-pd0-f176.google.com [209.85.192.176]) by dpdk.org (Postfix) with ESMTP id CE0B8C5AA for ; Mon, 27 Jul 2015 23:09:13 +0200 (CEST) Received: by pdrg1 with SMTP id g1so57969019pdr.2 for ; Mon, 27 Jul 2015 14:09:13 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:cc:subject:message-id:in-reply-to :references:mime-version:content-type:content-transfer-encoding; bh=fjqf4aU0IsSWbR/ZLfQlOppdfDMarm0AGZ0LGpUPTHo=; b=LUtPkW21O4I6jXOZmsUI5JTtKAdaC8cwJiWPsSadH6gd7gSdGxkM+6wtp+smpZo+og bHPkRprNftBRCc/qEimK53tWa3v07w4X3O8tdUo5l9GaNyI9FwkINnwMAEKWONYjS1ME /sBdRQUXyRxJD3IV9jjB3/ov1doKAVw73wVNn8FDeYbSOC3NjA9/tngruU8SP3BsxDAB T0GxQuT8cRlOwZXZSW+u8BSb2da+Zk81VvkT52WvRP+O/PMJWTWOeU5MzFSD6o5ZQ56A 7etW6CSjXl6tJSf0fZ61orOGNDRFidEnBmLpJ1iXDM8CDsQbAQL2BIYawqwNBk0z0/ro y+nA== X-Gm-Message-State: ALoCoQkMx+F4qkwRnMNqOiUKEu1ETXCm01Ac2nRRlvfBNKWxZ95kJdxWxZVd+VRC3MYFOLBTzk+l X-Received: by 10.70.98.170 with SMTP id ej10mr73556012pdb.12.1438031353043; Mon, 27 Jul 2015 14:09:13 -0700 (PDT) Received: from urahara (static-50-53-82-155.bvtn.or.frontiernet.net. [50.53.82.155]) by smtp.gmail.com with ESMTPSA id ml6sm31143633pdb.69.2015.07.27.14.09.12 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 27 Jul 2015 14:09:12 -0700 (PDT) Date: Mon, 27 Jul 2015 14:09:23 -0700 From: Stephen Hemminger To: Ravi Kerur Message-ID: <20150727140923.2a1cc852@urahara> In-Reply-To: References: <1429736748-16874-1-git-send-email-rkerur@gmail.com> <1429736803-16943-1-git-send-email-rkerur@gmail.com> <2280623.OZV87NhkWH@xps13> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Cc: "dev@dpdk.org" Subject: Re: [dpdk-dev] [PATCH] Use pthread_setname APIs 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: Mon, 27 Jul 2015 21:09:14 -0000 On Mon, 27 Jul 2015 13:40:08 -0700 Ravi Kerur wrote: > On Sun, Jul 26, 2015 at 2:54 PM, Thomas Monjalon > wrote: >=20 > > Hi Ravi, > > It seems to be a nice improvement but it needs some cleanup. > > > > Checkpatch returns some errors. > > > > 2015-04-22 14:06, Ravi Kerur: > > > use pthread_setname_np and pthread_set_name_np for Linux and > > > FreeBSD respectively. > > > Restrict pthread name len to 16 via config for both Linux and FreeBSD. > > > > One of the most important part of the commit message is to answer why. > > Here you probably should explain that the goal is to help debugging. > > >=20 > Sure will do it and will run checkpatch before next version. >=20 > > > > > # > > > +# Max pthread name len > > > +# > > > +CONFIG_RTE_MAX_THREAD_NAME_LEN=3D16 > > > > It doesn't have to be configurable. A define would be sufficient. > > Definitely should not be in the DPDK config. It is property of system, which change some config parameter doesn't change. Manpage implies it is fixed in glibc. The pthread_setname_np() function can be used to set a unique name for a thread, which can be useful for debugging mul= ti=E2=80=90 threaded applications. The thread name is a meaningful C langu= age string, whose length is restricted to 16 characters, including the t= er=E2=80=90 minating null byte ('\0'). =20 > Had run into issues(reported by Bruce) as name_len =3D 32 worked fine for > FreeBSD but not for Linux, hence thought of making it configurable for > Linux/FreeBSD and be able to have different name len's. Found out that > there is also a definition PTHREAD_MAX_NAMELEN_NP, if it's available on > both Linux and FreeBSD I will use this, else should I restrict name_len = =3D > 16? Not that I see on Linux $ find /usr/include -type f | xargs grep PTHREAD_MAX_NAMELEN_NP > > > > > + snprintf(thread_name, RTE_MAX_THREAD_NAME_LEN, > > "print-stats"); > > > > Why not put this line just before use of thread_name? > > >=20 > Will do it. >=20 > > > > > + > > > + ret =3D pthread_create(&tid, NULL, (void*)print_stats, = NULL > > ); > > > + > > > + if (ret !=3D 0) > > > + rte_exit(EXIT_FAILURE, > > > + "Cannot create print-stats thread\n"); > > > + > > > + ret =3D pthread_setname_np(tid, thread_name); > > > + > > > + if (ret !=3D 0) > > > + RTE_LOG(ERR, VHOST_CONFIG, > > > + "Cannot set print-stats name\n"); > > [...] > > > > > + pthread_set_name_np(lcore_config[i].thread_id, > > > + (const char *)thread_name); > > > > Is const casting really needed? > > >=20 > Function signature has a (const char *) for second parameter, I will doub= le > check and remove if not needed. You can always pass a char * when function takes const char *