Received: by 2002:a05:7412:b130:b0:e2:908c:2ebd with SMTP id az48csp2481471rdb; Mon, 20 Nov 2023 12:01:42 -0800 (PST) X-Google-Smtp-Source: AGHT+IFEuCqNFqfFqfG38GjT4YRNAU00w8bFMhDBHWqnshsIEK4VYoxeZX0muWZUogKgbK5NngeT X-Received: by 2002:a05:6871:590:b0:1f5:8313:6084 with SMTP id u16-20020a056871059000b001f583136084mr9184327oan.29.1700510501797; Mon, 20 Nov 2023 12:01:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700510501; cv=none; d=google.com; s=arc-20160816; b=c0DhbOOVkkcrcwN3gZTJnD5IBAgwMGfbJgUOiH0PtGrGTs7b1zTgXwF5Z3PWM/O+2y QfqMncAS+UTiJ8dr9JEDu1qlVC8cf+a8RxRgSMcG5/FfOQ2SGQh3CBMqpd2rYY59eTov jt9HUJHQTSF4hXdL4njMUDtgRZkOviuqaY/1w3utYjUrwcUPy1X6G8ncJ8mSy/mj4W5x ngaHOSWVEC4v5BDfivwj/xmzeMfwjI7HPzlc9JbPMIwzIyjNQ6hzL2X4lSf2Nvh6D+oN ol24uQ6H1On1NFe7mLSXQRXzp2OI5EcYZ9w0XUCiTTCMeb0pTn5mHOSALWe1QjS/xuwm vZ3w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=aIv8yb+/tKWqV05d2RvY4diJdtjepSEmXYNuaS4bJl4=; fh=BpmQCBPGJFyXdkV+lF0XhZdYORm5swww0zYxFO+Xlw8=; b=tPnhnnViVSbW/ete5SqHDuJyKIFFNqnk8nxiPyL5jClS3vKeIrAENzBt4TaRWZIhcW gHDy/wO0pWj1gw0HXznRWXOC2bwbwo2eK/mmneAG3XHFORAhPvg9KTEbFI15EZeJa2dg 10BAw2wpdZb1eKd8ZE9izGNFQrABPxRSwn8xnEEYh16Us2NMZ7AjaGSOoHBlUD9z8P0H 7mYe/WHgmo/5yoZ+hOsthn9c9Iqtwk7/8P8tFVCq0MSm6nrub43vO/5MfxX4HBNsIDJF UVhYu+RgHqnOiigtv4ePlXguUKIcE3GlYkoFhW7CsGK+BEc9mM1ps3Wd3LkA00C6Cgpb OPCQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b=tBqvHymb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id t24-20020a9d5918000000b006d33e8d641dsi3162751oth.84.2023.11.20.12.01.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Nov 2023 12:01:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b=tBqvHymb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id E805E80782BF; Mon, 20 Nov 2023 12:01:19 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230021AbjKTUBK (ORCPT + 99 others); Mon, 20 Nov 2023 15:01:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53264 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229497AbjKTUBI (ORCPT ); Mon, 20 Nov 2023 15:01:08 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0A25EBE for ; Mon, 20 Nov 2023 12:01:02 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5989AC433C8; Mon, 20 Nov 2023 20:01:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1700510461; bh=biW/bVGnRij9I2dtfarXJBwQG+bK+6YfrHHXjNnRcqk=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=tBqvHymbJhTUUeKJhYJ1zIxZgWcGaOQ3jNVvGf5SBCrH2TEz16QpYtyZ2qiwDEG8t 9eXkoqI92DPoAUCAnimFT+g/P3R2oH/KfI8gvXcAYbwe6ipA8r1ZYllhlmEyl1x6aF ecfZ4iSYbwr2eS9Tb4Kbt1ltQF+m3fCR9yFVN/Cs= Date: Mon, 20 Nov 2023 12:00:59 -0800 From: Andrew Morton To: Ming Lei Cc: Thomas Gleixner , linux-kernel@vger.kernel.org, Keith Busch , linux-nvme@lists.infradead.org, linux-block@vger.kernel.org, Yi Zhang , Guangwu Zhang , Chengming Zhou , Jens Axboe Subject: Re: [PATCH V4 resend] lib/group_cpus.c: avoid to acquire cpu hotplug lock in group_cpus_evenly Message-Id: <20231120120059.ef0614c2295b2102100cb56e@linux-foundation.org> In-Reply-To: <20231120083559.285174-1-ming.lei@redhat.com> References: <20231120083559.285174-1-ming.lei@redhat.com> X-Mailer: Sylpheed 3.8.0beta1 (GTK+ 2.24.33; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Mon, 20 Nov 2023 12:01:20 -0800 (PST) On Mon, 20 Nov 2023 16:35:59 +0800 Ming Lei wrote: > group_cpus_evenly() could be part of storage driver's error handler, > such as nvme driver, when may happen during CPU hotplug, in which > storage queue has to drain its pending IOs because all CPUs associated > with the queue are offline and the queue is becoming inactive. And > handling IO needs error handler to provide forward progress. > > Then dead lock is caused: > > 1) inside CPU hotplug handler, CPU hotplug lock is held, and blk-mq's > handler is waiting for inflight IO > > 2) error handler is waiting for CPU hotplug lock > > 3) inflight IO can't be completed in blk-mq's CPU hotplug handler because > error handling can't provide forward progress. > > Solve the deadlock by not holding CPU hotplug lock in group_cpus_evenly(), > in which two stage spreads are taken: 1) the 1st stage is over all present > CPUs; 2) the end stage is over all other CPUs. > > Turns out the two stage spread just needs consistent 'cpu_present_mask', and > remove the CPU hotplug lock by storing it into one local cache. This way > doesn't change correctness, because all CPUs are still covered. I'm not sure what is the intended merge path for this, but I can do lib/. Do you think that a -stable backport is needed? It sounds that way. If so, are we able to identify a suitable Fixes: target? That would predate f7b3ea8cf72f3 ("genirq/affinity: Move group_cpus_evenly() into lib/").