From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR03-DB5-obe.outbound.protection.outlook.com (mail-eopbgr40054.outbound.protection.outlook.com [40.107.4.54]) by dpdk.org (Postfix) with ESMTP id EBD5E2C12 for ; Wed, 25 Apr 2018 00:31:07 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Mellanox.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=MUc2m6Fo61ktq8n4zjiCLj9ajEzJIYTKwaRlWeqpvMA=; b=vr4ESWSxKociVY7AFg70gdOK1knzBi5qSym61X+Vhx79aHzxRmdoDkUvKZ4ae/FjVL7GHKOACWZLVSDW7vAbdtLFGG/iGyEi76V7b+593k4zqY33qXU0gln82S3tnUTewxibNcHZq/8BFuNMGwu65BzGipw3lB1/IpbXnz7J4nA= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=yskoh@mellanox.com; Received: from yongseok-MBP.local (209.116.155.178) by HE1PR0501MB2043.eurprd05.prod.outlook.com (2603:10a6:3:35::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.696.15; Tue, 24 Apr 2018 22:31:02 +0000 Date: Tue, 24 Apr 2018 15:30:49 -0700 From: Yongseok Koh To: Andrew Rybchenko Cc: wenzhuo.lu@intel.com, jingjing.wu@intel.com, olivier.matz@6wind.com, dev@dpdk.org, konstantin.ananyev@intel.com, adrien.mazarguil@6wind.com, nelio.laranjeiro@6wind.com Message-ID: <20180424223048.GB88208@yongseok-MBP.local> References: <20180310012532.15809-1-yskoh@mellanox.com> <20180424013854.33749-1-yskoh@mellanox.com> <934e714e-3cba-7f5d-9fcf-4f96611d758f@solarflare.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <934e714e-3cba-7f5d-9fcf-4f96611d758f@solarflare.com> User-Agent: Mutt/1.9.3 (2018-01-21) X-Originating-IP: [209.116.155.178] X-ClientProxiedBy: BN6PR14CA0003.namprd14.prod.outlook.com (2603:10b6:404:79::13) To HE1PR0501MB2043.eurprd05.prod.outlook.com (2603:10a6:3:35::21) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(48565401081)(5600026)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7153060)(7193020); SRVR:HE1PR0501MB2043; X-Microsoft-Exchange-Diagnostics: 1; HE1PR0501MB2043; 3:INIhwtVtxCCR3tf+ot5n68iFWgTqD6B8lHSjbjclHbACKBZOgWrUT4zgDahbtUFd9NARJMKmmiizCugjtQnLvBbyPEdsP4jCMJfL9aXXmrE1KvDA4Fo8hg3ioAwEs3u+J4xWoSzj/rwM2+hpjFnzACfQahoSdYyugJLhfo1A6t8Opthb4oeKY9sXiuL9EH+3skCfUDEPg7oqje3Bx6iNIHSUdnRT3uROdb3whLIWYReAmjzetgqPtl6VmxHbMf90; 25:Fnxw/3ser8VWJe8aDXbjJzwfFGKNV3Pi9f0jvOmJsi4GV7lIXcr4XVo4+Pen4H/SKSEpsJdMlVK+X+gxJVzC8ulgt8IDLS14VFf/cp0dQ6VHPCr2zHCBY5+TQhJ/Fty3nw+0q+g+bQQGlyQWmhwm4FyCcApAZVGNsQHwCQm1rjVnOKheyzhcOzjQoVyUH8pNdbERZyNaT7BX2pMEbpuqkCh0hbTgXDp2PexWuirtuCdqeN9JTjS1rUmy7WNAu26cvKVz0RDJzmlo5R8h+vHdBOwiLzimnUjTusJZEZh3Z05FE3aWOgzPsG0LvC3TMMs2BpvWehPklxUknSbhEvnlQg==; 31:yBxvGaxSxvIKy1dKGPxNf7A/qqCMdZVtgSZt8YnQb03eaRnf2mdU9u1/ld04Ac3pwawbsHYt9lpe366kP2xycT4leSMYyZrgO0WPRBRMNUqReUDOr9qIf5AR2C26oqTqVwo8wAzeK2c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oft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(17755550239193); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(3002001)(3231232)(944501410)(52105095)(10201501046)(93006095)(93001095)(6055026)(6041310)(20161123562045)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123558120)(6072148)(201708071742011); SRVR:HE1PR0501MB2043; BCL:0; PCL:0; RULEID:; SRVR:HE1PR0501MB2043; X-Forefront-PRVS: 0652EA5565 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(39380400002)(376002)(396003)(39860400002)(366004)(346002)(189003)(199004)(53936002)(186003)(23756003)(6916009)(55016002)(97736004)(6246003)(4326008)(486006)(33656002)(98436002)(956004)(446003)(16526019)(6666003)(2870700001)(9686003)(2906002)(86362001)(8936002)(58126008)(53546011)(68736007)(8676002)(305945005)(81166006)(81156014)(33896004)(59450400001)(76176011)(386003)(3846002)(11346002)(7696005)(52116002)(476003)(229853002)(6116002)(106356001)(105586002)(6506007)(50466002)(5660300001)(478600001)(5890100001)(25786009)(1076002)(7736002)(26005)(66066001)(316002)(47776003)(18370500001); DIR:OUT; SFP:1101; SCL:1; SRVR:HE1PR0501MB2043; H:yongseok-MBP.local; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; Received-SPF: None (protection.outlook.com: mellanox.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?iso-8859-1?Q?1; HE1PR0501MB2043; 23:Fn5iE9y5FDEZMINs/YQsGf3ZfL+foeq2RMpkU?= =?iso-8859-1?Q?4swT2h2ICLvZ81FtcTmjVaSz66KEuzhVRrbVmvXOq3D+5GWL1iSvVQSlGU?= =?iso-8859-1?Q?rWXr1SCVCfSMsAncSRzfo73Ikh7DgyS8f3wHJT+Qugss6jUg1XfAa6vZWa?= =?iso-8859-1?Q?eKd26+E7pc8qt0s3OQQGj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g1daszXbMnT564L6pCFZ/dx/r5W5rdswbIssdoHexIH0ng4Oly4c7UJck?= =?iso-8859-1?Q?mjFzT7I9knPZRo8mVVl0y6ca9c/K+R/0u9nW+MAEgtAC6At7t2TofZuYmI?= =?iso-8859-1?Q?0/RIFwYBbZ/QN6opbByCP2xODZJSQJWFkgZKFu2exNbD3e3hw3xTWTZpbW?= =?iso-8859-1?Q?JQNw8abUB+lzhj60jRJ4sx8PA2LaYovEV/9NExecNSxFOxOqKfeW5a+pdb?= =?iso-8859-1?Q?WPDrZQBLlk2cRP9PNnNXSMsP4XPWWcaNUTUnmGw1P5RMI0HwL7MFSJbhzn?= =?iso-8859-1?Q?93tFPLZUxFGgSv+VuKMPb3uMHdexzaBt01CqZGDUd/aYHA9ZSnc9NS+qiX?= =?iso-8859-1?Q?+Nu0cWBXckhfMtqw=3D?= X-Microsoft-Antispam-Message-Info: sOPKzsxZciFpiJHIhG6tnBN9iILoBYZK7WPhiYO1Nhkg5sJedlLERwlFCq30UwOuENU9dFCIM87FXGMVqDti/TtLrKohfgg2QwcFYCEE42l3MJGtitQ5n6/oeKRH3ms7aEVkK9Cnj4MTFvH2AynHE3EkQ1Q2+/ByQeFXwT79mB17gyWNhEJFTKvaZTjaVO/R X-Microsoft-Exchange-Diagnostics: 1; HE1PR0501MB2043; 6:UT62UIUY3WgOrfPMoSt4u1AXsYF6xPBwmVZ71IsqpNDaN9U/rt98w44TWTijnlLa8RCFOK79vf9evI69EyWnCjat4kBZ6Svab01xbQsAHC+BnACBwY4poVVNAOhh1lQomthrp91QBqCTxOgAtYdQHl5Hk2reTzk3mBW4Yia+3H09vd15EthKUCW5j6z9uDyz8getM0LtvKt+dwdELSg1RNVMyzzpz5oAwLqzYjwBwkFTzmLz9xFHLtGOC//U4rMOdaXSKvWbpOI5TgR/QIog1Dkmc+6328M3HB4m00v0BTL8i9cwDHREkDdcNFSUH2YMyvOeT1yTrr+XRJxuCXN9KMAgu80kRytS5V3+sLKnu/eu4tFDI7rufW5fWT9pukjz+cu0ELuZemW28P8t7mOeiGWsThfpXsfXjFOvaEcmyXPnZIh+DzkCIdaRqWXxkR11N1P0/MgmQJD2HhEsF0hqwA==; 5:H9xpXKAMysgzGPCHCI3CxN9kQptPGjsVmETt4fu4OvJO7R4pYbEN6o/mg0ZkQyk72lOLkUgTcLsF8qznRC+Wlr660w726KadsZmDvYWWTwM9WVGlk/auQAZBbLl4+ckKIbRBenf8AEam42jYwc1Ys8/7p/NziM55z8AmLflyRwU=; 24:Pdh0VXn1/RkATv1D6Xs7cLnb/C/NTSlbpg36i8RNkshqOr4pgtl2kcIet+aX5I0z+rpfQCG5yX6FyFK/DsD0ykuXim9eCMy7irjbgqRnAQs= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; HE1PR0501MB2043; 7:YYRSJWE/DUytGoxHBYVihETTRe3X/xWFWuG8T6v8tzuYJvlQfEEMGAZG9aJy2jHVNhJczmr920WxcVVpsaWZ3IhrnSM3HkFyYizF1DoS9JGdW3eO22QHZHBCBiBSEJaKSt+Ntc5Dg+Fc8N0XN6Yi3xxB9uUoQFiTUW7Oya5o7C61bJkuO/BJMqx7IWx7uuTkWLZ5ip5a0JuOCdn2Iics4mw841pXwnngzmcbSdUWrUA8UlBiiijdNgNESVg9O8A4 X-MS-Office365-Filtering-Correlation-Id: 87b2443c-854b-47e4-3604-08d5aa3310d6 X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Apr 2018 22:31:02.7195 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 87b2443c-854b-47e4-3604-08d5aa3310d6 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR0501MB2043 Subject: Re: [dpdk-dev] [PATCH v4 1/2] mbuf: support attaching external buffer to mbuf X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Apr 2018 22:31:08 -0000 On Tue, Apr 24, 2018 at 03:28:33PM +0300, Andrew Rybchenko wrote: > On 04/24/2018 04:38 AM, Yongseok Koh wrote: [...] > > diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h > > index 06eceba37..7f6507a66 100644 > > --- a/lib/librte_mbuf/rte_mbuf.h > > +++ b/lib/librte_mbuf/rte_mbuf.h > > @@ -326,7 +326,7 @@ extern "C" { > > PKT_TX_MACSEC | \ > > PKT_TX_SEC_OFFLOAD) > > -#define __RESERVED (1ULL << 61) /**< reserved for future mbuf use */ > > +#define EXT_ATTACHED_MBUF (1ULL << 61) /**< Mbuf having external buffer */ > > May be it should mention that shinfo is filled in. Okay. > > #define IND_ATTACHED_MBUF (1ULL << 62) /**< Indirect attached mbuf */ > > @@ -566,8 +566,24 @@ struct rte_mbuf { > > /** Sequence number. See also rte_reorder_insert(). */ > > uint32_t seqn; > > + struct rte_mbuf_ext_shared_info *shinfo; > > I think it would be useful to add comment that it is used in the case of > RTE_MBUF_HAS_EXTBUF() only. Oops, I missed that. Thanks. [...] > > +static inline char * __rte_experimental > > +rte_pktmbuf_attach_extbuf(struct rte_mbuf *m, void *buf_addr, > > + rte_iova_t buf_iova, uint16_t buf_len, > > + struct rte_mbuf_ext_shared_info *shinfo, > > + rte_mbuf_extbuf_free_callback_t free_cb, void *fcb_opaque) > > +{ > > + void *buf_end = RTE_PTR_ADD(buf_addr, buf_len); > > May I suggest to move it inside if (shinfo == NULL) to make it clear that it > is not used if shinfo pointer is provided. Done. [...] > > static inline void rte_pktmbuf_attach(struct rte_mbuf *mi, struct rte_mbuf *m) > > { > > - struct rte_mbuf *md; > > - > > RTE_ASSERT(RTE_MBUF_DIRECT(mi) && > > rte_mbuf_refcnt_read(mi) == 1); > > - /* if m is not direct, get the mbuf that embeds the data */ > > - if (RTE_MBUF_DIRECT(m)) > > - md = m; > > - else > > - md = rte_mbuf_from_indirect(m); > > + if (RTE_MBUF_HAS_EXTBUF(m)) { > > + rte_mbuf_ext_refcnt_update(m->shinfo, 1); > > + mi->ol_flags = m->ol_flags; > > + } else { > > + rte_mbuf_refcnt_update(rte_mbuf_from_indirect(m), 1); > > It looks like handling of the direct mbuf is lost here. May be it is > intentional > to avoid branching since result will be the same for direct mbuf as well, > but looks confusing. Deserves at least a comment which explains why. > Ideally it should be proven by measurements. Right, that was intentional to avoid the branch. Sometimes branch is more expensive than arithmetic ops in core's pipeline. Will add a comment. [...] > > +static inline void > > +__rte_pktmbuf_free_direct(struct rte_mbuf *m) > > +{ > > + struct rte_mbuf *md = rte_mbuf_from_indirect(m); > > Shouldn't it be done after below assertion? Just to be less confusing. Right. Done. > > + > > + RTE_ASSERT(RTE_MBUF_INDIRECT(m)); > > + > > + if (rte_mbuf_refcnt_update(md, -1) == 0) { > > It is not directly related to the changeset, but rte_pktmbuf_prefree_seg() > has many optimizations which could be useful here: >  - do not update if refcnt is 1 >  - do not set next/nb_seq if next is already NULL Would be better to have a separate patch later. Thanks, Yongseok > > + md->next = NULL; > > + md->nb_segs = 1; > > + rte_mbuf_refcnt_set(md, 1); > > + rte_mbuf_raw_free(md); > > + } > > +} > > [...]