DPDK patches and discussions
 help / color / mirror / Atom feed
From: huangdengdui <huangdengdui@huawei.com>
To: "Morten Brørup" <mb@smartsharesystems.com>, dev@dpdk.org
Cc: <stephen@networkplumber.org>, <david.marchand@redhat.com>,
	<roretzla@linux.microsoft.com>, <lihuisong@huawei.com>,
	<fengchengwen@huawei.com>, <liuyonglong@huawei.com>
Subject: Re: [PATCH v4] eal: fix uncheck lcore ID and lcore role
Date: Thu, 7 Aug 2025 10:43:09 +0800	[thread overview]
Message-ID: <079a2899-b2c4-4e50-b67a-eaff5b04e9ec@huawei.com> (raw)
In-Reply-To: <98CBD80474FA8B44BF855DF32C47DC35E9FDC0@smartserver.smartshare.dk>


On 2025/7/24 22:44, Morten Brørup wrote:
>> From: Dengdui Huang [mailto:huangdengdui@huawei.com]
>> Sent: Thursday, 24 July 2025 13.26
>>
>> The worker_id may come from user input. So it is necessary to verify it.
>>
>> In addition, only the lcore whose role is ROLE_RTE or ROLE_SERVICE can
>> be
>> launched. This patch adds the lcore role check.
>>
>> Fixes: a95d70547c57 ("eal: factorize lcore main loop")
>> Cc: stable@dpdk.org
>>
>> Signed-off-by: Dengdui Huang <huangdengdui@huawei.com>
>> ---
>>  lib/eal/common/eal_common_launch.c | 18 ++++++++++++++++++
>>  1 file changed, 18 insertions(+)
>>
>> diff --git a/lib/eal/common/eal_common_launch.c
>> b/lib/eal/common/eal_common_launch.c
>> index a7deac6ecd..09366ea404 100644
>> --- a/lib/eal/common/eal_common_launch.c
>> +++ b/lib/eal/common/eal_common_launch.c
>> @@ -20,6 +20,9 @@ RTE_EXPORT_SYMBOL(rte_eal_wait_lcore)
>>  int
>>  rte_eal_wait_lcore(unsigned worker_id)
>>  {
>> +	if (unlikely(worker_id >= RTE_MAX_LCORE))
>> +		return -EINVAL;
>> +
>>  	while (rte_atomic_load_explicit(&lcore_config[worker_id].state,
>>  			rte_memory_order_acquire) != WAIT)
>>  		rte_pause();
>> @@ -37,6 +40,18 @@ int
>>  rte_eal_remote_launch(lcore_function_t *f, void *arg, unsigned int
>> worker_id)
>>  {
>>  	int rc = -EBUSY;
>> +	uint8_t role;
> 
> Use the correct type:
> enum rte_lcore_role_t role;

OK, I made a mistake, and I will fix it in the next version.

> 
>> +
>> +	if (unlikely(worker_id >= RTE_MAX_LCORE)) {
>> +		rc = -EINVAL;
>> +		goto finish;
>> +	}
>> +
>> +	role = lcore_config[worker_id].core_role;
>> +	if (role != ROLE_RTE && role != ROLE_SERVICE) {
>> +		rc = -EINVAL;
>> +		goto finish;
>> +	}
>>
>>  	/* Check if the worker is in 'WAIT' state. Use acquire order
>>  	 * since 'state' variable is used as the guard variable.
>> @@ -98,6 +113,9 @@ RTE_EXPORT_SYMBOL(rte_eal_get_lcore_state)
>>  enum rte_lcore_state_t
>>  rte_eal_get_lcore_state(unsigned lcore_id)
>>  {
>> +	if (unlikely(lcore_id >= RTE_MAX_LCORE))
>> +		return -EINVAL;
> 
> The return type of this function is enum rte_lcore_state_t, so it cannot return (int)-EINVAL.
> 
> Maybe it's better to update the function's documentation instead of its implementation.
> Like the documentation of the lcore_id parameter passed to rte_eal_lcore_role():
> https://elixir.bootlin.com/dpdk/v25.07/source/lib/eal/include/rte_lcore.h#L44
> 
> After further consideration, updating the documentation might also be a better solution for the other functions.

This is a better solution, and I will do it in the next version.

> 
> If you add a new return value (-EINVAL) to a function, it must be listed in function's documentation, and in the documentation of functions calling that function.


> 
>> +
>>  	return lcore_config[lcore_id].state;
>>  }
>>
>> --
>> 2.33.0
> 
> 

  reply	other threads:[~2025-08-07  2:43 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-21  4:03 [PATCH 0/2] fix the problem of dma-perf infinite loop Dengdui Huang
2025-03-21  4:03 ` [PATCH 1/2] eal: fix wake a incorrect lcore Dengdui Huang
2025-03-21  4:03 ` [PATCH 2/2] app/dma-perf: fix infinite loop Dengdui Huang
2025-03-21 15:58   ` Stephen Hemminger
2025-03-24  3:42     ` huangdengdui
2025-03-21  7:49 ` [PATCH 0/2] fix the problem of dma-perf " David Marchand
2025-03-24  3:42   ` huangdengdui
2025-03-27  8:58 ` [PATCH] app/dma-perf: fix " Dengdui Huang
2025-03-27  8:58   ` [PATCH 1/2] eal: fix uncheck worker ID Dengdui Huang
2025-03-27  8:58   ` [PATCH 2/2] app/dma-perf: fix infinite loop Dengdui Huang
2025-03-27  9:01 ` [PATCH v2 0/2] fix the problem of dma-perf " Dengdui Huang
2025-03-27  9:01   ` [PATCH v2 1/2] eal: fix uncheck worker ID Dengdui Huang
2025-03-27  9:32     ` Morten Brørup
2025-04-02  8:28       ` huangdengdui
2025-03-27  9:01   ` [PATCH v2 2/2] app/dma-perf: fix infinite loop Dengdui Huang
2025-04-02 12:24 ` [PATCH v3 0/3] fix the problem of dma-perf " Dengdui Huang
2025-04-02 12:24   ` [PATCH v3 1/3] eal: fix uncheck lcore ID Dengdui Huang
2025-04-02 12:24   ` [PATCH v3 2/3] eal: fix unckeck pipe Dengdui Huang
2025-04-02 14:45     ` Morten Brørup
2025-04-03  8:12       ` huangdengdui
2025-04-02 12:24   ` [PATCH v3 3/3] app/dma-perf: fix infinite loop Dengdui Huang
2025-07-24 11:25 ` [PATCH v4] eal: fix uncheck lcore ID and lcore role Dengdui Huang
2025-07-24 14:44   ` Morten Brørup
2025-08-07  2:43     ` huangdengdui [this message]
2025-08-07  2:49   ` [PATCH v5] eal: fix uncheck " Dengdui Huang
2025-08-07  3:15     ` Stephen Hemminger
2025-08-07  3:57       ` huangdengdui

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=079a2899-b2c4-4e50-b67a-eaff5b04e9ec@huawei.com \
    --to=huangdengdui@huawei.com \
    --cc=david.marchand@redhat.com \
    --cc=dev@dpdk.org \
    --cc=fengchengwen@huawei.com \
    --cc=lihuisong@huawei.com \
    --cc=liuyonglong@huawei.com \
    --cc=mb@smartsharesystems.com \
    --cc=roretzla@linux.microsoft.com \
    --cc=stephen@networkplumber.org \
    /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).