From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pa0-f46.google.com (mail-pa0-f46.google.com [209.85.220.46]) by dpdk.org (Postfix) with ESMTP id C28E88D9B for ; Fri, 16 Oct 2015 18:09:53 +0200 (CEST) Received: by pabrc13 with SMTP id rc13so124566195pab.0 for ; Fri, 16 Oct 2015 09:09:53 -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=im1xQR0Y2G+gIYN9P02asgkk/ZDHhm2GOlcgYBu/n9U=; b=DRAPjHysuClVg7wPivxUrLGq6AFUz1354I44YOFaAd3a8UaSpRteVjSYAJJYdZbJ4/ 5Q1uS+0ic7ggDH6RFb/9SKT8gsGejN2zclI5qQpwvZunchyLb2vUnmR5bhsIHRYQ64Ir h1cDiStAlaS3UiidiVbXXoJS7JKbQ6D1uF/LsEWSEiO2JyEcx54MPlXaIpCI5890WB/7 M6vdm8PfIHFuKjoUidtOteOJbpLGoNg1mYBiQI7mDb+u5Rmnif3vqvYvm6BMpJ3/tRGA KzyfzAQ4DVZEvcI54zsdzn72AiwIF32r/aNofKhuSrdAgXXB2jKz0QTEdse6Z9MbbtSv fe6Q== X-Gm-Message-State: ALoCoQniUORctvGaexe+Fx1l0tdYr+5hgcafydlqD1XjJ13Pm8WjDCa0Pwdv+OfCiYIFwuv/1b0v X-Received: by 10.66.250.197 with SMTP id ze5mr17618524pac.50.1445011793009; Fri, 16 Oct 2015 09:09:53 -0700 (PDT) Received: from xeon-e3 (static-50-53-82-155.bvtn.or.frontiernet.net. [50.53.82.155]) by smtp.gmail.com with ESMTPSA id rp5sm22166546pab.0.2015.10.16.09.09.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 16 Oct 2015 09:09:52 -0700 (PDT) Date: Fri, 16 Oct 2015 09:10:02 -0700 From: Stephen Hemminger To: Simon =?UTF-8?B?S8OlZ3N0csO2bQ==?= Message-ID: <20151016091002.2ef7d507@xeon-e3> In-Reply-To: <562100BF.9010107@netinsight.net> References: <5620BA12.9060702@netinsight.net> <3EB4FA525960D640B5BDFFD6A3D89126478F0C50@IRSMSX108.ger.corp.intel.com> <562100BF.9010107@netinsight.net> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Cc: "dev@dpdk.org" Subject: Re: [dpdk-dev] Unsafe array accesses in rte_sched.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: Fri, 16 Oct 2015 16:09:54 -0000 On Fri, 16 Oct 2015 15:50:55 +0200 Simon K=C3=A5gstr=C3=B6m wrote: > On 2015-10-16 15:39, Dumitrescu, Cristian wrote: > >> port->qsize_add[12] =3D port->qsize_add[11] + port->qsize[2]; > >> port->qsize_add[13] =3D port->qsize_add[12] + port->qsize[3]; > >> port->qsize_add[14] =3D port->qsize_add[13] + port->qsize[3]; > >> port->qsize_add[15] =3D port->qsize_add[14] + port->qsize[3]; > >> > >> port->qsize_sum =3D port->qsize_add[15] + port->qsize[3]; > >> } > >> > >> but port->qsize is actually defined as > >> > >> uint16_t qsize[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE]; > >> > >=20 > > Not sure what you see "unsafe" here: qsize is an array of 4 elements, w= hile qsize_add is a different array of 16 elements? Please explain. >=20 > Sorry, I should have been more explicit: What I mean that the code > should loop over RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE instead of > hard-coding the numbers. >=20 > It certainly works with the current RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE, > but it would be safer (and in my opinion more clear) if it would not > assume RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE =3D=3D 4. >=20 > // Simon Unfortunately, current code has lots of hard wired assumptions about number of traffic classes. Lots of manually loop unrolling etc. It would be better if this was done using loops and telling compiler to unroll critical loops.