From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (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 0FB533EF658 for ; Tue, 19 May 2026 08:59:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779181172; cv=none; b=h45Gzma75nShuS4LGQNoumZvUsPRwR1OdzeHzw7leAnnJUFJR5Du9RmXxCCzH+CZZdDkpfkPQkJ7NQmmX6EcRDRtl0KiQ2fommO05SwaDvGAB6Xk7onyMXQ7dzust0b0qZO7dvS7sD899HCH+2+8EbAlQCRGJSXZsD8K21z6dpI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779181172; c=relaxed/simple; bh=OhUuxdYnQ8EXDp+B9zkq4d55hNYbQ3Iucnfakt2Snus=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=jEUVFiwMIec7RjNi3tIpdxUcRAn5A60Lr/iJXLrTff1o7xTQuuEOMmxySo4VX/t9kg/PCJ2fAiv/Lc9c9Bhh4o3E15hWVO9VNIVi6Yv0xlsc82w72bC/YE6rdfv6Au8oi8wEjhKpa4XNwT+oHiekhHQOzxMMH75xyMAymqSgIcE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=YJDZ7GjJ; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=XIiSRuKk; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="YJDZ7GjJ"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="XIiSRuKk" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1779181170; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=irXYXDyVAxFofevikDhz7cEViUnT1Nau5kq84wR5sdQ=; b=YJDZ7GjJKRCYwdz7zw8i+Fea20dNvQlAixo8FgXhmBWCzoO/tD/3BI7pzZqSwDcU09Rcq7 +X3p6LFgdCwo/1a5BL/mtM4EF6G9Q5sNZtlzv6RHJoU5a2rdJl7oklF4c+dq0NcSfLYyqe Crc1ftC65HMGsZMwMVrPP1D02o2aNb8= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-631-G4dxgAWyPh2VAfpKbxKGdg-1; Tue, 19 May 2026 04:59:28 -0400 X-MC-Unique: G4dxgAWyPh2VAfpKbxKGdg-1 X-Mimecast-MFC-AGG-ID: G4dxgAWyPh2VAfpKbxKGdg_1779181168 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-48fdc746a8bso16097215e9.0 for ; Tue, 19 May 2026 01:59:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1779181168; x=1779785968; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:content-language:from :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=irXYXDyVAxFofevikDhz7cEViUnT1Nau5kq84wR5sdQ=; b=XIiSRuKkFYwZcY8Zp/qm5mGq2V++yXaezk8JdcKfw1NGhvUGA2FWPRCs2OanYKdaKX fI6qqkkMFkmTztBeS0MsS6tEaMeq9wM7V6owrcNQIwd5Yh9nfAw+SidXXBTN6mQjU8lG Rq+wH7hobfZfH3ihcrYoRGBxXQ+/5bgQy2uX3PXEpcGM0OS9dYOj5XpuYXamUpxXy0uS CSYMZJVr7fVr1YAmAGvU4pjvCH8mWAfAU153ceThMHifANnHVbw6XuKKoBFq4sXbRApJ aQsTZoRe9UEwE9Bv3wdhxlPjNZynakSyX2avqNyrWikFmKE9uiT50QE9ORsEfmplqZp2 vtuQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779181168; x=1779785968; h=content-transfer-encoding:in-reply-to:content-language:from :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=irXYXDyVAxFofevikDhz7cEViUnT1Nau5kq84wR5sdQ=; b=fpcihhj5cMlbfLQQkaw/wtwvY/QvUp1Z51foM4utPTUtxU7O6/blesmlDW9jzM2zaD ZarICRFEGhP0vMMivZJJnYV2hUwpZhl8ObE0ZoJLTMtusGzHLiYADUrY3jQXNeZdGcup HRrm/c704cASq+bidxShVpGXKzKfcZnReoeSTJp88C19q4cszSVHte6ElAWwx4g29qjW wXCaO90/8efLqlffp7+tA7e5orosP23Pcj01L1HYzQ6X4Mi+T9A0TxI/ml3iwqQvWcAu 0rDgwwNwJkCuu/TtaBxCtCmQQGJc5b4TZAiKRb36ihaJcJsPeywFFIrP1kV4lz3taddI rBlw== X-Forwarded-Encrypted: i=1; AFNElJ9w6RpcwrOCOpo2ke7GZQf8IGQEkCyIKYuMUI2tajxwCSermItjRjgmLS58PsAIcHdX+X06JT8YzPj/R3w=@vger.kernel.org X-Gm-Message-State: AOJu0YxZyKOc+0lEvz5J4Erbvgrw/r3E8/7DDnlO0GJD6NvPW1TAU5dp XOs6Tji6YLuCZ4X4yE/sTK4UNM6yHhTAJKzERlg5/fbnaOje8F7+CqQvFXUXTvxlvLRdTxFFGJE dKQps8cWL1EqR4RT/RB2fZQOO6Kr4WQaej+31bn39npPPK9qH11bN7Js/NAieYKH+KA== X-Gm-Gg: Acq92OGykFLCktuL9/pZSZQCcqJNuZkLDYjii86yXEKnCnImv2ejHYWGlA3a9oQYCVx 8fubFkV6jtJL9y1z5mHR8K1zwQmsWoofpGJiHACjqtu3aMN5gKbQlwn7WaWjT3GV5DSqsgE6rTi fZOhVqaC3mxliy2fRX/lx2zjjc3yD/ZPteBqPJLxtjmqnLCTIXnrwEwaB4fiZaEYJODuRYjCa+T JS9KVkAfq45y/z2HQFHEHt6c0IgX8wcStIQ3mdg4yxv0qoezZg69oLTpyF2vLby+tH4Sskbmg92 7CrFON//lzi35YBZBA5K3mjdN3YPvEqJG4aVWbhNOGNy8pzgyxRBWPMmCaJ4Ew9qmCPDDliRILB mFZPOztl6yATsubaIHQcQuFRFdaoNI0ujcPBZGpZ+LT60v08WRrcYVyAsbyi3QCFhmA== X-Received: by 2002:a05:600c:35c5:b0:48f:f64c:c314 with SMTP id 5b1f17b1804b1-48ff64cc4d1mr236441605e9.30.1779181167584; Tue, 19 May 2026 01:59:27 -0700 (PDT) X-Received: by 2002:a05:600c:35c5:b0:48f:f64c:c314 with SMTP id 5b1f17b1804b1-48ff64cc4d1mr236441125e9.30.1779181167116; Tue, 19 May 2026 01:59:27 -0700 (PDT) Received: from [192.168.88.32] ([150.228.25.33]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-48fe53ab6aasm335423085e9.2.2026.05.19.01.59.24 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 19 May 2026 01:59:26 -0700 (PDT) Message-ID: Date: Tue, 19 May 2026 10:59:23 +0200 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v14 net-next 5/9] octeontx2-af: npc: cn20k: add subbank search order control To: Ratheesh Kannoth , linux-kernel@vger.kernel.org, linux-rdma@vger.kernel.org, netdev@vger.kernel.org, oss-drivers@corigine.com Cc: akiyano@amazon.com, andrew+netdev@lunn.ch, anthony.l.nguyen@intel.com, arkadiusz.kubalewski@intel.com, brett.creeley@amd.com, darinzon@amazon.com, davem@davemloft.net, donald.hunter@gmail.com, edumazet@google.com, horms@kernel.org, idosch@nvidia.com, ivecera@redhat.com, jiri@resnulli.us, kuba@kernel.org, leon@kernel.org, mbloch@nvidia.com, michael.chan@broadcom.com, pavan.chebbi@broadcom.com, petrm@nvidia.com, Prathosh.Satish@microchip.com, przemyslaw.kitszel@intel.com, saeedm@nvidia.com, sgoutham@marvell.com, tariqt@nvidia.com, vadim.fedorenko@linux.dev References: <20260514062537.3813802-1-rkannoth@marvell.com> <20260514062537.3813802-6-rkannoth@marvell.com> From: Paolo Abeni Content-Language: en-US In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 5/15/26 9:26 AM, Ratheesh Kannoth wrote: > On 2026-05-14 at 11:55:33, Ratheesh Kannoth (rkannoth@marvell.com) wrote: >>> + restrict_valid = false; >>> + >>> + for (prio = 0; prio < cnt; prio++) { >>> + sb_idx = narr[prio]; >>> + sb = &npc_priv.sb[sb_idx]; >>> + sb->arr_idx = prio; >>> + >>> + /* erase entry if exist */ >>> + xa_erase(&npc_priv.xa_sb_free, sb->arr_idx); >>> + xa_erase(&npc_priv.xa_sb_used, sb->arr_idx); >>> + >>> + xa = &npc_priv.xa_sb_free; >>> + if (sb->flags & NPC_SUBBANK_FLAG_USED) >>> + xa = &npc_priv.xa_sb_used; >>> + >>> + /* if xa_store() fails due to memory pressure, there is >>> + * no point in rolling back, as roll back may also fail >>> + */ >>> + rc = xa_err(xa_store(xa, sb->arr_idx, >>> + xa_mk_value(sb_idx), GFP_KERNEL)); >>> + if (rc) { >>> + dev_err(rvu->dev, >>> + "Setting arr_idx=%d for sb=%d failed\n", >>> + sb->arr_idx, sb_idx); >>> + goto fail; >>> + } >>> + } >> Does this error path leak subbank resources and leave the xarrays in a >> corrupted state? >> If xa_store() fails, the function jumps to the fail label and aborts >> without restoring the original state. Because the entry at the current >> priority index was already erased via xa_erase(), but the new subbank >> failed to store, that subbank is permanently lost. >> Additionally, the subbank that failed to store is left with a modified >> arr_idx pointing to an empty slot, potentially breaking future allocations. >> Could this function preallocate resources (such as using xa_reserve()) or >> build temporary xarrays to ensure the changes can be applied atomically >> without a destructive intermediate state? > > The omission of a transactional rollback path is intentional due to > the systemic implications of a GFP_KERNEL allocation failure inside > the xarray core. If xa_store() returns an ENOMEM error, the underlying > slab allocator is already exhausted, meaning any programmatic attempt > to erase or restore original indices would also fail, compounding the > unpredictable state. > > Because this devlink callback operates under the top-level mcam->lock > mutex, no concurrent allocation or translation worker can read the > partially modified xarrays while the driver is in this degraded state. > An xa_store() failure indicates a fatal, system-wide memory leak or > exhaustion event. At this threshold, the driver prints a critical > error payload to dmesg to allow deterministic post-mortem debugging of > the host's global memory subsystem, rather than attempting an unreliable > in-kernel rollback. I'm sorry, but I don't agree with your statement above: allocation may fail under memory pressure, and memory pressure can be transient; it should not brick the driver requiring a reload. Additionally I think it should be possible to handle gracefully the failure inverting the order of xa_store() and xa_erase() and performing the latter only on the relevant xarray (i.e. xa_sb_used when store operates on xa_sb_free, and vice versa). /P