From patchwork Mon Mar 7 07:35:56 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sunil Kovvuri X-Patchwork-Id: 8515911 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id A20C99F38C for ; Mon, 7 Mar 2016 07:34:43 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C011E2013A for ; Mon, 7 Mar 2016 07:34:42 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id DBE5220121 for ; Mon, 7 Mar 2016 07:34:41 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1acpfC-0007k8-Oe; Mon, 07 Mar 2016 07:33:10 +0000 Received: from mail-pa0-x242.google.com ([2607:f8b0:400e:c03::242]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1acpf6-0007TC-Os for linux-arm-kernel@lists.infradead.org; Mon, 07 Mar 2016 07:33:06 +0000 Received: by mail-pa0-x242.google.com with SMTP id fl4so7263289pad.2 for ; Sun, 06 Mar 2016 23:32:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=44wyzV5lBD7opEQuiq1aYcmyQU0aLaDXFsJn+L2zbfE=; b=BYBKMOc4VKTiAtpq5FMfVMrjldvOf7hchLme1qabFANU8+coAbLXzQWMWpypl10aYC 5WpXA8AXH7yEkFOB4RQWQWyaZgd5wQ/pzCZJU+YJtLzuc0hJ3Ff9GTfG6yh0aNb/n/Cw SFr0h+Xxnz9XgB9UDdDhAxsGuKtvTBsKDpOv3Kt+uuRemSW+p8+Syt+PBaMnXkdrHh4b u53M+yUibgsckwuMuQQMhRsR3ohrN/ywsqo/s1nvS3wsvyJjtDtrZVqjAnll7+HlNY1m 2X8nOGikwwkBRWEUflRGGhn1nkZuA1oeqqExKVdRK60ES+vQQ5gu3K9Ova0cQJKHVPp6 T0bg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=44wyzV5lBD7opEQuiq1aYcmyQU0aLaDXFsJn+L2zbfE=; b=McWbofG4WCiy10Rh318yzDe9IwCYFuELV0RAfk2U3/NBZVym4hXzN6/D0TfKsg+Aon 1D5pMHtjyn5gy0IATs1pVsYc/JQoaENHxywv2SQbQtBO96vuCy6AmRlOrMSIXvNGRXml rC25urQlBm1x6l0+YvEmZ3gY43bSUzEtuEA554H+MHi8KU4+AcKc60vhnak0mRTGkxYx PwOxom4kTxJyLYHL/y9Eg4a5Ai/LVgYmkKqGnSL5JL2adwBoInbRqyDGmXeCD2FswEq9 j51Hwiz2kbFi42zGyYpvxCNK/+apFcD+GeNgPOJYn9dnCMGBRw61pwkE2V9AzwhV/bNq sKAg== X-Gm-Message-State: AD7BkJJNk2KsjGCmEueFR0pUe0YOvrpTIoGVcTkvHCO53GTIeGKYVe+gN48eYxyqcAC6Sg== X-Received: by 10.66.174.199 with SMTP id bu7mr31517859pac.34.1457335964108; Sun, 06 Mar 2016 23:32:44 -0800 (PST) Received: from localhost.localdomain ([14.140.2.178]) by smtp.googlemail.com with ESMTPSA id wq3sm1742292pac.44.2016.03.06.23.32.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 06 Mar 2016 23:32:42 -0800 (PST) From: sunil.kovvuri@gmail.com To: netdev@vger.kernel.org Subject: [PATCH 1/2] net: thunderx: Set recevie buffer page usage count in bulk Date: Mon, 7 Mar 2016 13:05:56 +0530 Message-Id: <1457336157-31508-2-git-send-email-sunil.kovvuri@gmail.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1457336157-31508-1-git-send-email-sunil.kovvuri@gmail.com> References: <1457336157-31508-1-git-send-email-sunil.kovvuri@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160306_233304_967072_DAEE705D X-CRM114-Status: GOOD ( 16.45 ) X-Spam-Score: -2.7 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: sgoutham@cavium.com, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, robert.richter@caviumnetworks.com MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Sunil Goutham Instead of calling get_page() for every receive buffer carved out of page, set page's usage count at the end, to reduce no of atomic calls. Signed-off-by: Sunil Goutham --- drivers/net/ethernet/cavium/thunder/nic.h | 1 + drivers/net/ethernet/cavium/thunder/nicvf_queues.c | 31 ++++++++++++++----- 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/drivers/net/ethernet/cavium/thunder/nic.h b/drivers/net/ethernet/cavium/thunder/nic.h index 00cc915..5628aea 100644 --- a/drivers/net/ethernet/cavium/thunder/nic.h +++ b/drivers/net/ethernet/cavium/thunder/nic.h @@ -285,6 +285,7 @@ struct nicvf { u32 speed; struct page *rb_page; u32 rb_page_offset; + u16 rb_pageref; bool rb_alloc_fail; bool rb_work_scheduled; struct delayed_work rbdr_work; diff --git a/drivers/net/ethernet/cavium/thunder/nicvf_queues.c b/drivers/net/ethernet/cavium/thunder/nicvf_queues.c index 0dd1abf..fa05e34 100644 --- a/drivers/net/ethernet/cavium/thunder/nicvf_queues.c +++ b/drivers/net/ethernet/cavium/thunder/nicvf_queues.c @@ -18,6 +18,15 @@ #include "q_struct.h" #include "nicvf_queues.h" +static void nicvf_get_page(struct nicvf *nic) +{ + if (!nic->rb_pageref || !nic->rb_page) + return; + + atomic_add(nic->rb_pageref, &nic->rb_page->_count); + nic->rb_pageref = 0; +} + /* Poll a register for a specific value */ static int nicvf_poll_reg(struct nicvf *nic, int qidx, u64 reg, int bit_pos, int bits, int val) @@ -81,16 +90,15 @@ static inline int nicvf_alloc_rcv_buffer(struct nicvf *nic, gfp_t gfp, int order = (PAGE_SIZE <= 4096) ? PAGE_ALLOC_COSTLY_ORDER : 0; /* Check if request can be accomodated in previous allocated page */ - if (nic->rb_page) { - if ((nic->rb_page_offset + buf_len + buf_len) > - (PAGE_SIZE << order)) { - nic->rb_page = NULL; - } else { - nic->rb_page_offset += buf_len; - get_page(nic->rb_page); - } + if (nic->rb_page && + ((nic->rb_page_offset + buf_len) < (PAGE_SIZE << order))) { + nic->rb_pageref++; + goto ret; } + nicvf_get_page(nic); + nic->rb_page = NULL; + /* Allocate a new page */ if (!nic->rb_page) { nic->rb_page = alloc_pages(gfp | __GFP_COMP | __GFP_NOWARN, @@ -102,7 +110,9 @@ static inline int nicvf_alloc_rcv_buffer(struct nicvf *nic, gfp_t gfp, nic->rb_page_offset = 0; } +ret: *rbuf = (u64 *)((u64)page_address(nic->rb_page) + nic->rb_page_offset); + nic->rb_page_offset += buf_len; return 0; } @@ -158,6 +168,9 @@ static int nicvf_init_rbdr(struct nicvf *nic, struct rbdr *rbdr, desc = GET_RBDR_DESC(rbdr, idx); desc->buf_addr = virt_to_phys(rbuf) >> NICVF_RCV_BUF_ALIGN; } + + nicvf_get_page(nic); + return 0; } @@ -241,6 +254,8 @@ refill: new_rb++; } + nicvf_get_page(nic); + /* make sure all memory stores are done before ringing doorbell */ smp_wmb();