From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 53999A0C4D; Tue, 24 Aug 2021 12:58:12 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 145AF40687; Tue, 24 Aug 2021 12:58:12 +0200 (CEST) Received: from NAM12-MW2-obe.outbound.protection.outlook.com (unknown [40.107.244.61]) by mails.dpdk.org (Postfix) with ESMTP id 541594014E for ; Tue, 24 Aug 2021 12:58:10 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nEOlltcTJag0Sf30DTBa61ZZmV1KUpFixAHRohKNQNPPXV8iZBkV5iFDxWhcfMUJMWoENrMurt3WTjHjnwy4CHEfVhtviOByLlLmGlhRD9YxP/i+2GuTVQeOqq2om3K758nIGDZNazvTXB8T3RtF+UQ/4gKJE3gQt/i7aT2PHhDM5CC1KJMhY+VS3PuviKMu+u6XYYVPeg6z5TQhRbiEguFeCw5lwlqTyGLbllWVm1ljgVf0nfeMYJJE0pJHnKt3NqSRPgtrGaDv1wLNr3L4LDKlfbJjH1sZNzxSEFmdFbO9llrciey1IIaMfO/ccPnMlHBhOnNraScYgdK0z9jMHg== 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=+0uU98qS8tDqF3enVkoVP8Vxl92oURa48RKdAy90PQ4=; b=YcjvY/9dpGc+BZ6mSHNE2zVI2hAZKW8tWNS8eLv8an81oS90TQOqRhar6U7W8nMiqdnf3aDs6TP2kmg+x7zevE5GmRE701PUUNN3fYX9GxojOfZrS5phwpVYm9Wdd7ImD76tbs3VIjww1UaViutoWGiLRxBorIFBtmgMlJ2RUItZHb6HYu8bfnG6gndai+tAT6Ps8aFd5eFnBOKheyUwEs5P+iNKswhnLreUEF9gCjwNorqQPPUmuXqmZzdqrL45U7Aw/pVpkj7DOFpBT+CgARfDc2zE7Y6dgAExR/69wk4qWJMdjuLOIF76JK3KRmiHZCGxeYLgRprOp7VJXBleTQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=+0uU98qS8tDqF3enVkoVP8Vxl92oURa48RKdAy90PQ4=; b=ciPpXHeCpSZjAb4ynvJPlnifYN9PMXF0kjEHIyNNNc+Xr9xVRHO7eQ32Da7Df7DPdnjl1Dr5NtG8GQfchihanR5Xp9QEqMbcSTrTRO0g89C3OcOZ9wJsPdeMBi/aVKivnpR1d5YvNFheWavFt+Gz6bfVRxa5BxdIUuOaYnsiVUr+KMtx78GxNaT/fB2bJA2lN68cNQdmFiAqIPEWd2Ow8TIYkCohUXdcvopaWljc5wwSq2fIE5CDvTOk0t9aG16tx9pmRJ1NVr1UEqQHFCOudvgNfhzO5oCiSkVEc2wDA//8QKbezZw1+7CkeGKueP4t9nFzzR99lasKwzA3OLxVqA== Received: from CH0PR12MB5091.namprd12.prod.outlook.com (2603:10b6:610:be::10) by CH0PR12MB5249.namprd12.prod.outlook.com (2603:10b6:610:d0::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4436.19; Tue, 24 Aug 2021 10:58:08 +0000 Received: from CH0PR12MB5091.namprd12.prod.outlook.com ([fe80::6445:7cde:c742:f320]) by CH0PR12MB5091.namprd12.prod.outlook.com ([fe80::6445:7cde:c742:f320%5]) with mapi id 15.20.4436.024; Tue, 24 Aug 2021 10:58:08 +0000 From: Dmitry Kozlyuk To: "dev@dpdk.org" , Anatoly Burakov CC: "Xueming(Steven) Li" , Thomas Monjalon Thread-Topic: Zeroing out memory on free Thread-Index: AdeYzXnWKcwciIowRBuSOzYYPKZW/w== Date: Tue, 24 Aug 2021 10:58:08 +0000 Message-ID: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: dpdk.org; dkim=none (message not signed) header.d=none;dpdk.org; dmarc=none action=none header.from=nvidia.com; x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: f2222508-8408-4ac7-c9bc-08d966ee0ed7 x-ms-traffictypediagnostic: CH0PR12MB5249: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:9508; x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: O2upx4fWBbMf0W0XSYqeX9jmypECAeCOW2xY6HYgL3WjwL7TyeWpHtprVs7Vx/BHuRANSp28Atw28kANNzbKYSJyBzqM+ybkbeNw+iNGFs4A12Iqddj6rkc4HpxJxR7xBRJzsTo5zS2emQFs7r4m540I4nzBhGA5zeDgOXJwdnU94sBc91s8jLAxUsxZxo1i9XExR8mZW5DU/o/61kKWDQ6ZyexvuFuBad0t29k5BDoMMAL2FaEMGEuhsjxYPOK2vJhN7H+AuipuotHWpAXH2D99Zrhf7/Kg5sWa2ZpvSWV6XRega7etyrGdTXPiEu3pR9VPtGwH7HAdQoKzXzMuJaGMDu6EoBrcywI6j5K19KsLJ2JoCOS4uDxyu3V2DNYgtXnCfOrKpuGMhhCIFrNJd2+uVr23OshEPTzWmQjBCek6MwM5mkVxiKL+UiXu0W4CpcvDoJ+eyCIMEWpIoSD0KS0tqF+l38bEj/sJof3x0ShiZKTXzDNNzNzvnJ24Fk8air7old7MP04m3gGtEAn7opvTXmvDB5HQ9XpJdUoDC0tC9Uwa5wH3EtRKPqXFGUXOLy4RQmxq9P7UzfEIONq2B8DtjiyIZh/5BKsb+BWwyW4zmKbtq9Ivazi4fpqlS3ieMtr8V4zKz0CoAkceD3eJABB5R//v5pSjyAxDIDIcCD05eBI6qD3zGQuMbUkpO9G3GfZ+jkK0xa6AY4OBPp6lRw== x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:CH0PR12MB5091.namprd12.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(107886003)(66476007)(66946007)(9686003)(76116006)(8936002)(66446008)(66556008)(64756008)(316002)(4326008)(2906002)(5660300002)(26005)(7696005)(33656002)(86362001)(110136005)(8676002)(6506007)(186003)(55016002)(54906003)(38100700002)(122000001)(38070700005)(71200400001)(508600001)(52536014)(83380400001); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?XwnhPULx0lTGdrWx1g0vVvRodWpTCYjEosgvf8EdVxU/MDuiSAm23OuChxaP?= =?us-ascii?Q?scSHEJryeo1HSYFYEB6tyUikOJSDnhLaeV8/HbjLdV9gccG4BMvuZfb/YwqT?= =?us-ascii?Q?73nvG5e7WJTQFbmiPW01OGOXpMb2EimxkTIUCVx5WdHiTd/9yFMieJwjWVtt?= =?us-ascii?Q?5u0YY06/XdVQ5iLi8qQ6D03bVRI+lo2zWQmicp92BQ31FK0JLYWq1yBRSnnu?= =?us-ascii?Q?1pd4OwXrCCWsv9fLZBbpUJ91ri4FjE005l+2CJBtdthoX3V2SSaLV96DiInc?= =?us-ascii?Q?xCnN59R/7DUwtKlDLtXyW546VOLCMysXNrvN7XNF3P3RwbfKXTJEzgCtrTPH?= =?us-ascii?Q?rmq8RKj6RAq7ZWo7Tqlit1f7e53rSDm44tT7BfDDyaMA5fkk1kUmaFj/VwmU?= =?us-ascii?Q?9qX3CQEuz9DkX3WKbAW1ci1dWZPDoG4Y9V8tCp7yReHs6rQfA1sadGA3kroj?= =?us-ascii?Q?QB3U/LwxVtyc72Aliqm8RmUD0gFHHVBujAvrxpAaomoedS/r2vHxxvLrJHeM?= =?us-ascii?Q?sHqyDi0gn2IrhaODNHCdE7hsgSrw4nzAhjTEgKJmmmUYTaNCSURaNtiUcqLA?= =?us-ascii?Q?ayYpUsDhaFf7b4Hqu+W6DAOTicX0EVFY30GMq74d7Jk+46wOU6yfbLK8yAR9?= =?us-ascii?Q?jtsuIrXtKYEFsi4Vz8Fh3dd3eefo6VEv0UesBvxIx9CKlPiGAttIjGppp+VD?= =?us-ascii?Q?wwJtycSEzYkMffbuk8HLicgP5vDsl2PD+5l6M5dZ8dz24kPu4CoWKyQRx7GD?= =?us-ascii?Q?q4K6DJrNKEPuZeFEz6kueMHjnAPIs0omxLCNvlYROTVf/Wyt5flUxd4rgMNg?= =?us-ascii?Q?q3rh/OtflcPQTgYnRON4hrPE/4Qo7c6biGrm/0rCUNtHrhLKEoLIqHFCPie+?= =?us-ascii?Q?8BMfX1Tu6+o94PfRiu8vPh90ZglgmlNGaEl1Qs31APeOh7NfBG/dSSCiTaDn?= =?us-ascii?Q?F+tQZRCzOyNRTupaeE8Xgjc2jos//y4aHDXtyaGm4fZ6LXmTgnj7QUAqGeDm?= =?us-ascii?Q?JdiAtjUWRG1pG3NKzGqpoJRziU23/fuL/R8SvlNRpXnbdKbye7UZmdgGOnS6?= =?us-ascii?Q?369ZynUMjNul6Y8g1WAMzYJg4C6on3Ij4sjsVlXQYXR+fb39FTyMEP92Krgl?= =?us-ascii?Q?/x4nzHLqKCRRbpYUwnEFeyQYeGBmPTrJdLl8pUIENBl8yUmnIVyn4UjA1AcF?= =?us-ascii?Q?gE0vVWwG6snVmJIubvDMEC3vlK5vY7D251YDL0XEZxUbjaEULSYEvOZnJ2tx?= =?us-ascii?Q?xdouQvJD2ow1LMos1eB8vykUsDMtkuhVI6AZzww0tPXZdBnGWhbFZFBNM+yN?= =?us-ascii?Q?nDA=3D?= Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: CH0PR12MB5091.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: f2222508-8408-4ac7-c9bc-08d966ee0ed7 X-MS-Exchange-CrossTenant-originalarrivaltime: 24 Aug 2021 10:58:08.5056 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: tZNRyl835r+uRF+yoqxgXVqVZFV3avyC1wGKHzBZFx4pBZEMoMYNRCByiAwox9meUJADZbFnSQ6wahd7VCcfRw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR12MB5249 Subject: [dpdk-dev] Zeroing out memory on free X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 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" Hello, Me and Xueming are wondering why DPDK clears the memory on free and not only when it's explicitly requested (rte_zmalloc). It's been so for a while: commit ea0bddbd14e68fb42d9774bc3543e51b510e48d3 Author: Sergio Gonzalez Monroy Date: Tue Jul 5 12:01:15 2016 +0100 mem: zero out memory on free =20 Since commit fafcc11985a2, memzones are not guaranteed to be zeroed out= . This could potentially cause issues as applications might have been relying on the allocated memory being zeroed out. =20 On init all allocated memory is zeroed by the kernel, so by zeroing out memory on free, all available dpdk memory is always zeroed. =20 Fixes: fafcc11985a2 ("mem: rework memzone to be allocated by malloc") =20 Signed-off-by: Sergio Gonzalez Monroy At present this explanation doesn't look satisfying: 1. Memzone API does not promise they will be zeroed out. Memzones are mostly used for DMA, so their content will likely be overwr= itten. 2. If application assumptions are wrong, DPDK should not try to fix it. Memory manager poisons memory in debug mode to detect such errors. Zeroing memory is quite slow, but in many cases unneeded. It looks attractive to only do it in rte_zmalloc(). AFAIK what prohibits moving memset() there unconditionally is that the kernel already gives us cleared pages, so the first allocation of each piece of memory would do unnecessary work. This can be solved by giving the user a choice in EAL options or with more elaborate tracking of memory dirtiness in MM. Are there any other reasons why clearing is done the current way?