From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR01-VE1-obe.outbound.protection.outlook.com (mail-ve1eur01on0072.outbound.protection.outlook.com [104.47.1.72]) by dpdk.org (Postfix) with ESMTP id B906C1BA24 for ; Tue, 10 Apr 2018 03:59:18 +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=ZA7whD1Np3BX9o/OYeyJfJ6qVmmcV8x9khiPOOtS23I=; b=OUVitBUqvlBhIipHubJtoeB6dYqU2f2eT8B5jnBqidoincBo9mmOjoBIfTZdEWB3QaFtEmMqumlVVUlxMZFbsdhBuB6tqDtMzVKACvvlUnX8E9dcQf+M5tvbsgCRRxAE58PR31QNmOP1ZTQCiRyCbxb3lNV3kMaCh3e1f94LuLA= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=yskoh@mellanox.com; Received: from yongseok-MBP.local (209.116.155.178) by DB6PR0501MB2037.eurprd05.prod.outlook.com (2603:10a6:4:6::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.653.12; Tue, 10 Apr 2018 01:59:15 +0000 Date: Mon, 9 Apr 2018 18:59:03 -0700 From: Yongseok Koh To: Olivier Matz Cc: wenzhuo.lu@intel.com, jingjing.wu@intel.com, adrien.mazarguil@6wind.com, nelio.laranjeiro@6wind.com, dev@dpdk.org Message-ID: <20180410015902.GA20627@yongseok-MBP.local> References: <20180310012532.15809-1-yskoh@mellanox.com> <20180402185008.13073-1-yskoh@mellanox.com> <20180402185008.13073-2-yskoh@mellanox.com> <20180403082615.etnr33cuyey7i3u3@platinum> <20180404001205.GB1867@yongseok-MBP.local> <20180409160434.kmw4iyztemrkzmtc@platinum> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180409160434.kmw4iyztemrkzmtc@platinum> User-Agent: Mutt/1.9.3 (2018-01-21) X-Originating-IP: [209.116.155.178] X-ClientProxiedBy: BL0PR02CA0040.namprd02.prod.outlook.com (2603:10b6:207:3d::17) To DB6PR0501MB2037.eurprd05.prod.outlook.com (2603:10a6:4:6::19) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: afa2299e-4b5f-4935-6d69-08d59e86aa67 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7153060)(7193020); SRVR:DB6PR0501MB2037; X-Microsoft-Exchange-Diagnostics: 1; DB6PR0501MB2037; 3:XXiUxU0U7VgnNIZ8i9aWlDUpN4zy9EfLc2z7bfYYTUM6RwbHEf4GVjmIZdbeLm7YSW/VTVG2PrLcz8iaNHIpspV00FcE9Mu6VgD1bGR0m0zErwo6v+rh2o2I28YY9r7aAci96MBZneRhBEJdAkfQHemuLjKDsxc5fWFb2FNDbVr6c2R4mbDTjCJIDV6tReBsGnbi+QsfZmdOz0PVXVST6Oj7wiK0Ee8nSJRSaQRpB4+yK6aapWzzN+vMUvi92FJW; 25:sANJBPsjIN1jn1AZZUCLlRA/s7lkhDi5NGEqOOwsnsKjQ9StyGCb36QOjTMPaukxpWiS6xabPZCkghM//zFb48H0gXZaxusVZ2XMXMuFUa5yEg0xO33X8o/H1f9aiGufZkPH8y64OHJhQFRoJ3pWzQ8+5VZXs6txiibfLZ+bjQ9jwcZOBRKHvSrlyLUIHIXgwx30lVrPSDo5zfFHSA4VXb5GaM3w9qQxEoG+LmCoVR4EoP22g4JBSlZ6cxI4x8GJOVIoCXxpyHuTlVJIGWQ/qy/OVVnRE6/Mp0cVkPlzdyw/fnRgoBPxsQhrdMxaNlJzB0x7FxwBUW9UGFf9jw55Dw==; 31:GYRjtUNEOEhhRP5BJtXgvtuPb/b28PBjAqate7rvdEee7UVFjqocXmyHHaPEm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hSccbYRozSlb0augxAy8m3UwmwxCEKKlJy1V7lwZSdsMLiyqoI0XngOlF8Nla0JF/keIBWe7nDYLGZFuU+8O0/xEIbpxNZ+DBfWuPxBypSkqTAXp4+fpDcfXRUzV9zbjy6W2Hg+I+vjLHRePlaXmBCktoJMK8= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(189930954265078)(45079756050767)(17755550239193)(15185016700835); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(3231221)(944501327)(52105095)(93006095)(93001095)(3002001)(10201501046)(6055026)(6041310)(20161123564045)(20161123560045)(20161123558120)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011); SRVR:DB6PR0501MB2037; BCL:0; PCL:0; RULEID:; SRVR:DB6PR0501MB2037; X-Forefront-PRVS: 0638FD5066 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(39860400002)(396003)(376002)(39380400002)(346002)(366004)(189003)(199004)(8936002)(446003)(2906002)(68736007)(81156014)(8676002)(97736004)(1076002)(66066001)(23726003)(55016002)(9686003)(4326008)(6246003)(81166006)(6306002)(47776003)(25786009)(7696005)(6916009)(33656002)(98436002)(6666003)(5660300001)(105586002)(478600001)(3846002)(6116002)(53936002)(305945005)(45080400002)(7736002)(966005)(50466002)(5890100001)(386003)(6506007)(106356001)(229853002)(186003)(33896004)(76176011)(16586007)(16526019)(476003)(956004)(86362001)(58126008)(316002)(93886005)(11346002)(486006)(26005)(52116002)(18370500001); DIR:OUT; SFP:1101; SCL:1; SRVR:DB6PR0501MB2037; 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: =?us-ascii?Q?1; DB6PR0501MB2037; 23:+kY0GbNqyfOS0j13K1yc5Tz2pY9WxUA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M4fryG/5CLFSJ84LSr44FyVX+xGaNvY1qx?= =?us-ascii?Q?LQiCXGulMF+jXg0eHCH1HfuplKs6bDXfZmhujEnnj2RzZ9xUGYzOOhTuE5bV?= =?us-ascii?Q?n6xOz4nYIYqBo3ma4Uf1J/VohR+QFacoZPEfZHDOh5/TuTxHKxe4Valh2QI0?= =?us-ascii?Q?pEwZgdq4CS88m1aK2jgsCYLX4bt8oXE3Cs5U2hZLbBkh5rJL/jklffp3aTdX?= =?us-ascii?Q?O+N51BojRMECbfaUx5uLo9kuSlF3iUHI1DIlExCBexxXJ/7aFNGucq9941n/?= =?us-ascii?Q?+NGCoGhtqtodDKfN54FB7sJM1TKJTBebjj74hDWjUSbKBJMYAKkk14RXx2pc?= =?us-ascii?Q?3BirrlyZogE0Q/b3MiYLirBfIYgq3DYFNNp6rRTScIdkGWxKFTdFk3OPysvS?= =?us-ascii?Q?v1CnJczQF4+3CI2p3ANqYpK9Qnmp1UI2kZ0s+srsLhN2oVqkiTARKypc3Pyn?= =?us-ascii?Q?sAG2WatGUXK0yYkQi9mxtj0fWoJIevbAwaMWjPB3SK77s/hWg?= X-Microsoft-Antispam-Message-Info: kXBSmqVd12mhK78x+bu6/UZvZY/sepykRfrmtQhs5Pm64FTDvf028IuplvGO6qT5za+BoPR34BL+ixym8WQB0uiNe3dssI26HYjQFOAuUNpBHNpt0Z6/QEreO8j5kUZS2+UWZtJjVn7dMGt+V/D383vHfMUC74jueEkB7sU8KRySDAGhjP9R8H/Vp/unCXuB X-Microsoft-Exchange-Diagnostics: 1; DB6PR0501MB2037; 6:jdXLQYEPGnV7ELYtz0umfXEx/n5NWxoZ6hTW7wBYxhS+e7ddfitky5b73NsnmsHG75nL0F8N+/hJ9DuZ6KKhSzYGgV6LuldQXawATpYx4/Xi0W6y8O7LOBR3CTWrDaxFht/HsmBhp9HKwPkB5ERKjQKm99dJ51QSzGwBu/VLGrB3vUS4fz7VJ5IB2aw78ze6hdov0oZzgv2dA0Z5xE+4DTf82FNrDKVUjapar7LxWseSTyW7w2CZuImp2D3qTeLy9i0TmWrZ8lqDkYSY98JxcjGR8aCWf1qyrs83oMVL4uTIpDBlPMdBS1VjQ5/cbaDeNTbAsTezrIKMheQTvTrDKat/9IyWaAlKEtG8OQVOQifcDBJRohx5W1eF6ebCb3rTdseNbt3c2AjytCQ3BeKRmKfvR+wF20gjGmPnwQDVDLpaPnrPYTXQttvvpHuIDe9vt9csaqTX7aZcvGtC9pkTaw==; 5:6Bvqkg5kwl1uWv1WsUdp52mFf4fU6ysH23m+1kJrrArfAJQRxubKBkeqPP1wqi2OfukUmx9R7dOjwbfLcRgu798bPDw8F6yDADFLfokpqdCUR0p9shCr2wSBhTFqxlHHmqNStGF5cFDrlBkreii8pehMFtfXbfj5jRZ/hvQzRMs=; 24:CjV+FcSmb8/xTDpsW7CZJOu0knOtxm2Qqnt9FAil+feQPK1M94suowsD2lnCRomWd61UGRKRyrJX16Ucnd5P03fKPZb0pfY8BSn//grNXI4= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; DB6PR0501MB2037; 7:+GrkX0JsfN5YLCnJYlH/hyRp4Awspla9nxyj5DWzHTYI7Yu4/qd2RNDON8+rdz7BX7UHjUsN9fg8oStDHMWMT99aDAFBApa9uqU7l5eFaThxlWoEtnePpAKlrrsAGbDRQUKT4tf+/vIpG39tSiMN10UuTaYAcIvja9/3TuSttR74aSF7AI6BN7nxYABnBuJnibkFOvN+ngueWmIskMwVWhSKn7y6r5kDz6bUUuf2WG2S0WxmPzlLSJnV0tUewdFK X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Apr 2018 01:59:15.1066 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: afa2299e-4b5f-4935-6d69-08d59e86aa67 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR0501MB2037 Subject: Re: [dpdk-dev] [PATCH v2 1/6] mbuf: add buffer offset field for flexible indirection 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, 10 Apr 2018 01:59:19 -0000 On Mon, Apr 09, 2018 at 06:04:34PM +0200, Olivier Matz wrote: > Hi Yongseok, > > On Tue, Apr 03, 2018 at 05:12:06PM -0700, Yongseok Koh wrote: > > On Tue, Apr 03, 2018 at 10:26:15AM +0200, Olivier Matz wrote: > > > Hi, > > > > > > On Mon, Apr 02, 2018 at 11:50:03AM -0700, Yongseok Koh wrote: > > > > When attaching a mbuf, indirect mbuf has to point to start of buffer of > > > > direct mbuf. By adding buf_off field to rte_mbuf, this becomes more > > > > flexible. Indirect mbuf can point to any part of direct mbuf by calling > > > > rte_pktmbuf_attach_at(). > > > > > > > > Possible use-cases could be: > > > > - If a packet has multiple layers of encapsulation, multiple indirect > > > > buffers can reference different layers of the encapsulated packet. > > > > - A large direct mbuf can even contain multiple packets in series and > > > > each packet can be referenced by multiple mbuf indirections. > > > > > > > > Signed-off-by: Yongseok Koh > > > > > > I think the current API is already able to do what you want. > > > > > > 1/ Here is a mbuf m with its data > > > > > > off > > > <--> > > > len > > > +----+ <----------> > > > | | > > > +-|----v----------------------+ > > > | | -----------------------| > > > m | buf | XXXXXXXXXXX || > > > | -----------------------| > > > +-----------------------------+ > > > > > > > > > 2/ clone m: > > > > > > c = rte_pktmbuf_alloc(pool); > > > rte_pktmbuf_attach(c, m); > > > > > > Note that c has its own offset and length fields. > > > > > > > > > off > > > <--> > > > len > > > +----+ <----------> > > > | | > > > +-|----v----------------------+ > > > | | -----------------------| > > > m | buf | XXXXXXXXXXX || > > > | -----------------------| > > > +------^----------------------+ > > > | > > > +----+ > > > indirect | > > > +-|---------------------------+ > > > | | -----------------------| > > > c | buf | || > > > | -----------------------| > > > +-----------------------------+ > > > > > > off len > > > <--><----------> > > > > > > > > > 3/ remove some data from c without changing m > > > > > > rte_pktmbuf_adj(c, 10) // at head > > > rte_pktmbuf_trim(c, 10) // at tail > > > > > > > > > Please let me know if it fits your needs. > > > > No, it doesn't. > > > > Trimming head and tail with the current APIs removes data and make the space > > available. Adjusting packet head means giving more headroom, not shifting the > > buffer itself. If m has two indirect mbufs (c1 and c2) and those are pointing to > > difference offsets in m, > > > > rte_pktmbuf_adj(c1, 10); > > rte_pktmbuf_adj(c2, 20); > > > > then the owner of c2 regard the first (off+20)B as available headroom. If it > > wants to attach outer header, it will overwrite the headroom even though the > > owner of c1 is still accessing it. Instead, another mbuf (h1) for the outer > > header should be linked by h1->next = c2. > > Yes, after these operations c1, c2 and m should become read-only. So, to > prepend headers, another mbuf has to be inserted before as you suggest. It > is possible to wrap this in a function rte_pktmbuf_clone_area(m, offset, > length) that will: > - alloc and attach indirect mbuf for each segment of m that is > in the range [offset : length+offset]. > - prepend an empty and writable mbuf for the headers > > > If c1 and c2 are attached with shifting buffer address by adjusting buf_off, > > which actually shrink the headroom, this case can be properly handled. > > What do you mean by properly handled? > > Yes, prepending data or adding data in the indirect mbuf won't override > the direct mbuf. But prepending data or adding data in the direct mbuf m > won't be protected. > > From an application point of view, indirect mbufs, or direct mbufs that > have refcnt != 1, should be both considered as read-only because they > may share their data. How an application can know if the data is shared > or not? > > Maybe we need a flag to differentiate mbufs that are read-only > (something like SHARED_DATA, or simply READONLY). In your case, if my > understanding is correct, you want to have indirect mbufs with RW data. Agree that indirect mbuf must be treated as read-only, Then the current code is enough to handle that use-case. > > And another use-case (this is my actual use-case) is to make a large mbuf have > > multiple packets in series. AFAIK, this will also be helpful for some FPGA NICs > > because it transfers multiple packets to a single large buffer to reduce PCIe > > overhead for small packet traffic like the Multi-Packet Rx of mlx5 does. > > Otherwise, packets should be memcpy'd to regular mbufs one by one instead of > > indirect referencing. > > > > Does this make sense? > > I understand the need. > > Another option would be to make the mbuf->buffer point to an external > buffer (not inside the direct mbuf). This would require to add a > mbuf->free_cb. See "Mbuf with external data buffer" (page 19) in [1] for > a quick overview. > > [1] https://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fdpdksummit.com%2FArchive%2Fpdf%2F2016Userspace%2FDay01-Session05-OlivierMatz-Userspace2016.pdf&data=02%7C01%7Cyskoh%40mellanox.com%7Ca5405edb36e445e6540808d59e339a38%7Ca652971c7d2e4d9ba6a4d149256f461b%7C0%7C0%7C636588866861082855&sdata=llw%2BwiY5cC56naOUhBbIg8TKtfFN6VZcIRY5PV7VqZs%3D&reserved=0 > > The advantage is that it does not require the large data to be inside a > mbuf (requiring a mbuf structure before the buffer, and requiring to be > allocated from a mempool). On the other hand, it is maybe more complex > to implement compared to your solution. I knew that you presented the slides and frankly, I had considered that option at first. But even with that option, metadata to store refcnt should also be allocated and managed anyway. Kernel also maintains the skb_shared_info at the end of the data segment. Even though it could have smaller metadata structure, I just wanted to make full use of the existing framework because it is less complex as you mentioned. Given that you presented the idea of external data buffer in 2016 and there hasn't been many follow-up discussions/activities so far, I thought the demand isn't so big yet thus I wanted to make this patch simpler. I personally think that we can take the idea of external data seg when more demands come from users in the future as it would be a huge change and may break current ABI/API. When the day comes, I'll gladly participate in the discussions and write codes for it if I can be helpful. Do you think this patch is okay for now? Thanks for your comments, Yongseok