From: "Morten Brørup" <mb@smartsharesystems.com>
To: "Ananyev, Konstantin" <konstantin.ananyev@intel.com>,
"Yigit, Ferruh" <ferruh.yigit@intel.com>,
"Thomas Monjalon" <thomas@monjalon.net>,
"Richardson, Bruce" <bruce.richardson@intel.com>
Cc: <dev@dpdk.org>, <olivier.matz@6wind.com>,
<andrew.rybchenko@oktetlabs.ru>, <honnappa.nagarahalli@arm.com>,
<jerinj@marvell.com>, <gakhil@marvell.com>
Subject: Re: [dpdk-dev] [PATCH] parray: introduce internal API for dynamic arrays
Date: Tue, 22 Jun 2021 15:18:55 +0200 [thread overview]
Message-ID: <98CBD80474FA8B44BF855DF32C47DC35C6187E@smartserver.smartshare.dk> (raw)
In-Reply-To: <DM6PR11MB44911C15E5D894A4FD5679F69A099@DM6PR11MB4491.namprd11.prod.outlook.com>
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Ananyev,
> Konstantin
>
> >
> > > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Ananyev,
> > > Konstantin
> > >
> > > >
> > > > > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Ananyev,
> > > > > Konstantin
> > > > >
> > > > > >
> > > > > > > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of
> Ananyev,
> > > > > > > Konstantin
> > > > > > >
> > > > > > > > > How can we hide the callbacks since they are used by
> inline
> > > > > burst
> > > > > > > functions.
> > > > > > > >
> > > > > > > > I probably I owe a better explanation to what I meant in
> > > first
> > > > > mail.
> > > > > > > > Otherwise it sounds confusing.
> > > > > > > > I'll try to write a more detailed one in next few days.
> > > > > > >
> > > > > > > Actually I gave it another thought over weekend, and might
> be
> > > we
> > > > > can
> > > > > > > hide rte_eth_dev_cb even in a simpler way. I'd use
> > > eth_rx_burst()
> > > > > as
> > > > > > > an example, but the same principle applies to other 'fast'
> > > > > functions.
> > > > > > >
> > > > > > > 1. Needed changes for PMDs rx_pkt_burst():
> > > > > > > a) change function prototype to accept 'uint16_t
> port_id'
> > > and
> > > > > > > 'uint16_t queue_id',
> > > > > > > instead of current 'void *'.
> > > > > > > b) Each PMD rx_pkt_burst() will have to call
> > > > > rte_eth_rx_epilog()
> > > > > > > function at return.
> > > > > > > This inline function will do all CB calls for
> that
> > > queue.
> > > > > > >
> > > > > > > To be more specific, let say we have some PMD: xyz with RX
> > > > > function:
> > > > > > >
> > > > > > > uint16_t
> > > > > > > xyz_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
> > > uint16_t
> > > > > > > nb_pkts)
> > > > > > > {
> > > > > > > struct xyz_rx_queue *rxq = rx_queue;
> > > > > > > uint16_t nb_rx = 0;
> > > > > > >
> > > > > > > /* do actual stuff here */
> > > > > > > ....
> > > > > > > return nb_rx;
> > > > > > > }
> > > > > > >
> > > > > > > It will be transformed to:
> > > > > > >
> > > > > > > uint16_t
> > > > > > > xyz_recv_pkts(uint16_t port_id, uint16_t queue_id, struct
> > > rte_mbuf
> > > > > > > **rx_pkts, uint16_t nb_pkts)
> > > > > > > {
> > > > > > > struct xyz_rx_queue *rxq;
> > > > > > > uint16_t nb_rx;
> > > > > > >
> > > > > > > rxq = _rte_eth_rx_prolog(port_id, queue_id);
> > > > > > > if (rxq == NULL)
> > > > > > > return 0;
> > > > > > > nb_rx = _xyz_real_recv_pkts(rxq, rx_pkts,
> nb_pkts);
> > > > > > > return _rte_eth_rx_epilog(port_id, queue_id,
> rx_pkts,
> > > > > > > nb_pkts);
> > > > > > > }
> > > > > > >
> > > > > > > And somewhere in ethdev_private.h:
> > > > > > >
> > > > > > > static inline void *
> > > > > > > _rte_eth_rx_prolog(uint16_t port_id, uint16_t queue_id);
> > > > > > > {
> > > > > > > struct rte_eth_dev *dev = &rte_eth_devices[port_id];
> > > > > > >
> > > > > > > #ifdef RTE_ETHDEV_DEBUG_RX
> > > > > > > RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, NULL);
> > > > > > > RTE_FUNC_PTR_OR_ERR_RET(*dev->rx_pkt_burst, NULL);
> > > > > > >
> > > > > > > if (queue_id >= dev->data->nb_rx_queues) {
> > > > > > > RTE_ETHDEV_LOG(ERR, "Invalid RX
> queue_id=%u\n",
> > > > > > > queue_id);
> > > > > > > return NULL;
> > > > > > > }
> > > > > > > #endif
> > > > > > > return dev->data->rx_queues[queue_id];
> > > > > > > }
> > > > > > >
> > > > > > > static inline uint16_t
> > > > > > > _rte_eth_rx_epilog(uint16_t port_id, uint16_t queue_id,
> struct
> > > > > rte_mbuf
> > > > > > > **rx_pkts, const uint16_t nb_pkts);
> > > > > > > {
> > > > > > > struct rte_eth_dev *dev = &rte_eth_devices[port_id];
> > > > > > >
> > > > > > > #ifdef RTE_ETHDEV_RXTX_CALLBACKS
> > > > > > > struct rte_eth_rxtx_callback *cb;
> > > > > > >
> > > > > > > /* __ATOMIC_RELEASE memory order was used when the
> > > > > > > * call back was inserted into the list.
> > > > > > > * Since there is a clear dependency between
> loading
> > > > > > > * cb and cb->fn/cb->next, __ATOMIC_ACQUIRE memory
> > > order is
> > > > > > > * not required.
> > > > > > > */
> > > > > > > cb = __atomic_load_n(&dev-
> >post_rx_burst_cbs[queue_id],
> > > > > > > __ATOMIC_RELAXED);
> > > > > > >
> > > > > > > if (unlikely(cb != NULL)) {
> > > > > > > do {
> > > > > > > nb_rx = cb->fn.rx(port_id,
> queue_id,
> > > > > rx_pkts,
> > > > > > > nb_rx,
> > > > > > > nb_pkts,
> cb-
> > > > > >param);
> > > > > > > cb = cb->next;
> > > > > > > } while (cb != NULL);
> > > > > > > }
> > > > > > > #endif
> > > > > > >
> > > > > > > rte_ethdev_trace_rx_burst(port_id, queue_id, (void
> > > > > **)rx_pkts,
> > > > > > > nb_rx);
> > > > > > > return nb_rx;
> > > > > > > }
> > > > > >
> > > > > > That would make the compiler inline _rte_eth_rx_epilog() into
> the
> > > > > driver when compiling the DPDK library. But
> > > > > > RTE_ETHDEV_RXTX_CALLBACKS is a definition for the application
> > > > > developer to use when compiling the DPDK application.
> > > > >
> > > > > I believe it is for both - user app and DPDK drivers.
> > > > > AFAIK, they both have to use the same rte_config.h, otherwise
> > > things
> > > > > will be broken.
> > > > > If let say RTE_ETHDEV_RXTX_CALLBACKS is not enabled in ethdev,
> then
> > > > > user wouldn't be able to add a callback at first place.
> > > >
> > > > In the case of RTE_ETHDEV_RXTX_CALLBACKS, it is independent:
> > >
> > > Not really.
> > > There are few libraries within DPDK that do rely on rx/tx
> callbacks:
> > > bpf, latencystat, pdump, power.
> >
> > I do not consider these to be core libraries in DPDK. If these
> libraries are used in an application, that application must be compiled
> with
> > RTE_ETHDEV_RXTX_CALLBACKS.
> >
> > > With the approach above their functionality will be broken -
> > > setup functions will return success, but actual callbacks will not
> be
> > > invoked.
> >
> > I just took a look at bpf and latencystat. Bpf correctly checks for
> the return code, and returns an error if ethdev has been compiled
> without
> > RTE_ETHDEV_RXTX_CALLBACKS. Latencystat checks for the return code,
> but only logs the error and continues as if everything is good
> > anyway. That is a bug in the latencystat library.
>
> If RTE_ETHDEV_RXTX_CALLBACKS Is enabled or disabled for both DPDK and
> user app - everything will work as expected.
> But, as I understand, you consider approach when
> RTE_ETHDEV_RXTX_CALLBACKS Is enabled in the DPDK, but disabled in the
> app.
> Such approach will cause a problems with some libraries - as I
> outlined above.
>
> >
> > > From other side, some libraries do invoke rx/tx burst on their own:
> ip-
> > > pipeline, graph.
> > > For them callback invocation will continue to work, even when
> > > RTE_ETHDEV_RXTX_CALLBACKS is disabled in the app.
> > > In general, building DPDK libs and user app with different
> rte_config.h
> > > is really a bad idea.
> > > It might work in some cases, but I believe it is not supported and
> user
> > > should not rely on it.
> > > If user needs to disable RTE_ETHDEV_RXTX_CALLBACKS in his app, then
> the
> > > proper way would be:
> > > - update rte_config.h
> > > - rebuild both DPDK and the app with new config
> >
> > In principle, I completely agree with your reasoning from a high
> level perspective.
> >
> > However, accepting it would probably lead to the
> RTE_ETHDEV_RXTX_CALLBACKS compile time configuration option being
> completely
> > removed,
>
> For now, we are not talking about removing or even deprecating
> RTE_ETHDEV_RXTX_CALLBACKS.
> What I am talking about - user has to use it (and other rte_config.h
> options) properly.
> He can't use different configs for DPDK libs and app and expect things
> 'just work'.
> This is not supported right now, I think it will never be.
> If it works right now, this is just implementation specifics, which
> user should not rely on.
I agree.
>
> > and ethdev callbacks being always supported. And I don't think such a
> performance degradation of a core DPDK library should be
> > accepted.
>
> As I said above, RTE_ETHDEV_RXTX_CALLBACKS Is still there.
> If it is really critical for your app to disable it - you can still do
> it, you just need to do it in a proper way.
I hope so. This is exactly what I am pleading for: Keep the ability to disable RTE_ETHDEV_RXTX_CALLBACKS at compile time, so there is no performance impact for applications not using it.
I also agree with the limitation that both library and application should be compiled with the same configuration.
>
> > <rant on>
> > I was opposed to the "callback hooks" concept from the beginning, and
> still am. The path that packets take through various functions and
> > pipeline stages should be determined and implemented by the
> application, not by the DPDK libraries.
> >
> > If we want to provide a standardized advanced IP pipeline for DPDK,
> we could offer it as a middle layer library using the underlying DPDK
> > libraries to implement various callbacks, IP fragmentation
> reassembly, etc.. Don't tweak the core libraries (costing memory and/or
> > performance) to support an increasing amount of supplemental
> libraries, which may not be used by all applications.
> >
> > We don't want DPDK to become like the Linux IP stack, with callback
> hooks and runtime installable protocol handling everywhere. All this
> > cruft with their small performance degradations adds up!
> > <rant off>
> >
> > >
> > > >
> > > > If it is not compiled with the DPDK library, attempts to install
> > > callbacks from the application will fail with ENOTSUP.
> > > >
> > > > If it is not compiled with the DPDK application, no time will be
> > > spent trying to determine if any there are any callbacks to call.
> > > >
> > > > > BTW, such change will allow us to make
> RTE_ETHDEV_RXTX_CALLBACKS
> > > > > internal for ethdev/PMD layer, which is a good thing from my
> > > > > perspective.
> > > >
> > > > If it can be done without degrading performance for applications
> not
> > > using callbacks.
next prev parent reply other threads:[~2021-06-22 13:18 UTC|newest]
Thread overview: 61+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-14 10:58 Thomas Monjalon
2021-06-14 12:22 ` Morten Brørup
2021-06-14 13:15 ` Bruce Richardson
2021-06-14 13:32 ` Thomas Monjalon
2021-06-14 14:59 ` Ananyev, Konstantin
2021-06-14 15:48 ` Jerin Jacob
2021-06-15 6:52 ` Thomas Monjalon
2021-06-15 8:00 ` Jerin Jacob
2021-06-15 9:18 ` Thomas Monjalon
2021-06-15 9:33 ` Ananyev, Konstantin
2021-06-15 9:50 ` Thomas Monjalon
2021-06-15 10:08 ` Ananyev, Konstantin
2021-06-15 14:02 ` Thomas Monjalon
2021-06-15 14:37 ` Honnappa Nagarahalli
2021-06-14 15:54 ` Ananyev, Konstantin
2021-06-17 13:08 ` Ferruh Yigit
2021-06-17 14:58 ` Ananyev, Konstantin
2021-06-17 15:17 ` Morten Brørup
2021-06-17 16:12 ` Ferruh Yigit
2021-06-17 16:55 ` Morten Brørup
2021-06-18 10:21 ` Ferruh Yigit
2021-06-17 17:05 ` Ananyev, Konstantin
2021-06-18 9:14 ` Morten Brørup
2021-06-18 10:47 ` Ferruh Yigit
2021-06-18 11:16 ` Morten Brørup
2021-06-18 10:28 ` Ferruh Yigit
2021-06-17 15:44 ` Ferruh Yigit
2021-06-18 10:41 ` Ananyev, Konstantin
2021-06-18 10:49 ` Ferruh Yigit
2021-06-21 11:06 ` Ananyev, Konstantin
2021-06-21 12:10 ` Morten Brørup
2021-06-21 12:30 ` Ananyev, Konstantin
2021-06-21 13:28 ` Morten Brørup
[not found] ` <DM6PR11MB4491D4F6FAFDD6E8EEC2A78F9A099@DM6PR11MB4491.namprd11.prod.outlook .com>
2021-06-22 8:33 ` Ananyev, Konstantin
2021-06-22 10:01 ` Morten Brørup
2021-06-22 12:13 ` Ananyev, Konstantin
2021-06-22 13:18 ` Morten Brørup [this message]
2021-06-21 14:10 ` Ferruh Yigit
2021-06-21 14:38 ` Ananyev, Konstantin
2021-06-21 15:56 ` Ferruh Yigit
2021-06-21 18:17 ` Ananyev, Konstantin
2021-06-21 14:05 ` Ferruh Yigit
2021-06-21 14:42 ` Ananyev, Konstantin
2021-06-21 15:32 ` Ferruh Yigit
2021-06-21 15:37 ` Ananyev, Konstantin
2021-06-14 15:48 ` Morten Brørup
2021-06-15 6:48 ` Thomas Monjalon
2021-06-15 7:53 ` Morten Brørup
2021-06-15 8:44 ` Bruce Richardson
2021-06-15 9:28 ` Thomas Monjalon
2021-06-16 9:42 ` Jerin Jacob
2021-06-16 11:27 ` Morten Brørup
2021-06-16 12:00 ` Jerin Jacob
2021-06-16 13:02 ` Bruce Richardson
2021-06-16 15:01 ` Morten Brørup
2021-06-16 17:40 ` Bruce Richardson
2021-06-16 12:22 ` Burakov, Anatoly
2021-06-16 12:59 ` Jerin Jacob
2021-06-16 22:58 ` Dmitry Kozlyuk
2021-06-14 13:28 ` Thomas Monjalon
2021-06-16 11:11 ` Burakov, Anatoly
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=98CBD80474FA8B44BF855DF32C47DC35C6187E@smartserver.smartshare.dk \
--to=mb@smartsharesystems.com \
--cc=andrew.rybchenko@oktetlabs.ru \
--cc=bruce.richardson@intel.com \
--cc=dev@dpdk.org \
--cc=ferruh.yigit@intel.com \
--cc=gakhil@marvell.com \
--cc=honnappa.nagarahalli@arm.com \
--cc=jerinj@marvell.com \
--cc=konstantin.ananyev@intel.com \
--cc=olivier.matz@6wind.com \
--cc=thomas@monjalon.net \
/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).