From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <dev-bounces@dpdk.org>
Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124])
	by inbox.dpdk.org (Postfix) with ESMTP id DE34F42D76;
	Wed, 28 Jun 2023 03:25:10 +0200 (CEST)
Received: from mails.dpdk.org (localhost [127.0.0.1])
	by mails.dpdk.org (Postfix) with ESMTP id B856C406B3;
	Wed, 28 Jun 2023 03:25:10 +0200 (CEST)
Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188])
 by mails.dpdk.org (Postfix) with ESMTP id ACA9040151
 for <dev@dpdk.org>; Wed, 28 Jun 2023 03:25:08 +0200 (CEST)
Received: from dggpeml100024.china.huawei.com (unknown [172.30.72.57])
 by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4QrP4Z3TJFzTlfn;
 Wed, 28 Jun 2023 09:24:14 +0800 (CST)
Received: from [10.67.100.224] (10.67.100.224) by
 dggpeml100024.china.huawei.com (7.185.36.115) with Microsoft SMTP Server
 (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id
 15.1.2507.27; Wed, 28 Jun 2023 09:25:05 +0800
From: fengchengwen <fengchengwen@huawei.com>
Subject: Re: [PATCH v14 5/6] memarea: support dump API
To: "Burakov, Anatoly" <anatoly.burakov@intel.com>, <thomas@monjalon.net>,
 <david.marchand@redhat.com>
CC: <dev@dpdk.org>, <mb@smartsharesystems.com>, <dmitry.kozliuk@gmail.com>,
 <jerinjacobk@gmail.com>, <hofors@lysator.liu.se>,
 <stephen@networkplumber.org>
References: <20220721044648.6817-1-fengchengwen@huawei.com>
 <20230209063610.35501-1-fengchengwen@huawei.com>
 <20230209063610.35501-6-fengchengwen@huawei.com>
 <5cccddc4-7aef-d261-be78-536d3839dbc2@intel.com>
Message-ID: <737ba792-19f9-bd35-82df-68218b54bc2e@huawei.com>
Date: Wed, 28 Jun 2023 09:25:05 +0800
User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101
 Thunderbird/68.11.0
MIME-Version: 1.0
In-Reply-To: <5cccddc4-7aef-d261-be78-536d3839dbc2@intel.com>
Content-Type: text/plain; charset="utf-8"
Content-Language: en-US
Content-Transfer-Encoding: 8bit
X-Originating-IP: [10.67.100.224]
X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To
 dggpeml100024.china.huawei.com (7.185.36.115)
X-CFilter-Loop: Reflected
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: DPDK patches and discussions <dev.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
Errors-To: dev-bounces@dpdk.org

Hi Anatoly,

  Thanks for your review, a lot of valuable advice.

  PS: This library stays for a long time, want to hear TB's opinion: whether to continue or stop.
      If continue I will push a new version.

Thanks.

On 2023/6/22 23:55, Burakov, Anatoly wrote:
> On 2/9/2023 6:36 AM, Chengwen Feng wrote:
>> This patch supports rte_memarea_dump() API which could be used for
>> debug.
>>
>> Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
>> Reviewed-by: Dongdong Liu <liudongdong3@huawei.com>
>> Acked-by: Morten Brørup <mb@smartsharesystems.com>
>> ---
> 
> Provisionally,
> 
> Acked-by: Anatoly Burakov <anatoly.burakov@intel.com>
> 
> As long as below is addressed.
> 
>> +static void
>> +memarea_dump_objects_detail(struct rte_memarea *ma, FILE *f)
>> +{
>> +    struct memarea_objhdr *hdr;
>> +    size_t offset;
>> +    void *ptr;
>> +
>> +    fprintf(f, "  objects:\n");
>> +    TAILQ_FOREACH(hdr, &ma->obj_list, obj_next) {
>> +        if (hdr == ma->guard_hdr)
>> +            break;
>> +        memarea_check_cookie(ma, hdr, 2);
>> +        ptr = RTE_PTR_ADD(hdr, sizeof(struct memarea_objhdr));
>> +        offset = RTE_PTR_DIFF(ptr, ma->area_base);
>> +#ifdef RTE_LIBRTE_MEMAREA_DEBUG
>> +        fprintf(f, "    %p off: 0x%zx size: 0x%zx %s\n",
>> +            ptr, offset, MEMAREA_OBJECT_GET_SIZE(hdr),
>> +            MEMAREA_OBJECT_IS_ALLOCATED(hdr) ? "allocated" : "");
>> +#else
>> +        fprintf(f, "    off: 0x%zx size: 0x%zx %s\n",
>> +            offset, MEMAREA_OBJECT_GET_SIZE(hdr),
>> +            MEMAREA_OBJECT_IS_ALLOCATED(hdr) ? "allocated" : "");
>> +#endif
>> +    }.
>> +}
>> +
>> +int
>> +rte_memarea_dump(struct rte_memarea *ma, FILE *f, bool dump_all)
>> +{
>> +    if (ma == NULL || f == NULL)
>> +        return -EINVAL;
> 
> I feel like the API is inconsistent in this way. I would suggest picking a method of error reporting, and sticking with it. I would suggest returning 0/-1 or ptr/NULL with rte_errno set to indicate error, as that is how most libraries in DPDK behave.
>