Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp5597812rwl; Tue, 4 Apr 2023 00:22:28 -0700 (PDT) X-Google-Smtp-Source: AKy350a2zCFQX2G+9gdsZJJC4KQYtkNni8nuQeas2aRNhxKQ+19y/qLzyjoEJqVcGyj8ARlwWygY X-Received: by 2002:a17:906:9f14:b0:931:2f49:c040 with SMTP id fy20-20020a1709069f1400b009312f49c040mr1568222ejc.51.1680592948698; Tue, 04 Apr 2023 00:22:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680592948; cv=none; d=google.com; s=arc-20160816; b=IbZt4QKBojXgU8BMQHL9ZsRk6f4l56Z38mIXCh1Jz+GZlO3hFLqmHls6GtW/ynVzFt +bj2oNMiyFekkhEvaGwaG4rDzSwL19PXA/Mr/kMbpzff7/+ayPafPKI0e+k2VFKGdAtI 3P3zQBlwgI4kb5sASQ5qTEXzEeOao4JNWu1oME3e/Oa/eREBdcs0uEBSFEwO4xjjFwF8 4ZBiZf1tPtSdx1wyDcgejYM/ZC2wq3AyjTgSAU22kKt4EygZCIXUZ0HrK4Zl0WulQ3pD sIlYW5mKgV6f25CEO9IsItHeG/K6sPu0cwtDeELotiNPOQrRRk+WvWaX0obFUC/bWddj p40w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=hLbeGhYUN7RnG6++2RqONKQkGZVwfn8OaLboDI884hQ=; b=BQmzMCNcY1eYKdleI1pAG+KZx/e/VLW+U2ekC7Iwxv/T+pdILyLyhX09kCO/gFC5iU 7QvbZ3D3dbT74zL9H3QYi4vcpX5UG6dLUlsGgOI8NVVzRAosMabWI9ogrNZlW1jPe+ji 6dLDCT6+esocqEzHWIinpVKBXZhdnCTmwth4GGGn6SfyGNgi6+K3a1i1ENX4OPxNfE+y ZIeUdD23I7mTxG2aN3JtGpN3QJoE/ayd8XdpwHr8Ban1VSY86bu88xtVKAIxNXnbp9Jl OwTMfTol5oaT5B1/YsGGwBDBl1Z4JVdm73VKeu8a0gN47bNRtPRSwJcjfyoF1IAVglBY UKlA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@126.com header.s=s110527 header.b=ZjTO67Ef; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=126.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j16-20020a170906051000b009335b4238c2si5077322eja.433.2023.04.04.00.22.04; Tue, 04 Apr 2023 00:22:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@126.com header.s=s110527 header.b=ZjTO67Ef; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=126.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233625AbjDDHDd (ORCPT + 99 others); Tue, 4 Apr 2023 03:03:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39656 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231767AbjDDHDP (ORCPT ); Tue, 4 Apr 2023 03:03:15 -0400 X-Greylist: delayed 14194 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Tue, 04 Apr 2023 00:03:13 PDT Received: from m126.mail.126.com (m126.mail.126.com [220.181.12.37]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 25F922D72; Tue, 4 Apr 2023 00:03:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=126.com; s=s110527; h=Message-ID:Date:MIME-Version:Subject:From: Content-Type; bh=hLbeGhYUN7RnG6++2RqONKQkGZVwfn8OaLboDI884hQ=; b=ZjTO67EfPOZHIeqnL6m+MPONfHpZAHvRG9KZP6VJqIuAtJ3vi7Ez5DLs+Ly7HK suGBNPgX3xeE0/wMXGeV+I0ywRm1UhD89xE/lgvBn+KFDrGSH7A/GIiDb/J/N/5D rojzmrs8irpchHUbN7oPXure5hos7Pss2Hrg51E1pLZrg= Received: from [172.20.125.11] (unknown [116.128.244.169]) by zwqz-smtp-mta-g0-1 (Coremail) with SMTP id _____wBnX89myytkEaGrAw--.283S2; Tue, 04 Apr 2023 15:01:59 +0800 (CST) Message-ID: <940e1807-7e89-4de0-ee69-9346d231a59f@126.com> Date: Tue, 4 Apr 2023 15:01:58 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.2.2 Subject: Re: [PATCH] RDMA/hfi: add a judgment on the availability of cpumask To: Leon Romanovsky Cc: dennis.dalessandro@cornelisnetworks.com, jgg@ziepe.ca, linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org, Linkui Xiao References: <20230404030525.24020-1-xiaolinkui@126.com> <20230404060522.GH4514@unreal> Content-Language: en-US From: xiaolinkui In-Reply-To: <20230404060522.GH4514@unreal> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-CM-TRANSID: _____wBnX89myytkEaGrAw--.283S2 X-Coremail-Antispam: 1Uf129KBjvJXoW7Gw1fKFW8Wry5CrW8uF1xXwb_yoW8JF4rpF 4fWa1j9ay5Xay0ga1ktay3ArZ8tayfJ3yqyFyqyw18XF98X3ZrX345K3WF9r97Gr4ku3WS qF4DXFs0kF4xAaDanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07j17KsUUUUU= X-Originating-IP: [116.128.244.169] X-CM-SenderInfo: p0ld0z5lqn3xa6rslhhfrp/1tbiig9H1lpEDPhFrQAAsW X-Spam-Status: No, score=-1.5 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,NICE_REPLY_A,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 lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Thanks for your reply. When CONFIG_CPUMASK_OFFSTACK=y, "ret" will be false if diff==NULL. However, when CONFIG_CPUMASK_OFFSTACK=n, these two are not necessarily equivalent. Thanks On 4/4/23 14:05, Leon Romanovsky wrote: > On Tue, Apr 04, 2023 at 11:05:25AM +0800, xiaolinkui wrote: >> From: Linkui Xiao >> >> When CONFIG_CPUMASK_OFFSTACK is n, cpumask may fail to allocate, cpumask may >> be NULL, and performing a bitmap operation on cpumask may cause problems at >> this time. >> >> Of course, this is a unlikely event. >> >> Signed-off-by: Linkui Xiao >> --- >> drivers/infiniband/hw/hfi1/affinity.c | 8 ++++---- >> 1 file changed, 4 insertions(+), 4 deletions(-) >> >> diff --git a/drivers/infiniband/hw/hfi1/affinity.c b/drivers/infiniband/hw/hfi1/affinity.c >> index 77ee77d4000f..3caa861f4d1d 100644 >> --- a/drivers/infiniband/hw/hfi1/affinity.c >> +++ b/drivers/infiniband/hw/hfi1/affinity.c >> @@ -1047,16 +1047,16 @@ int hfi1_get_proc_affinity(int node) >> */ >> >> ret = zalloc_cpumask_var(&diff, GFP_KERNEL); >> - if (!ret) >> + if (!ret || unlikely(!diff)) > Why do you think that check of "ret" is not enough? > "ret" will be false if diff == NULL. > > Thanks