DPDK patches and discussions
 help / color / mirror / Atom feed
From: Maxime Coquelin <maxime.coquelin@redhat.com>
To: "Chautru, Nicolas" <nicolas.chautru@intel.com>,
	David Marchand <david.marchand@redhat.com>
Cc: Stephen Hemminger <stephen@networkplumber.org>,
	"dev@dpdk.org" <dev@dpdk.org>, "Rix, Tom" <trix@redhat.com>,
	"hemant.agrawal@nxp.com" <hemant.agrawal@nxp.com>,
	"Vargas, Hernan" <hernan.vargas@intel.com>
Subject: Re: [PATCH v1 1/1] doc: announce change in bbdev api related to operation extension
Date: Tue, 13 Jun 2023 22:00:25 +0200	[thread overview]
Message-ID: <8f201884-8a40-468e-c02a-52bc5e646024@redhat.com> (raw)
In-Reply-To: <BY5PR11MB4451D99CC29DBB4F3847EA49F855A@BY5PR11MB4451.namprd11.prod.outlook.com>

Hi,

On 6/13/23 19:16, Chautru, Nicolas wrote:
> Hi Maxime,
> 
>> -----Original Message-----
>> From: Maxime Coquelin <maxime.coquelin@redhat.com>
> 
>>
>> On 6/12/23 22:53, Chautru, Nicolas wrote:
>>> Hi Maxime, David,
>>>
>>>> -----Original Message-----
>>>> From: Maxime Coquelin <maxime.coquelin@redhat.com>
>>>>
>>>> On 6/6/23 23:01, Chautru, Nicolas wrote:
>>>>> Hi David,
>>>>>
>>>>>> -----Original Message-----
>>>>>> From: David Marchand <david.marchand@redhat.com>> >> On Mon, Jun
>> 5,
>>>>>> 2023 at 10:08 PM Chautru, Nicolas <nicolas.chautru@intel.com>
>>>>>> wrote:
>>>>>>> Wrt the MLD functions: these are new into the related serie but
>>>>>>> still the
>>>>>> break the ABI since the struct rte_bbdev includes these functions
>>>>>> hence causing offset changes.
>>>>>>>
>>>>>>> Should I then just rephrase as:
>>>>>>>
>>>>>>> +* bbdev: Will extend the API to support the new operation type
>>>>>>>     +``RTE_BBDEV_OP_MLDTS`` as per
>>>>>>>     +  this `v1
>>>>>>>     +<https://patches.dpdk.org/project/dpdk/list/?series=28192>`.
>>>>>>> This
>>>>>>> + will notably introduce  +  new symbols for
>>>>>>> ``rte_bbdev_dequeue_mldts_ops``,  +``rte_bbdev_enqueue_mldts_ops``
>>>>>>> into the stuct rte_bbdev.
>>>>>>
>>>>>> I don't think we need this deprecation notice.
>>>>>>
>>>>>>
>>>>>> Do you need to expose those new mldts ops in rte_bbdev?
>>>>>> Can't they go to dev_ops?
>>>>>> If you can't, at least moving those new ops at the end of the
>>>>>> structure would avoid the breakage on rte_bbdev.
>>>>>
>>>>> It would probably be best to move all these ops at the end of the
>>>>> structure
>>>> (ie. keep them together).
>>>>> In that case the deprecation notice would call out that the
>>>>> rte_bbdev
>>>> structure content is more generally modified. Probably best for the
>>>> longer run.
>>>>> David, Maxime, ok with that option?
>>>>>
>>>>> struct __rte_cache_aligned rte_bbdev {
>>>>>         rte_bbdev_enqueue_enc_ops_t enqueue_enc_ops;
>>>>>         rte_bbdev_enqueue_dec_ops_t enqueue_dec_ops;
>>>>>         rte_bbdev_dequeue_enc_ops_t dequeue_enc_ops;
>>>>>         rte_bbdev_dequeue_dec_ops_t dequeue_dec_ops;
>>>>>         rte_bbdev_enqueue_enc_ops_t enqueue_ldpc_enc_ops;
>>>>>         rte_bbdev_enqueue_dec_ops_t enqueue_ldpc_dec_ops;
>>>>>         rte_bbdev_dequeue_enc_ops_t dequeue_ldpc_enc_ops;
>>>>>         rte_bbdev_dequeue_dec_ops_t dequeue_ldpc_dec_ops;
>>>>>         rte_bbdev_enqueue_fft_ops_t enqueue_fft_ops;
>>>>>         rte_bbdev_dequeue_fft_ops_t dequeue_fft_ops;
>>>>>         const struct rte_bbdev_ops *dev_ops;
>>>>>         struct rte_bbdev_data *data;
>>>>>         enum rte_bbdev_state state;
>>>>>         struct rte_device *device;
>>>>>         struct rte_bbdev_cb_list list_cbs;
>>>>>         struct rte_intr_handle *intr_handle;
>>>>>     };
>>>>
>>>> The best thing, as suggested by David, would be to move all the ops
>>>> out of struct rte_bbdev, as these should not be visible to the application.
>>>
>>> That would be quite disruptive across all PMDs and possible perf impact to
>> validate. I don’t think this is anywhere realistic to consider such a change in
>> 23.11.
>>> I believe moving these function at the end of the structure is a good
>> compromise to avoid future breakage of rte_bbdev structure with almost
>> seamless impact (purely a ABI break when moving into 23.11 which is not
>> avoidable. Retrospectively we should have done that in 22.11 really.
>>
>> If we are going to break the ABI, better to do the right rework directly. Otherwise
>> we'll end-up breaking it again next year.
> 
> With the suggested change, this will not break ABI next year. Any future functions are added at the end of the structure anyway.

I'm not so sure, it depends if adding a new field at the end cross a 
cacheline boundary or not:

/*
  * Global array of all devices. This is not static because it's used by the
  * inline enqueue and dequeue functions
  */
struct rte_bbdev rte_bbdev_devices[RTE_BBDEV_MAX_DEVS];

If the older inlined functions used by the application retrieve the dev
pointer from the array directly (they do) and added new fields in new
version cross a cacheline, then there will be a misalignement between
the new lib version and the application using the older inlined
functions.

ABI-wise, this is not really future proof.

> 
>>
>> IMHO, moving these ops should be quite trivial and not much work.
>>
>> Otherwise, if we just placed the rte_bbdev_dequeue_mldts_ops and
>> rte_bbdev_enqueue_mldts_ops at the bottom of struct rte_bbdev, it may not
>> break the ABI, but that's a bit fragile:
>> - rte_bbdev_devices[] is not static, but is placed in the BSS section so
>>     should be OK
>> - struct rte_bbdev is cache-aligned, so it may work if adding these two
>>     ops do not overlap a cacheline which depends on the CPU architecture.
> 
> If you prefer to add the only 2 new functions at the end of the structure that is okay. I believe it would be cleaner to move all these enqueue/dequeue funs down together without drawback I can think of. Let me know.

Adding the new ones at the end is not future proof, but at least it does 
not break ABI just for cosmetic reasons (that's a big drawback IMHO).

I just checked using pahole:

struct rte_bbdev {
	rte_bbdev_enqueue_enc_ops_t enqueue_enc_ops;     /*     0     8 */
	rte_bbdev_enqueue_dec_ops_t enqueue_dec_ops;     /*     8     8 */
	rte_bbdev_dequeue_enc_ops_t dequeue_enc_ops;     /*    16     8 */
	rte_bbdev_dequeue_dec_ops_t dequeue_dec_ops;     /*    24     8 */
	rte_bbdev_enqueue_enc_ops_t enqueue_ldpc_enc_ops; /*    32     8 */
	rte_bbdev_enqueue_dec_ops_t enqueue_ldpc_dec_ops; /*    40     8 */
	rte_bbdev_dequeue_enc_ops_t dequeue_ldpc_enc_ops; /*    48     8 */
	rte_bbdev_dequeue_dec_ops_t dequeue_ldpc_dec_ops; /*    56     8 */
	/* --- cacheline 1 boundary (64 bytes) --- */
	rte_bbdev_enqueue_fft_ops_t enqueue_fft_ops;     /*    64     8 */
	rte_bbdev_dequeue_fft_ops_t dequeue_fft_ops;     /*    72     8 */
	const struct rte_bbdev_ops  * dev_ops;           /*    80     8 */
	struct rte_bbdev_data *    data;                 /*    88     8 */
	enum rte_bbdev_state       state;                /*    96     4 */

	/* XXX 4 bytes hole, try to pack */

	struct rte_device *        device;               /*   104     8 */
	struct rte_bbdev_cb_list   list_cbs;             /*   112    16 */
	/* --- cacheline 2 boundary (128 bytes) --- */
	struct rte_intr_handle *   intr_handle;          /*   128     8 */

	/* size: 192, cachelines: 3, members: 16 */
	/* sum members: 132, holes: 1, sum holes: 4 */
	/* padding: 56 */
} __attribute__((__aligned__(64)));

We're lucky on x86, we still have 56 bytes, so we can add 7 new ops at 
the end before breaking the ABI if I'm not mistaken.

I checked the other architecture, and it seems we don't support any with
32B cacheline size so we're good for a while.

Maxime

> 
>>
>> Maxime
>>
>>> What do you think Maxime, David? Based on this I can adjust the change for
>> 23.11 and update slightly the deprecation notice accordingly.
>>>
>>> Thanks
>>> Nic
>>>
> 


  reply	other threads:[~2023-06-13 20:00 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-26  2:11 [PATCH v1 0/1] doc: accounce change in bbdev extension Nicolas Chautru
2023-05-26  2:11 ` [PATCH v1 1/1] doc: announce change in bbdev api related to operation extension Nicolas Chautru
2023-05-26  3:47   ` Stephen Hemminger
2023-06-05 19:07     ` Maxime Coquelin
2023-06-05 20:08       ` Chautru, Nicolas
2023-06-06  9:20         ` David Marchand
2023-06-06 21:01           ` Chautru, Nicolas
2023-06-08  8:47             ` Maxime Coquelin
2023-06-12 20:53               ` Chautru, Nicolas
2023-06-13  8:14                 ` Maxime Coquelin
2023-06-13 17:16                   ` Chautru, Nicolas
2023-06-13 20:00                     ` Maxime Coquelin [this message]
2023-06-13 21:22                       ` Stephen Hemminger
2023-06-14 18:18                       ` Chautru, Nicolas
2023-06-15  7:52                         ` Maxime Coquelin
2023-06-15 19:30                           ` Chautru, Nicolas
2023-06-16  7:36                             ` Maxime Coquelin
2023-06-16 15:48                               ` Chautru, Nicolas

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=8f201884-8a40-468e-c02a-52bc5e646024@redhat.com \
    --to=maxime.coquelin@redhat.com \
    --cc=david.marchand@redhat.com \
    --cc=dev@dpdk.org \
    --cc=hemant.agrawal@nxp.com \
    --cc=hernan.vargas@intel.com \
    --cc=nicolas.chautru@intel.com \
    --cc=stephen@networkplumber.org \
    --cc=trix@redhat.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).