From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM03-BY2-obe.outbound.protection.outlook.com (mail-by2nam03on0070.outbound.protection.outlook.com [104.47.42.70]) by dpdk.org (Postfix) with ESMTP id 080F62BF4 for ; Mon, 19 Feb 2018 09:36:34 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=CAVIUMNETWORKS.onmicrosoft.com; s=selector1-cavium-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=XDEMSs8Au4sqd6ZfuPY4ngt6CPlO/v7vv+gz/hi00Z4=; b=EBaiqfO3/+nAl4UzOSDugHdyMQ12JQaCAWlM67OWmRNRuZSzBUSdeSI0COzQKCaQUMeD2kpdcWjUylXlJ0FmXr5cpL9XKNT3DDXga4T/PA3kCFGD4jCqVNnweOEEHOFTc48VjBlSuWp1GK/eronoO11I4lEGunGzotS4YSZzjkg= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Pavan.Bhagavatula@cavium.com; Received: from ltp-pvn (111.93.218.67) by CY4PR07MB3462.namprd07.prod.outlook.com (2603:10b6:910:75::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.506.18; Mon, 19 Feb 2018 08:36:29 +0000 Date: Mon, 19 Feb 2018 14:06:08 +0530 From: Pavan Nikhilesh To: Matan Azrad , "jerin.jacob@caviumnetworks.com" , Thomas Monjalon Cc: dev@dpdk.org Message-ID: <20180219083607.GA2841@ltp-pvn> References: <20180217104934.17291-1-pbhagavatula@caviumnetworks.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.3 (2018-01-21) X-Originating-IP: [111.93.218.67] X-ClientProxiedBy: BM1PR01CA0118.INDPRD01.PROD.OUTLOOK.COM (2603:1096:b00::34) To CY4PR07MB3462.namprd07.prod.outlook.com (2603:10b6:910:75::15) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 89d77be4-12ce-4c6e-8e86-08d57773e131 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(5600026)(4604075)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603307)(7153060)(7193020); SRVR:CY4PR07MB3462; X-Microsoft-Exchange-Diagnostics: 1; CY4PR07MB3462; 3:tBBwSp0+ejL8DKGA59OeDZB0Oufu1mX71iJrFid6dkgxhmjt0G02UawZ2s4pqLr422krjJdhEt3PboBXkA0FEX+GLdnWbFk/Ml9f7PeWDEn52ka3zlprU5b03RupN3g2sZjoj7FdV9RVepWAn8mutYOg7dJzgQAUffK6v5ZlXm7EAU3rnUUVUWpH2YbRnn8/wv7IS7NrZtX0qjyQ6eOU8gdhOl3L/iMCAWNjV1NXr93mqc7ABdCbKKaqCOBqtsYs; 25:F8yQNZUnwp4PciFPwt9ju3cidY+SxgS54FzQ6DGZ3ahePwpArwHNvuKhzznspxxo+QAZydL/PMgXi8dZdxJcWxa/Q7KWEW9aP4DEpsuzmGJwMkUXmnhiB/DaRLQP6kTFQpqwm++kqPMNmUlu9B6vmNgrUzJ34bU+9McvDXNmZ4cmt6b4w0tkwUJgSeV8J8Uxl8/2Ttxi6LucpBH7j1gCuhWfO9PJiZQuimd/gShBO3A5QiizvDi/IFn5mI5BAYrRlcaxCpwzS5/ZN6AaAAW0piw0z8qwsK+OvoAlJNWtasc3AMTqXKKPKcdj3Ni3oh1YiK/Ka6JxvvEhhWFaojUyTw==; 31:+EqieBQk4L17dgMIlfUzKwT8rrw3d3dV518Lav2hhs9jhxrDE/+9KqVTMZ82i4fqX5QGcrONVmgK9qb9BonzBH5GR4+c5AMsHPDNNbDQteATQnDEWIWkJ08RldG8ohjB7+IpY0lLlobP9upVkfrLP3/1XzBB8JmXlPXXtRL69Xwk3E0LH+2iXk2lrjOJdlSo+xcwIGLAw4QyFFcxaNGKHxsDS+oldrcDj1/pj56tcVs= X-MS-TrafficTypeDiagnostic: CY4PR07MB3462: X-Microsoft-Exchange-Diagnostics: 1; CY4PR07MB3462; 20:RZrynBxhBf43CofKSvRtAz/C43NLfk6Pw+jN83E8SRiRjRP/JBRJMnoVl0GagC+yDMmdwlC19X9ZvHtcWY/i5CX+FRpTxW7G5sqZ78m2vb0YvdY8OAZJ9aYBb1gfhMQFyegubfy9x+QDrKM3vB+anra673VxDm3ZIFzmGper2jTWIL2HU9SBY/opzKl5A3+s0WYS78zSr8+ET/P3wFTO+N/8y6FuJoFuguhawDbqbmcm33sfLZ/p8E14XwHhAb6zr0qwDTAMBJRWwQQP5GU31F4Rk8nYTnwtdJ6pXtUbqAs401L1Z/Tf1F7pA0VcHQ+yCLgUYXcXLpEcjUxMa6VH7YFOmm8GqeoxshPDmOKk0pcuG/kAJj1Z2hpbR/VzBOtbeYIsOkmUXfzhFClrSrLQF9TovSRccOistYNevenxVmH1vkp8p3Xwd+c+OOSL/Ha0c8k3V6rDtXwb6l8YYsU3qDGQnfo4XdRK8fA0s/JzHPWwl7MJuirlixH9A08yIfzINu+Wf/JyXbArNEHFmuGhZVfxTnzil37lI9ODREaXGPeqAJd6/W8XmiI8+Ppl29W/sfLq2nMAzYbPl6L9Vxs2CdL8Oy6lSkUBdict7XPSxvo=; 4:jm/Rsle+UhAVGJa8CeOgmXZeMBWCUEpcfMdjJAsrp0EpNBRaFhzk9MHIhUyQ4fjmbvyuKL/v6s6I7eP09wXi20/kE9ABpsRPGUGAWuQVLpx5GKN7OywBzirE4CG/cCHiFWYBJT7t1XIC279XH6WjUCMPqSTMA5PF4AnE5xgVUuWw2F5nqRVuMcoX55JoIhzu5isXTlyOoa4Lm1pe35BHmNP+e6WKPedxQZDPNpQCBnOKChvsfg7PJqgaiGIw9uG4iTrlTG5Smv6MMmrw0ku1jA== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001056)(6040501)(2401047)(8121501046)(5005006)(3231101)(944501161)(93006095)(10201501046)(3002001)(6041288)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123564045)(20161123558120)(20161123562045)(6072148)(201708071742011); SRVR:CY4PR07MB3462; BCL:0; PCL:0; RULEID:; SRVR:CY4PR07MB3462; X-Forefront-PRVS: 0588B2BD96 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(346002)(366004)(396003)(39380400002)(39850400004)(376002)(76104003)(199004)(189003)(72206003)(81156014)(83506002)(8676002)(81166006)(8936002)(5660300001)(33656002)(2906002)(106356001)(3846002)(1076002)(6116002)(5009440100003)(50466002)(4326008)(23726003)(6496006)(316002)(33896004)(386003)(25786009)(105586002)(6246003)(53936002)(68736007)(47776003)(9686003)(55016002)(52116002)(26005)(76176011)(6666003)(33716001)(110136005)(305945005)(478600001)(42882006)(97736004)(7736002)(2501003)(16526019)(2950100002)(186003)(66066001)(16586007)(229853002)(58126008)(18370500001)(107986001)(42262002); DIR:OUT; SFP:1101; SCL:1; SRVR:CY4PR07MB3462; H:ltp-pvn; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; Received-SPF: None (protection.outlook.com: cavium.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; CY4PR07MB3462; 23:uC0Gy1LdwWd9HR3XRgL9SChBAOjb9D8R4DzY9UKDI?= =?us-ascii?Q?sovOjSYoHVdSrkJ39k9+2lCgxnSMMOLpPeRuXwcwSzk6DqUe/81sIJhQ2VsX?= =?us-ascii?Q?rSGJft1edwto6UfbFCnjwHXWDA5GFs8oM3JZFvCMXXJRDdpLvURzx65l3rzf?= =?us-ascii?Q?BHglyfns7WoM8Abq3ERmdtJ1tmxXWJINcYxAf1BoszDRZZJ2M99z6pSFzX/o?= =?us-ascii?Q?hVT/eR1oGy7xI/qdrldS9CkYXURhNrRYXwKbY4QH5QB5iA+y1wgpP84tcvly?= =?us-ascii?Q?ksQ9rwe0I9s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H/flte+ucN1U7NYZ+bqo0eQ4kRe3vLT0HzBvirp+lgD7p7vvKxs2iJA9bnkble7NsnRxGNX5YFSMgXE3SjoaDXz6g4VyiEQz2+bVtxo+XfygEVqmzRQNAkWndDlbSa2uMquocP5W2XHmjsk42Qhepr7zln5lW SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Feb 2018 08:36:29.4717 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 89d77be4-12ce-4c6e-8e86-08d57773e131 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 711e4ccf-2e9b-4bcf-a551-4094005b6194 X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR07MB3462 Subject: Re: [dpdk-dev] [PATCH 1/2] eal: add API to align integer to previous power of 2 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 19 Feb 2018 08:36:35 -0000 Hi Matan, On Sun, Feb 18, 2018 at 06:11:20AM +0000, Matan Azrad wrote: > Hi Pavan > > Please see some comments below. > > From: Pavan Nikhilesh, Saturday, February 17, 2018 12:50 PM > > Add 32b and 64b API's to align the given integer to the previous power of 2. > > > > Signed-off-by: Pavan Nikhilesh > > --- > > lib/librte_eal/common/include/rte_common.h | 36 > > ++++++++++++++++++++++++++++++ > > 1 file changed, 36 insertions(+) > > > > diff --git a/lib/librte_eal/common/include/rte_common.h > > b/lib/librte_eal/common/include/rte_common.h > > index c7803e41c..126914f07 100644 > > --- a/lib/librte_eal/common/include/rte_common.h > > +++ b/lib/librte_eal/common/include/rte_common.h > > @@ -259,6 +259,24 @@ rte_align32pow2(uint32_t x) > > return x + 1; > > } > > > > +/** > > + * Aligns input parameter to the previous power of 2 > > + * > > + * @param x > > + * The integer value to algin > > + * > > + * @return > > + * Input parameter aligned to the previous power of 2 > > I think the zero case(x=0) result should be documented. The existing API i.e. rte_align32pow2() behaves in similar manner i.e. returns 0 when 0 is passed. > > > + */ > > +static inline uint32_t > > +rte_align32lowpow2(uint32_t x) > > What do you think about " rte_align32prevpow2"? I think rte_align32prevpow2() fits better will modify and send v2. > > > +{ > > + x = rte_align32pow2(x); > > In case of x is power of 2 number(already aligned), looks like the result here is x and the final result is (x >> 1)? > Is it as you expect? I overlooked that bit while trying to make use of the existing API, will modify the implementation to return x if its already a power of 2. > > > + x--; > > + > > + return x - (x >> 1); > > Why can't the implementation just be: > return rte_align32pow2(x) >> 1; > > If the above is correct, Are you sure we need this API? > > > +} > > + > > /** > > * Aligns 64b input parameter to the next power of 2 > > * > > @@ -282,6 +300,24 @@ rte_align64pow2(uint64_t v) > > return v + 1; > > } > > > > +/** > > + * Aligns 64b input parameter to the previous power of 2 > > + * > > + * @param v > > + * The 64b value to align > > + * > > + * @return > > + * Input parameter aligned to the previous power of 2 > > + */ > > +static inline uint64_t > > +rte_align64lowpow2(uint64_t v) > > +{ > > + v = rte_align64pow2(v); > > + v--; > > + > > + return v - (v >> 1); > > +} > > + > > Same comments for 64b API. > > > /*********** Macros for calculating min and max **********/ > > > > /** > > -- > > 2.16.1 > > > If it is a new API, I think it should be added to the map file and to be tagged as experimental. No? Static inline functions need not be a part of map files, as for experimental tag I don't think its needed for a math API. I don't have a strong opinion tagging it experimental, if it is really needed I will send a re-do the patch marking it experimental. > > Matan Thanks, Pavan