From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pa0-f41.google.com (mail-pa0-f41.google.com [209.85.220.41]) by dpdk.org (Postfix) with ESMTP id EF0797E6A for ; Sun, 14 Feb 2016 21:21:56 +0100 (CET) Received: by mail-pa0-f41.google.com with SMTP id yy13so74176737pab.3 for ; Sun, 14 Feb 2016 12:21:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:in-reply-to:references :mime-version:content-type:content-transfer-encoding; bh=j1UQKendDulFu7JuGZZbukliEiBdARBdQHoCz9FGd50=; b=Q2UUmsEQ0wXIw5eNzLcCpcimn783+LiiKe3cUD0+6yrz49CTsRbnmMTNMpqf2JVgk6 9Jmn82aeedacuEb+fzD8MVP+X9uoN0kCLRhu6EZapZRcTQuspiyJNGK2Tc6sF/vi0lQP 0j6YrwQVBN1bbnRxCiOWQkK6P212aRxEk3Jih5gsaxRZedt2p9vs+6K6bHjw6UIi6dT8 nyDfxHYEUfZaY4g7vEIkc5fB+wFqzDx/iYvaLMAN11s6Vu4J+js5+Hve6MiPpeYG1PnB M+lVYdbTOn3rHMmkDGovUtX/PdMOJdRsGPEh4NOiBeHZDMLUP/aHywepmiJXNzK0Yzjb ipVw== 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=j1UQKendDulFu7JuGZZbukliEiBdARBdQHoCz9FGd50=; b=aqqM+mgbqcBVssmY2Uy71eZVl+7r70ILuHtiZG5R9YXbIXv+u1qxdU+SP9VVWSVERf 2z4DieN/N6lLqZ5WAJJzUVclOVJpJqBkwGCw2v4KogP1BEnt8Jlvc/IbQZt06lwjxJbT UQsk8IXUK/PiEsWKWY1oDjVt24gvaAYQykT9nZFUl2Rk4zQBBIGzQMhznFlOU2O2iSDX tK+lZQtIilcmZvoFldd50BD+zYkAYHTp6ulavZTYyDhASDQnse8k+tu8is6O/O9TW4FF ouhBVN+nLSWSphhU/4u78mMF5dGEFy6lH5OeXmtCDoAHiU9GkC2dSxgZJb3COexJWSSa wNUw== X-Gm-Message-State: AG10YOQqn86TDXRzBDhnhSACPxlDBr7ij4ugNyJdUV9aKHdLM+bRYCOlAReMaBr4UXMx9Q== X-Received: by 10.66.248.198 with SMTP id yo6mr18372866pac.54.1455481316211; Sun, 14 Feb 2016 12:21:56 -0800 (PST) Received: from xeon-e3 (static-50-53-82-155.bvtn.or.frontiernet.net. [50.53.82.155]) by smtp.gmail.com with ESMTPSA id h66sm33261535pfd.91.2016.02.14.12.21.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 14 Feb 2016 12:21:55 -0800 (PST) Date: Sun, 14 Feb 2016 12:22:09 -0800 From: Stephen Hemminger To: Matthew Hall Message-ID: <20160214122209.38b0efb6@xeon-e3> In-Reply-To: <1455345678-17662-1-git-send-email-mhall@mhcomputing.net> References: <1455345678-17662-1-git-send-email-mhall@mhcomputing.net> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Cc: dev@dpdk.org Subject: Re: [dpdk-dev] [PATCH] eal_interrupts.c: properly init struct epoll_event (valgrind) 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: Sun, 14 Feb 2016 20:21:57 -0000 On Fri, 12 Feb 2016 22:41:18 -0800 Matthew Hall wrote: > Signed-off-by: Matthew Hall > --- > lib/librte_eal/linuxapp/eal/eal_interrupts.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/lib/librte_eal/linuxapp/eal/eal_interrupts.c b/lib/librte_eal/linuxapp/eal/eal_interrupts.c > index 06b26a9..b33ccdb 100644 > --- a/lib/librte_eal/linuxapp/eal/eal_interrupts.c > +++ b/lib/librte_eal/linuxapp/eal/eal_interrupts.c > @@ -800,6 +800,7 @@ static __attribute__((noreturn)) void * > eal_intr_thread_main(__rte_unused void *arg) > { > struct epoll_event ev; > + memset(&ev, 0, sizeof(ev)); > > /* host thread, never break out */ > for (;;) { I wonder why valgrind is giving this false report. The only place this data structure is used is here, and all fields in epoll_event are correctly set. TAILQ_FOREACH(src, &intr_sources, next) { if (src->callbacks.tqh_first == NULL) continue; /* skip those with no callbacks */ ev.events = EPOLLIN | EPOLLPRI; ev.data.fd = src->intr_handle.fd; /** * add all the uio device file descriptor * into wait list. */ if (epoll_ctl(pfd, EPOLL_CTL_ADD, src->intr_handle.fd, &ev) < 0){ rte_panic("Error adding fd %d epoll_ctl, %s\n", src->intr_handle.fd, strerror(errno)); A better patch would be to move the data structure into the code block used, and get rid of the useless else (rte_panic never returns); and fix the indentation, and use C99 initialization which should make valgrind happier. The moral is don't just slap memsets around diff --git a/lib/librte_eal/linuxapp/eal/eal_interrupts.c b/lib/librte_eal/linuxapp/eal/eal_interrupts.c index 06b26a9..d53826e 100644 --- a/lib/librte_eal/linuxapp/eal/eal_interrupts.c +++ b/lib/librte_eal/linuxapp/eal/eal_interrupts.c @@ -799,8 +799,6 @@ eal_intr_handle_interrupts(int pfd, unsigned totalfds) static __attribute__((noreturn)) void * eal_intr_thread_main(__rte_unused void *arg) { - struct epoll_event ev; - /* host thread, never break out */ for (;;) { /* build up the epoll fd with all descriptors we are to @@ -834,20 +832,22 @@ eal_intr_thread_main(__rte_unused void *arg) TAILQ_FOREACH(src, &intr_sources, next) { if (src->callbacks.tqh_first == NULL) continue; /* skip those with no callbacks */ - ev.events = EPOLLIN | EPOLLPRI; - ev.data.fd = src->intr_handle.fd; + + struct epoll_event ev = { + .events = EPOLLIN | EPOLLPRI, + .data.fd = src->intr_handle.fd, + }; /** * add all the uio device file descriptor * into wait list. */ if (epoll_ctl(pfd, EPOLL_CTL_ADD, - src->intr_handle.fd, &ev) < 0){ + src->intr_handle.fd, &ev) < 0) rte_panic("Error adding fd %d epoll_ctl, %s\n", src->intr_handle.fd, strerror(errno)); - } - else - numfds++; + + numfds++; } rte_spinlock_unlock(&intr_lock); /* serve the interrupt */