From patchwork Mon Mar 14 11:06:14 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sunil Kovvuri X-Patchwork-Id: 8578311 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 A2A509F54C for ; Mon, 14 Mar 2016 11:05:13 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B03872041D for ; Mon, 14 Mar 2016 11:05:12 +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 BE4B920412 for ; Mon, 14 Mar 2016 11:05:11 +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 1afQHc-0004p3-3z; Mon, 14 Mar 2016 11:03:32 +0000 Received: from mail-pa0-x241.google.com ([2607:f8b0:400e:c03::241]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1afQHV-0004jj-2c for linux-arm-kernel@lists.infradead.org; Mon, 14 Mar 2016 11:03:27 +0000 Received: by mail-pa0-x241.google.com with SMTP id q6so14329140pav.0 for ; Mon, 14 Mar 2016 04:03:04 -0700 (PDT) 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=BRFXH4ISlzErs2TNQ84WQROvCYmjPNVpQ9GVxfaVQxE=; b=AR6nkW6HdUc5rb+d0i944O5Y7ldpUaJGFiWKgC+vIyDU2QlzGCX0CloP+Elv3ToDbO YsWjfqHGxdqiB4DHkOXQQVwivcKFW+QhmpMm/FWIpnjkoIrVFIYJG4Fkh+XdKjFjdskD +wtFPxQR1c86IAQRQKsKGmr0nk6kBBXQuh4EJkQ0ta2SkMlfx0PE52ZX78lNvUHvrmsS ZmqSytvuzVddRnMGTlqD5cyyq7IMkxmnef7A0pBgGY/xJ4aWowPM7t5qNPVmiK755XA7 DI0Vhn5Y51U5j2xg0dyqvlyiyrlyVfozOfBMIBAGCUj69a8A5F0MoCMVc4/Z0+Qmrv+6 4CTg== 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=BRFXH4ISlzErs2TNQ84WQROvCYmjPNVpQ9GVxfaVQxE=; b=QwcIJSYJcMQNGhk2bfV7j8dRV1UfAIuHIu2w71LJntIJAf8mpWylIT/I6v4ScaWlWl F+eYvz9N7HrGaSU7pNbMVabwGZGI9abRZXGBlI+8FXgd4aQaGTCppyLspGmQPeyoDm+k J5mdnbziUzXElMv3tQcvJGRYLTBMmGrnP6kCKE0Dgck5qeHFMgoGMZ7InkaUjQV0GVKM a5A0aoZxVU7sFzU5GM6PQMfsWOz2/i8aqOKKOaGKiW/rzetnJuTzaS78FqeuI7GKtqiW b8UMMNIN+41D5dPipMPGtqLc2gyVDmX8PETwpCLgYxkwcm+zHYm5EMA6LvgWhCMKTbrX GV0A== X-Gm-Message-State: AD7BkJIMkaFvfv7Xr0hdWzNv4G6J7uKOZhPHa7w9Vi6gneuyJrUeCJf2GvVhtnJJY3BRHg== X-Received: by 10.66.55.70 with SMTP id q6mr32548588pap.126.1457953384412; Mon, 14 Mar 2016 04:03:04 -0700 (PDT) Received: from localhost.localdomain ([14.140.2.178]) by smtp.googlemail.com with ESMTPSA id a22sm31388211pfj.2.2016.03.14.04.03.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 14 Mar 2016 04:03:03 -0700 (PDT) From: sunil.kovvuri@gmail.com To: netdev@vger.kernel.org Subject: [PATCH v2 1/2] net: thunderx: Set recevie buffer page usage count in bulk Date: Mon, 14 Mar 2016 16:36:14 +0530 Message-Id: <1457953578-7054-2-git-send-email-sunil.kovvuri@gmail.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1457953578-7054-1-git-send-email-sunil.kovvuri@gmail.com> References: <1457953578-7054-1-git-send-email-sunil.kovvuri@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160314_040325_347059_4780CD4C X-CRM114-Status: GOOD ( 17.05 ) 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: robert.richter@caviumnetworks.com, sgoutham@cavium.com, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, davem@davemloft.net 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 092f097..872b22d 100644 --- a/drivers/net/ethernet/cavium/thunder/nic.h +++ b/drivers/net/ethernet/cavium/thunder/nic.h @@ -294,6 +294,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();