From nobody Wed Oct 8 16:43:49 2025 Received: from mail-oi1-f172.google.com (mail-oi1-f172.google.com [209.85.167.172]) (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 EB24D2D8794 for ; Wed, 25 Jun 2025 20:19:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750882752; cv=none; b=o+jp2w38Jv3sOCyCsa2taLbTcdNK8mxwZEzSlWCsxEAWrKHJ5rMP3NsBsZnPkgmBjDeF2Xhbc30lv5h1zzOaQDXz7rUw18zlbQaGufV3dNA4xS9N0ANIr/F5xq2WJ+GGz/mSLhSq3/qXq1g8YrGaN9h3jj+ZTATXJtLv+vg7Djg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750882752; c=relaxed/simple; bh=zCwnFT6YvpOnBXES6Ar8fdc609/zgYWwY3IzSAw9dtM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=MS2Ug+c/hf6fssoGv6E9WcuUFt76Cm5POleOlLe+AGN6OClb4w12bUrAC+YiLqkLEm40AAD+M5GHxZh5mi+2wwSmCopiKnNOkA6BjUnXrtrW/3ehbAcyXkU6Gm6BiiJYyIBSNJK6b8eUDX8M5t9nCWn2Wl0/kQwLtm2JBQ5O+yE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=jsTJBsug; arc=none smtp.client-ip=209.85.167.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="jsTJBsug" Received: by mail-oi1-f172.google.com with SMTP id 5614622812f47-4080548891fso144777b6e.3 for ; Wed, 25 Jun 2025 13:19:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1750882750; x=1751487550; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Ii7F3KTd50OP4ELYVVkfKIFESVbr68GqYZUwUTPpVR4=; b=jsTJBsugYFdJ17Aawxfq727ghHg0g6TcjXxAeugya96z1hV84YogPa2UsrJz1c93DY dWXkvjSfNqB1iexv5dbRfQpRlZw7abc8t+QRMtfyNvV6dS3dzQt7dimKM/yNdF5ucUnu ZesP8RHNoCmF9PRQ+OUTRuVy+1R0wT8oq1N4LFWAeEDwtgVyExNMFtvknR5Nd6liv0Xv gLnIBNUBDqEfOylCSmNrIx1yqRYt8aZYOnzeiEQa+0jdZrpXS9vywYCW/z806H40aqFD 72C5YqJrBkV2YBZX3ITqHIq4wxXxSs/7tjjOBzeg1bz1ZZ3iKoShGt+VuAq59nVuucga DLsA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1750882750; x=1751487550; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Ii7F3KTd50OP4ELYVVkfKIFESVbr68GqYZUwUTPpVR4=; b=fhnm1Wh95ej5uctsvXIlQcDPwfcboOu7/N2Ps2xa4qtywzAiXiAC3YsjgPqFyaiSG5 BeFzuXzCTkXc+8/V2a7FM6Ty+duB4gpDUhuynCA6/wFJWaxHZrZNzaRVZF3G3KBabGNu pjeB9JX8/9nVXgZYRKzY5Q/lJTGSkzSYD0c+fhDXFdhDAXal8NBnGk4To+1c5VuwrlHn h4Dq7ioAxthpSAdn0eWo5h6oB+y3KXxr6IG/QfW2sv1jj78DSEkIdjBvIpnbIqfT4xrS Tx2hTNhZPQtGk/ZIY66P9FTedWBHxoL//JVatY9dH5BjOe+hkynQ7NedtwqfwVz4d1OG lM+g== X-Gm-Message-State: AOJu0Yy76JtOJyRsBFBzIXRjagKGLJWBc0RZXSYCp7IDuE1Z/Z1eLafB a4lR8rIPY31xUoeZLOkj8/7aUwkL+r+zKilXawyLc3MCEZiMQ5soasTCBmj7s/7W X-Gm-Gg: ASbGncs8UO37NIDmnRFxYmrFY2YNANtF7kIqdxPaUrJe9Zj+pqoEAgHDwDxPiCdiPb0 4qL7FKQ6XGHCOM+oHNZS37Oau1YYPIDOT7OTkLVJBfEshq8wwQe0IhVKwMtNn59eAFZGBVKmRMD EFhmmDWG4js+78FsVTRKeM9EPln+T7H3EV/IkJAocdWygqENjH04ypCPita+EcDqKeynRdWzM/+ Tvjo2bgqYQhodTIF3pVYIii9ll/TBqBD2bNx/wWyzcATAxHJ452CrWCIJ0fYc54u05tbZLTNJNi EZ5zCEgT4jptRzZgijpOh0DtWS+Vpv/3t2/qLm6KY3EP2XiDEnrE2/5a3ye1sBwl1kg6SCNHF22 KrS66dm8= X-Google-Smtp-Source: AGHT+IGEZJwCIISdIXRvS1gnBkGMKpKYrYU/Oz1NxYRz4ecK56zRfo/tvDDixdQKK2GCSXYcSwb2ng== X-Received: by 2002:a05:6808:2001:b0:408:e68d:975a with SMTP id 5614622812f47-40b05a11227mr3693289b6e.39.1750882749745; Wed, 25 Jun 2025 13:19:09 -0700 (PDT) Received: from localhost.localdomain ([143.166.81.254]) by smtp.gmail.com with ESMTPSA id 5614622812f47-40ac6d22c23sm2319188b6e.42.2025.06.25.13.19.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Jun 2025 13:19:09 -0700 (PDT) From: Stuart Hayes To: linux-kernel@vger.kernel.org, Greg Kroah-Hartman , "Rafael J . Wysocki" , Martin Belanger , Oliver O'Halloran , Daniel Wagner , Keith Busch , Lukas Wunner , David Jeffery , Jeremy Allison , Jens Axboe , Christoph Hellwig , Sagi Grimberg , linux-nvme@lists.infradead.org, Nathan Chancellor , Jan Kiszka , Bert Karwatzki Cc: Stuart Hayes Subject: [PATCH v10 1/5] kernel/async: streamline cookie synchronization Date: Wed, 25 Jun 2025 15:18:49 -0500 Message-Id: <20250625201853.84062-2-stuart.w.hayes@gmail.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20250625201853.84062-1-stuart.w.hayes@gmail.com> References: <20250625201853.84062-1-stuart.w.hayes@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: David Jeffery To prevent a thundering herd effect, implement a custom wake function for the async shubsystem which will only wake waiters which have all their dependencies completed. The async subsystem currently wakes all waiters on async_done when an async task completes. When there are many tasks trying to synchronize on differnt async values, this can create a thundering herd problem when an async task wakes up all waiters, most of whom go back to waiting after causing lock contention and wasting CPU. Signed-off-by: David Jeffery Signed-off-by: Stuart Hayes --- kernel/async.c | 42 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/kernel/async.c b/kernel/async.c index 4c3e6a44595f..ae327f29bac9 100644 --- a/kernel/async.c +++ b/kernel/async.c @@ -76,6 +76,12 @@ struct async_entry { struct async_domain *domain; }; =20 +struct async_wait_entry { + wait_queue_entry_t wait; + async_cookie_t cookie; + struct async_domain *domain; +}; + static DECLARE_WAIT_QUEUE_HEAD(async_done); =20 static atomic_t entry_count; @@ -298,6 +304,24 @@ void async_synchronize_full_domain(struct async_domain= *domain) } EXPORT_SYMBOL_GPL(async_synchronize_full_domain); =20 +/** + * async_domain_wake_function - wait function for cooking synchronization + * + * Custom wait function for async_synchronize_cookie_domain to check cookie + * value. This prevents waking up waiting threads unnecessarily. + */ +static int async_domain_wake_function(struct wait_queue_entry *wait, + unsigned int mode, int sync, void *key) +{ + struct async_wait_entry *await =3D + container_of(wait, struct async_wait_entry, wait); + + if (lowest_in_progress(await->domain) < await->cookie) + return 0; + + return autoremove_wake_function(wait, mode, sync, key); +} + /** * async_synchronize_cookie_domain - synchronize asynchronous function cal= ls within a certain domain with cookie checkpointing * @cookie: async_cookie_t to use as checkpoint @@ -310,11 +334,27 @@ EXPORT_SYMBOL_GPL(async_synchronize_full_domain); void async_synchronize_cookie_domain(async_cookie_t cookie, struct async_d= omain *domain) { ktime_t starttime; + struct async_wait_entry await =3D { + .cookie =3D cookie, + .domain =3D domain, + .wait =3D { + .func =3D async_domain_wake_function, + .private =3D current, + .flags =3D 0, + .entry =3D LIST_HEAD_INIT(await.wait.entry), + }}; =20 pr_debug("async_waiting @ %i\n", task_pid_nr(current)); starttime =3D ktime_get(); =20 - wait_event(async_done, lowest_in_progress(domain) >=3D cookie); + for (;;) { + prepare_to_wait(&async_done, &await.wait, TASK_UNINTERRUPTIBLE); + + if (lowest_in_progress(domain) >=3D cookie) + break; + schedule(); + } + finish_wait(&async_done, &await.wait); =20 pr_debug("async_continuing @ %i after %lli usec\n", task_pid_nr(current), microseconds_since(starttime)); --=20 2.39.3 From nobody Wed Oct 8 16:43:49 2025 Received: from mail-oi1-f175.google.com (mail-oi1-f175.google.com [209.85.167.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 017AA2D9ED7 for ; Wed, 25 Jun 2025 20:19:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750882753; cv=none; b=iIvh7/L3nm2FjyBjcTGEjXfHmFyJXZWavZkrnf2Y0vb4XGEefMuO5HRvBg/AyBkZYMK1Obwk5p50a373lE/ta/0h9ZIHa4F/pg2FdFpvtA2QWxjCVDlV4Aof4j8wXBSqAI6YL+viThyAd22UZrFmjFFCEgcdFYphpf+WnaLj0d8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750882753; c=relaxed/simple; bh=h7rNjT3qiAFAf02O0q1TiHR0k+rR9JvQ409LLZcGSDw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=RE02NLZs3nwsXfl+h8DxhedSrUwtTqItqZcawpYco9UfoMrZenVDXLNVeRPprRzS2P9ZmaC15OMRbySfs6haa5vbvNV5DkKKhJI1fQp6buMzG8xGk/pZLngGxTJGb3Xr9bRnCYZZpSRXXmgSFsEjlzPL4V4QJPe2NsWOGAhSvwk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=DtH+WcwU; arc=none smtp.client-ip=209.85.167.175 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="DtH+WcwU" Received: by mail-oi1-f175.google.com with SMTP id 5614622812f47-4079f80ff0fso884907b6e.1 for ; Wed, 25 Jun 2025 13:19:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1750882751; x=1751487551; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=I+3SW8vJVKoCSfPWTHdZMGnwJ8NA6WVZ3bsZQcUT5XA=; b=DtH+WcwUWlIkTOdYgvCFwoHxa+nNZu0v1r6qe7xGhs+UgYiHI7Mhph4M4LoZJXMWty jMA1dx7KF9KIpJ2lcbUb6VYphRcRANVpM7kv5+B2WdZq7wZyDNbKfIU4BDy1sZ/E/Ld7 PEwejlONHo431dtYkLnkhnCzdNPxt4+cZhCY4qCcxZbPmuNNFldWTUco6wXvBHhVVesT jXRVNQJNQZSKR43GNTLbwusOqT8S95j6EFriHcRLet/e99saUi4shkIfq9Mm/D0I6cK1 3ck8VyW3jsEJrw8yp23ptpKIlzZUukI8QW6M6ZipyKqKi5ozHMr1bfZFoAil/1w50I6r dweA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1750882751; x=1751487551; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=I+3SW8vJVKoCSfPWTHdZMGnwJ8NA6WVZ3bsZQcUT5XA=; b=EmTKGhtElw3qosiCsoo56b08YgGwQo9VDhLdYJS6mY/raGR/8Lh5VBPyCyPp5C/m4x Tkrg/DQZpgoDjDkhGVfHP3r/1yN9vi5g4aEjzh2uboh+X60Vs86HaMyzaXs1jHY7el3L 8mPOEEqH2PvNZqQtRGpSMpU5QzGrklTy+AnPE3z49TIqvZqz5809bQ19PF/9DKOR8djN x7ErgWk+fUXMR8MDIs9krd+ZvIz7zp36S8A0PPiXWVeVAa7zjywLgcF6QLNtpad1Eme5 moKoY4VpOFDstcR9pDC6QKNgaz3ExyKj+FeAqJMDJ6ZGqTv6lJ8a+xgMfapXbvIMQrOt BGDA== X-Gm-Message-State: AOJu0Yyh6aaviNMpZngibSAKmw8B+sdW3N0bO5FqrtTy//ahP5/Id7aO j+blubUebFbBrKP6wR8RMGmDoR2Be2VRri2ul/klZMIsHJ4OWHuTfs5Iel60dVq7 X-Gm-Gg: ASbGnct4HfmX7dz19nnp/znFa5ntcE8sZLjPiQ/WFaeQ9YjmXIGv2ZHuvVgJSpbm4X6 87oaLzqA+o7Xte/vjp7VVwR/u72Zmh2fLlcDT+UZW127RG/tfQgtMx5rrZHwcrVfTpz9Huh1hNw HoYznt8YE8A/erSBg6xiv3D56AlkLedf2gMBKP/H0QOz90lSy6NfXOADmpBhVfub4b9lYzwT4N7 jZxlCYXhx/ki7c/WXvLqJEvDubQzeB5s+WQxqnRitngqckTaqvhmw+ZOFla4zecSX3Z0EHlVhaG M7EfDyoguPUyyFpufUM3rvYdjrvGsSjRmQCAOonk59A6JrqqGVjy8CPa/Ho68003ksdu1H6Je+t hahU5YnU= X-Google-Smtp-Source: AGHT+IH3tdJswFN36V2uHSc+zADQ3AIuPT/3nG6JE2jqxtQe0s1SSwBgNwMBzhMPrf7gPrzC+jyOYQ== X-Received: by 2002:a05:6808:3021:b0:3f3:d6f9:69a5 with SMTP id 5614622812f47-40b1c8ca908mr942017b6e.8.1750882750920; Wed, 25 Jun 2025 13:19:10 -0700 (PDT) Received: from localhost.localdomain ([143.166.81.254]) by smtp.gmail.com with ESMTPSA id 5614622812f47-40ac6d22c23sm2319188b6e.42.2025.06.25.13.19.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Jun 2025 13:19:10 -0700 (PDT) From: Stuart Hayes To: linux-kernel@vger.kernel.org, Greg Kroah-Hartman , "Rafael J . Wysocki" , Martin Belanger , Oliver O'Halloran , Daniel Wagner , Keith Busch , Lukas Wunner , David Jeffery , Jeremy Allison , Jens Axboe , Christoph Hellwig , Sagi Grimberg , linux-nvme@lists.infradead.org, Nathan Chancellor , Jan Kiszka , Bert Karwatzki Cc: Stuart Hayes Subject: [PATCH v10 2/5] driver core: don't always lock parent in shutdown Date: Wed, 25 Jun 2025 15:18:50 -0500 Message-Id: <20250625201853.84062-3-stuart.w.hayes@gmail.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20250625201853.84062-1-stuart.w.hayes@gmail.com> References: <20250625201853.84062-1-stuart.w.hayes@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Don't lock a parent device unless it is needed in device_shutdown. This is in preparation for making device shutdown asynchronous, when it will be needed to allow children of a common parent to shut down simultaneously. Signed-off-by: Stuart Hayes Signed-off-by: David Jeffery --- drivers/base/core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/base/core.c b/drivers/base/core.c index cbc0099d8ef2..58c772785606 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c @@ -4823,7 +4823,7 @@ void device_shutdown(void) spin_unlock(&devices_kset->list_lock); =20 /* hold lock to avoid race with probe/release */ - if (parent) + if (parent && dev->bus && dev->bus->need_parent_lock) device_lock(parent); device_lock(dev); =20 @@ -4847,7 +4847,7 @@ void device_shutdown(void) } =20 device_unlock(dev); - if (parent) + if (parent && dev->bus && dev->bus->need_parent_lock) device_unlock(parent); =20 put_device(dev); --=20 2.39.3 From nobody Wed Oct 8 16:43:49 2025 Received: from mail-oi1-f171.google.com (mail-oi1-f171.google.com [209.85.167.171]) (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 37EFE2DECB7 for ; Wed, 25 Jun 2025 20:19:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750882755; cv=none; b=dMEzCKtKRCGZBX4RL9OnTsnTLok4ialYJNbL7CFkrcHRV9GNRNn5Ti61HC/3ywmOPT8PkGh7ZOBleWSFYpB0AwPT/HKgD2YlvbvuvmSThw5n1rVLbuwW1B/bmulmqJUehC7KUZSnm60UgoJ4MEJ8BXUcB9cF/GKISlW8KX3Dyfk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750882755; c=relaxed/simple; bh=x3K6oL6zDAKX3oSlTP1PWuUNMB8dHUYGjU9fGTdea7Q=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=osbjaOkqkrE8ZT1RIe0MuuSyRdKU42uuE+HwretmRxirzRn9oSefNZN1Wa1sojennB0MgeRlJlxtUoXNFdR4L3v/IQRhceNKQF1BSq7tZlC41akSXrJw5NfQfy2k4HQ/gjkzzBI+0/Kqqi21dZ0Q1eDn3OyPx7FBB6F3NLu2RnU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=g2eLKVCM; arc=none smtp.client-ip=209.85.167.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="g2eLKVCM" Received: by mail-oi1-f171.google.com with SMTP id 5614622812f47-40abe6f8f08so211913b6e.0 for ; Wed, 25 Jun 2025 13:19:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1750882752; x=1751487552; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=f60N3EWufzAACjrb2TEVwWx0frS0X8r/okvyufls31E=; b=g2eLKVCMYjIT8ebCAgS09wYZaXeVcN/hVB8Wo1BpkVf7xAOxPCEUPBSjBsX03hveJ+ uhfCauBzITG89CgkgpfwRtuMeiBsZzh5EUlrAojh9IlgBklejlpszYnDe2xdTi/bO4RW gpV46QeCI8giOE4tCdU1JCvIn8xjzZv8g+MkUf9/L0lmgqB6657Qi1ppVLi+Lp+YFaYz WBM27uolc3SiULd9JDJp8ECFmaUVqz4O5MpS6HRfiGe/8s/W2L0FvPAZS0+aRuCdIpfz kcKTCQvY5W9IxzPhDxL/NpKeXtyX7i+V3u96g4oK+q8u8i4YSWfuCMSHaTwRVrmVh+yZ Wh0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1750882752; x=1751487552; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=f60N3EWufzAACjrb2TEVwWx0frS0X8r/okvyufls31E=; b=O8Bw42tCmP6XpxN/QdWIEsb0aAgmMZYZDmGRtNOQTrSHDcym3rlgkyTex1BC8Z3cpN D0R/MQzMH6m2ACLoEhQ9wJ19ecy/HBS93FIKyO7MDBZP6ojlDgDVurGsTZoaINOGeapy U7PsKPrzVLk5WxxtvBKVgwIih72tdopcWghj7VslJm5zS1y3N0/+utagV/sR5eeJIoJ4 zYW0JkSQiUzGeQG9WuWn/pT4sBmg/bLJT25GqkavtYZ+8cR75N5WZPomwgklIuyGFhHO bVqkXxOKykJlN178i34TBSc5GHucwmwvvz0KYyqB+OQZrfNKcb65b5oHDSjheGEHW6pD Tb6Q== X-Gm-Message-State: AOJu0YyqAEwdbZbUGR6/liMHek9P0+rhRxPHcyuyfB594q0gNY2lk5d5 iVKS3cZ1pr2sddit6pgmuP2Kd+v5sWw7sTKepUdDp5KSmDe87ge5Dzq7wZYtZ5AO X-Gm-Gg: ASbGncvf/uDCPo/aU7bcE4xh0gF52V+zte2tX5MPcWY6Y1Q1gEYGH1RD2kEKOacN/06 w4xGfE5qcx82Jvwo88sCffIsmbRkS3t+FdgJ94IAcPJLymrSjFfeTuJTSVzkUFsu7TxFzPq4I+r rsy7nj80R6UCjQkUHLy4zbBJ+N8Njj5uK3UTpQ/8vVW1+Hnz6mGkIEAgG20EbCu35fz3Ko9/AZl 71Rb52rqxUho8lOKnbd2WJlqrmd5X2R6sXaYTr6l9DChYgUjHE51LTTa5+YBm93+SYcCPdnrORG znAbAjuTbx2ncwmI97m3rgWA4Cc8Fwe24I9+dd94s2/oSXEcY7fei+Pa3suLSEhRdU97q7T6lHu RyAmE0+8= X-Google-Smtp-Source: AGHT+IE1GiyMI3FcPixO8wBehxm6oIdPGjQDw2GVFgAwIwdC14AZtTmqP0n8EzwJ7ZQqJDCh44hL0g== X-Received: by 2002:a05:6808:150f:b0:40a:a633:b1f8 with SMTP id 5614622812f47-40b05a81997mr3795477b6e.9.1750882752169; Wed, 25 Jun 2025 13:19:12 -0700 (PDT) Received: from localhost.localdomain ([143.166.81.254]) by smtp.gmail.com with ESMTPSA id 5614622812f47-40ac6d22c23sm2319188b6e.42.2025.06.25.13.19.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Jun 2025 13:19:11 -0700 (PDT) From: Stuart Hayes To: linux-kernel@vger.kernel.org, Greg Kroah-Hartman , "Rafael J . Wysocki" , Martin Belanger , Oliver O'Halloran , Daniel Wagner , Keith Busch , Lukas Wunner , David Jeffery , Jeremy Allison , Jens Axboe , Christoph Hellwig , Sagi Grimberg , linux-nvme@lists.infradead.org, Nathan Chancellor , Jan Kiszka , Bert Karwatzki Cc: Stuart Hayes Subject: [PATCH v10 3/5] driver core: separate function to shutdown one device Date: Wed, 25 Jun 2025 15:18:51 -0500 Message-Id: <20250625201853.84062-4-stuart.w.hayes@gmail.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20250625201853.84062-1-stuart.w.hayes@gmail.com> References: <20250625201853.84062-1-stuart.w.hayes@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Make a separate function for the part of device_shutdown() that does the shutown for a single device. This is in preparation for making device shutdown asynchronous. Signed-off-by: Stuart Hayes Signed-off-by: David Jeffery --- drivers/base/core.c | 66 ++++++++++++++++++++++++--------------------- 1 file changed, 36 insertions(+), 30 deletions(-) diff --git a/drivers/base/core.c b/drivers/base/core.c index 58c772785606..39502621e88e 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c @@ -4786,6 +4786,41 @@ int device_change_owner(struct device *dev, kuid_t k= uid, kgid_t kgid) } EXPORT_SYMBOL_GPL(device_change_owner); =20 +static void shutdown_one_device(struct device *dev) +{ + /* hold lock to avoid race with probe/release */ + if (dev->parent && dev->bus && dev->bus->need_parent_lock) + device_lock(dev->parent); + device_lock(dev); + + /* Don't allow any more runtime suspends */ + pm_runtime_get_noresume(dev); + pm_runtime_barrier(dev); + + if (dev->class && dev->class->shutdown_pre) { + if (initcall_debug) + dev_info(dev, "shutdown_pre\n"); + dev->class->shutdown_pre(dev); + } + if (dev->bus && dev->bus->shutdown) { + if (initcall_debug) + dev_info(dev, "shutdown\n"); + dev->bus->shutdown(dev); + } else if (dev->driver && dev->driver->shutdown) { + if (initcall_debug) + dev_info(dev, "shutdown\n"); + dev->driver->shutdown(dev); + } + + device_unlock(dev); + if (dev->parent && dev->bus && dev->bus->need_parent_lock) + device_unlock(dev->parent); + + if (dev->parent) + put_device(dev->parent); + put_device(dev); +} + /** * device_shutdown - call ->shutdown() on each device to shutdown. */ @@ -4822,36 +4857,7 @@ void device_shutdown(void) list_del_init(&dev->kobj.entry); spin_unlock(&devices_kset->list_lock); =20 - /* hold lock to avoid race with probe/release */ - if (parent && dev->bus && dev->bus->need_parent_lock) - device_lock(parent); - device_lock(dev); - - /* Don't allow any more runtime suspends */ - pm_runtime_get_noresume(dev); - pm_runtime_barrier(dev); - - if (dev->class && dev->class->shutdown_pre) { - if (initcall_debug) - dev_info(dev, "shutdown_pre\n"); - dev->class->shutdown_pre(dev); - } - if (dev->bus && dev->bus->shutdown) { - if (initcall_debug) - dev_info(dev, "shutdown\n"); - dev->bus->shutdown(dev); - } else if (dev->driver && dev->driver->shutdown) { - if (initcall_debug) - dev_info(dev, "shutdown\n"); - dev->driver->shutdown(dev); - } - - device_unlock(dev); - if (parent && dev->bus && dev->bus->need_parent_lock) - device_unlock(parent); - - put_device(dev); - put_device(parent); + shutdown_one_device(dev); =20 spin_lock(&devices_kset->list_lock); } --=20 2.39.3 From nobody Wed Oct 8 16:43:49 2025 Received: from mail-oi1-f176.google.com (mail-oi1-f176.google.com [209.85.167.176]) (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 D17112DECDA for ; Wed, 25 Jun 2025 20:19:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.176 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750882756; cv=none; b=i4ZN1solH34nDL9q/EhXHU4yrNB8dq5ilxsNY4Fe+ReajyHG//MPf8clT/4DqOEFhYDirj3JnxjMLR6T+KcnQYBKvm5RpIN3ucxUMSJIL2sAo4ROwYweesCEwBiStK58ls7UswJksYeT7BpIBr29usEn7lkFbezWK341hobBiM8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750882756; c=relaxed/simple; bh=SuhUWkxepCKwUTJDVQuQYNJ1JlgH4TR7LESd1alMoq4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=mtE0Vs6kIVVuGblW/VNQ0mdq8KVTOanQmCNwepfttIURNlc9qZPCWhxYUDlgZy/EkrHRx2dVnKGnMRpEUdT0A8hN6GM+bCNn/f9z6XPCgcUvhkYV/ULkohk/rETLwdPtbT+Uvhqv5yXVHrjU5mY9ZVXT6sN9lBcktooNHqi4JSw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=je0qoRYL; arc=none smtp.client-ip=209.85.167.176 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="je0qoRYL" Received: by mail-oi1-f176.google.com with SMTP id 5614622812f47-40b1c099511so212515b6e.0 for ; Wed, 25 Jun 2025 13:19:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1750882754; x=1751487554; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=kjfYUz5Sj9VCDUhJbZKoCap8L6aycyxFsKLXfxsEkRo=; b=je0qoRYLVIIpaHoRSy3WFF6cAbO3Svu7lRYle1dhMy36Kf/Y5Pmh5DmTFed/QxzpDf zrdLzkVe0F+my1K2glq7oRAvm4tavT6JIWYL8n6sISk1ZJO8UejcTA3uqEJSu17iEPk2 bF4bXh3f2pwzjY9E7KEfcOxEtbCmlsLTk2eKh/1F8hKZ18U4sjiu3pJwe/XMbFZPkpf8 M0fIFXzG3zZhuS5mGzr6jxHhegdbIJ6vEy+/Fmh2GC/7gd9lTbjFXJEimzOlNpNQ842A aon2Uz8hQ2I9y7TYBuZPakVYp8AKPbQ/1m8i0mwbaMIWfowE8d0P5D8bnJU1NEngfCG+ pQSA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1750882754; x=1751487554; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=kjfYUz5Sj9VCDUhJbZKoCap8L6aycyxFsKLXfxsEkRo=; b=nNprKuE/MUmqPmWQWgXjd+wZ6D5uWyew54qpwdzd+nYafDrp4LGXtc3iKPQLvklBp6 op6SaybZ7UtDITbrjINSuS/Q9od0Do/sNxZNEdyHf8iL0BEKkUJqxscKwxtOrTqm1Tj5 +L392dGPBIdnR48AdDQ1j5X0iRefxl1Fv4X+WXiBFkGhAUtPh6HsOX2NpIkNqJNxNVdf 5BfKpJMRk2b13UXuM+0deka+eBo7QAKyL6GLoNjE+uF53n9I53pMUvpsMFF9sPTWOJza ytexDbGsrCa15e5ZtuzY3aP+/0Heb25i+9kdGqBN+QQgm/t4hsEPX0ch7onGQv53w+sZ mJ2g== X-Gm-Message-State: AOJu0Yz3E8m3j8XQnj8oyczZ/YVCXxDeuYTDjf0SE21kx8DbxunDzIm8 MeRlg1VqxvqogMIiPgu3I6uyuo9wl4PvFx96MBbrodX8l/7PWlD8B3r8ukFYtIY0 X-Gm-Gg: ASbGncvWb3hwzLh5EDzUISJPcXObH0uIbPmD6WygL8VzXpcphwWOarfgWB3RKQIMitA eztU186ZYuNMg8Xs+w4zFfVIRfQ54K2df9qvcVxXEYui1CHVxMh4BhlMwDxQCQ5QmlIDhPr2Zic 9EXANoCHCXRxwynVrbKPEs0/uGWoPLwo1UMz8X6CKFgnQ9gz3gPaHNgtem5aqZNLg3Rgs/IhiBy 2OkCSdhAhuLw+N1nlvMU+07qYgQYm3tPAGX8onTD/Ub4qOxQUzqbk6fjEcDxh/QFSCjd06u7Nh1 FMvMRyuEj0wa1f+DuMrPh91SDBmbXkaNER+1fGIF0aO4iLpkqXUxeIVDsg6cUWNePFtr49x1YNj Lxw1REt4= X-Google-Smtp-Source: AGHT+IEPPX6GdITt8r22TB09bMzNMI1EoDKyu9xgoJ9OiZYs/o7KlircW0SgMKIhPLWaoccM3UA6HA== X-Received: by 2002:a05:6808:3021:b0:3f3:d6f9:69a5 with SMTP id 5614622812f47-40b1c8ca908mr942132b6e.8.1750882753614; Wed, 25 Jun 2025 13:19:13 -0700 (PDT) Received: from localhost.localdomain ([143.166.81.254]) by smtp.gmail.com with ESMTPSA id 5614622812f47-40ac6d22c23sm2319188b6e.42.2025.06.25.13.19.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Jun 2025 13:19:13 -0700 (PDT) From: Stuart Hayes To: linux-kernel@vger.kernel.org, Greg Kroah-Hartman , "Rafael J . Wysocki" , Martin Belanger , Oliver O'Halloran , Daniel Wagner , Keith Busch , Lukas Wunner , David Jeffery , Jeremy Allison , Jens Axboe , Christoph Hellwig , Sagi Grimberg , linux-nvme@lists.infradead.org, Nathan Chancellor , Jan Kiszka , Bert Karwatzki Cc: Stuart Hayes Subject: [PATCH v10 4/5] driver core: shut down devices asynchronously Date: Wed, 25 Jun 2025 15:18:52 -0500 Message-Id: <20250625201853.84062-5-stuart.w.hayes@gmail.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20250625201853.84062-1-stuart.w.hayes@gmail.com> References: <20250625201853.84062-1-stuart.w.hayes@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add code to allow asynchronous shutdown of devices. Devices allowed to do asynchronous shutdown can start to shut down in their own thread as soon as all of the devices dependent on them have finished shutting down. All other devices will wait until the previous device in the devices_kset list have finished shutting down. Only devices with drivers that have async_shutdown_enable set will be shut down asynchronously. Devices shutting down asynchronously will be shut down in their own thread, but synchronous devices in the devices_kset list between asynch devices will be put in a list, and that list will be shut down in a single thread. This avoids burdening the system with hundreds of threads on shutdown. This can dramatically reduce system shutdown/reboot time on systems that have multiple devices that take many seconds to shut down (like certain NVMe drives). On one system tested, the shutdown time went from 11 minutes without this patch to 55 seconds when this patch. Signed-off-by: David Jeffery Signed-off-by: Stuart Hayes --- drivers/base/base.h | 8 ++ drivers/base/core.c | 157 +++++++++++++++++++++++++++++++++- include/linux/device/driver.h | 2 + 3 files changed, 165 insertions(+), 2 deletions(-) diff --git a/drivers/base/base.h b/drivers/base/base.h index 123031a757d9..214207ca5392 100644 --- a/drivers/base/base.h +++ b/drivers/base/base.h @@ -10,6 +10,7 @@ * shared outside of the drivers/base/ directory. * */ +#include #include =20 /** @@ -85,6 +86,11 @@ struct driver_private { }; #define to_driver(obj) container_of(obj, struct driver_private, kobj) =20 +union shutdown_private { + struct device *next; + async_cookie_t after; +}; + /** * struct device_private - structure to hold the private to the driver cor= e portions of the device structure. * @@ -98,6 +104,7 @@ struct driver_private { * the device; typically because it depends on another driver getting * probed first. * @async_driver - pointer to device driver awaiting probe via async_probe + * @shutdown - used during device shutdown to ensure correct shutdown orde= ring. * @device - pointer back to the struct device that this structure is * associated with. * @dead - This device is currently either in the process of or has been @@ -115,6 +122,7 @@ struct device_private { struct list_head deferred_probe; const struct device_driver *async_driver; char *deferred_probe_reason; + union shutdown_private shutdown; struct device *device; u8 dead:1; }; diff --git a/drivers/base/core.c b/drivers/base/core.c index 39502621e88e..f0484ceefc52 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c @@ -9,6 +9,7 @@ */ =20 #include +#include #include #include #include @@ -4786,6 +4787,8 @@ int device_change_owner(struct device *dev, kuid_t ku= id, kgid_t kgid) } EXPORT_SYMBOL_GPL(device_change_owner); =20 +static ASYNC_DOMAIN(sd_domain); + static void shutdown_one_device(struct device *dev) { /* hold lock to avoid race with probe/release */ @@ -4821,12 +4824,116 @@ static void shutdown_one_device(struct device *dev) put_device(dev); } =20 +static bool device_wants_async_shutdown(struct device *dev) +{ + if (dev->driver && dev->driver->async_shutdown_enable) + return true; + + return false; +} + +/** + * set_wait_cookies + * @dev: device to find parents and suppliers for + * @cookie: shutdown cookie for dev + * + * Look for parent and suppliers of dev that want async shutdown, and + * set shutdown.after to cookie on those devices to ensure they + * don't shut down before dev. + * + * Passing a cookie of zero will return whether any such devices are found + * without setting shutdown.after. + * + * Return true if any async supplier/parent devices are found. + */ +static bool device_set_async_cookie(struct device *dev, async_cookie_t coo= kie) +{ + int idx; + struct device_link *link; + bool ret =3D false; + struct device *parent =3D dev->parent; + + if (parent && device_wants_async_shutdown(parent)) { + ret =3D true; + if (cookie) + parent->p->shutdown.after =3D cookie; + else + goto done; + } + + idx =3D device_links_read_lock(); + list_for_each_entry_rcu(link, &dev->links.suppliers, c_node, + device_links_read_lock_held()) { + if (!device_link_flag_is_sync_state_only(link->flags) + && device_wants_async_shutdown(link->supplier)) { + ret =3D true; + if (cookie) + link->supplier->p->shutdown.after =3D cookie; + else + break; + } + } + device_links_read_unlock(idx); +done: + return ret; +} + +#define is_async_shutdown_dependency(dev) device_set_async_cookie(dev, 0) + +/** + * shutdown_devices_async + * @data: list of devices to be shutdown + * @cookie: not used + * + * Shuts down devices after waiting for previous devices to shut down (for + * synchronous shutdown) or waiting for device's last child or consumer to + * be shutdown (for async shutdown). + * + * shutdown.after is set to the shutdown cookie of the last child or consu= mer + * of this device (if any). + */ +static void shutdown_devices_async(void *data, async_cookie_t cookie) +{ + struct device *next, *dev =3D data; + async_cookie_t wait =3D cookie; + bool async =3D device_wants_async_shutdown(dev); + + if (async) { + wait =3D dev->p->shutdown.after + 1; + /* + * To prevent system hang, revert to sync shutdown in the event + * that shutdown.after would make this shutdown wait for a + * shutdown that hasn't been scheduled yet. + * + * This can happen if a parent or supplier is not ordered in the + * devices_kset list before a child or consumer, which is not + * expected. + */ + if (wait > cookie) { + wait =3D cookie; + dev_warn(dev, "Unsafe shutdown ordering, forcing sync order\n"); + } + } + + async_synchronize_cookie_domain(wait, &sd_domain); + + /* + * Shut down the async device or list of sync devices + */ + do { + next =3D dev->p->shutdown.next; + shutdown_one_device(dev); + dev =3D next; + } while (!async && dev); +} + /** * device_shutdown - call ->shutdown() on each device to shutdown. */ void device_shutdown(void) { - struct device *dev, *parent; + struct device *dev, *parent, *synclist =3D NULL, *syncend =3D NULL; + async_cookie_t cookie =3D 0; =20 wait_for_device_probe(); device_block_probing(); @@ -4857,11 +4964,57 @@ void device_shutdown(void) list_del_init(&dev->kobj.entry); spin_unlock(&devices_kset->list_lock); =20 - shutdown_one_device(dev); + get_device(dev); + get_device(parent); + + if (device_wants_async_shutdown(dev)) { + /* + * async devices run alone in their own async task, + * push out any waiting sync devices to maintain + * ordering. + */ + if (synclist) { + async_schedule_domain(shutdown_devices_async, + synclist, &sd_domain); + synclist =3D syncend =3D NULL; + } + + cookie =3D async_schedule_domain(shutdown_devices_async, + dev, &sd_domain); + device_set_async_cookie(dev, cookie); + } else { + if (!synclist) { + synclist =3D syncend =3D dev; + } else { + syncend->p->shutdown.next =3D dev; + syncend =3D dev; + } + if (is_async_shutdown_dependency(dev)) { + /* + * dev is a dependency for an async device, + * kick off a new thread so it can complete + * and allow the async device to run its + * shutdown. + */ + cookie =3D async_schedule_domain( + shutdown_devices_async, + synclist, &sd_domain); + device_set_async_cookie(dev, cookie); + synclist =3D syncend =3D NULL; + } + } + + put_device(parent); + put_device(dev); =20 spin_lock(&devices_kset->list_lock); } spin_unlock(&devices_kset->list_lock); + + if (synclist) + async_schedule_domain(shutdown_devices_async, synclist, + &sd_domain); + async_synchronize_full_domain(&sd_domain); } =20 /* diff --git a/include/linux/device/driver.h b/include/linux/device/driver.h index cd8e0f0a634b..c63bc0050c84 100644 --- a/include/linux/device/driver.h +++ b/include/linux/device/driver.h @@ -56,6 +56,7 @@ enum probe_type { * @mod_name: Used for built-in modules. * @suppress_bind_attrs: Disables bind/unbind via sysfs. * @probe_type: Type of the probe (synchronous or asynchronous) to use. + * @async_shutdown_enable: Enables devices to be shutdown asynchronously. * @of_match_table: The open firmware table. * @acpi_match_table: The ACPI match table. * @probe: Called to query the existence of a specific device, @@ -102,6 +103,7 @@ struct device_driver { =20 bool suppress_bind_attrs; /* disables bind/unbind via sysfs */ enum probe_type probe_type; + bool async_shutdown_enable; =20 const struct of_device_id *of_match_table; const struct acpi_device_id *acpi_match_table; --=20 2.39.3 From nobody Wed Oct 8 16:43:50 2025 Received: from mail-oi1-f176.google.com (mail-oi1-f176.google.com [209.85.167.176]) (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 1F8992DFA58 for ; Wed, 25 Jun 2025 20:19:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.176 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750882757; cv=none; b=R0v+knV4fRtgls2b2JX6UyQq6LMzTOocJrEYeyyJ5B0vPNh3Z6N/a7HR5KLzR8zZCDcIGhN81qTMW4o9oQukemKPMOcG+fA2BPW5PrZJdgdjLAzDYx7ZFueQwE+hancV+DTcxJDr1k8a+KUuWp8peTDSWbSozV7G+82wbNtuwW0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750882757; c=relaxed/simple; bh=UghlVNqiIgpdScPnDJwUCgMkfLA9c8dgrWlNZ4F4kJI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=On2f8ZNqQ1R59dDhAHOwJGLvG9r+V5tgdhMdwIuVihGsTApwcqe7wh7Hhvf8dKJbcvulyi+HqQf09GO3M44++Y81SRDauQRCtkzI4IrgTa80lrX8aSqEDttGbUb5UrbLUeXwruFQu0BHjIRYdKR7w5Uq4g8k//rWSmaKZUA0V7g= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=WzgU+FC6; arc=none smtp.client-ip=209.85.167.176 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="WzgU+FC6" Received: by mail-oi1-f176.google.com with SMTP id 5614622812f47-40a4de175a3so218420b6e.0 for ; Wed, 25 Jun 2025 13:19:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1750882755; x=1751487555; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=u+kL5Owd/b/uNVufMn9kQ7uWapXNIP2yBqmENsKSMRw=; b=WzgU+FC6DdUkuBpN/NERAF7SKWjYrA8E4lrdWUPljUkSSM0YWeQppIKDRq9Bihbvkh WBGjpKNcpm0rWkFJNOiCR90B+i4algKh88m4v9Vk0642oAFkIWJMmFfwf3r1viOuFk53 uf5SZF8CAWJd2a7Zb9GDGEyGsnXfoVrlgX+QdRspskJNdJY0jQ35COonVIxM+JkZJh88 1J/NF1ZW1mUAJhN91huTqm2jrjiRugsTBHyc3BWU321vtRKAmjsO1XymgHpGFIp/LJ7i fbO7oOHJdzgKhCjjlsomM8OrN6A850Hj/OqlgazUO0UxTokf8pKshsqVYrvLmcepo6f6 57ww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1750882755; x=1751487555; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=u+kL5Owd/b/uNVufMn9kQ7uWapXNIP2yBqmENsKSMRw=; b=NgwHwvJGMP1uTBzyIbhEuGcOsatlhuVNZOibOEZNboZ2IMOKivVDjqj2dpLfvt9rNp aiAicf6qruyrQCnLOnaoFui1ubH56lv4n0LFHbysIdJXEKoIwMO22N9UeLu31b1SHP3B iyXhfQYQrey4b/oCffBfusbZLMG5y87fkIyuHOi1diX50Q2kLJSWhQjbXL0PEPNLs7qQ yv1mTolqzkWC7FEb6cyX33sAu/nuz9MouxU2vWo6k8k0TYyMxNoO7UJFvNI3zZt9x119 TduqlmERjAdOiR2w/R3wckCZ98QTzn7T/1puHRIMMsGnZGxhXv1dCxpb4Ww4AxElUbPD Dahg== X-Gm-Message-State: AOJu0YwbEXFz9dJptQzIAYNnzFnsq22TT1Oo40PwyBVPPIQXpcFSPYrQ PE/aQ0KSFmkF8xUql0oyVPQaV1zOlOusghhRrGx3eYMB9YiTO3RsyTtOIPE+j9W6 X-Gm-Gg: ASbGncvUrjifjx53g6oZEqxMGzu10RtWcbJ9Wpli4y6JEn7L/+kw7+Csq2VdyuCvsy+ x4lQgkQZjOVgWhwPgPW0rItCpyotRqoHnOLSU5lyXu2a4Jxxd5FbILFOFF7lQoXR18OEOk11LyX PKfXY1FaAGwiqRT2RnURkSbTMiLhMANbV7XzcKKEpeghBkuDwiXxxVlfJg2ZI+2hkRNyqnh/afJ 4w5LyyP58pIUzqH9KeOwTZp8sHLHaaHYrI81Cy+lX41vJU5xLxfL3pNHLRgF+vOsMY7hfyS1WAM v67Jb2pAwTshLuNaJvY2lafypBodd9jkcFWBZAwwSAqGUM57hT73eut6Z5jxkCJc+UFjKSqpAQW 5YUZu0ec= X-Google-Smtp-Source: AGHT+IErlKTN6Obe2eJ+hIRHlWBHfaYeu4HODg60y4Vj953Lq/di1qxS4riYzV3zaqb0HmNNI5o1iQ== X-Received: by 2002:a05:6808:14d1:b0:40a:57cc:d9f0 with SMTP id 5614622812f47-40b057d76f4mr3175226b6e.25.1750882755168; Wed, 25 Jun 2025 13:19:15 -0700 (PDT) Received: from localhost.localdomain ([143.166.81.254]) by smtp.gmail.com with ESMTPSA id 5614622812f47-40ac6d22c23sm2319188b6e.42.2025.06.25.13.19.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Jun 2025 13:19:14 -0700 (PDT) From: Stuart Hayes To: linux-kernel@vger.kernel.org, Greg Kroah-Hartman , "Rafael J . Wysocki" , Martin Belanger , Oliver O'Halloran , Daniel Wagner , Keith Busch , Lukas Wunner , David Jeffery , Jeremy Allison , Jens Axboe , Christoph Hellwig , Sagi Grimberg , linux-nvme@lists.infradead.org, Nathan Chancellor , Jan Kiszka , Bert Karwatzki Cc: Stuart Hayes Subject: [PATCH v10 5/5] nvme-pci: Make driver prefer asynchronous shutdown Date: Wed, 25 Jun 2025 15:18:53 -0500 Message-Id: <20250625201853.84062-6-stuart.w.hayes@gmail.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20250625201853.84062-1-stuart.w.hayes@gmail.com> References: <20250625201853.84062-1-stuart.w.hayes@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Set the driver default to enable asynchronous shutdown. Signed-off-by: Stuart Hayes Signed-off-by: David Jeffery --- drivers/nvme/host/pci.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c index 8ff12e415cb5..727527ef3896 100644 --- a/drivers/nvme/host/pci.c +++ b/drivers/nvme/host/pci.c @@ -3831,6 +3831,7 @@ static struct pci_driver nvme_driver =3D { .shutdown =3D nvme_shutdown, .driver =3D { .probe_type =3D PROBE_PREFER_ASYNCHRONOUS, + .async_shutdown_enable =3D true, #ifdef CONFIG_PM_SLEEP .pm =3D &nvme_dev_pm_ops, #endif --=20 2.39.3