Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935976AbcKXJBd (ORCPT ); Thu, 24 Nov 2016 04:01:33 -0500 Received: from mout.kundenserver.de ([212.227.17.24]:56614 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932884AbcKXJBb (ORCPT ); Thu, 24 Nov 2016 04:01:31 -0500 From: Arnd Bergmann To: linux-arm-kernel@lists.infradead.org Cc: Jisheng Zhang , Marcin Wojtas , Gregory CLEMENT , Thomas Petazzoni , Andrew Lunn , Jason Cooper , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, "David S. Miller" , Sebastian Hesselbarth Subject: Re: [PATCH net-next 1/4] net: mvneta: Convert to be 64 bits compatible Date: Thu, 24 Nov 2016 10:00:36 +0100 Message-ID: <21520380.oWTKcrq8DS@wuerfel> User-Agent: KMail/5.1.3 (Linux/4.4.0-34-generic; KDE/5.18.0; x86_64; ; ) In-Reply-To: <20161124163327.1cc261ab@xhacker> References: <20161122164844.19566-1-gregory.clement@free-electrons.com> <20161124163327.1cc261ab@xhacker> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-Provags-ID: V03:K0:DUK3Oz0kS56iuzPu4vmuovvJE4ShxY0Wm0uYlOrEAEIMry8mO4k pjLHLZsItJG2DBrZhls5zvvQ4iiyjBUEA9nKeL9Rfs+MZXBKxFHGM6WnRiam5saZ5Rq1qd6 7mCFg1kVOdn7cL3WpsCTwH1A+hZXT2AkeYpZl0GxDMrqbJXUwJrtnAGFeW0u7V47e7h63Yh 42chjH6NxRG66vdsayBtg== X-UI-Out-Filterresults: notjunk:1;V01:K0:Vk7E+6jTI1o=:amiFxn6nGrfZ7mZEgS/Cox kff5ohC8L7h/oVSVXrSQMp0eCXdhYLYZJnvL4BfSJBpHdmRqO1phEzKmSlI0SnWF87alBkwXU 8+/t8i9KaFtGWjtBpeeG0cT+K/t2h5ozlZf6o1DAOe9cfbNV6PzZndw0YvoYsDzPD+HhOl6Zk whGNV9lahp7vSh/JHgPiyQgbzvceN3IUH2mq7y0R6CGZdo1wd98P0wB757OB7ntgLPTLj7ImJ 3JB6nIcBrWkVY+00rlIwqvTj07TSS2uCpY2AX01IYjbrQGKSrXunOzs5Zepgbpox760aggYcH RRpzmcK3hV3pbi0YRLRNi2BBxdCWjlxIfV/jmj+7GFUCCG1qmKannn92Qmy9Cc3NZnCTs9RMM 4hN+Jr7ERJ9GqCxBxnSECRnD7OC8RXmo3b4qQeLh5xSQnq5Rdlelm6xcIatwHf7BoburCaxdf f2Gbw4Nd5hiumxEHqBFlrxQLcaUxkXGLmvuhKhAylnUkVOJFR8rKJJtjgsoyDAqZl3vC2AS0J /QNh2QYJaTMYG5tvKSCrbqzoF8nZR6kszpV+0uvQL/sh0c05C+N4CK11qOkscu4w8sBZTURRo PvAjtKs5wcbm2dA8LknjnTld28knCB2pbizQA2Mu4khd3G8a6YNhN4Wp4ucbUt4xCEj+LBQmT 9SHZVV0WhqCQqXjQlBk+qBoH1oVDG7iFV85l2y0PX/qUo4rmni3B7d+37lV3HIyfXIlPO1DsN 6psRsCLO+hNZnpvY Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2069 Lines: 46 On Thursday, November 24, 2016 4:37:36 PM CET Jisheng Zhang wrote: > solB (a SW shadow cookie) perhaps gives a better performance: in hot path, > such as mvneta_rx(), the driver accesses buf_cookie and buf_phys_addr of > rx_desc which is allocated by dma_alloc_coherent, it's noncacheable if the > device isn't cache-coherent. I didn't measure the performance difference, > because in fact we take solA as well internally. From your experience, > can the performance gain deserve the complex code? Yes, a read from uncached memory is fairly slow, so if you have a chance to avoid that it will probably help. When adding complexity to the code, it probably makes sense to take a runtime profile anyway quantify how much it gains. On machines that have cache-coherent DMA, accessing the descriptor should be fine, as you already have to load the entire cache line to read the status field. Looking at this snippet: rx_status = rx_desc->status; rx_bytes = rx_desc->data_size - (ETH_FCS_LEN + MVNETA_MH_SIZE); data = (unsigned char *)rx_desc->buf_cookie; phys_addr = rx_desc->buf_phys_addr; pool_id = MVNETA_RX_GET_BM_POOL_ID(rx_desc); bm_pool = &pp->bm_priv->bm_pools[pool_id]; if (!mvneta_rxq_desc_is_first_last(rx_status) || (rx_status & MVNETA_RXD_ERR_SUMMARY)) { err_drop_frame_ret_pool: /* Return the buffer to the pool */ mvneta_bm_pool_put_bp(pp->bm_priv, bm_pool, rx_desc->buf_phys_addr); err_drop_frame: I think there is more room for optimizing if you start: you read the status field twice (the second one in MVNETA_RX_GET_BM_POOL_ID) and you can cache the buf_phys_addr along with the virtual address once you add that. Generally speaking, I'd recommend using READ_ONCE()/WRITE_ONCE() to access the descriptor fields, to ensure the compiler doesn't add extra references as well as to annotate the expensive operations. Arnd