From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-db5eur01on0073.outbound.protection.outlook.com [104.47.2.73]) by dpdk.org (Postfix) with ESMTP id 90B0C1B1D4 for ; Wed, 14 Feb 2018 04:16:34 +0100 (CET) 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=q+Llq2w+NR1wGs+g4jrqij2SFTdrxC+8O5PIZzyQJeY=; b=kuZBlcI0Px57RQ0xVGtOFFJAaelflZnShSEQNkNsQTfn9IrI4+Arp2Tw4kAOMvaX7DkFoUtOe/DARpE39kJ5TgNA82dYt3re8EMm+YXFGEn5EVsnqUlk7LfyzO4FMIrMhh7q0ZV+AtkLkQhY7qNoMjXkY100va9OSfbHbIjZxN8= Received: from VI1PR0501MB2045.eurprd05.prod.outlook.com (10.167.195.147) by VI1PR0501MB2157.eurprd05.prod.outlook.com (10.167.196.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.506.18; Wed, 14 Feb 2018 03:16:32 +0000 Received: from VI1PR0501MB2045.eurprd05.prod.outlook.com ([fe80::5ccf:86b:106c:a93a]) by VI1PR0501MB2045.eurprd05.prod.outlook.com ([fe80::5ccf:86b:106c:a93a%14]) with mapi id 15.20.0485.017; Wed, 14 Feb 2018 03:16:32 +0000 From: Yongseok Koh To: Olivier Matz CC: "dev@dpdk.org" Thread-Topic: Accessing 2nd cacheline in rte_pktmbuf_prefree_seg() Thread-Index: AQHTpRxp6JK2s2emFk2+Vdr56OBIeaOjOjMA Date: Wed, 14 Feb 2018 03:16:32 +0000 Message-ID: <97910E4F-11F5-4BDB-A460-2656B88EA87D@mellanox.com> References: In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=yskoh@mellanox.com; x-originating-ip: [73.222.116.174] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; VI1PR0501MB2157; 7:GVkLMAe2YNfaqQ6FcKfFAlWiAztuGSOmyj2GsTVrG5qNgwaV/hC9J+wEyrDF5KoyfhsTto8IzLMj7NlXR9AKpAkcPwpA5JNznWUm2ElDPo3UskyIw8cY7NUG9cFMvY3a+R7JMrI7j8zDNxwmrFH/u9sBHyGLtWMvFfVgblqs/BL5ASRLZ7bBXromxpFwQpc3HaUN4mkrMlU8dKjVuNa4vz6BEN35jT6M5aJtGTTZSDDrAUxmOSk19I+sZ89jUigG x-ms-exchange-antispam-srfa-diagnostics: SSOS; x-ms-office365-filtering-ht: Tenant x-ms-office365-filtering-correlation-id: 1161a98b-50ac-4008-f7b4-08d5735958ff x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(48565401081)(4534165)(4627221)(201703031133081)(201702281549075)(5600026)(4604075)(3008032)(2017052603307)(7153060)(7193020); SRVR:VI1PR0501MB2157; x-ms-traffictypediagnostic: VI1PR0501MB2157: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:; x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(6040501)(2401047)(8121501046)(5005006)(10201501046)(3231101)(944501161)(3002001)(93006095)(93001095)(6055026)(6041288)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123562045)(20161123558120)(6072148)(201708071742011); SRVR:VI1PR0501MB2157; BCL:0; PCL:0; RULEID:; SRVR:VI1PR0501MB2157; x-forefront-prvs: 0583A86C08 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(396003)(346002)(376002)(39860400002)(366004)(39380400002)(501624003)(189003)(199004)(36756003)(229853002)(86362001)(97736004)(33656002)(316002)(53936002)(6486002)(66066001)(5660300001)(82746002)(106356001)(6246003)(6916009)(2950100002)(6512007)(6436002)(305945005)(478600001)(3846002)(2900100001)(5250100002)(25786009)(4326008)(76176011)(3280700002)(6116002)(8936002)(3660700001)(81156014)(81166006)(14454004)(8676002)(2906002)(99286004)(102836004)(105586002)(26005)(6506007)(68736007)(59450400001)(53546011)(186003)(83716003)(7736002); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR0501MB2157; H:VI1PR0501MB2045.eurprd05.prod.outlook.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; received-spf: None (protection.outlook.com: mellanox.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: ar0us+Jv85BTLihfnn43+h4sRzS4k1i+6XaXJwImO2yVbTD25COa8WLTx5mUQcba2X4Dsw40joAhFhWsbFBDCw== spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="us-ascii" Content-ID: <60B2ED325DFCB141B8CE4986C113FC5F@eurprd05.prod.outlook.com> Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1161a98b-50ac-4008-f7b4-08d5735958ff X-MS-Exchange-CrossTenant-originalarrivaltime: 14 Feb 2018 03:16:32.3684 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0501MB2157 Subject: Re: [dpdk-dev] Accessing 2nd cacheline in rte_pktmbuf_prefree_seg() 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: Wed, 14 Feb 2018 03:16:34 -0000 > On Feb 13, 2018, at 2:45 PM, Yongseok Koh wrote: >=20 > Hi Olivier >=20 > I'm wondering why rte_pktmbuf_prefree_seg() checks m->next instead of > m->nb_segs? As 'next' is in the 2nd cacheline, checking nb_segs seems ben= eficial > to the cases where almost mbufs have single segment. >=20 > A customer reported high rate of cache misses in the code and I thought t= he > following patch could be helpful. I haven't had them try it yet but just = wanted > to hear from you. >=20 > I'd appreciate if you can review this idea. >=20 > diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h > index 62740254d..96edbcb9e 100644 > --- a/lib/librte_mbuf/rte_mbuf.h > +++ b/lib/librte_mbuf/rte_mbuf.h > @@ -1398,7 +1398,7 @@ rte_pktmbuf_prefree_seg(struct rte_mbuf *m) > if (RTE_MBUF_INDIRECT(m)) > rte_pktmbuf_detach(m); >=20 > - if (m->next !=3D NULL) { > + if (m->nb_segs > 1) { > m->next =3D NULL; > m->nb_segs =3D 1; > } > @@ -1410,7 +1410,7 @@ rte_pktmbuf_prefree_seg(struct rte_mbuf *m) > if (RTE_MBUF_INDIRECT(m)) > rte_pktmbuf_detach(m); >=20 > - if (m->next !=3D NULL) { > + if (m->nb_segs > 1) { > m->next =3D NULL; > m->nb_segs =3D 1; > } Well, m->pool in the 2nd cacheline has to be accessed anyway in order to pu= t it back to the mempool. It looks like the cache miss is unavoidable. Thanks Yongseok=