From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f175.google.com (mail-pl1-f175.google.com [209.85.214.175]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A6D1D379ED4 for ; Thu, 30 Apr 2026 20:36:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.175 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777581403; cv=none; b=R+pJWqgGF20MSUFh8WcrNny74Wi7Vmxuu/krjDkqfGBCnsvycz3crzbu9gc6OPJVazmHAC6d+6+ObXiPIbTa+kQzpNT8h8jcYteU7CjVHBO+p2LVV9P3GQx34KC8PGq3MCaOst8EFKYvhXknMNj2rYL65OzufgKYFZXThzlUKyY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777581403; c=relaxed/simple; bh=EwPsMmwDlEf4Sg12GI+V/on0UHI6jKuUp1UpMdnjbrI=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=TciNKX+l8ezrhSgbxurthtxM27DmfDH3ZRKBJbBerVevX0V2v4WftiyclHJEa2cC7xgRenfsaR6ebDQ/Tkl+PH71DZmh+m8NqdLVpX09ll5diAi5cGq5dWRyaxNcPuX9Xi+FywJ3GXnkDN0onpiJFE17t/wVaS0EHgNSzQbQp4o= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=NOXuKwx9; arc=none smtp.client-ip=209.85.214.175 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="NOXuKwx9" Received: by mail-pl1-f175.google.com with SMTP id d9443c01a7336-2ad9f316d68so5750325ad.2 for ; Thu, 30 Apr 2026 13:36:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1777581402; x=1778186202; darn=vger.kernel.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=h7XgKHoPXsQn1bRJuoPg0uZx0GmeDlDmcffd2v4MAfo=; b=NOXuKwx9JwJ6dR1ro+o7v+0/CEPyHX+hUiCJPa+dj5PB8bc/pdCTMLY2//T/qEyu4w fmcv2YbeuWeiLw0gcZFfX+ThO9HBIZhrzlESuuds1BtWn7QuYtWLEwmJnUVNXO2y/l0a pTgJPuujBToBBE1qr4PqeFKXr57wVfUJMmnmgykVuLPZ1Jz461o0MjoUlyJg7retMxhO mKdbUM8dJLWDrV3fJgYTw/KiSEnHyilR5DS6RWZvqWpGxPKrO09WLrwLkAWYLPNZ9mme exA2MIPVlfImAEMfNIfaoM+yigw7M0ylUIwYuQARnxddN+SRNMesNlBE+b5Paop8BguR +L1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777581402; x=1778186202; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=h7XgKHoPXsQn1bRJuoPg0uZx0GmeDlDmcffd2v4MAfo=; b=PT+CoJD+SuwEb21/nUoz1fnRAgErBDiDYNbEwBwrTcFPjoB0KxbLQ69SEuiy/kNQIN rwFEqLrFAsYLGRXl4YBzFN+6125WMdf7QH5aXinKYqi3s5Z+EpJ3IciNa/rMt+8MZNvR l4m3J8KX2CiveWNq7UOAV1Ue6TQOF7vqBGMVrDv02+t2tO4PeyTip2Ny3i9GYCBWMP/E 7yXeGQ4M6IVXCuQWZkQER0i//3OzgfCsaXWOTP+vlAwuGisAyPktoi9Nn8JUlOmGmHJm 7zZXsSMWNnron+/pQaIhJw1rDIH2N1AUkrTzcwjUSXJGBgtpH72ljJE1QScbVC4w9HVb pyiQ== X-Forwarded-Encrypted: i=1; AFNElJ8ln6HFpgUG8HL4V4M5OG3RjuU+Fv/b+8G0CFXi4ve5hKLVdJHCYwhSImcl40ZX874+Q4s0Nz0gQbL8eDQ=@vger.kernel.org X-Gm-Message-State: AOJu0YxhjLNUFtlf1cZNjdLafu1xwzyTszIncLCAE7Mk9gcv9r/6QfQq krOArF1ZOo/XTYPXqCkVRwOrUp4yhvIUTCfU4uX9D1W9mya9ZDX+RsmSM8YaLxPvEA== X-Gm-Gg: AeBDiesaZLLweXmsTKbONmoBSC57r9VTRKd1pjZAnJIHgSFs9QMCK3Bw1G8UMRAgnDc /QIfNNHiGVKUMW1gm4nyA/sSlgwtQPrfYhUsSgQT7y1cX327B+Y+rhemVCPv5pjFU8MzvgEAhjB DpL0+wXNf7RvmLJ9Bg63LDGyqBXCOBGd/zPRFO1nHbXC/i/S2yEiPBSLpLNCrmU0cVSrMI3HdnJ XlRTy6IsUB5R+6kshuLEyBJPfeJNYD0jQ3Q22t722HR7yjPAYg3XumcTuxSpVWto5dE/wfQ1nCp 4p5/X710yKDGIAPH49LqFOUqlZVIHBT8ckWuigAv3QFw0cswVpTU5Fzr4hrcPp1kkYAJbz87qHb KML3YhL7vQ8MZC8WeBOQxoL3yoz/Nkxeh5XmoZLjCQL9C5qMf9G/Nai5dkDavBXswiDVq4Q57XB txtrxFiUegX//e9CK5FtJxI71Svooa/OcA2xwICfCs3dCq2+RJkOo1N9L1xUVVR2Nk3fX4k7nN+ +BI4w== X-Received: by 2002:a17:902:bcc4:b0:2b2:490c:410e with SMTP id d9443c01a7336-2b9a23195femr34674875ad.7.1777581401489; Thu, 30 Apr 2026 13:36:41 -0700 (PDT) Received: from google.com (76.9.127.34.bc.googleusercontent.com. [34.127.9.76]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2b9cae4a127sm5909845ad.67.2026.04.30.13.36.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Apr 2026 13:36:40 -0700 (PDT) Date: Thu, 30 Apr 2026 20:36:36 +0000 From: David Matlack To: Vipin Sharma Cc: iommu@lists.linux.dev, kexec@lists.infradead.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-pci@vger.kernel.org, Adithya Jayachandran , Alexander Graf , Alex Williamson , Bjorn Helgaas , Chris Li , David Rientjes , Jacob Pan , Jason Gunthorpe , Joerg Roedel , Jonathan Corbet , Josh Hilke , Leon Romanovsky , Lukas Wunner , Mike Rapoport , Parav Pandit , Pasha Tatashin , Pranjal Shrivastava , Pratyush Yadav , Robin Murphy , Saeed Mahameed , Samiullah Khawaja , Shuah Khan , Will Deacon , William Tu , Yi Liu Subject: Re: [PATCH v4 02/11] PCI: liveupdate: Track outgoing preserved PCI devices Message-ID: References: <20260423212316.3431746-1-dmatlack@google.com> <20260423212316.3431746-3-dmatlack@google.com> <20260428201231.GA3885809.vipinsh@google.com> <20260430175916.GA13902.vipinsh@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20260430175916.GA13902.vipinsh@google.com> On 2026-04-30 11:25 AM, Vipin Sharma wrote: > On Tue, Apr 28, 2026 at 02:12:13PM -0700, David Matlack wrote: > > On Tue, Apr 28, 2026 at 1:20 PM Vipin Sharma wrote: > > > > > > On Thu, Apr 23, 2026 at 09:23:06PM +0000, David Matlack wrote: > > > > +int pci_liveupdate_preserve(struct pci_dev *dev) > > > > +{ > > > > + if (ser->nr_devices == ser->max_nr_devices) > > > > + return -ENOSPC; > > > > + > > > > + for (i = 0; i < ser->max_nr_devices; i++) { > > > > + /* > > > > + * Start searching at index ser->nr_devices. This should result > > > > + * in a constant time search under expected conditions (devices > > > > + * are not getting unpreserved). > > > > + */ > > > > + int index = (ser->nr_devices + i) % ser->max_nr_devices; > > > > + struct pci_dev_ser *dev_ser = &ser->devices[index]; > > > > + > > > > + if (dev_ser->refcount) > > > > + continue; > > > > + > > > > + pci_info(dev, "Device will be preserved across next Live Update\n"); > > > > + ser->nr_devices++; > > > > + > > > > + dev_ser->domain = pci_domain_nr(dev->bus); > > > > + dev_ser->bdf = pci_dev_id(dev); > > > > + dev_ser->refcount = 1; > > > > + > > > > + dev->liveupdate_outgoing = dev_ser; > > > > + return 0; > > > > + } > > > > + > > > > + return -ENOSPC; > > > > > > Since it is executing under a mutex, and we already failed > > > 'if (ser->nr_devices == ser->max_nr_devices) check above, will we ever reach > > > here and return -ENOSPC? > > > > Yeah I wouldn't expect to ever reach here. > > Will you be removing it or want to keep it just in case scenario? I'm not sure how I would remove it. The code doesn't not compile without a return.