From: Zhu Yanjun <yanjun.zhu@linux.dev>
To: Eric Dumazet <edumazet@google.com>
Cc: Jacob Moroni <jmoroni@google.com>,
jgg@ziepe.ca, leon@kernel.org, markzhang@nvidia.com,
linux-rdma@vger.kernel.org
Subject: Re: [PATCH] IB/cm: use rwlock for MAD agent lock
Date: Sat, 22 Feb 2025 11:31:45 +0100 [thread overview]
Message-ID: <b7921ac7-574d-461f-9e1d-8c3faff86edc@linux.dev> (raw)
In-Reply-To: <CANn89i+52deipLpK4jPiQmM4kZk6gfhHBOt91j2vXZCd2GG8DA@mail.gmail.com>
在 2025/2/22 8:38, Eric Dumazet 写道:
> On Sat, Feb 22, 2025 at 7:21 AM Zhu Yanjun <yanjun.zhu@linux.dev> wrote:
>>
>> 在 2025/2/21 18:32, Eric Dumazet 写道:
>>> On Fri, Feb 21, 2025 at 6:04 PM Zhu Yanjun <yanjun.zhu@linux.dev> wrote:
>>>>
>>>> On 20.02.25 18:56, Jacob Moroni wrote:
>>>>> In workloads where there are many processes establishing
>>>>> connections using RDMA CM in parallel (large scale MPI),
>>>>> there can be heavy contention for mad_agent_lock in
>>>>> cm_alloc_msg.
>>>>>
>>>>> This contention can occur while inside of a spin_lock_irq
>>>>> region, leading to interrupts being disabled for extended
>>>>> durations on many cores. Furthermore, it leads to the
>>>>> serialization of rdma_create_ah calls, which has negative
>>>>> performance impacts for NICs which are capable of processing
>>>>> multiple address handle creations in parallel.
>>>>
>>>> In the link:
>>>> https://www.cs.columbia.edu/~jae/4118-LAST/L12-interrupt-spinlock.html
>>>> "
>>>> ...
>>>> spin_lock() / spin_unlock()
>>>>
>>>> must not lose CPU while holding a spin lock, other threads will wait for
>>>> the lock for a long time
>>>>
>>>> spin_lock() prevents kernel preemption by ++preempt_count in
>>>> uniprocessor, that’s all spin_lock() does
>>>>
>>>> must NOT call any function that can potentially sleep
>>>> ex) kmalloc, copy_from_user
>>>>
>>>> hardware interrupt is ok unless the interrupt handler may try to lock
>>>> this spin lock
>>>> spin lock not recursive: same thread locking twice will deadlock
>>>>
>>>> keep the critical section as small as possible
>>>> ...
>>>> "
>>>> And from the source code, it seems that spin_lock/spin_unlock are not
>>>> related with interrupts.
>>>>
>>>> I wonder why "leading to interrupts being disabled for extended
>>>> durations on many cores" with spin_lock/spin_unlock?
>>>>
>>>> I am not against this commit. I am just obvious why
>>>> spin_lock/spin_unlock are related with "interrupts being disabled".
>>>
>>> Look at drivers/infiniband/core/cm.c
>>>
>>> spin_lock_irqsave(&cm_id_priv->lock, flags);
>>
>> Thanks a lot. spin_lock_irq should be spin_lock_irqsave?
>
> Both spin_lock_irq and spin_lock_irqsave are masking all interrupts.
Maybe the commit log should be written clearly. Thanks.
Zhu Yanjun
>
>
>
>>
>> Follow the steps of reproducer, I can not reproduce this problem on
>> KVMs. Maybe I need a powerful host.
>>
>> Anyway, read_lock should be a lighter lock than spin_lock.
>>
>> Thanks,
>> Reviewed-by: Zhu Yanjun <yanjun.zhu@linux.dev>
>>
>> Zhu Yanjun
>>
>>>
>>> -> Then call cm_alloc_msg() while hard IRQ are masked.
>>
next prev parent reply other threads:[~2025-02-22 10:31 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-20 17:56 [PATCH] IB/cm: use rwlock for MAD agent lock Jacob Moroni
2025-02-21 16:50 ` Eric Dumazet
2025-02-21 17:00 ` Jason Gunthorpe
2025-02-21 17:03 ` Zhu Yanjun
2025-02-21 17:32 ` Eric Dumazet
2025-02-21 17:39 ` Jacob Moroni
2025-02-22 6:20 ` Zhu Yanjun
2025-02-22 7:38 ` Eric Dumazet
2025-02-22 10:31 ` Zhu Yanjun [this message]
2025-04-01 16:18 ` Jason Gunthorpe
2025-04-07 18:41 ` Jason Gunthorpe
-- strict thread matches above, loose matches on Subject: below --
2025-02-20 17:04 Jacob Moroni
2025-02-20 17:37 ` Eric Dumazet
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=b7921ac7-574d-461f-9e1d-8c3faff86edc@linux.dev \
--to=yanjun.zhu@linux.dev \
--cc=edumazet@google.com \
--cc=jgg@ziepe.ca \
--cc=jmoroni@google.com \
--cc=leon@kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=markzhang@nvidia.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.