From owner-freebsd-hackers@FreeBSD.ORG Wed Feb 6 19:43:26 2013 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 4A0337BC; Wed, 6 Feb 2013 19:43:26 +0000 (UTC) (envelope-from lsanfil@marvell.com) Received: from na3sys009aog110.obsmtp.com (na3sys009aog110.obsmtp.com [74.125.149.203]) by mx1.freebsd.org (Postfix) with ESMTP id 0B58237A; Wed, 6 Feb 2013 19:43:14 +0000 (UTC) Received: from SC-OWA.marvell.com ([199.233.58.135]) (using TLSv1) by na3sys009aob110.postini.com ([74.125.148.12]) with SMTP ID DSNKURKyQ2mFExrBQYhOxAcfT3iJ7bQsWFbl@postini.com; Wed, 06 Feb 2013 11:43:15 PST Received: from SC-VEXCH4.marvell.com ([::1]) by SC-OWA.marvell.com ([::1]) with mapi; Wed, 6 Feb 2013 11:41:33 -0800 From: Lino Sanfilippo To: Jacques Fourie , John Baldwin Date: Wed, 6 Feb 2013 11:41:32 -0800 Subject: RE: Mbuf memory handling Thread-Topic: Mbuf memory handling Thread-Index: Ac4Ei/tlxSbHW20uRt6xXMY67TQq1gACPnQg Message-ID: <175CCF5F49938B4D99B2E3EF7F558EBE1C73F4038E@SC-VEXCH4.marvell.com> References: <175CCF5F49938B4D99B2E3EF7F558EBE1C73F401F3@SC-VEXCH4.marvell.com> <201302060836.55404.jhb@freebsd.org> <201302061137.35651.jhb@freebsd.org> In-Reply-To: Accept-Language: de-DE, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: acceptlanguage: de-DE, en-US MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable X-Content-Filtered-By: Mailman/MimeDel 2.1.14 Cc: Hackers freeBSD , Axel Fischer , Ralf Assmann , Markus Althoff X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 06 Feb 2013 19:43:26 -0000 John, Jacques, thank you very much for your help. An mbuf cluster seems to be the right di= rection. So I would have to do something like mbuf =3D m_getjcl(how, MT_DATA, M_PKTHDR, MJUMPAGESIZE); left_for_next_rcv =3D m_split(mbuf, chunksize); if_input(ifp, mbuf); right? >I agree that read-only buffers may be ok in this case but would like to po= int out that the M_WRITABLE() macro will evaluate to 0 if the refcount on t= he cluster is >1 The fact that the resulting mbufs returned by m_split() are not writeable a= ny more is indeed a problem: What I would like to do is keep the 'left_for_next_rcv' mbuf until the next= packet arrives and then fill it with the next packets data only up to 'chunksize', split it ag= ain to pass the new mbuf to the protocol stack and so on until 'left_for_next_rcv' becomes too small to= be splitted further. Only then I would want to allocate a new "fresh" jumbo sized mbuf. Is it po= ssible to realize this with cluster mbufs? Thx, Lino