All of lore.kernel.org
 help / color / mirror / Atom feed
From: Guangguan Wang <guangguan.wang@linux.alibaba.com>
To: Paolo Abeni <pabeni@redhat.com>,
	Zhengchao Shao <shaozhengchao@huawei.com>
Cc: wenjia@linux.ibm.com, jaka@linux.ibm.com,
	alibuda@linux.alibaba.com, tonylu@linux.alibaba.com,
	guwen@linux.alibaba.com, weiyongjun1@huawei.com,
	yuehaibing@huawei.com, tangchengchang@huawei.com,
	kuba@kernel.org, edumazet@google.com, davem@davemloft.net,
	netdev@vger.kernel.org, linux-s390@vger.kernel.org
Subject: Re: [PATCH net] net/smc: fix potential sleeping issue in smc_switch_conns
Date: Wed, 17 Apr 2024 15:32:05 +0800	[thread overview]
Message-ID: <a94de96f-8b18-482c-90e2-7f8584528bc8@linux.alibaba.com> (raw)
In-Reply-To: <b2573ccf2340a19b6cb039dac639b2d431c1404c.camel@redhat.com>



On 2024/4/16 20:06, Paolo Abeni wrote:
> On Sat, 2024-04-13 at 11:51 +0800, Zhengchao Shao wrote:
>> Potential sleeping issue exists in the following processes:
>> smc_switch_conns
>>   spin_lock_bh(&conn->send_lock)
>>   smc_switch_link_and_count
>>     smcr_link_put
>>       __smcr_link_clear
>>         smc_lgr_put
>>           __smc_lgr_free
>>             smc_lgr_free_bufs
>>               __smc_lgr_free_bufs
>>                 smc_buf_free
>>                   smcr_buf_free
>>                     smcr_buf_unmap_link
>>                       smc_ib_put_memory_region
>>                         ib_dereg_mr
>>                           ib_dereg_mr_user
>>                             mr->device->ops.dereg_mr
>> If scheduling exists when the IB driver implements .dereg_mr hook
>> function, the bug "scheduling while atomic" will occur. For example,
>> cxgb4 and efa driver. Use mutex lock instead of spin lock to fix it.
> 
> I tried to inspect all the lock call sites, and it *look* like they are
> all in process context, so the switch should be feasible.

There exist some calls from tasklet, where mutex lock is infeasible.
For example:
- tasklet -> smc_wr_tx_tasklet_fn -> smc_wr_tx_process_cqe -> pnd_snd.handler -> smc_cdc_tx_handler -> smc_tx_pending -> smc_tx_sndbuf_nonempty -> smcr_tx_sndbuf_nonempty -> spin_lock_bh(&conn->send_lock)
- tasklet -> smc_wr_rx_tasklet_fn -> smc_wr_rx_process_cqes -> smc_wr_rx_demultiplex -> smc_cdc_rx_handler -> smc_cdc_msg_validate -> spin_lock_bh(&conn->send_lock)

Thanks,
Guangguan Wang

> 
> Still the fact that the existing lock is a BH variant is suspect.
> Either the BH part was not needed or this can introduce subtle
> regressions/issues. 
> 
> I think this deserves at least a 3rd party testing.
> 
> Thanks,
> 
> Paolo
> 

  reply	other threads:[~2024-04-17  7:32 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-13  3:51 [PATCH net] net/smc: fix potential sleeping issue in smc_switch_conns Zhengchao Shao
2024-04-15 17:37 ` Wenjia Zhang
2024-04-16 12:06 ` Paolo Abeni
2024-04-17  7:32   ` Guangguan Wang [this message]
2024-04-17 15:17     ` Wenjia Zhang
2024-04-17  8:00 ` Guangguan Wang
2024-04-17  8:29   ` shaozhengchao
2024-04-17 15:23     ` Wenjia Zhang
2024-04-18  1:48       ` shaozhengchao
2024-04-18  7:50         ` Wenjia Zhang
2024-04-18 11:01           ` shaozhengchao
2024-04-18 11:57             ` Wenjia Zhang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a94de96f-8b18-482c-90e2-7f8584528bc8@linux.alibaba.com \
    --to=guangguan.wang@linux.alibaba.com \
    --cc=alibuda@linux.alibaba.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=guwen@linux.alibaba.com \
    --cc=jaka@linux.ibm.com \
    --cc=kuba@kernel.org \
    --cc=linux-s390@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=shaozhengchao@huawei.com \
    --cc=tangchengchang@huawei.com \
    --cc=tonylu@linux.alibaba.com \
    --cc=weiyongjun1@huawei.com \
    --cc=wenjia@linux.ibm.com \
    --cc=yuehaibing@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.