From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id C82E6A0516; Tue, 9 Jun 2020 13:15:02 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 2D75F2986; Tue, 9 Jun 2020 13:15:02 +0200 (CEST) Received: from EUR02-HE1-obe.outbound.protection.outlook.com (mail-eopbgr10051.outbound.protection.outlook.com [40.107.1.51]) by dpdk.org (Postfix) with ESMTP id B356D2862 for ; Tue, 9 Jun 2020 13:15:00 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Y1HscP5W506A56Wa2omyOdyDdrU9jcZxhwdeYLTWBRC9Un71eijRu8ElpyooLFRHx+WpeAktylKkcNYIX/McNjQX9lwQmpAyrfSxudsYo9wBFCvZ7I4p/DBM3tMTlCOdFYFofPg/petdTADqRRbtQcx5wTB7PoE3rXHYOy2X0iyBw8oWtJ39pASVHFnmEToAMnqQZCw1sBdvYsBlLEqfCGjMpfIw0KMREfY2TmkA5caiAUPo9IYLgnCymA2FWBDooJsiTz/Q8EeOba8XZDY8iEuPkxL/O+gj9y+dHCSHw7EN9zWWP5yF4PS0EZgl1MkFqOxVfOFydgkZxupZMjV4+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=hpzzjGAyfKXLemURq9bnMcsOmRR7JcvO1C8nVkC523k=; b=Zw+/K6qnf5LE7fLyRFUMpNLgp8vYlIEzIwAAGaridQNO/JDDOKMUheYuRtDHPWqxcJz3VQjJMrP4xY3uEyLzshIb5uR9rzANExHIGmQ8dVFkJ01f5gNWRVTc3HCI3AxEAzDwYx8xkDlnVdByZ9jXxI4Zo+Hvtw2jGIdu7FSh3g5rWT81oNEV87tCjFBokXef3T9tKSGlWXwTvjXFbTLVnu0zyaHM3Rb5QBko/nTUzG1HMhaa+55nLBOeatZs8esi4NVqKzImej4izkStoUqe7XtT98LpdHztthVLK3TrdMIZVi4i9ZgmlG5hfffmtF/X7uFQDI1O9reuBOa4ECKygA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=mellanox.com; dmarc=pass action=none header.from=mellanox.com; dkim=pass header.d=mellanox.com; arc=none 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:X-MS-Exchange-SenderADCheck; bh=hpzzjGAyfKXLemURq9bnMcsOmRR7JcvO1C8nVkC523k=; b=bYkLJYRL+UByxVfwLX/hTniW/lg1g48PmC+iVl8wHwHX/dTd8diEKW8Le8ZjMm0MvjROavX/A8W4NefsyTDhSQsUITBTCyqKUkmrIKRg+Zhbvc4P5b/Bt8qFAm9VigA+BP75+D5eE+gXvdmLoknY9SsITs5y3pq56djAT28tmtA= Received: from AM0PR05MB5313.eurprd05.prod.outlook.com (2603:10a6:208:f2::28) by AM0PR05MB4499.eurprd05.prod.outlook.com (2603:10a6:208:5b::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3088.18; Tue, 9 Jun 2020 11:14:56 +0000 Received: from AM0PR05MB5313.eurprd05.prod.outlook.com ([fe80::3069:d8f4:fadc:4d7]) by AM0PR05MB5313.eurprd05.prod.outlook.com ([fe80::3069:d8f4:fadc:4d7%5]) with mapi id 15.20.3066.023; Tue, 9 Jun 2020 11:14:56 +0000 From: Tal Shnaiderman To: Dmitry Kozlyuk , "dev@dpdk.org" CC: Dmitry Malloy , Narcisa Ana Maria Vasile , Fady Bader , Anatoly Burakov , Bruce Richardson Thread-Topic: [PATCH v7 04/11] eal/mem: extract common code for memseg list initialization Thread-Index: AQHWPWhV0ihDl4MJTUmI44GTTIJdw6jQGxgg Date: Tue, 9 Jun 2020 11:14:56 +0000 Message-ID: References: <20200602230329.17838-1-dmitry.kozliuk@gmail.com> <20200608074153.29611-1-dmitry.kozliuk@gmail.com> <20200608074153.29611-5-dmitry.kozliuk@gmail.com> In-Reply-To: <20200608074153.29611-5-dmitry.kozliuk@gmail.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: gmail.com; dkim=none (message not signed) header.d=none;gmail.com; dmarc=none action=none header.from=mellanox.com; x-originating-ip: [37.142.1.17] x-ms-publictraffictype: Email x-ms-office365-filtering-ht: Tenant x-ms-office365-filtering-correlation-id: b811af92-6db6-42ee-c49a-08d80c665768 x-ms-traffictypediagnostic: AM0PR05MB4499: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:1284; x-forefront-prvs: 042957ACD7 x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: eiSHLo3yYeKgWdQgOAwIYVY8sE22eoFvoA1tLKZkb40bUw/5AEzWww9+utZ/i0SeNQFdYvs9atobI9SWplRbXYNR5UtXsM9QqQ9/ndujt2YG5rCaAAvzHfDIzq8egC03XAykUlKVbTwi1C6/7APUm1SZxGYBb15J4c1/bXSVdgAbAegOgqaVQmW/K68dzJ1tEf4/Bz2TtUvSjyeK7onWF/hV8X7rBLreirS0NAy2thKjCtu9DI0eY0f/RnXRHakY3GcZ+BggQiFwKqt0mJN731WGftmwkiYIj1spxjowYiqA2OUQBWPS7Y9L+wIcjChcypCg4Uec7I0aRfINriUKJA== x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM0PR05MB5313.eurprd05.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:(4636009)(366004)(396003)(346002)(376002)(136003)(39860400002)(55016002)(71200400001)(8936002)(8676002)(54906003)(110136005)(316002)(2906002)(33656002)(186003)(478600001)(86362001)(4326008)(52536014)(6506007)(7696005)(26005)(5660300002)(66476007)(64756008)(66556008)(9686003)(83380400001)(66446008)(66946007)(76116006); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata: 3IxoOmsXX30HQoBVF1rN65FuS+dlaVxAVOS722yiWqITqIrmv7fl9edriVaAMALQDHtMxtC/Bk2QyYMtvayqF9FM/GKnt7EgHotDeqH9OCa1YDeGobb3fhf7gk2UJ1H9AblqGkiFiidRk0mq77VfXvg62PjvZ8tldjWZg4OJKnwhoLBaqBzKShhKwWLx0n0tWZL9h4jPcDpT9aJQ3D+5JuKbHF2VzPHc2N8LtUTNOQfv5xhR63IZiCgaVOISRsSXnD/qZMes+Z9EWafYtMhFK7QcM4sn3JtQuL8dZQoRSxGfX6XF+lSh0aBh85uTAb+DLJ8aIm7eGE+r798g94XDyxW6/WNXlodUoc1uO5M2SrXKSPetNakHc6Yf0MR77YFLEpWwYQcCQNX4+q0TFALG90CUHwBMNarBqxT+f1MD+kn9/qW06/6SF1u8u3wOL/eee7fpVRQLX6ux4WHUiW27G+Tw1qp/VoxeBrGJRHoBbho= Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: b811af92-6db6-42ee-c49a-08d80c665768 X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Jun 2020 11:14:56.4237 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: 61ZpvZfiA2aP0angCV8x5tiZ4eO2VUrTPY1BwnjLa3MFrbR/NIFM49bj6rd6iaHg9924DEAUBQI4GkuCj9aeNQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR05MB4499 Subject: Re: [dpdk-dev] [PATCH v7 04/11] eal/mem: extract common code for memseg list initialization 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" > Subject: [PATCH v7 04/11] eal/mem: extract common code for memseg list > initialization >=20 > All supported OS create memory segment lists (MSL) and reserve VA space > for them in a nearly identical way. Move common code into EAL private > functions to reduce duplication. >=20 > Signed-off-by: Dmitry Kozlyuk > --- > lib/librte_eal/common/eal_common_memory.c | 97 > ++++++++++++++++++ > lib/librte_eal/common/eal_private.h | 62 ++++++++++++ > lib/librte_eal/freebsd/eal_memory.c | 94 ++++-------------- > lib/librte_eal/linux/eal_memory.c | 115 +++++----------------- > 4 files changed, 200 insertions(+), 168 deletions(-) >=20 > diff --git a/lib/librte_eal/common/eal_common_memory.c > b/lib/librte_eal/common/eal_common_memory.c > index f9fbd3e4e..3325d8c35 100644 > --- a/lib/librte_eal/common/eal_common_memory.c > +++ b/lib/librte_eal/common/eal_common_memory.c [snip] > +void > +eal_memseg_list_populate(struct rte_memseg_list *msl, void *addr, int > +n_segs) { > + size_t page_sz =3D msl->page_sz; > + int i; > + > + for (i =3D 0; i < n_segs; i++) { > + struct rte_fbarray *arr =3D &msl->memseg_arr; > + struct rte_memseg *ms =3D rte_fbarray_get(arr, i); Since rte_fbarray_get() can return NULL you should verify *ms isn't derefer= enced. > + > + if (rte_eal_iova_mode() =3D=3D RTE_IOVA_VA) > + ms->iova =3D (uintptr_t)addr; > + else > + ms->iova =3D RTE_BAD_IOVA; > + ms->addr =3D addr; > + ms->hugepage_sz =3D page_sz; > + ms->socket_id =3D 0; > + ms->len =3D page_sz; > + > + rte_fbarray_set_used(arr, i); > + > + addr =3D RTE_PTR_ADD(addr, page_sz); > + } > +} [snip] > -- > 2.25.4