DPDK patches and discussions
 help / color / mirror / Atom feed
From: Ferruh Yigit <ferruh.yigit@intel.com>
To: Igor Ryzhov <iryzhov@nfware.com>, dev@dpdk.org
Subject: Re: [dpdk-dev] [PATCH v2] kni: dynamically allocate memory for each KNI
Date: Wed, 26 Sep 2018 11:41:19 +0100	[thread overview]
Message-ID: <594e0f5a-7f4f-5713-3cdf-d41e492e0a04@intel.com> (raw)
In-Reply-To: <20180923191202.64896-1-iryzhov@nfware.com>

On 9/23/2018 8:12 PM, Igor Ryzhov wrote:
> Long time ago preallocation of memory for KNI was introduced in commit
> 0c6bc8e. It was done because of lack of ability to free previously
> allocated memzones, which led to memzone exhaustion. Currently memzones
> can be freed and this patch uses this ability for dynamic KNI memory
> allocation. 

Hi Igor,

Good cleanup, thanks.
+1 to eal_tailq for ctx

A few minor comments below, but they are not significant enough to block the
patch, please let us know if you don't have bandwidth for a new version.

> Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
<...>

> @@ -294,41 +180,52 @@ rte_kni_alloc(struct rte_mempool *pktmbuf_pool,
>  {
>  	int ret;
>  	struct rte_kni_device_info dev_info;
> -	struct rte_kni *ctx;
> -	char intf_name[RTE_KNI_NAMESIZE];
> -	const struct rte_memzone *mz;
> -	struct rte_kni_memzone_slot *slot = NULL;
> +	struct rte_kni *kni;
> +	struct rte_tailq_entry *te = NULL;
> +	struct rte_kni_list *kni_list;
> +
> +	kni_list = RTE_TAILQ_CAST(rte_kni_tailq.head, rte_kni_list);

Can you move this below input validation, no need this assignment if API will
fail because of wrong input.

>  	if (!pktmbuf_pool || !conf || !conf->name[0])
>  		return NULL;
>  
>  	/* Check if KNI subsystem has been initialized */
> -	if (kni_memzone_pool.initialized != 1) {
> +	if (kni_fd < 0) {
>  		RTE_LOG(ERR, KNI, "KNI subsystem has not been initialized. Invoke rte_kni_init() first\n");
>  		return NULL;
>  	}
>  
> -	/* Get an available slot from the pool */
> -	slot = kni_memzone_pool_alloc();
> -	if (!slot) {
> -		RTE_LOG(ERR, KNI, "Cannot allocate more KNI interfaces; increase the number of max_kni_ifaces(current %d) or release unused ones.\n",
> -			kni_memzone_pool.max_ifaces);
> -		return NULL;
> +	rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
> +
> +	TAILQ_FOREACH(te, kni_list, next) {
> +		kni = (struct rte_kni *) te->data;
> +		if (strncmp(conf->name, kni->name, RTE_KNI_NAMESIZE) == 0)
> +			break;
>  	}

This is rte_kni_get(), why not reuse it. You can create an version of it without
lock.

like _rte_kni_get() which you can call here.

And
rte_kni_get()
	rte_rwlock_read_lock(RTE_EAL_TAILQ_RWLOCK);
	_rte_kni_get()
	rte_rwlock_read_unlock(RTE_EAL_TAILQ_RWLOCK);

<...>

> +
> +	if (te == NULL) {
> +		goto unlock;
> +	}

No need {} for single line.
One more below.

  reply	other threads:[~2018-09-26 10:41 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-02 14:25 [dpdk-dev] [PATCH] " Igor Ryzhov
2018-08-27 17:06 ` Ferruh Yigit
2018-08-29  9:52   ` Igor Ryzhov
2018-08-30 10:55     ` Ferruh Yigit
2018-09-23 19:12 ` [dpdk-dev] [PATCH v2] " Igor Ryzhov
2018-09-26 10:41   ` Ferruh Yigit [this message]
2018-09-26 13:31     ` Igor Ryzhov
2018-09-26 16:21   ` [dpdk-dev] [PATCH v3] " Igor Ryzhov
2018-09-27 19:20     ` Ferruh Yigit
2018-10-02 13:06     ` Thomas Monjalon
2018-10-02 13:27       ` Ferruh Yigit
2018-10-02 13:27         ` Ferruh Yigit
2018-10-02 15:29     ` Thomas Monjalon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=594e0f5a-7f4f-5713-3cdf-d41e492e0a04@intel.com \
    --to=ferruh.yigit@intel.com \
    --cc=dev@dpdk.org \
    --cc=iryzhov@nfware.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).