From: Shrikanth Hegde <sshegde@linux.ibm.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: maddy@linux.ibm.com, linuxppc-dev@lists.ozlabs.org,
npiggin@gmail.com, christophe.leroy@csgroup.eu,
mpe@ellerman.id.au, fbarrat@linux.ibm.com, ajd@linux.ibm.com,
mahesh@linux.ibm.com, oohall@gmail.com, hbathini@linux.ibm.com,
dhowells@redhat.com, haren@linux.ibm.com,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 4/6] powerpc: book3s: vas: use lock guard for mutex
Date: Fri, 14 Mar 2025 14:57:13 +0530 [thread overview]
Message-ID: <333198fd-e028-42cb-8847-bd5ddd2a623b@linux.ibm.com> (raw)
In-Reply-To: <20250314082527.GU5880@noisy.programming.kicks-ass.net>
On 3/14/25 13:55, Peter Zijlstra wrote:
> On Fri, Mar 14, 2025 at 11:15:42AM +0530, Shrikanth Hegde wrote:
>> use guard(mutex) for scope based resource management of mutex.
>> This would make the code simpler and easier to maintain.
>>
>> More details on lock guards can be found at
>> https://lore.kernel.org/all/20230612093537.614161713@infradead.org/T/#u
>>
>> There is also an example of using scoped_guard.
>>
>> Signed-off-by: Shrikanth Hegde <sshegde@linux.ibm.com>
>> ---
>> arch/powerpc/platforms/book3s/vas-api.c | 19 ++++++-------------
>> 1 file changed, 6 insertions(+), 13 deletions(-)
>>
>> diff --git a/arch/powerpc/platforms/book3s/vas-api.c b/arch/powerpc/platforms/book3s/vas-api.c
>> index 0b6365d85d11..eb1a97271afb 100644
>> --- a/arch/powerpc/platforms/book3s/vas-api.c
>> +++ b/arch/powerpc/platforms/book3s/vas-api.c
>> @@ -425,7 +425,7 @@ static vm_fault_t vas_mmap_fault(struct vm_fault *vmf)
>> return VM_FAULT_SIGBUS;
>> }
>>
>> - mutex_lock(&txwin->task_ref.mmap_mutex);
>> + guard(mutex)(&txwin->task_ref.mmap_mutex);
>> /*
>> * The window may be inactive due to lost credit (Ex: core
>> * removal with DLPAR). If the window is active again when
>> @@ -437,11 +437,9 @@ static vm_fault_t vas_mmap_fault(struct vm_fault *vmf)
>> if (paste_addr) {
>> fault = vmf_insert_pfn(vma, vma->vm_start,
>> (paste_addr >> PAGE_SHIFT));
>> - mutex_unlock(&txwin->task_ref.mmap_mutex);
>> return fault;
>> }
>> }
>> - mutex_unlock(&txwin->task_ref.mmap_mutex);
>
> I had to open up this file to check, but this seems incorrect since you
> now also run do_fail_paste() with the lock held, where previously you
> did not.
>
Yes. Got it. let me use scoped_guard for it as well. There is get_user
and other things in the fail parse and having it with mutex will not be
good.
I went through the rest of the patches too. It is mostly return after
mutex.
Only in Patch 5/6 there is additional debug statement. Let me put a
comment there.
>
>> /*
>> * Received this fault due to closing the actual window.
next prev parent reply other threads:[~2025-03-14 9:27 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-14 5:45 [PATCH 0/6] powerpc: use lock guards for mutex Set 1 Shrikanth Hegde
2025-03-14 5:45 ` [PATCH 1/6] powerpc: eeh: use lock guard for mutex Shrikanth Hegde
2025-03-14 5:45 ` [PATCH 2/6] powerpc: rtas: " Shrikanth Hegde
2025-03-14 5:45 ` [PATCH 3/6] powerpc: fadump: " Shrikanth Hegde
2025-03-14 8:22 ` Peter Zijlstra
2025-03-14 9:08 ` Shrikanth Hegde
2025-03-14 5:45 ` [PATCH 4/6] powerpc: book3s: vas: " Shrikanth Hegde
2025-03-14 8:25 ` Peter Zijlstra
2025-03-14 9:27 ` Shrikanth Hegde [this message]
2025-03-14 5:45 ` [PATCH 5/6] powerpc: powenv: oxcl: " Shrikanth Hegde
2025-03-14 6:06 ` Andrew Donnellan
2025-03-14 6:57 ` Shrikanth Hegde
2025-03-14 9:30 ` Shrikanth Hegde
2025-03-14 10:33 ` Shrikanth Hegde
2025-03-19 3:59 ` Andrew Donnellan
2025-03-14 5:45 ` [PATCH 6/6] powerpc: sysdev: " Shrikanth Hegde
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=333198fd-e028-42cb-8847-bd5ddd2a623b@linux.ibm.com \
--to=sshegde@linux.ibm.com \
--cc=ajd@linux.ibm.com \
--cc=christophe.leroy@csgroup.eu \
--cc=dhowells@redhat.com \
--cc=fbarrat@linux.ibm.com \
--cc=haren@linux.ibm.com \
--cc=hbathini@linux.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=maddy@linux.ibm.com \
--cc=mahesh@linux.ibm.com \
--cc=mpe@ellerman.id.au \
--cc=npiggin@gmail.com \
--cc=oohall@gmail.com \
--cc=peterz@infradead.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 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.