Received: by 2002:a05:7412:251c:b0:e2:908c:2ebd with SMTP id w28csp2250635rda; Tue, 24 Oct 2023 18:11:26 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG8tt6p0hl1XFgVQ0V5weWY5JIe92y9XxDQSFRjPd1QwTzbCUGwAS4bJVXFmcsZZsYpDo6d X-Received: by 2002:a0d:ca4f:0:b0:5a7:d4d7:aaa1 with SMTP id m76-20020a0dca4f000000b005a7d4d7aaa1mr19193849ywd.16.1698196286327; Tue, 24 Oct 2023 18:11:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698196286; cv=none; d=google.com; s=arc-20160816; b=R1xnmrP4ukJFNq1bYpKo8ahHHaWRoj63kNCxlrIgwzFqU2B+e60NxmIB5SnM14e5AB aH69js9iQZ09DTvtZJjVeOP1nPz6Ec1crbOdHWeynQwPm9LnrgbtD6PiGo/u/9engxmc hYebeAr24J/hRITViztSDH4YTh8CpbYEk3hRFuJho1RKeNmz/3Y/mnBT83jdzDPQN5dK gzs5ZzVNi1Ncv1g6JawoyoVzd6Bg18mdn+E1/R09nOC+r+MUA7xfCE/WKd4YQ+6BA1jj dcBDW1qqO9XrLGqa/pknYV/NcDnpbe05Kk5tI0eALor4WP+C57iT8B1EtHYutS8iXOXt F24A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=tMh9TC0aGjaUuBRnwLbHZHlLYYDSCkNxx3aEz5NxIz4=; fh=VqVw5iUFtR8cARLPIRcBDZuxT+GaFNWWJExFPrVvU8c=; b=ZFDXKPkTSKVLHtJgKOj6ocbxtjaXd7bO+KHCx5EDwdEiaCgzWiO+VH0Obf9ZcA77m4 WiVFPLWbwrOJ2ZjIlluguVNbM+L35IIKMJUVho9HJm2TRF4+67ELA4xfI8Mjv25gORTt jn727hQg/7LbjYrP6EiECLnyp32SnuyS/alvf9n2ZSd11WA6KbDnXdeS4E8rhpfpbvAc LtDpX/86iYyfP23Ma2S2iwSt+uF7YGBjqaZIDLSR5230v1bhj7DZ3pV7tQsAfUiHtBPh xl9X/Ir12w9uRXJYFsvXB98UiDzTA04L2syyeMe1nb/vJUKjKPI0TTj6rHNFB3t20pmH 0fbA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=NVHQQo3a; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id x72-20020a0dd54b000000b005869cf4fe20si9415072ywd.76.2023.10.24.18.11.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Oct 2023 18:11:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=NVHQQo3a; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id B1FE08087256; Tue, 24 Oct 2023 18:10:35 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229968AbjJYBGI (ORCPT + 99 others); Tue, 24 Oct 2023 21:06:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44452 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229606AbjJYBGG (ORCPT ); Tue, 24 Oct 2023 21:06:06 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 39846D7D for ; Tue, 24 Oct 2023 18:05:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1698195918; 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: in-reply-to:in-reply-to:references:references; bh=tMh9TC0aGjaUuBRnwLbHZHlLYYDSCkNxx3aEz5NxIz4=; b=NVHQQo3ajOZdJiyJKEh4R4b/qLMUx+UQ6wBU99zIV7pkvnY7GoFqiDngg9s/m/PaGqCK0V 8CZ9aqbXchC3DYXZuODW3d9iqJ4PK/dASYypchUt8T8UPXEJJS7AcfY0gnr6ygrvESn8u2 4vC7uy8hDyO5A2B73ucwFxjMa6jo/yI= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-629-04EUR9UwNgW4NGA7Q-eNFw-1; Tue, 24 Oct 2023 21:05:14 -0400 X-MC-Unique: 04EUR9UwNgW4NGA7Q-eNFw-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 773423811F21; Wed, 25 Oct 2023 01:05:14 +0000 (UTC) Received: from fedora (unknown [10.72.120.2]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 683732026D4C; Wed, 25 Oct 2023 01:05:08 +0000 (UTC) Date: Wed, 25 Oct 2023 09:05:03 +0800 From: Ming Lei To: Bart Van Assche Cc: Jens Axboe , linux-block@vger.kernel.org, Tejun Heo , linux-kernel@vger.kernel.org, Juri Lelli , Andrew Theurer , Joe Mario , Sebastian Jug , Frederic Weisbecker , ming.lei@redhat.com Subject: Re: [PATCH V2] blk-mq: don't schedule block kworker on isolated CPUs Message-ID: References: <20231013124758.1492796-1-ming.lei@redhat.com> <293c16d2-f556-4d42-ab06-2e0acf1cc601@acm.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <293c16d2-f556-4d42-ab06-2e0acf1cc601@acm.org> X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.4 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.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 (morse.vger.email [0.0.0.0]); Tue, 24 Oct 2023 18:10:36 -0700 (PDT) On Tue, Oct 24, 2023 at 09:53:49AM -0700, Bart Van Assche wrote: > > On 10/13/23 05:47, Ming Lei wrote: > > @@ -3926,6 +3941,15 @@ static void blk_mq_map_swqueue(struct request_queue *q) > > */ > > sbitmap_resize(&hctx->ctx_map, hctx->nr_ctx); > > + /* > > + * rule out isolated CPUs from hctx->cpumask for avoiding to > > + * run wq worker on isolated CPU > > + */ > > + for_each_cpu(cpu, hctx->cpumask) { > > + if (cpu_is_isolated(cpu)) > > + cpumask_clear_cpu(cpu, hctx->cpumask); > > + } > > What will happen if this code makes hctx->cpumask empty? Code like > blk_mq_first_mapped_cpu() and blk_mq_hctx_next_cpu() assumes that > hctx->cpumask is not empty. There may be other code that assumes that > hctx->cpumask is not empty. hctx->cpumask is only used for selecting next cpu to schedule run queue now, so it is fine for hctx->cpumask to be empty. But the patch has one hole, following the delta fix: diff --git a/block/blk-mq.c b/block/blk-mq.c index 0917f8eabab9..1d9a7ded27af 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -2159,7 +2159,7 @@ static int blk_mq_hctx_next_cpu(struct blk_mq_hw_ctx *hctx) bool tried = false; int next_cpu = hctx->next_cpu; - if (hctx->queue->nr_hw_queues == 1) + if (hctx->queue->nr_hw_queues == 1 || next_cpu >= nr_cpu_ids) return WORK_CPU_UNBOUND; if (--hctx->next_cpu_batch <= 0) { Thanks, Ming