From patchwork Mon Mar 6 16:06:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vernon Yang X-Patchwork-Id: 660991 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id EFEA3C61DA4 for ; Mon, 6 Mar 2023 16:20:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229817AbjCFQUg (ORCPT ); Mon, 6 Mar 2023 11:20:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45442 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231636AbjCFQT5 (ORCPT ); Mon, 6 Mar 2023 11:19:57 -0500 Received: from mail-qt1-x834.google.com (mail-qt1-x834.google.com [IPv6:2607:f8b0:4864:20::834]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 92DBF3928F; Mon, 6 Mar 2023 08:17:42 -0800 (PST) Received: by mail-qt1-x834.google.com with SMTP id c3so11092033qtc.8; Mon, 06 Mar 2023 08:17:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678119375; 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=IYGyvuAOKnVSJLZ+PGJAH4uPpRYGFdgKO1BedlDVykI=; b=kgi1+iWFbxRLTFxekjD2pI2NKmQgD+RR4bdx2BeL+4I/+FSqc5MHFSucYLuIohUpfa 0345mB2OordJ4yoq9g5ZqU5h5S6HXkLlCJTBmm5KS1MY2jgy5zaC4Kw7q9JK3dAqjt5Y Y9mnpyZ/39xns9YJxuiTnFz5lCiwRFa6gkdGYyKIx21hcLaLytX3yhaFob4UvWdnLyvV HQRc5NdeHtka0/Fw7mDs+/regvI+w/sWpWbOitUTXj18CkacGgUUL8guO/5WYpDVvzFh n0FDNV5EAN51UuNBhea3wLhq3oYrnQHiHevrMTRk9GXoS6JFBtlu21u3GXFxYov7OinU sdtQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678119375; 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=IYGyvuAOKnVSJLZ+PGJAH4uPpRYGFdgKO1BedlDVykI=; b=R1HTbg/r7jGD/VOvLvnmokJ41mWdEitSgVv2m97OPoB8Yt2mbG3QwTjAkNYeUnasvh O0NNY5WUkJ6PavXP4ngGiOMYFGmA6zfVuhh0oZhSsCnJraOha0l2WwaDJjY3hLotR84S g9AsPyD2yoEXoW4pnUJLpPVY3PAIpfjWGoBkCYtPmSICg9RCuYDgv9EyO0z3MmxbLMPP /OihA2MdmOu+bBAHe/uK6pt0p/DVBd2EG/Rw9Q/PpfQ29ss9VqdNsJ+eaUulf8WRNhhE ia2/j1AiGKCAt+pFSxEwKLhPYzwFQu2W3lUsUW+TsWOWuieeAsE8gw2P7/vGgzF15YVS yU/A== X-Gm-Message-State: AO0yUKVYuxUueYcKfZaWp3YUD1W+kA5Du7vzEh6KhJWU7keow2lvrBKK s9CFwDO5yPTz0C7zLpxEMsOFUGLwdHo6V6dC X-Google-Smtp-Source: AK7set9FRJJ4bXIzCpqYTe8FRO5hxEPWPyG4KeJpbdnQ94eOSJ9cEuAei2kEStRQ6ROkgIXiyTXqbg== X-Received: by 2002:a62:7b45:0:b0:5a9:b4eb:d262 with SMTP id w66-20020a627b45000000b005a9b4ebd262mr10996934pfc.1.1678118827070; Mon, 06 Mar 2023 08:07:07 -0800 (PST) Received: from vernon-pc.. ([49.67.2.142]) by smtp.gmail.com with ESMTPSA id u6-20020aa78386000000b005d35695a66csm6465318pfm.137.2023.03.06.08.07.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Mar 2023 08:07:06 -0800 (PST) From: Vernon Yang To: torvalds@linux-foundation.org, tytso@mit.edu, Jason@zx2c4.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, jejb@linux.ibm.com, martin.petersen@oracle.com, yury.norov@gmail.com, andriy.shevchenko@linux.intel.com, linux@rasmusvillemoes.dk, james.smart@broadcom.com, dick.kennedy@broadcom.com Cc: linux-kernel@vger.kernel.org, wireguard@lists.zx2c4.com, netdev@vger.kernel.org, linux-scsi@vger.kernel.org, Vernon Yang Subject: [PATCH 1/5] random: fix try_to_generate_entropy() if no further cpus set Date: Tue, 7 Mar 2023 00:06:47 +0800 Message-Id: <20230306160651.2016767-2-vernon2gm@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230306160651.2016767-1-vernon2gm@gmail.com> References: <20230306160651.2016767-1-vernon2gm@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org After commit 596ff4a09b89 ("cpumask: re-introduce constant-sized cpumask optimizations"), when NR_CPUS <= BITS_PER_LONG, small_cpumask_bits used a macro instead of variable-sized for efficient. If no further cpus set, the cpumask_next() returns small_cpumask_bits, it must greater than or equal to nr_cpumask_bits, so fix it to correctly. Signed-off-by: Vernon Yang --- drivers/char/random.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/char/random.c b/drivers/char/random.c index ce3ccd172cc8..d76f12a5f74f 100644 --- a/drivers/char/random.c +++ b/drivers/char/random.c @@ -1311,7 +1311,7 @@ static void __cold try_to_generate_entropy(void) /* Basic CPU round-robin, which avoids the current CPU. */ do { cpu = cpumask_next(cpu, &timer_cpus); - if (cpu == nr_cpumask_bits) + if (cpu >= nr_cpumask_bits) cpu = cpumask_first(&timer_cpus); } while (cpu == smp_processor_id() && num_cpus > 1); From patchwork Mon Mar 6 16:06:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vernon Yang X-Patchwork-Id: 660992 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C7A04C6FA99 for ; Mon, 6 Mar 2023 16:19:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229732AbjCFQTB (ORCPT ); Mon, 6 Mar 2023 11:19:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47838 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229983AbjCFQSb (ORCPT ); Mon, 6 Mar 2023 11:18:31 -0500 Received: from mail-yw1-x112f.google.com (mail-yw1-x112f.google.com [IPv6:2607:f8b0:4864:20::112f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 403E331E26; Mon, 6 Mar 2023 08:15:44 -0800 (PST) Received: by mail-yw1-x112f.google.com with SMTP id 00721157ae682-536cb25982eso192429647b3.13; Mon, 06 Mar 2023 08:15:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678119264; 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=eWkkRYesFCW1vKhYnmJIj+4iqGRi3O7KEL7awX6yNM8=; b=pmjrtiY7gp20NCr+vKnn4yGu04mC3tZN9zzamVSVVrmNoZg79k94s5yiqQxqiDCLs8 sgEtKrOsdGrbZ+j6+N8SpebLVmMluBNm4Xmiyw1tSsjtZuMqUAqoECEoIpVAlmJBQrvg 1R7oOfN3oPqlD1fI3NyPKKaHKbcCyWscdWUGc/hCdpi1kn3QxQC9P2FqHVrdI4bOpUQo FpM0nBmgGQDB5VWTozNa/GJN6rsM6iC1phCrzxb6vIBy7ZqvmLkv6w3AWdBmeScS/yLk d1p1Ls2w4kt7vL1nYaynzaEGd5IifDxEWKJPPut1GRZYHsyXLsC2WoaoH2j0qPnOXbOV EpPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678119264; 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=eWkkRYesFCW1vKhYnmJIj+4iqGRi3O7KEL7awX6yNM8=; b=A7wuKV8/AdN/+c8CbSSBKGR1Ldz3vaV3FQM2dHXx3BHI1RVEn4FJz/u2pixX2kcr30 v8FY7ZQEsd4sFQGtzXI25clOgRvs37x0s2iisUo861/I0YS88ACZrkxzL9a4jLvLajRd G9AoBA16+UlO+L0w+cAQ44niSr5vsjNX+DerXRWj8oJeWPtgimEBCqdGsl7RtQYBbT6m uqObyRq8zqxH5v1MJuUlAWYrLQutovlV06sD1TkIHW+TsOf2aZMs2ZRNrd2JyPqld+JF h1G7FvqmpND/gIrgaqSCmQeAvOsIRh+rS7mCjzbcK5cpNH8gMuySCwZJMDiwkUxH37Mp eWZw== X-Gm-Message-State: AO0yUKW+Tbxvi8lnnnYEl96h0Cz8Edg0CeEudlVml1NPgK2sJpdO/Rer +Z5runJjfZ0JrBqcTelbddjAV+NfHGYTf3dq X-Google-Smtp-Source: AK7set/jXyku28q+ivaz+ryE2alL97ENe0rhsGlfLmALivyk2C0qphcGmohIX43LtAVrDFFmgh+SZA== X-Received: by 2002:a62:1dd0:0:b0:590:7616:41eb with SMTP id d199-20020a621dd0000000b00590761641ebmr10105161pfd.30.1678118832374; Mon, 06 Mar 2023 08:07:12 -0800 (PST) Received: from vernon-pc.. ([49.67.2.142]) by smtp.gmail.com with ESMTPSA id u6-20020aa78386000000b005d35695a66csm6465318pfm.137.2023.03.06.08.07.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Mar 2023 08:07:12 -0800 (PST) From: Vernon Yang To: torvalds@linux-foundation.org, tytso@mit.edu, Jason@zx2c4.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, jejb@linux.ibm.com, martin.petersen@oracle.com, yury.norov@gmail.com, andriy.shevchenko@linux.intel.com, linux@rasmusvillemoes.dk, james.smart@broadcom.com, dick.kennedy@broadcom.com Cc: linux-kernel@vger.kernel.org, wireguard@lists.zx2c4.com, netdev@vger.kernel.org, linux-scsi@vger.kernel.org, Vernon Yang Subject: [PATCH 2/5] wireguard: fix wg_cpumask_choose_online() if no further cpus set Date: Tue, 7 Mar 2023 00:06:48 +0800 Message-Id: <20230306160651.2016767-3-vernon2gm@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230306160651.2016767-1-vernon2gm@gmail.com> References: <20230306160651.2016767-1-vernon2gm@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org After commit 596ff4a09b89 ("cpumask: re-introduce constant-sized cpumask optimizations"), when NR_CPUS <= BITS_PER_LONG, small_cpumask_bits used a macro instead of variable-sized for efficient. If no further cpus set, the cpumask_next() returns small_cpumask_bits, it must greater than or equal to nr_cpumask_bits, so fix it to correctly. Signed-off-by: Vernon Yang --- drivers/net/wireguard/queueing.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/wireguard/queueing.h b/drivers/net/wireguard/queueing.h index 583adb37ee1e..41adeac3ee0b 100644 --- a/drivers/net/wireguard/queueing.h +++ b/drivers/net/wireguard/queueing.h @@ -106,7 +106,7 @@ static inline int wg_cpumask_choose_online(int *stored_cpu, unsigned int id) { unsigned int cpu = *stored_cpu, cpu_index, i; - if (unlikely(cpu == nr_cpumask_bits || + if (unlikely(cpu >= nr_cpumask_bits || !cpumask_test_cpu(cpu, cpu_online_mask))) { cpu_index = id % cpumask_weight(cpu_online_mask); cpu = cpumask_first(cpu_online_mask); From patchwork Mon Mar 6 16:06:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vernon Yang X-Patchwork-Id: 659671 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A8E74C61DA4 for ; Mon, 6 Mar 2023 16:19:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230189AbjCFQT2 (ORCPT ); Mon, 6 Mar 2023 11:19:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44716 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229812AbjCFQTJ (ORCPT ); Mon, 6 Mar 2023 11:19:09 -0500 Received: from mail-oi1-x232.google.com (mail-oi1-x232.google.com [IPv6:2607:f8b0:4864:20::232]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0E8792CFD0; Mon, 6 Mar 2023 08:16:30 -0800 (PST) Received: by mail-oi1-x232.google.com with SMTP id e21so7464901oie.1; Mon, 06 Mar 2023 08:16:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678119321; 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=0XbTdGx8oMSPf4HhkoZWFz5gkpw9U1/T7K2pkx4Uby0=; b=fxiIFrRAiYwXMWVwLl0J/TnSrG/3gWirNRX//9xrxQirrRzkifylGupfFSquPy2NX/ cjsso/QxXb15E/BA/+oXrKU0cXo0+QwGBsczSi4mxQy/RiVQFwIMTkr8i+ouxB1Gl0vw J6tzlBo8rTml7rGXfhsI79Fxvyzw7DDG5ZTX1Wb2G+6X2AzTy6687ai8AMhSmVmuleiL r1hHDkGpKqRJprzblWRpdCU3OpEO7H1hVcsldtpkH4JNfo5w1SvK2kyFPl3QXFVST7Oz kjTbHaIGaJXWufEtD3f5WvUpBN7hPIGRZ7Q2ehVbGHrfPrmN2q91JJELNReZbv3l4XUN bO6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678119321; 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=0XbTdGx8oMSPf4HhkoZWFz5gkpw9U1/T7K2pkx4Uby0=; b=fERl1uf/nh/gqj0xSf5muVxUQ5n+8ki5gEBYxZ9HOu2NADrQwT2fMmRQxUMZwHInRo 8RUMHEWFFT1QYuUHfC/Cfr7AguR12pfLG2PA4eCa6qPiN8KTMwA2Vj1MUWXRqQaC67I5 ugCRdmvA+N6qY287BXnj+5FTy8zmoekUAj85R4pMemPtH/hyfmsFTeDb44/yVNR2Zu0H UewVvDh9KmkJ5GaX3CZIhyR1qPssPb3vcPS1Y4FC+D9ydI7amhNu+4xcnnzRlEME2PlA u4kWiNb2t4M39nXjRNEcUkMU7VgkWycQzTtc2yCpSqUsvS08qdLqcuoCP2+6+RhXKEz1 OL4w== X-Gm-Message-State: AO0yUKWT+DcxARGV28vLRb9XN/FJ5QcT6d99wlI1K8+DO8sd384wwRbp FbbWZkj0+YCZkmzUZXcW6UtIHTEqF+ryFyjO X-Google-Smtp-Source: AK7set+tQVdHJh4e+PqliYudDb3ddl76u0In93Ak366TBVp36ZG0/TpUrXOnnQYXS7peWeuLObbsvQ== X-Received: by 2002:a05:6a00:2d28:b0:5a8:4ae7:25d5 with SMTP id fa40-20020a056a002d2800b005a84ae725d5mr17256165pfb.8.1678118837403; Mon, 06 Mar 2023 08:07:17 -0800 (PST) Received: from vernon-pc.. ([49.67.2.142]) by smtp.gmail.com with ESMTPSA id u6-20020aa78386000000b005d35695a66csm6465318pfm.137.2023.03.06.08.07.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Mar 2023 08:07:17 -0800 (PST) From: Vernon Yang To: torvalds@linux-foundation.org, tytso@mit.edu, Jason@zx2c4.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, jejb@linux.ibm.com, martin.petersen@oracle.com, yury.norov@gmail.com, andriy.shevchenko@linux.intel.com, linux@rasmusvillemoes.dk, james.smart@broadcom.com, dick.kennedy@broadcom.com Cc: linux-kernel@vger.kernel.org, wireguard@lists.zx2c4.com, netdev@vger.kernel.org, linux-scsi@vger.kernel.org, Vernon Yang Subject: [PATCH 3/5] scsi: lpfc: fix lpfc_cpu_affinity_check() if no further cpus set Date: Tue, 7 Mar 2023 00:06:49 +0800 Message-Id: <20230306160651.2016767-4-vernon2gm@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230306160651.2016767-1-vernon2gm@gmail.com> References: <20230306160651.2016767-1-vernon2gm@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org After commit 596ff4a09b89 ("cpumask: re-introduce constant-sized cpumask optimizations"), when NR_CPUS <= BITS_PER_LONG, small_cpumask_bits used a macro instead of variable-sized for efficient. If no further cpus set, the cpumask_next() returns small_cpumask_bits, it must greater than or equal to nr_cpumask_bits, so fix it to correctly. Signed-off-by: Vernon Yang --- drivers/scsi/lpfc/lpfc_init.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c index 61958a24a43d..01c0e2f47cf7 100644 --- a/drivers/scsi/lpfc/lpfc_init.c +++ b/drivers/scsi/lpfc/lpfc_init.c @@ -12563,7 +12563,7 @@ lpfc_cpu_affinity_check(struct lpfc_hba *phba, int vectors) goto found_same; new_cpu = cpumask_next( new_cpu, cpu_present_mask); - if (new_cpu == nr_cpumask_bits) + if (new_cpu >= nr_cpumask_bits) new_cpu = first_cpu; } /* At this point, we leave the CPU as unassigned */ @@ -12577,7 +12577,7 @@ lpfc_cpu_affinity_check(struct lpfc_hba *phba, int vectors) * selecting the same IRQ. */ start_cpu = cpumask_next(new_cpu, cpu_present_mask); - if (start_cpu == nr_cpumask_bits) + if (start_cpu >= nr_cpumask_bits) start_cpu = first_cpu; lpfc_printf_log(phba, KERN_INFO, LOG_INIT, @@ -12613,7 +12613,7 @@ lpfc_cpu_affinity_check(struct lpfc_hba *phba, int vectors) goto found_any; new_cpu = cpumask_next( new_cpu, cpu_present_mask); - if (new_cpu == nr_cpumask_bits) + if (new_cpu >= nr_cpumask_bits) new_cpu = first_cpu; } /* We should never leave an entry unassigned */ @@ -12631,7 +12631,7 @@ lpfc_cpu_affinity_check(struct lpfc_hba *phba, int vectors) * selecting the same IRQ. */ start_cpu = cpumask_next(new_cpu, cpu_present_mask); - if (start_cpu == nr_cpumask_bits) + if (start_cpu >= nr_cpumask_bits) start_cpu = first_cpu; lpfc_printf_log(phba, KERN_INFO, LOG_INIT, @@ -12704,7 +12704,7 @@ lpfc_cpu_affinity_check(struct lpfc_hba *phba, int vectors) goto found_hdwq; } new_cpu = cpumask_next(new_cpu, cpu_present_mask); - if (new_cpu == nr_cpumask_bits) + if (new_cpu >= nr_cpumask_bits) new_cpu = first_cpu; } @@ -12719,7 +12719,7 @@ lpfc_cpu_affinity_check(struct lpfc_hba *phba, int vectors) goto found_hdwq; new_cpu = cpumask_next(new_cpu, cpu_present_mask); - if (new_cpu == nr_cpumask_bits) + if (new_cpu >= nr_cpumask_bits) new_cpu = first_cpu; } @@ -12730,7 +12730,7 @@ lpfc_cpu_affinity_check(struct lpfc_hba *phba, int vectors) found_hdwq: /* We found an available entry, copy the IRQ info */ start_cpu = cpumask_next(new_cpu, cpu_present_mask); - if (start_cpu == nr_cpumask_bits) + if (start_cpu >= nr_cpumask_bits) start_cpu = first_cpu; cpup->hdwq = new_cpup->hdwq; logit: From patchwork Mon Mar 6 16:06:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vernon Yang X-Patchwork-Id: 660994 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9E0C5C61DA4 for ; Mon, 6 Mar 2023 16:12:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230445AbjCFQMO (ORCPT ); Mon, 6 Mar 2023 11:12:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56048 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232802AbjCFQMA (ORCPT ); Mon, 6 Mar 2023 11:12:00 -0500 Received: from mail-pj1-x102b.google.com (mail-pj1-x102b.google.com [IPv6:2607:f8b0:4864:20::102b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3B20951F88; Mon, 6 Mar 2023 08:08:40 -0800 (PST) Received: by mail-pj1-x102b.google.com with SMTP id p3-20020a17090ad30300b0023a1cd5065fso9279474pju.0; Mon, 06 Mar 2023 08:08:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678118843; 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=5DGQdrsotz8W8EizOYEyX2DBff0cLsAl7IvbnLHf+bg=; b=nXoibcR7ByMCQICFh5RhNYtLXdctMhTA+mzKcFRnYoLe927/eL+h0tzDLTd0dnKoT0 Z3z05jUPKUt4emgJ2q/iGj/eZsyitdS6TXa8ihVDkWpV5/onJknq0FNf2pphCFSu+Hui bfptA7x0gTIXK959Q7/8biA0Vay9WSDh5KGaN/pBGNJ4AwT+lqKhbtwJOumDaShaudGH eK3XnWbpdhfZ94ConuZv+3ifSNIUkwJtJW+K4hV2030YfNY2qXypG3VI4bApQIEQmMeI +blufCszN17pGg/ZQbNZPcgOJn42gOhr8krF48cXhsPkmWGitk3GARXgsrXa8ghyVQzo cI4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678118843; 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=5DGQdrsotz8W8EizOYEyX2DBff0cLsAl7IvbnLHf+bg=; b=KvaCHzqGpFrm+i+msy9s54lfypKKNNDFtdTXb+rc9ijlrGQpyP8yONbZIV8OT8gmMD 13SMoBHCtharMQoiEFQOqrM2ja/n9YE58HVi4GEtTcrYhlPLV/nH9qrAK9TycczSVgmk QP4FG7Rl5XOK/8C/PaKXh7qCLmBJN0CSJVhss+n1ncDInOCArcm9owHcObu31uXOiqRO /0ILE934odIlKJxo7lbxN3XGij4CvwCMBpMj+E+OfNmE08hm9szs4VEfh9SVb23b4juI cUPAnDGYxZtV+aftrE5TcO8cG9MGEU9y+aQY1MEteaitcBHfh9z71Knugi67D/3OlzUD w8Vw== X-Gm-Message-State: AO0yUKVck0KpqH8AOnDeCs5/fGc08skr+FWSIF3LPhARx2DtGiqQLm2S tt9gj0klaDroMRBbmYoLKHA= X-Google-Smtp-Source: AK7set/tMWsOQQEdPjLWbhhz2SNcZHDm9AMA47AGQ9t0MP6KYTtdnCDlPd0/4DIKsgVEc6b4smPKLA== X-Received: by 2002:a05:6a20:a10b:b0:c7:1da3:e3a with SMTP id q11-20020a056a20a10b00b000c71da30e3amr13357543pzk.16.1678118842755; Mon, 06 Mar 2023 08:07:22 -0800 (PST) Received: from vernon-pc.. ([49.67.2.142]) by smtp.gmail.com with ESMTPSA id u6-20020aa78386000000b005d35695a66csm6465318pfm.137.2023.03.06.08.07.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Mar 2023 08:07:22 -0800 (PST) From: Vernon Yang To: torvalds@linux-foundation.org, tytso@mit.edu, Jason@zx2c4.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, jejb@linux.ibm.com, martin.petersen@oracle.com, yury.norov@gmail.com, andriy.shevchenko@linux.intel.com, linux@rasmusvillemoes.dk, james.smart@broadcom.com, dick.kennedy@broadcom.com Cc: linux-kernel@vger.kernel.org, wireguard@lists.zx2c4.com, netdev@vger.kernel.org, linux-scsi@vger.kernel.org, Vernon Yang Subject: [PATCH 4/5] scsi: lpfc: fix lpfc_nvmet_setup_io_context() if no further cpus set Date: Tue, 7 Mar 2023 00:06:50 +0800 Message-Id: <20230306160651.2016767-5-vernon2gm@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230306160651.2016767-1-vernon2gm@gmail.com> References: <20230306160651.2016767-1-vernon2gm@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org After commit 596ff4a09b89 ("cpumask: re-introduce constant-sized cpumask optimizations"), when NR_CPUS <= BITS_PER_LONG, small_cpumask_bits used a macro instead of variable-sized for efficient. If no further cpus set, the cpumask_next() returns small_cpumask_bits, it must greater than or equal to nr_cpumask_bits, so fix it to correctly. Signed-off-by: Vernon Yang --- drivers/scsi/lpfc/lpfc_nvmet.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/scsi/lpfc/lpfc_nvmet.c b/drivers/scsi/lpfc/lpfc_nvmet.c index 7517dd55fe91..3ae7f330f827 100644 --- a/drivers/scsi/lpfc/lpfc_nvmet.c +++ b/drivers/scsi/lpfc/lpfc_nvmet.c @@ -1621,7 +1621,7 @@ lpfc_nvmet_setup_io_context(struct lpfc_hba *phba) continue; } cpu = cpumask_next(cpu, cpu_present_mask); - if (cpu == nr_cpu_ids) + if (cpu >= nr_cpu_ids) cpu = cpumask_first(cpu_present_mask); } From patchwork Mon Mar 6 16:06:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vernon Yang X-Patchwork-Id: 659672 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B586CC64EC4 for ; Mon, 6 Mar 2023 16:12:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231245AbjCFQMc (ORCPT ); Mon, 6 Mar 2023 11:12:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56394 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232834AbjCFQMD (ORCPT ); Mon, 6 Mar 2023 11:12:03 -0500 Received: from mail-pl1-x62f.google.com (mail-pl1-x62f.google.com [IPv6:2607:f8b0:4864:20::62f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3F0B838B79; Mon, 6 Mar 2023 08:08:48 -0800 (PST) Received: by mail-pl1-x62f.google.com with SMTP id x11so6381112pln.12; Mon, 06 Mar 2023 08:08:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678118849; 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=FM1lIxzBxTQV7ok7VPz6lBRdsK456pDusIxuwYzkcv4=; b=E9qG/kRFTkvrs9snccj1cvb86saeOam5VaFR6MawtDhga1BKhqKQ9EYqTiLWp7M9GG BJUTmmhg9V3ahDIsVF7a3ZXfmkSmavFjiU0VPmbbKuBumFvxyed63ApWypWQj9b/wvhw ylamvdLwRR9+2n67Uz07H+iOa4ekqfebY430MWCOkNM5jkwPeqXadrIfvCfc57nt7sUN xPMoTVL3mw2tPz39tJug0hGe0PSP1gxQ+TUcb9mRAs1QDoqbbKj5bo9YlZKGkTYW/31C BQcxwYWIIK/HfUofAnPgNdbPdR8s71DBeezW+a84EZdVqBP6XUBp4nBga7JZefZLJF0T EWGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678118849; 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=FM1lIxzBxTQV7ok7VPz6lBRdsK456pDusIxuwYzkcv4=; b=s/KONnNCljW+9UwP0NLkiTlqd3H0eAyFUtGR8njBoJjKxYm1lmuXmnNVmyRP4kwDvC LtReeGSMZiLTl9CGEs5RhFA4zaJeAJBhq1FY5H2QELtE9x3zA2LzwBgpF6k0zl5KyNkO vSP23UACKbHHEsaYfk9LX1b8+WNpSOrNvl8sontCYkScMFiThQ+Yk7+vtN4lTxURzdQZ 3mLJfqwDSYf7DCbWDnlXKCUYXecgUJHshdNuOYuQVQG+XMp4uaO+JOATx/fEwIudQPbQ RsGhWOb1s5ZUsUJkM94hQTxKL9upW46HHfEtksN+rkVxlv/YgIfER/7mgONcP5bB7oHW F0Dw== X-Gm-Message-State: AO0yUKX5KVHVzp9a7NFMm0L/mJ/gIvM/7cQ/Oy6aIQ13RzSZZrLnk32w o8HZpxedvnhnhEJHWxLUlSc= X-Google-Smtp-Source: AK7set+PZV6WMzfRWk4Gf3xHJ7wl7d9AHTIm8PuQMxtywxGOBbDomTl5Vex4hvxj2mK8Qmx4Faud8w== X-Received: by 2002:a05:6a20:6a1c:b0:c7:61cc:11d4 with SMTP id p28-20020a056a206a1c00b000c761cc11d4mr13799160pzk.44.1678118847959; Mon, 06 Mar 2023 08:07:27 -0800 (PST) Received: from vernon-pc.. ([49.67.2.142]) by smtp.gmail.com with ESMTPSA id u6-20020aa78386000000b005d35695a66csm6465318pfm.137.2023.03.06.08.07.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Mar 2023 08:07:27 -0800 (PST) From: Vernon Yang To: torvalds@linux-foundation.org, tytso@mit.edu, Jason@zx2c4.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, jejb@linux.ibm.com, martin.petersen@oracle.com, yury.norov@gmail.com, andriy.shevchenko@linux.intel.com, linux@rasmusvillemoes.dk, james.smart@broadcom.com, dick.kennedy@broadcom.com Cc: linux-kernel@vger.kernel.org, wireguard@lists.zx2c4.com, netdev@vger.kernel.org, linux-scsi@vger.kernel.org, Vernon Yang Subject: [PATCH 5/5] cpumask: fix comment of cpumask_xxx Date: Tue, 7 Mar 2023 00:06:51 +0800 Message-Id: <20230306160651.2016767-6-vernon2gm@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230306160651.2016767-1-vernon2gm@gmail.com> References: <20230306160651.2016767-1-vernon2gm@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org After commit 596ff4a09b89 ("cpumask: re-introduce constant-sized cpumask optimizations"), the cpumask size is divided into three different case, so fix comment of cpumask_xxx correctly. Signed-off-by: Vernon Yang --- include/linux/cpumask.h | 46 ++++++++++++++++++++--------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h index 8fbe76607965..248bdb1c50dc 100644 --- a/include/linux/cpumask.h +++ b/include/linux/cpumask.h @@ -155,7 +155,7 @@ static __always_inline unsigned int cpumask_check(unsigned int cpu) * cpumask_first - get the first cpu in a cpumask * @srcp: the cpumask pointer * - * Returns >= nr_cpu_ids if no cpus set. + * Returns >= small_cpumask_bits if no cpus set. */ static inline unsigned int cpumask_first(const struct cpumask *srcp) { @@ -166,7 +166,7 @@ static inline unsigned int cpumask_first(const struct cpumask *srcp) * cpumask_first_zero - get the first unset cpu in a cpumask * @srcp: the cpumask pointer * - * Returns >= nr_cpu_ids if all cpus are set. + * Returns >= small_cpumask_bits if all cpus are set. */ static inline unsigned int cpumask_first_zero(const struct cpumask *srcp) { @@ -178,7 +178,7 @@ static inline unsigned int cpumask_first_zero(const struct cpumask *srcp) * @src1p: the first input * @src2p: the second input * - * Returns >= nr_cpu_ids if no cpus set in both. See also cpumask_next_and(). + * Returns >= small_cpumask_bits if no cpus set in both. See also cpumask_next_and(). */ static inline unsigned int cpumask_first_and(const struct cpumask *srcp1, const struct cpumask *srcp2) @@ -190,7 +190,7 @@ unsigned int cpumask_first_and(const struct cpumask *srcp1, const struct cpumask * cpumask_last - get the last CPU in a cpumask * @srcp: - the cpumask pointer * - * Returns >= nr_cpumask_bits if no CPUs set. + * Returns >= small_cpumask_bits if no CPUs set. */ static inline unsigned int cpumask_last(const struct cpumask *srcp) { @@ -202,7 +202,7 @@ static inline unsigned int cpumask_last(const struct cpumask *srcp) * @n: the cpu prior to the place to search (ie. return will be > @n) * @srcp: the cpumask pointer * - * Returns >= nr_cpu_ids if no further cpus set. + * Returns >= small_cpumask_bits if no further cpus set. */ static inline unsigned int cpumask_next(int n, const struct cpumask *srcp) @@ -218,7 +218,7 @@ unsigned int cpumask_next(int n, const struct cpumask *srcp) * @n: the cpu prior to the place to search (ie. return will be > @n) * @srcp: the cpumask pointer * - * Returns >= nr_cpu_ids if no further cpus unset. + * Returns >= small_cpumask_bits if no further cpus unset. */ static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp) { @@ -258,7 +258,7 @@ unsigned int cpumask_any_distribute(const struct cpumask *srcp); * @src1p: the first cpumask pointer * @src2p: the second cpumask pointer * - * Returns >= nr_cpu_ids if no further cpus set in both. + * Returns >= small_cpumask_bits if no further cpus set in both. */ static inline unsigned int cpumask_next_and(int n, const struct cpumask *src1p, @@ -276,7 +276,7 @@ unsigned int cpumask_next_and(int n, const struct cpumask *src1p, * @cpu: the (optionally unsigned) integer iterator * @mask: the cpumask pointer * - * After the loop, cpu is >= nr_cpu_ids. + * After the loop, cpu is >= small_cpumask_bits. */ #define for_each_cpu(cpu, mask) \ for_each_set_bit(cpu, cpumask_bits(mask), small_cpumask_bits) @@ -310,7 +310,7 @@ unsigned int __pure cpumask_next_wrap(int n, const struct cpumask *mask, int sta * * The implementation does not assume any bit in @mask is set (including @start). * - * After the loop, cpu is >= nr_cpu_ids. + * After the loop, cpu is >= small_cpumask_bits. */ #define for_each_cpu_wrap(cpu, mask, start) \ for_each_set_bit_wrap(cpu, cpumask_bits(mask), small_cpumask_bits, start) @@ -327,7 +327,7 @@ unsigned int __pure cpumask_next_wrap(int n, const struct cpumask *mask, int sta * for_each_cpu(cpu, &tmp) * ... * - * After the loop, cpu is >= nr_cpu_ids. + * After the loop, cpu is >= small_cpumask_bits. */ #define for_each_cpu_and(cpu, mask1, mask2) \ for_each_and_bit(cpu, cpumask_bits(mask1), cpumask_bits(mask2), small_cpumask_bits) @@ -345,7 +345,7 @@ unsigned int __pure cpumask_next_wrap(int n, const struct cpumask *mask, int sta * for_each_cpu(cpu, &tmp) * ... * - * After the loop, cpu is >= nr_cpu_ids. + * After the loop, cpu is >= small_cpumask_bits. */ #define for_each_cpu_andnot(cpu, mask1, mask2) \ for_each_andnot_bit(cpu, cpumask_bits(mask1), cpumask_bits(mask2), small_cpumask_bits) @@ -375,7 +375,7 @@ unsigned int cpumask_any_but(const struct cpumask *mask, unsigned int cpu) * @srcp: the cpumask pointer * @cpu: the N'th cpu to find, starting from 0 * - * Returns >= nr_cpu_ids if such cpu doesn't exist. + * Returns >= small_cpumask_bits if such cpu doesn't exist. */ static inline unsigned int cpumask_nth(unsigned int cpu, const struct cpumask *srcp) { @@ -388,7 +388,7 @@ static inline unsigned int cpumask_nth(unsigned int cpu, const struct cpumask *s * @srcp2: the cpumask pointer * @cpu: the N'th cpu to find, starting from 0 * - * Returns >= nr_cpu_ids if such cpu doesn't exist. + * Returns >= small_cpumask_bits if such cpu doesn't exist. */ static inline unsigned int cpumask_nth_and(unsigned int cpu, const struct cpumask *srcp1, @@ -404,7 +404,7 @@ unsigned int cpumask_nth_and(unsigned int cpu, const struct cpumask *srcp1, * @srcp2: the cpumask pointer * @cpu: the N'th cpu to find, starting from 0 * - * Returns >= nr_cpu_ids if such cpu doesn't exist. + * Returns >= small_cpumask_bits if such cpu doesn't exist. */ static inline unsigned int cpumask_nth_andnot(unsigned int cpu, const struct cpumask *srcp1, @@ -421,7 +421,7 @@ unsigned int cpumask_nth_andnot(unsigned int cpu, const struct cpumask *srcp1, * @srcp3: the cpumask pointer * @cpu: the N'th cpu to find, starting from 0 * - * Returns >= nr_cpu_ids if such cpu doesn't exist. + * Returns >= small_cpumask_bits if such cpu doesn't exist. */ static __always_inline unsigned int cpumask_nth_and_andnot(unsigned int cpu, const struct cpumask *srcp1, @@ -529,7 +529,7 @@ static inline void cpumask_setall(struct cpumask *dstp) } /** - * cpumask_clear - clear all cpus (< nr_cpu_ids) in a cpumask + * cpumask_clear - clear all cpus (< large_cpumask_bits) in a cpumask * @dstp: the cpumask pointer */ static inline void cpumask_clear(struct cpumask *dstp) @@ -650,7 +650,7 @@ static inline bool cpumask_subset(const struct cpumask *src1p, /** * cpumask_empty - *srcp == 0 - * @srcp: the cpumask to that all cpus < nr_cpu_ids are clear. + * @srcp: the cpumask to that all cpus < small_cpumask_bits are clear. */ static inline bool cpumask_empty(const struct cpumask *srcp) { @@ -659,7 +659,7 @@ static inline bool cpumask_empty(const struct cpumask *srcp) /** * cpumask_full - *srcp == 0xFFFFFFFF... - * @srcp: the cpumask to that all cpus < nr_cpu_ids are set. + * @srcp: the cpumask to that all cpus < nr_cpumask_bits are set. */ static inline bool cpumask_full(const struct cpumask *srcp) { @@ -668,7 +668,7 @@ static inline bool cpumask_full(const struct cpumask *srcp) /** * cpumask_weight - Count of bits in *srcp - * @srcp: the cpumask to count bits (< nr_cpu_ids) in. + * @srcp: the cpumask to count bits (< small_cpumask_bits) in. */ static inline unsigned int cpumask_weight(const struct cpumask *srcp) { @@ -677,8 +677,8 @@ static inline unsigned int cpumask_weight(const struct cpumask *srcp) /** * cpumask_weight_and - Count of bits in (*srcp1 & *srcp2) - * @srcp1: the cpumask to count bits (< nr_cpu_ids) in. - * @srcp2: the cpumask to count bits (< nr_cpu_ids) in. + * @srcp1: the cpumask to count bits (< small_cpumask_bits) in. + * @srcp2: the cpumask to count bits (< small_cpumask_bits) in. */ static inline unsigned int cpumask_weight_and(const struct cpumask *srcp1, const struct cpumask *srcp2) @@ -727,7 +727,7 @@ static inline void cpumask_copy(struct cpumask *dstp, * cpumask_any - pick a "random" cpu from *srcp * @srcp: the input cpumask * - * Returns >= nr_cpu_ids if no cpus set. + * Returns >= small_cpumask_bits if no cpus set. */ #define cpumask_any(srcp) cpumask_first(srcp) @@ -736,7 +736,7 @@ static inline void cpumask_copy(struct cpumask *dstp, * @mask1: the first input cpumask * @mask2: the second input cpumask * - * Returns >= nr_cpu_ids if no cpus set. + * Returns >= small_cpumask_bits if no cpus set. */ #define cpumask_any_and(mask1, mask2) cpumask_first_and((mask1), (mask2))