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 3E619A0352; Tue, 8 Feb 2022 17:36:27 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 30AB241141; Tue, 8 Feb 2022 17:36:27 +0100 (CET) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by mails.dpdk.org (Postfix) with ESMTP id 71CF0410FD for ; Tue, 8 Feb 2022 17:36:25 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1644338185; x=1675874185; h=message-id:date:subject:to:references:from:in-reply-to: content-transfer-encoding:mime-version; bh=wHtkbyw4Ms2eE57pDfk6b9vmMoCGJBaYh9KeOHPrn/g=; b=NUezhg6N8902WAQgRnhVpEfH7T6vLwlOq2Os8P3T5Yu/nz0KT3jwmyM+ EnwVrBs1xaksYEY1iuqIBm9xNF6ZchISZHX8dVyM4o0Ne3DCUYNG7JnK8 RrBzlJLIGhIkw56L/SPI4Ef8edNyqC372cRRFR7UO/oHHA+hkWdUCdSKK GZXFoS0wwu5YBSN7CS0rXVSLahUCh1A+XzBshndShSUHf2pqOrEp3P6yx 1mCy6vQE/kO5VHm7AVhb9LdeMx8NZgLfa6KZzg6t902ly9ZP5zy+b5zWy 5nJF+U8h+XO25jxZsNaCTa6YH1rZhiUkOtKmvze2XCuafDXskH9g/Gs4R g==; X-IronPort-AV: E=McAfee;i="6200,9189,10252"; a="312283943" X-IronPort-AV: E=Sophos;i="5.88,353,1635231600"; d="scan'208";a="312283943" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Feb 2022 08:36:24 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.88,353,1635231600"; d="scan'208";a="525610670" Received: from fmsmsx603.amr.corp.intel.com ([10.18.126.83]) by orsmga007.jf.intel.com with ESMTP; 08 Feb 2022 08:36:24 -0800 Received: from fmsmsx611.amr.corp.intel.com (10.18.126.91) by fmsmsx603.amr.corp.intel.com (10.18.126.83) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.20; Tue, 8 Feb 2022 08:36:24 -0800 Received: from fmsmsx609.amr.corp.intel.com (10.18.126.89) by fmsmsx611.amr.corp.intel.com (10.18.126.91) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.20; Tue, 8 Feb 2022 08:36:23 -0800 Received: from FMSEDG603.ED.cps.intel.com (10.1.192.133) by fmsmsx609.amr.corp.intel.com (10.18.126.89) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.20 via Frontend Transport; Tue, 8 Feb 2022 08:36:23 -0800 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (104.47.56.172) by edgegateway.intel.com (192.55.55.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2308.20; Tue, 8 Feb 2022 08:36:22 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lD/c3dTYFeW3SPshnqw5LPUwU8JWO0U33bEExp3PqOg6+ksMWtBGgI4HCxzmVLmPxsdTBj/BFhRfURy62jANnBKZpPXiizd9X6tR3JEM8QLNUOQB6wvST9EH+yW6CIo13NPNjqJvOS2MUJKrx3xaAsOKM/Xs7231PJJv0RCSNOByXwfvICDSCuTHLnwRIBWo9YObkYuvAsjciY36cRSp5AycYZ/hFq4EieCeC+PuMA67duDXw3TDjPGxgV77ZeIZkXjkWeOvzPmMZu+CirfIHo1Bnb2bdOp1lcDXHKhAoGI0KYTO4vPbYJmUghzpDQSf+lKgIqmgnQXWt3CCv17yNQ== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=LuCvoA89WGpSN9BNGxNaSDtnm15UEC3yyNuZocd4eGY=; b=UkVZrcLcdyBMMwfKWptny06yDyn+muiofAz5YIKloFIc6mDjpCN6+3mCIxhBvjgnhLj47BcWTu7HQZQTAVNAFVZp/HycGgaVZf2ljjefrX0BH3lzlvpY5ddhXpFNqDIPRhbaE1bki5Za2ukJtriXcFqxbfhmwocWHTs34LQ/rvTO8f0rsHErztfjgrg0WF9WvkoVw1ISYtCjyYeDCaLMxXHCGHqr8kFuBAEQXxKorI71d7rE+ldDVzyoOs5zPe6eOBSgEEc4TVXbuWzxcuEvWVtp8KKjxRkZv8ZC8QkX+WzxaCSgB5/u8FRCWdyvXbPA5sQFuCU86w7nmUh9+sHCrw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; Received: from PH0PR11MB5093.namprd11.prod.outlook.com (2603:10b6:510:3e::23) by BN6PR11MB1537.namprd11.prod.outlook.com (2603:10b6:405:c::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4975.11; Tue, 8 Feb 2022 16:36:21 +0000 Received: from PH0PR11MB5093.namprd11.prod.outlook.com ([fe80::ad52:b9b6:8147:b4d5]) by PH0PR11MB5093.namprd11.prod.outlook.com ([fe80::ad52:b9b6:8147:b4d5%4]) with mapi id 15.20.4951.019; Tue, 8 Feb 2022 16:36:21 +0000 Message-ID: <8a28f104-a534-e01c-15b3-efc73eca0360@intel.com> Date: Tue, 8 Feb 2022 16:36:16 +0000 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Firefox/91.0 Thunderbird/91.5.1 Subject: Re: [PATCH v3 3/6] mem: add dirty malloc element support Content-Language: en-US To: Dmitry Kozlyuk , References: <20220119210917.765505-1-dkozlyuk@nvidia.com> <20220203181337.759161-1-dkozlyuk@nvidia.com> <20220203181337.759161-4-dkozlyuk@nvidia.com> From: "Burakov, Anatoly" In-Reply-To: <20220203181337.759161-4-dkozlyuk@nvidia.com> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-ClientProxiedBy: LO2P265CA0304.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:a5::28) To PH0PR11MB5093.namprd11.prod.outlook.com (2603:10b6:510:3e::23) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 20a7aa6f-fe5a-4845-9ac4-08d9eb21238d X-MS-TrafficTypeDiagnostic: BN6PR11MB1537:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:10000; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: H3Oxdbq41+a4LgvRBQ7qPPIggsOoGQeN8GZutpA0WU/GltXkrTgwjuham9ui9nSaskYwI2LuL5CRDPFxosf2WDW8+yKKCy2AG3x2UQsDbU244pF3+xI0qMBU7rIhDlP3kJh4Db8sYiakRmatocWc+IVV8/yDe451S7z6XaB+4P5+hZblygPD9XSQPYyDJIuD1AUy94KH3EVk6kk7SuxCdYk81jqK6D2vjk+caJUjUP0JVicjElOKP0BLyDxD7zUZTnygsb0IwYgqOPj4naP8hJ2KZf84zDDkIWRIWp4Q4WwI4iPN8tfLW30HVK6F3DQ7dVOWn9ExofrVEUWSoH7v3nyHyvXXjwR4T9Gajv/Rcup+keQ6kV52u6q2Mt+8E276l1wgJ2OhoaOgSsbwD6Eh2EXpmzvLcaNvfOZ909s/HOHKmHN+jUA8mE23YpTZO+2a2AkowgO/38VF6dc7k0xcCzIlo7b62LetbLSa2iZkhHX/3E6wPv5N2ChRFlUG82nm8yiGh7wEQQPfDr9BokJSmti/v2GHrZtyjcA99hcYTwdtD758kGnHenhbfOIN6v+jykbPkjF56+Sc5ApKj0MLKcGfEKrpCR/8LircDuI4BJla3AntefSIeSd+BdfKA5NJaFsHye/bT8Z9zUMUABrpc2evWFiyzJtXzxjUlKLrv4/cYA806XALmeKRE18rPLkHzpLMI6b36wGal6UhQH2G+3KB2g4EXBTHihAl335Fh3GdHD7GRh5d39dn8BWrkRbbNSeGq2AqdIHilVTtdn0e6w== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:PH0PR11MB5093.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(366004)(6666004)(5660300002)(86362001)(53546011)(6512007)(8676002)(31696002)(66476007)(66556008)(6506007)(8936002)(38100700002)(36756003)(508600001)(66946007)(82960400001)(83380400001)(6486002)(186003)(2616005)(2906002)(316002)(26005)(31686004)(14143004)(43740500002)(45980500001); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?RXVDNkhUVHBPNEhzQWhEaXozdmZaUWJuZkRTclZZVW1ieGcyUTVnQzQ0UlBJ?= =?utf-8?B?WkFvbHZITHZyUXo3Y0dnSXhnL2dNem04TkJ5emIzeEtlSFNlMWxMMHY4bFBO?= =?utf-8?B?NkNSckcvMER5RWF2THpIbmQrNnJRVTZBazgzdTZES25CMGhwSFNzaTNYandz?= =?utf-8?B?QzBGVWFkbWZzL0NManNEM1VUWXRmNUlxM1YxZDRRSVduZHF6VFdTcU5tSUlL?= =?utf-8?B?Rnh5Vk5BY0VrQmpUUUxlMHNM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GxXcnc0?= =?utf-8?B?YTFSSE9pOUVOamNkSHNJa1BUcFlCMlFZRWtEOUd6K1hNdkNQMTYrakpRZ1pq?= =?utf-8?B?T1dtQStjM0ttY250c0Roa1d1TkhpdnhsbG1xaTNqZnpxZVIzdkRacTc0cGFa?= =?utf-8?B?aVJsYzUva2N4L3FrQUpIeFpQbEd4MDBleWd5aUxabnd2UmtOUFBxbjc5aWxW?= =?utf-8?B?U2NFbE8xL2NGdDJ6aXlKc0c4K3RBPT0=?= X-MS-Exchange-CrossTenant-Network-Message-Id: 20a7aa6f-fe5a-4845-9ac4-08d9eb21238d X-MS-Exchange-CrossTenant-AuthSource: PH0PR11MB5093.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Feb 2022 16:36:21.5066 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: J5aGnylUzqshhFfMgDYlCQCkIJH92qDMFpGwSxsx1SA97PHf4QD9MDMebsq01nFHBQ/sqOsyUsk/Ffmut4TOU7wxJL4X2lWdh23ty+SgJ+Y= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR11MB1537 X-OriginatorOrg: intel.com 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 On 03-Feb-22 6:13 PM, Dmitry Kozlyuk wrote: > EAL malloc layer assumed all free elements content > is filled with zeros ("clean"), as opposed to uninitialized ("dirty"). > This assumption was ensured in two ways: > 1. EAL memalloc layer always returned clean memory. > 2. Freed memory was cleared before returning into the heap. > > Clearing the memory can be as slow as around 14 GiB/s. > To save doing so, memalloc layer is allowed to return dirty memory. > Such segments being marked with RTE_MEMSEG_FLAG_DIRTY. > The allocator tracks elements that contain dirty memory > using the new flag in the element header. > When clean memory is requested via rte_zmalloc*() > and the suitable element is dirty, it is cleared on allocation. > When memory is deallocated, the freed element is joined > with adjacent free elements, and the dirty flag is updated: > > a) If the joint element contains dirty parts, it is dirty: > > dirty + freed + dirty = dirty => no need to clean > freed + dirty = dirty the freed memory > > Dirty parts may be large (e.g. initial allocation), > so clearing them could create unpredictable slowdown. > > b) If the only dirty part of the joint element > is the freed memory, the joint element can be made clean: > > clean + freed + clean = clean => freed memory > clean + freed = clean must be cleared > freed + clean = clean > freed = clean > > This logic naturally reproduces the old behavior > and always applies in modes when EAL memalloc layer > returns only clean segments. > > As a result, memory is either cleared on free, as before, > or it will be cleared on allocation if need be, but never twice. > > Signed-off-by: Dmitry Kozlyuk > --- Reviewed-by: Anatoly Burakov -- Thanks, Anatoly