Ping

On 08/07/15 19:44, Zoltan Kiss wrote:


On 03/07/15 09:05, Savolainen, Petri (Nokia - FI/Espoo) wrote:
Maybe it's better to add this into packet pool parameters. Usage of
build time config macros should be minimized in the future.

Sounds OK, but we'll need an accessor which tells this based on packet,
so it could be easily inlined.

odp_bool_t odp_packet_udata_persistent(odp_packet_t pkt)

    /** User area size in bytes. Specify as 0 if no user
        area is needed. */
    uint32_t uarea_size;

    /** Static user area data.
      * 0: User area data can be overwritten while in pool (between
free and alloc calls).
      * 1: User area data is static. System will never overwrite the
area.
         *    Entire area is initialized to zero in pool creation.
      * Default is 0.
      */
    int uarea_static;
it should be odp_bool_t as well, and I would use the word 'persistent'
rather than 'static'.


Every platform should be able to provided static area, but the
performance may degrade due to extra indirection etc.
I'm not just worried about performance, but how would e.g. linux-generic
do that? As the packet and its udata comes from a completely new chunk
of memory every time, how does it know what contents should be in the
next allocated buffer? Just keep the copy of the udata of an packet
previously allocated? How does it know if it was initialized properly?
What happens when the app decides to change the initialization during
runtime?
I think this should be rather part of odp_pool_info_t, as an output
parameter from a pool, and let the application deal with the two cases.


Zero initialization would help user to tell if the area has valid data
or not.
I'd like to avoid callbacks from pool create to keep it simple.

I think a callback is still more simple than allocating all the buffers
and initializing them one by one in the application.
I like the idea in the text sent by Bill:
- if uarea_static == 0, then init callback is called during alloc, if
any. If no callback, uarea is not inited, obviously
- if uarea_static == 1, then callback runs during pool creattion, or if
no callback, then init to zero


-Petri


-----Original Message-----
From: ext Zoltan Kiss [mailto:zoltan.k...@linaro.org]
Sent: Thursday, July 02, 2015 7:43 PM
To: lng-odp@lists.linaro.org
Cc: lng-odp-d...@lists.linaro.org; lng-odp-...@lists.linaro.org;
Savolainen, Petri (Nokia - FI/Espoo)
Subject: [API-NEXT PATCH RFC] api: packet: add optional persistent
metadata

This requirement came from ODP-OVS: it handles buffers through 'struct
ofpbuf'
(in upstream it became 'struct dp_packet'), and they can be non-ODP
buffers as
well. Therefore after receiving a packet currently we have to reset
three
fields in it: 'source' (to ODP), 'allocated' (segment size, OVS doesn't
support
multiple segments in this struct) and 'odp_pkt' (points to the
containing
odp_packet_t)
The native DPDK implementation takes advantage of the fact that the
buffer
and
user metadata area, where this struct is stored is allocated during pool
creation time, therefore it initializes it to static values at startup.
When
I've tried this behaviour with ODP-DPDK, the performance increased from
~12.7
to ~12.9 Mpp. That's only ~%1.6 increase, but in other words it's
~%17 of
the
gap between the current and OVS-DPDK performance (13.9 Mpp)
I would like a propose an optional feature where the implementation can
signal
if it guarantees this behaviour. I think most implementations would
preallocate these areas to achieve good performance, but e.g. linux-
generic
does not AFAIK.

Signed-off-by: Zoltan Kiss <zoltan.k...@linaro.org>
---
  include/odp/api/config.h | 10 ++++++++++
  include/odp/api/packet.h |  4 +++-
  2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/include/odp/api/config.h b/include/odp/api/config.h
index 91ea34e..d48030e 100644
--- a/include/odp/api/config.h
+++ b/include/odp/api/config.h
@@ -121,6 +121,16 @@ extern "C" {
   */
  #define ODP_CONFIG_PACKET_BUF_LEN_MAX
(ODP_CONFIG_PACKET_SEG_LEN_MIN*6)

+/**
+ * Guarantee that user metadata is allocated during pool creation
+ *
+ * If this parameter is 1, applications can avoid reseting persistent
parts of
+ * the area returned by odp_packet_user_area() by setting them once,
after pool
+ * creation. It will keep its content between odp_packet_free() and
+ * odp_packet_alloc().
+ */
+#define ODP_CONFIG_PACKET_PERSISTENT_MD 0
+
  /** Maximum number of shared memory blocks.
   *
   * This the the number of separate SHM areas that can be reserved
concurrently
diff --git a/include/odp/api/packet.h b/include/odp/api/packet.h
index 91a124a..d7aeb95 100644
--- a/include/odp/api/packet.h
+++ b/include/odp/api/packet.h
@@ -448,7 +448,9 @@ void odp_packet_user_ptr_set(odp_packet_t pkt, const
void *ctx);
   * User area address
   *
   * Each packet has an area for user data. Size of the area is fixed
and
defined
- * in packet pool parameters.
+ * in packet pool parameters. If ODP_CONFIG_PACKET_PERSISTENT_MD is 1,
this
+ * area is allocated during pool creation, and keep its content between
+ * odp_packet_free() and odp_packet_alloc().
   *
   * @param pkt  Packet handle
   *
--
1.9.1

_______________________________________________
lng-odp mailing list
lng-odp@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/lng-odp

Reply via email to