mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Josh Law <hlcj1234567@gmail.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org,
	Josh Law <objecting@objecting.org>
Subject: Re: [PATCH] staging: axis-fifo: minimize lock duration in write
Date: Mon, 9 Mar 2026 17:04:00 +0000	[thread overview]
Message-ID: <f202c101-6b9b-45e4-912d-ea5e9c3dd69c@gmail.com> (raw)
In-Reply-To: <2026030903-although-gratitude-49a6@gregkh>

9 Mar 2026 16:56:37 Greg Kroah-Hartman <gregkh@linuxfoundation.org>:

> On Mon, Mar 09, 2026 at 04:11:25PM +0000, Josh Law wrote:
>> 9 Mar 2026 16:07:50 Greg Kroah-Hartman <gregkh@linuxfoundation.org>:
>>
>>> On Sun, Mar 01, 2026 at 12:58:36AM +0000, Josh Law wrote:
>>>> Memory allocation and copy from user space with vmemdup_user() is relatively slow and can sleep. Move it outside the lock to minimize the time the mutex is held, reducing contention for concurrent accesses.
>>>
>>> Something happened with your line wrapping :(
>>>
>>> And are you sure that your change works?  What is wrong with grabbing
>>> the lock this way?
>>>
>>> thanks,
>>>
>>> greg k-h
>>
>> The issue with grabbing the lock before vmemdup_user() is that the allocation and user-space copy can take a significant amount of time and can sleep.
>
> But what is wrong with that?
>
>> Also, it's just to be more efficient haha, and yes I'm sure this change works, I own the hardware, and it operates better...
>
> Great, please put the performance numbers in the patch, that will show
> the need for this change.
>
> thanks,
>
> greg k-h

Hi Greg,
Fair point. Because mutexes are allowed to sleep, holding it during vmemdup_user() isn't inherently a bug. The issue is that while it sleeps, it blocks other processes from acquiring the lock, which bottlenecks CPU usage times slightly



Perf numbers:

sys before: about 18 seconds
sys after: 14 seconds

V/R

Josh law

      reply	other threads:[~2026-03-09 17:04 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-01  0:58 Josh Law
2026-03-01 18:39 ` Ethan Tidmore
2026-03-09 16:07 ` Greg Kroah-Hartman
2026-03-09 16:11   ` Josh Law
2026-03-09 16:56     ` Greg Kroah-Hartman
2026-03-09 17:04       ` Josh Law [this message]

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=f202c101-6b9b-45e4-912d-ea5e9c3dd69c@gmail.com \
    --to=hlcj1234567@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-staging@lists.linux.dev \
    --cc=objecting@objecting.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®