Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp6016724ybi; Wed, 29 May 2019 01:19:06 -0700 (PDT) X-Google-Smtp-Source: APXvYqwdIdKkfncw/FF82kiAT9FZ66v/Cb7DRcLVvgnHnRR74fAqF/FnaNE8byf8nhsoC8oKfatv X-Received: by 2002:a17:902:3a3:: with SMTP id d32mr42488887pld.14.1559117946082; Wed, 29 May 2019 01:19:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559117946; cv=none; d=google.com; s=arc-20160816; b=geXu4bZkLKOvAfs8J1lO4r3tUYFOqBr8/zcPUYf627H3NlSA6PkiorXGl5Y/UXae59 sWynFXWfcPNZXa+c9g6oWNTejbS6EXrrzEIn/pgKlbPqqN2K+w73kVgG0nZa27wWrZeg geVKWE4GQxLtqzu03JYMFQO3jvrlk7DVs9iqJ4G6/II53queQVJ7Im95I2TJySBcqJRB BLQB4TmViVapYg240390gR2tDhPlpqIiErs6YEbhSKmlGPbc4RqSXcLVOhWgLnOIeeXJ mVIW7wIwolPWX2Q9zgD2IDLdbtulAi6MJpQ9JiB8uxFBGIA7P5wqGh4C6izY9e0v2gsW Biqg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date; bh=Eekmt8ytDsp0wkAdhpLSCn8g2q06OcVeBrviSFcygow=; b=bDu9BxeMSLwKrSCGWtmgnpDosIZF16dM53o+ZsewsnNIYDT1xklM0yB+yqmFttGSy6 rB99t+mzynoV56WB+8v2h7Q3j5XmrvKWJ+zxJbJqAgBk9TV3jARTy7jOjEKUjTYOjGfn YKdVctlbb/NcodAuJwk1ADeWTjqAkcdaTsvZyJSKhNTA+UmuBhUR7QdbK92TKDvQMXoU zSasq1+EzXU1YT8eUJL15FwGKCR7CgLYVtD02TM8YUdP8aaC1vOFtgaYtg8zhjEfWDwE YgnDFeOEn94jnZGF9u6aYCv/GsrnSQcMnLY7bbaItFpc7e/Kb3uFNt6UlsrewY+tivAs sYfA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l93si5847317pjb.35.2019.05.29.01.18.49; Wed, 29 May 2019 01:19:06 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726855AbfE2IRR (ORCPT + 99 others); Wed, 29 May 2019 04:17:17 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34218 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725956AbfE2IRR (ORCPT ); Wed, 29 May 2019 04:17:17 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6A60781F12; Wed, 29 May 2019 08:17:09 +0000 (UTC) Received: from carbon (ovpn-200-30.brq.redhat.com [10.40.200.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7F45760BDF; Wed, 29 May 2019 08:17:01 +0000 (UTC) Date: Wed, 29 May 2019 10:16:59 +0200 From: Jesper Dangaard Brouer To: Ivan Khoronzhuk Cc: grygorii.strashko@ti.com, hawk@kernel.org, davem@davemloft.net, ast@kernel.org, linux-kernel@vger.kernel.org, linux-omap@vger.kernel.org, xdp-newbies@vger.kernel.org, ilias.apalodimas@linaro.org, netdev@vger.kernel.org, daniel@iogearbox.net, jakub.kicinski@netronome.com, john.fastabend@gmail.com, brouer@redhat.com Subject: Re: [PATCH net-next 3/3] net: ethernet: ti: cpsw: add XDP support Message-ID: <20190529101659.2aa714b8@carbon> In-Reply-To: <20190523182035.9283-4-ivan.khoronzhuk@linaro.org> References: <20190523182035.9283-1-ivan.khoronzhuk@linaro.org> <20190523182035.9283-4-ivan.khoronzhuk@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Wed, 29 May 2019 08:17:17 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 23 May 2019 21:20:35 +0300 Ivan Khoronzhuk wrote: > +static struct page *cpsw_alloc_page(struct cpsw_common *cpsw) > +{ > + struct page_pool *pool = cpsw->rx_page_pool; > + struct page *page, *prev_page = NULL; > + int try = pool->p.pool_size << 2; > + int start_free = 0, ret; > + > + do { > + page = page_pool_dev_alloc_pages(pool); > + if (!page) > + return NULL; > + > + /* if netstack has page_pool recycling remove the rest */ > + if (page_ref_count(page) == 1) > + break; > + > + /* start free pages in use, shouldn't happen */ > + if (prev_page == page || start_free) { > + /* dma unmap/puts page if rfcnt != 1 */ > + page_pool_recycle_direct(pool, page); > + start_free = 1; > + continue; > + } > + > + /* if refcnt > 1, page has been holding by netstack, it's pity, > + * so put it to the ring to be consumed later when fast cash is > + * empty. If ring is full then free page by recycling as above. > + */ > + ret = ptr_ring_produce(&pool->ring, page); This looks very wrong to me! First of all you are manipulation directly with the internal pool->ring and not using the API, which makes this code un-maintainable. Second this is wrong, as page_pool assume the in-variance that pages on the ring have refcnt==1. > + if (ret) { > + page_pool_recycle_direct(pool, page); > + continue; > + } > + > + if (!prev_page) > + prev_page = page; > + } while (try--); > + > + return page; > +} -- Best regards, Jesper Dangaard Brouer MSc.CS, Principal Kernel Engineer at Red Hat LinkedIn: http://www.linkedin.com/in/brouer