From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.11]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 123553DA7DD; Mon, 1 Jun 2026 15:51:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=198.175.65.11 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780329104; cv=fail; b=RcSlTQBh9AnNJ6BYumsaPAHHY8lvSiF1iS1EslpKhDgHpDjB7qa3qfNVCbGSK7XbNQt4TYXD5uafG3Yh9yBzQc/Itg8XtON/h5f+zcT0gSMqa3cBrQAeIKqewBpTG5BsvZbM8hpU/jauvrYBcTR5d1JaxjZZfAfiNgqwLH9epuo= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780329104; c=relaxed/simple; bh=2V+2917W8KrSIKxn+2HFFQ/DVM0Uu+BGUIqS1AoE4xo=; h=Date:From:To:CC:Subject:Message-ID:References:Content-Type: Content-Disposition:In-Reply-To:MIME-Version; b=rvmdt9y40LVNShOtcmcXm7oDR6QwyLiosEvbzZxjs1z6NTO6nUpKr+quGfX94y5kRZzBllpXpkT7X9ZPZ1RLoMJHAL99aDzd/OAUiMfZ2LgBZixxRf4Lz6uu0z+oREU1Z11llJ5V09H+Xh54G1mQFU/Yxdiw1WUg5VngOPnjWMg= ARC-Authentication-Results:i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=PQgkyXLy; arc=fail smtp.client-ip=198.175.65.11 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="PQgkyXLy" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1780329104; x=1811865104; h=date:from:to:cc:subject:message-id:references: content-transfer-encoding:in-reply-to:mime-version; bh=2V+2917W8KrSIKxn+2HFFQ/DVM0Uu+BGUIqS1AoE4xo=; b=PQgkyXLylZBYM241KDJBUCi7xdLGQONmJzrjMIgOFV5xD+ZHoKBLiSMc ukTx644KKwTk6i4J3Fc02AsNunyaAY9sxVNcliei5fQWOjXhBNEVc8amL KK7WXHdacYKqZ+QRRK4C4DXmmJDDD1ICuGwmR7ftEw86gXzgVYvABntTn DKBzJ9IE/JPv+QoJ89dn75jwvDArh7JIPnVY+BNiPMS/CAXj+5VaEpS0q IhKqFm7fXOhQHGACOmYJjCVlrdOibb1Rfn2hrXTpVFBi3hrBk6O41fhXg fdDK/JWRzCwgiJlKSVrw77i7DH7+KtuWrtnreBK89nV6F3CaDw/KGdfT0 A==; X-CSE-ConnectionGUID: wUsdHqi9R9un7C4VvilRcA== X-CSE-MsgGUID: TnWfVVEeQoydLy/sw0KFyw== X-IronPort-AV: E=McAfee;i="6800,10657,11804"; a="91402681" X-IronPort-AV: E=Sophos;i="6.24,181,1774335600"; d="scan'208";a="91402681" Received: from orviesa007.jf.intel.com ([10.64.159.147]) by orvoesa103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jun 2026 08:51:31 -0700 X-CSE-ConnectionGUID: ymaJJUxwSGa9uZa7GVpeJw== X-CSE-MsgGUID: rCI88x2iTBCLceYhlrHz1Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.24,181,1774335600"; d="scan'208";a="243732745" Received: from orsmsx903.amr.corp.intel.com ([10.22.229.25]) by orviesa007.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jun 2026 08:51:29 -0700 Received: from ORSMSX901.amr.corp.intel.com (10.22.229.23) by ORSMSX903.amr.corp.intel.com (10.22.229.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37; Mon, 1 Jun 2026 08:51:28 -0700 Received: from ORSEDG902.ED.cps.intel.com (10.7.248.12) by ORSMSX901.amr.corp.intel.com (10.22.229.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37 via Frontend Transport; Mon, 1 Jun 2026 08:51:28 -0700 Received: from SJ2PR03CU001.outbound.protection.outlook.com (52.101.43.43) by edgegateway.intel.com (134.134.137.112) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37; Mon, 1 Jun 2026 08:51:28 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=hzSQsdJDjxeBgmRSl+Wb2pyvToVXyUnPpLlT8VKReJ8AKz/QNrcwwV2KNzOkrDlwa++f38tANo3EkuxF0E68VOr7b86gcGq9eI6t5uOPqQSybmDbjPsaTdT+eDCQXpb9bZQf3e90fzl2cfrPK4qA1Tdp11GoTyoN7P5XfKFbfUvqFS4KNZ5QBbn9lFNz+XDuIcKMxHVxZfo9T3jWHhl5LYzTVhNMShHqyfacl4wnkG2swZjTsxg63J+hDbXu2rEjG/a1yajmgBIp7NFqbTSeq/LEBTm8VZMtJFjBOW91IS6eu5wTZWm1x5t9uhoM3GkuC8g//P9r40/n9lTpHy5p9Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=JBRkL8nQihDGQNVyl/hfOXNYBa5k6cfuI4xF/gr+X0Q=; b=WFm1hAIbZh2apKrC64yAE32URtFLGfZXXoHDSDN73/GqU9y9Iim6fECLVFbxeL+a1uotVkt2M9AKmti0TTx6OpP6pp/uKZm4CmawHeedCOSflW1h/VJUReYtcXkQO2vjW0exjFX81jCT1+W3KmguIQRQTBWD/42rBc9GHACJcwNoeRu92Ndc2IxNMvDoRZy20fQ5OkdjBi4io8O7/gS+SA4RtDHWUN5mr5WMd4W7Wgn00RtSpNaw0GLmg87JjOwaIBsG3xgG9VolbeOLVFIvt5G4992iqjvmFKYquyO0OWitEBxM7a/0EdgBhKUS/Bf2mKE9x0ArN1XsEVBAoMg8Rg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; Received: from DM4PR11MB6117.namprd11.prod.outlook.com (2603:10b6:8:b3::19) by IA3PR11MB8920.namprd11.prod.outlook.com (2603:10b6:208:578::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.71.12; Mon, 1 Jun 2026 15:51:25 +0000 Received: from DM4PR11MB6117.namprd11.prod.outlook.com ([fe80::d9b3:e942:2686:3cdd]) by DM4PR11MB6117.namprd11.prod.outlook.com ([fe80::d9b3:e942:2686:3cdd%5]) with mapi id 15.21.0071.015; Mon, 1 Jun 2026 15:51:25 +0000 Date: Mon, 1 Jun 2026 17:51:12 +0200 From: Maciej Fijalkowski To: Petr Oros CC: Jacob Keller , David Laight , John Ousterhout , , , , , Subject: Re: [Intel-wired-lan] [PATCH net v3] ice: fix packet corruption due to extraneous page flip Message-ID: References: <20260512181953.1689-1-ouster@cs.stanford.edu> <20260513100732.499e3f49@pumpkin> <20260513214927.17a8dd45@pumpkin> <20260514110112.12bdf5ff@pumpkin> <30dc284c-8cc0-4bae-b7b0-99d6d71a66e3@intel.com> Content-Type: text/plain; charset="utf-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-ClientProxiedBy: VI4PEPF00000143.AUTP296.PROD.OUTLOOK.COM (2603:10a6:808:1::88a) To DM4PR11MB6117.namprd11.prod.outlook.com (2603:10b6:8:b3::19) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM4PR11MB6117:EE_|IA3PR11MB8920:EE_ X-MS-Office365-Filtering-Correlation-Id: 76898746-f86f-4c84-9aa9-08debff5a2d9 X-LD-Processed: 46c98d88-e344-4ed4-8496-4ed7712e255d,ExtAddr X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|1800799024|376014|6133799003|18002099003|22082099003|56012099006|11063799006|5023799004|4143699003|20046099003; X-Microsoft-Antispam-Message-Info: ie16KaxgbC9rICKvX2Yfk8vt8w9/h8w18BShF1PyfkGps/J3pOBkfd3mAXI1orb59nqO0381W4+OtsC2Nv0y0MWupHvkHHIN366XyUw2vPiipel/QgesCuSkoXJ7AvckrcGb5ZfFX3SI+Z3V0sHqhwsnKVPOXso1HTRQUsYji70j8c90cwWIje3GsJiyItjhZJ4d55CBwFjuSBAKbDQvUzTA+CNYoN4S9QxI5w2AVR9t8n2vt6cttlTgvhznT8xlrylLN5MgWFSg3m1nIraOLpxZSHvtAb5r409VslYZTPRwVvv2J26j5cPqkJSiEjIncpTWO+AtWT1bCXbObar4xfwMP320hCNFOjwYpq4E7odYJTFzfovBz4cqKBItqYjkP1K0eozMmr9XtKoswodcQu30V3gqU6qsAnqCbAGgz/xpXZAzuWdwuKAp53lwUfI57poRTiYs6J9pO+jimzxH8NBjfTNDsL2wMQjrGJtAh9RNjsbpjpgW+9GErzVc6ee4+rlqgWczbc5ZVfxF5tFCwUF3M6IxFeMD/oMGpKyUXagqRQr2L8+Ytw8YxtRPhtG/9td+CuKtP3puj48Nqd2OtwXRNIENln9gRO4GP+nBLEWjQ45+7CSq23JuthBJTMPmiXAhbbaQ/HZAvGQcsVVXHwYonFuQam5lgeIZAFBB5i2T1dU+U6Rrzg03aSMJACJs X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM4PR11MB6117.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(1800799024)(376014)(6133799003)(18002099003)(22082099003)(56012099006)(11063799006)(5023799004)(4143699003)(20046099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?UXgzN1Q5RWU5NDVHRDRLQ0QyOTJjdm4vNStXUUNBZ24vcFZXaEd0YjJILzJD?= =?utf-8?B?YmZOT2pzNnJpT3dxQUZBczNFR1JVRDNjS1d4TmVTTlVnMU5IQVhSRTVjREN6?= =?utf-8?B?aU13K1libkp5Q0tSNFU0RVdnSG5RUnhQYlRidzFEakhuWmVPTFZVYUwzb1pi?= =?utf-8?B?aHphbXFhNWFHU1MzNFBJRXJ1anViZ3lHM2Z2K1JIK25Uald1SnN6a2UycG0v?= =?utf-8?B?elJxazFMZ0R3OW1raWVONmdsa0xUZklSd2M5Snh4UkxMclN4NGFFZCtVejBJ?= =?utf-8?B?ZHFFSFUzR1pyNTFhTVBXQThkNlV2cnZWeWFnNkY3Q2JNeDRTUEtxazgrclhW?= =?utf-8?B?eWVDY3hMWjA4R0R5eHdiSG50UGVIK1ROdWhudS9Xa3p3T29icEtrYjMyNldv?= =?utf-8?B?S3FMWEJyd2F3U0VZQXlVaHl1c1lqeFQvamJhZllWS3dHdG0wcUxJWmRoZkx6?= =?utf-8?B?eHFGaFQwUkwxTWRsbElKRmIya2N3V3RsZWRWUVhBOXZuT1UybzEzMk9UaHpV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UNlUUVPZUFvdkM0enVOR2pISkZQNFUrc1ZG?= =?utf-8?Q?NzqD4YyAGfQhobYY=3D?= X-Exchange-RoutingPolicyChecked: UCFe0lJU28fzchTRy8z7UpUYBIKjrc1fheAoG8fQI1xmMqkqT2Hd5nXJsuw+rqxKR0FjrPwHNi8wasGeZSxDM3y/HA0ILBqXSkr78acWqyeR5aef6D30kqA6xh96U7PIkdfVB0I8gnbnOFGUwuKN9kOQTO/Od+peRYr2zPc+xTO7bUEmOpLt1hC8vIdPPIPGn73hVVUVo0eHXxOxxGL63KrV6iRNE3IictbYroTeote1CJcNZ83mlP9+Xc7g5l2S9G1LtTvg8a3yR8nyjxFSwpLoECh//dJvVjomDZW6n7ICmX/5m0AlD/smjmpnmK1oF3nfSK1ODBU4Mvs6AfBo6A== X-MS-Exchange-CrossTenant-Network-Message-Id: 76898746-f86f-4c84-9aa9-08debff5a2d9 X-MS-Exchange-CrossTenant-AuthSource: DM4PR11MB6117.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Jun 2026 15:51:25.6814 (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: Z1IJ6nx3SE8SPapmc/usXjqeQkoKkx9QUu2JT8iVVH2EWh5xXSS2OrP0VEv/4DkjDeSu6QDBSHFNbMrHfT3aKq8iO2f3+5N+jajwExq4mFc= X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA3PR11MB8920 X-OriginatorOrg: intel.com On Tue, May 26, 2026 at 02:47:42PM +0200, Petr Oros wrote: > > On 5/14/26 18:43, Jacob Keller wrote: > > On 5/14/2026 3:01 AM, David Laight wrote: > > > On Wed, 13 May 2026 21:47:11 -0700 > > > John Ousterhout wrote: > > > > > > > On Wed, May 13, 2026 at 1:49 PM David Laight > > > > wrote: > > > > > On Wed, 13 May 2026 09:28:40 -0700 > > > > > John Ousterhout wrote: > > > > > > On Wed, May 13, 2026 at 2:07 AM David Laight > > > > > > wrote: > > > > > > > On Tue, 12 May 2026 11:19:53 -0700 > > > > > > > John Ousterhout wrote: > > > > > > > > Consider the following sequence of events: > > > > > > > > * The bottom half of a buffer page is filled with data from > > > > > > > > packet A. The page has a net reference count (reference count > > > > > > > > - bias) of 1. The page is returned to the NIC, flipped to > > > > > > > > use the top half. > > > > > > > > * Before the reference on the page is released, the NIC returns > > > > > > > > the page with no data in it ('size' is zero in ice_clean_rx_irq). > > > > > > > > In this case the bias does not get decremented. The page still > > > > > > > > has a net reference count of 1, so it gets returned to the NIC. > > > > > > > > However, ice_put_rx_mbuf flipped the page so that the bottom > > > > > > > > half is active. > > > > > > > > * If the NIC stores another packet in the page before packet A > > > > > > > > has released its reference, the data in packet A will be > > > > > > > > overwritten with data from the new packet. > > > > > > > > * Unfortunately zero-length buffers occur frequently: they seem > > > > > > > > to occur whenever a packet uses every available byte in a > > > > > > > > buffer, ending precisely at the end of the buffer. When this > > > > > > > > happens the NIC seems to generate an extra zero-length > > > > > > > > buffer. > > > > > > > > The fix is for ice_put_rx_mbuf not to flip pages that have a > > > > > > > > size of 0. > > > > > > > How is this different from packet B (in the top half) being > > > > > > > freed before packet A (in the bottom half)? > > > > > > I'm not sure exactly what you're referring to here. Are you asking > > > > > > about a situation where both halves of the page get filled with packet > > > > > > data and then the second half to be filled is the first to be freed? I > > > > > > believe that the ICE driver abandons a page if both halves are ever > > > > > > occupied simultaneously; the page will be returned to the system once > > > > > > both halves have dropped their references. Thus it doesn't matter > > > > > > which half is freed first. > > > > > That is what I was thinking, seems like the logic is over complicated. > > > > > > > > > > If you need to put 4k pages into some kind of iommu rather than 2k buffers > > > > > (to contain 1536 byte ethernet packets) then I'd have thought you'd > > > > > initially put both halves into adjacent tx ring entries. > > > > > If a rx buffer is discarded (eg a zero length fragment or a CRC error, > > > > > or even 'copy break' for short packets) then, as an optimisation, > > > > > you could reuse the buffer for another receive. > > > > > The same could be done if the page is freed by an application. > > > > > > > > > > However it sounds like it doesn't use the 2nd half until the first > > > > > completes - otherwise you'd never 'flip' to make the other half > > > > > active. > > > > > > > > > > Thinks... > > > > > By only putting half of each 4k 'page' into the rx ring the code > > > > > will usually save (expensive) iommu setup in the (probably) normal > > > > > case where the buffers are freed 'reasonably quickly'. > > > > > But that really requires a 'free/with_nic/busy' state for each half > > > > > rather then trying to guess from a reference count. > > > > > > > > > > But if the low-level code is recycling the rx buffer (for any reason) > > > > > it wants to use the same buffer. > > > > > > > > > > The ethernet driver I wrote (a long time ago, early 90s) allocated > > > > > 64k as 128 512byte buffers and did an aligned word-sized copy of > > > > > every receive frame - most frames were in contiguous memory. > > > > > The simplicity of it made up for the cost of the copy, especially > > > > > since that was an iommu system. > > > > I'm not here to defend the logic (and it has been replaced with > > > > something that is probably simpler and more efficient); I'm just > > > > suggesting a bug fix for the stable releases that still have this > > > > logic. > > Right. We definitely want a fix for the possible data corruption in > > stable. Ideally one as simple as possible. > > > > > You've forced me to look at all of the function :-) > > > I've noticed a few things: > > > - If ice_add_xdp_frag() fails (because there are too many fragments) > > > then the rest of the fragments are left in the tx ring (instead > > > of being discarded) - so are likely to be treated as a full packet > > > later on. > > > - Frames with status errors (crc, framing etc) are discarded after > > > the skb is built - surely that should happen before the xdp 'program' > > > is called. > > > - If the remote system send a very very long frame (traditionally the PHY's > > > 'jabber detect' didn't always work) you can end up with all of the rx > > > ring being full of a single partial packet. > > > > > > I think you need to avoid calling ice_add_xdp_frag() when 'size == 0'. > > > Then in ice_put_rx_mbuf() unconditionally call ice_put_rx_buf() for > > > zero length fragments. > > > The comment would be 'zero length fragments can always be reused'. > > > > > That seems correct. > > > > > The zero length fragments almost certainly exist because the mac hardware > > > advances the the new buffer expecting more data - but only gets the > > > 4 byte CRC. So the zero length buffer contains the receive status. > > > > > That matches my understanding. > Hi John, > > I have been looking at the same area in the pre-page-pool ice code and > I want to ask whether you observed memory growth during your Homa runs > that exposed the corruption, because in my testing the same bias mismatch > also produces a slow page leak that your v3 does not close. > > Short version of the leak path, in the PASS (!CONSUMED) branch: > >   1. ice_get_rx_buf(size=0) does pagecnt_bias-- unconditionally >      (added by commit ef68094cb09e ("ice: Fix kernel panic due to page >      refcount underflow") as the fix for the matching panic). you mean in ice_get_rx_buf() ? I do not see this part anywhere. Must be your custom recipe when you ported 84bf1ac85af8 ("ice: fix Rx page leak on multi-buffer frames") ? Given the amount of issues 0 sized frags gave us I was thinking whether they should be treated in the same manner as normal frags. But please rule this out on your side to align with John so we could proceed with this fix. Thanks Maciej >   2. ice_add_xdp_frag() then returns 0 for size==0, so that page is >      never attached to the xdp_buff/SKB. Nobody downstream will ever >      call put_page() to balance the pagecnt_bias-- from step 1. >   3. Your v3 in ice_put_rx_mbuf() correctly skips the page flip for >      size==0, which closes the corruption window. But it does not >      restore pagecnt_bias for that zero size buffer, so the page is >      handed back to ice_reuse_rx_page() with a permanent deficit of 1. >   4. On the next reuse of that page with size > 0, pagecnt_bias drops >      again. ice_can_reuse_rx_page() now sees pgcnt - bias == 2 and >      drains via __page_frag_cache_drain(page, pagecnt_bias). Because >      pagecnt_bias is one too low, the drain undershoots by 1: page >      refcount stays at 2 instead of 1. >   5. The SKB eventually releases its reference (refcount -> 1), but >      nothing ever brings it to 0. The page is leaked. >      ice_alloc_rx_bufs() just allocates a fresh page to fill the slot. > > At the zero size frequency you mentioned (thousands per second), this > adds up to roughly MB/s of leaked page cache, which Jaroslav Pulchart > originally reported against 6.13.y on NUMA nodes and which motivated > the libeth/page_pool conversion in mainline. So in stable trees the > leak side of this bug is still live. > > Two questions: > >   - Did you monitor RSS / page allocator stats over the duration of >     your Homa runs? If you did and did not see growth, I would like >     to understand what is different about your setup, because by my >     reading of the code the leak should fire whenever both halves of >     a page end up in SKBs simultaneously and one of them carried a >     zero size descriptor along the way. > >   - If your focus was specifically the corruption, would you be open >     to extending v3 (or replacing it) with a fix that also restores >     pagecnt_bias for the size==0 case? The minimal extension is one >     extra branch in ice_put_rx_mbuf: > >         if (verdict != ICE_XDP_CONSUMED && size != 0) >                 ice_rx_buf_adjust_pg_offset(buf, xdp->frame_sz); >         else >                 buf->pagecnt_bias++; > >     which restores bias on every path where the page is not actually >     going out to an SKB. (I have a slightly different variant that >     tracks has_data in struct ice_rx_buf to also handle the broken >     positional 'i <= xdp_frags' counter in the CONSUMED path, where >     zero size descriptors in the middle of a frame steal bias++ slots >     from real fragments. Happy to share it if useful.) > > Regards, > Petr > >