Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp6106060ybi; Wed, 29 May 2019 02:59:56 -0700 (PDT) X-Google-Smtp-Source: APXvYqyoYIer3aY+freihm49DrkkcT5ssm1N2o/Xr1wJo4ZFsyb2ovETnZRZM06X1iVVaf6HgCyS X-Received: by 2002:a62:d205:: with SMTP id c5mr145971989pfg.219.1559123996693; Wed, 29 May 2019 02:59:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559123996; cv=none; d=google.com; s=arc-20160816; b=h8ciMltU8RlaU/md0XJBx0vBjNvqzRpvyY+ItQ27fUDvxg53QjLvPyKgHZWZlFpHpO 3WHPpElnv1oIoOGeQ3ymMKXHn3iGshGYv6o48cSBhDjZ0fGiToeomp1RkQ7DbxMj1izH eTr5sJ/gJ/n0LCsMR236yk0qG0tMz+act7qsOFlPBjlijPKwCq0H2NhDZPXknKw+cHk9 7MrVJpYJ5umtF7/LqvB3OS/P2PkB1Sr48kFLVPGMs2pl/AcfeD5LbXS8sFfWg7jPvC1t 7KU9AhvrcbtiXR6+ZlPXJQPNUXX/qjtigPktqXFHLupmeDH28fgOPAY8WYSMT640pnK1 a/yA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:mail-followup-to :message-id:subject:cc:to:from:date:dkim-signature; bh=/sVA9YKu8BEhrQsD2y3FdbEDwI/iZvTti9LgKUCmCho=; b=BcPDpM/cDAxpoTu5uzA2rg82zlw/QE1b5qFr9ufX6c5crbpEJH6/c1f5rIGUOl8UYb 9HbDTvSswOQSUFrzRSFYWUcooiQ+XpX1lqVXp7uWmhX1wXnXKJwEV6+/4TJvzh7N+Sox eMoF1lQ5YjXRcgmhYN8BDDqJkr+vHA0snA0c5Fj048vdq7yKZBPZlmRy2nbpgWi3GpGU 0uLnAKTQq/wbcSHCKqrWdIMDK7AYByLemilt2dISxrlfavHRq4u7Rfbmk53feCnyO/S6 qobmL5WdDTz3qaLwA3RSxEoYTUXBHk36aoYmdpeceUeqJGReA58u/dkjRpcKxPscaVbH iZcQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=g+VZs9Wx; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q7si23704998pgp.245.2019.05.29.02.59.39; Wed, 29 May 2019 02:59:56 -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; dkim=pass header.i=@linaro.org header.s=google header.b=g+VZs9Wx; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726721AbfE2J6W (ORCPT + 99 others); Wed, 29 May 2019 05:58:22 -0400 Received: from mail-lj1-f193.google.com ([209.85.208.193]:35585 "EHLO mail-lj1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726516AbfE2J6U (ORCPT ); Wed, 29 May 2019 05:58:20 -0400 Received: by mail-lj1-f193.google.com with SMTP id h11so1830878ljb.2 for ; Wed, 29 May 2019 02:58:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:mail-followup-to:references :mime-version:content-disposition:in-reply-to:user-agent; bh=/sVA9YKu8BEhrQsD2y3FdbEDwI/iZvTti9LgKUCmCho=; b=g+VZs9Wxzz58VQ5DfHuZCBSCmF8aIdt6hK2FWdf0aNvXP76PgEkEf4YXVcL7dYgQHM VpIeRvv5y1ZohW1l8kwQ1c890KodOvZp0InN/sTV9/KjSQEYcDEXqVue1N/EBRHpf1UD m2osWXg00PBOXJjV+EHuOoBB/GHktgYIA/LqkSY+ZUWgKu/urkNwpq8DWtOZTc/6egeV NE9etHNAxCUyYK3TH6bo2fQpZRnnr2lM4RfGEc0eiN2Z5wGJFVIrFscKwD7vSDgBc/hK 4aRzH1y/V6P1mdWF4oOeZZp/vj/703I/BX3k0UU3AVEA9WhXraoDNNN8qLYYSnRy2aNC TitA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id :mail-followup-to:references:mime-version:content-disposition :in-reply-to:user-agent; bh=/sVA9YKu8BEhrQsD2y3FdbEDwI/iZvTti9LgKUCmCho=; b=Wm9LkIfnuJNGOkLO+Xqirwn+FppkFqblX2qrQyaFpKJ3tzzuQA8mIvxHLt9BJg66jk zLWUptNroF2sW0YfymR3Moq0cpFExCV/pRwv9eggkFOT34g0XXcvCbW9aAnYQJ+L01Q+ 85N+P/TY+b5fVOd7j6KJlPOhh2k4r6hWJfwFrNBKyNpuHTCIm8uJ/tIoK3KTr/Ewjtfs LZnzqEheSyonE41JObmkRBAEl1Pa5kzsXslVH/zvPyNtbzX8OEGb9pu4nT4VG8cXkxf6 eyIpBk2qNNNo8A7Mic9+RuOBBepPLqMG7q866XBPsRCLTioitj1n3Cu0yim47a/PsOmx NTAQ== X-Gm-Message-State: APjAAAWLCnOG+/hBP7PbQCSgmm06E2LxnJzMYfG1kQ0PGU6qNwTWo2k7 COpe8CDfDkXcgW+TpSg9xZDrWw== X-Received: by 2002:a2e:9c09:: with SMTP id s9mr39657738lji.74.1559123899025; Wed, 29 May 2019 02:58:19 -0700 (PDT) Received: from khorivan (59-201-94-178.pool.ukrtel.net. [178.94.201.59]) by smtp.gmail.com with ESMTPSA id h10sm3937299ljm.9.2019.05.29.02.58.17 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 29 May 2019 02:58:18 -0700 (PDT) Date: Wed, 29 May 2019 12:58:16 +0300 From: Ivan Khoronzhuk To: Jesper Dangaard Brouer 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 Subject: Re: [PATCH net-next 3/3] net: ethernet: ti: cpsw: add XDP support Message-ID: <20190529095814.GA4639@khorivan> Mail-Followup-To: Jesper Dangaard Brouer , 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 References: <20190523182035.9283-1-ivan.khoronzhuk@linaro.org> <20190523182035.9283-4-ivan.khoronzhuk@linaro.org> <20190529101659.2aa714b8@carbon> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <20190529101659.2aa714b8@carbon> User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, May 29, 2019 at 10:16:59AM +0200, Jesper Dangaard Brouer wrote: >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. Yes I know, it's hack, it was with assumption to be dropped once page_pool recycling is added. >Second this is wrong, as page_pool >assume the in-variance that pages on the ring have refcnt==1. Yes, but this is w/o obvious reason, seems like it can work with refcnt > 1 if remove restriction and use >= instead of ==. As I answered on Ilias comment, I'm going to leave version from RFC and drop this one. > >> + 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 -- Regards, Ivan Khoronzhuk