* [PATCH v2 5/5] mm/hugetlb: avoid calculating fault_mutex_hash in truncate_op case
@ 2021-03-16 2:27 Miaohe Lin
2021-03-16 3:07 ` Mike Kravetz
0 siblings, 1 reply; 5+ messages in thread
From: Miaohe Lin @ 2021-03-16 2:27 UTC (permalink / raw)
To: akpm, mike.kravetz; +Cc: linux-kernel, linux-mm, linmiaohe
The fault_mutex hashing overhead can be avoided in truncate_op case
because page faults can not race with truncation in this routine. So
calculate hash for fault_mutex only in !truncate_op case to save some cpu
cycles.
Reviewed-by: Mike Kravetz <mike.kravetz@oracle.com>
Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
Cc: Mike Kravetz <mike.kravetz@oracle.com>
---
v1->v2:
remove unnecessary initialization for variable hash
collect Reviewed-by tag from Mike Kravetz
---
fs/hugetlbfs/inode.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
index c262566f7c5d..f7ec94bc7337 100644
--- a/fs/hugetlbfs/inode.c
+++ b/fs/hugetlbfs/inode.c
@@ -485,7 +485,6 @@ static void remove_inode_hugepages(struct inode *inode, loff_t lstart,
u32 hash;
index = page->index;
- hash = hugetlb_fault_mutex_hash(mapping, index);
if (!truncate_op) {
/*
* Only need to hold the fault mutex in the
@@ -493,6 +492,7 @@ static void remove_inode_hugepages(struct inode *inode, loff_t lstart,
* page faults. Races are not possible in the
* case of truncation.
*/
+ hash = hugetlb_fault_mutex_hash(mapping, index);
mutex_lock(&hugetlb_fault_mutex_table[hash]);
}
--
2.19.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v2 5/5] mm/hugetlb: avoid calculating fault_mutex_hash in truncate_op case
2021-03-16 2:27 [PATCH v2 5/5] mm/hugetlb: avoid calculating fault_mutex_hash in truncate_op case Miaohe Lin
@ 2021-03-16 3:07 ` Mike Kravetz
2021-03-16 6:49 ` Miaohe Lin
0 siblings, 1 reply; 5+ messages in thread
From: Mike Kravetz @ 2021-03-16 3:07 UTC (permalink / raw)
To: Miaohe Lin, akpm; +Cc: linux-kernel, linux-mm
On 3/15/21 7:27 PM, Miaohe Lin wrote:
> The fault_mutex hashing overhead can be avoided in truncate_op case
> because page faults can not race with truncation in this routine. So
> calculate hash for fault_mutex only in !truncate_op case to save some cpu
> cycles.
>
> Reviewed-by: Mike Kravetz <mike.kravetz@oracle.com>
> Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
> Cc: Mike Kravetz <mike.kravetz@oracle.com>
> ---
> v1->v2:
> remove unnecessary initialization for variable hash
> collect Reviewed-by tag from Mike Kravetz
My apologies for not replying sooner and any misunderstanding from my
previous comments.
If the compiler is going to produce a warning because the variable is
not initialized, then we will need to keep the initialization.
Otherwise, this will show up as a build regression. Ideally, there
would be a modifier which could be used to tell the compiler the
variable will used. I do not know if such a modifier exists.
The patch can not produce a new warning. So, if you need to initialize
the variable then do it. My Reviewed-by still applies.
--
Mike Kravetz
> ---
> fs/hugetlbfs/inode.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
> index c262566f7c5d..f7ec94bc7337 100644
> --- a/fs/hugetlbfs/inode.c
> +++ b/fs/hugetlbfs/inode.c
> @@ -485,7 +485,6 @@ static void remove_inode_hugepages(struct inode *inode, loff_t lstart,
> u32 hash;
>
> index = page->index;
> - hash = hugetlb_fault_mutex_hash(mapping, index);
> if (!truncate_op) {
> /*
> * Only need to hold the fault mutex in the
> @@ -493,6 +492,7 @@ static void remove_inode_hugepages(struct inode *inode, loff_t lstart,
> * page faults. Races are not possible in the
> * case of truncation.
> */
> + hash = hugetlb_fault_mutex_hash(mapping, index);
> mutex_lock(&hugetlb_fault_mutex_table[hash]);
> }
>
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2 5/5] mm/hugetlb: avoid calculating fault_mutex_hash in truncate_op case
2021-03-16 3:07 ` Mike Kravetz
@ 2021-03-16 6:49 ` Miaohe Lin
2021-03-17 0:27 ` Mike Kravetz
0 siblings, 1 reply; 5+ messages in thread
From: Miaohe Lin @ 2021-03-16 6:49 UTC (permalink / raw)
To: Mike Kravetz, akpm; +Cc: linux-kernel, linux-mm
On 2021/3/16 11:07, Mike Kravetz wrote:
> On 3/15/21 7:27 PM, Miaohe Lin wrote:
>> The fault_mutex hashing overhead can be avoided in truncate_op case
>> because page faults can not race with truncation in this routine. So
>> calculate hash for fault_mutex only in !truncate_op case to save some cpu
>> cycles.
>>
>> Reviewed-by: Mike Kravetz <mike.kravetz@oracle.com>
>> Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
>> Cc: Mike Kravetz <mike.kravetz@oracle.com>
>> ---
>> v1->v2:
>> remove unnecessary initialization for variable hash
>> collect Reviewed-by tag from Mike Kravetz
>
> My apologies for not replying sooner and any misunderstanding from my
> previous comments.
>
That's all right.
> If the compiler is going to produce a warning because the variable is
> not initialized, then we will need to keep the initialization.
> Otherwise, this will show up as a build regression. Ideally, there
> would be a modifier which could be used to tell the compiler the
> variable will used. I do not know if such a modifier exists.
>
I do not know if such a modifier exists too. But maybe not all compilers are intelligent
enough to not produce a warning. It would be safe to keep the initialization...
> The patch can not produce a new warning. So, if you need to initialize
So just drop this version of the patch? Or should I send a new version with your Reviewed-by tag and
keep the initialization?
> the variable then do it. My Reviewed-by still applies.
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2 5/5] mm/hugetlb: avoid calculating fault_mutex_hash in truncate_op case
2021-03-16 6:49 ` Miaohe Lin
@ 2021-03-17 0:27 ` Mike Kravetz
2021-03-17 1:44 ` Miaohe Lin
0 siblings, 1 reply; 5+ messages in thread
From: Mike Kravetz @ 2021-03-17 0:27 UTC (permalink / raw)
To: Miaohe Lin, akpm; +Cc: linux-kernel, linux-mm
On 3/15/21 11:49 PM, Miaohe Lin wrote:
> On 2021/3/16 11:07, Mike Kravetz wrote:
>> On 3/15/21 7:27 PM, Miaohe Lin wrote:
>>> The fault_mutex hashing overhead can be avoided in truncate_op case
>>> because page faults can not race with truncation in this routine. So
>>> calculate hash for fault_mutex only in !truncate_op case to save some cpu
>>> cycles.
>>>
>>> Reviewed-by: Mike Kravetz <mike.kravetz@oracle.com>
>>> Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
>>> Cc: Mike Kravetz <mike.kravetz@oracle.com>
>>> ---
>>> v1->v2:
>>> remove unnecessary initialization for variable hash
>>> collect Reviewed-by tag from Mike Kravetz
>>
>> My apologies for not replying sooner and any misunderstanding from my
>> previous comments.
>>
>
> That's all right.
>
>> If the compiler is going to produce a warning because the variable is
>> not initialized, then we will need to keep the initialization.
>> Otherwise, this will show up as a build regression. Ideally, there
>> would be a modifier which could be used to tell the compiler the
>> variable will used. I do not know if such a modifier exists.
>>
>
> I do not know if such a modifier exists too. But maybe not all compilers are intelligent
> enough to not produce a warning. It would be safe to keep the initialization...
>
>> The patch can not produce a new warning. So, if you need to initialize
>
> So just drop this version of the patch? Or should I send a new version with your Reviewed-by tag and
> keep the initialization?
>
Yes, drop this version of the patch. You can add my Reviewed-by to the
previous version that included the initialization and resend.
All the cleanup patches in this series should be good to go.
--
Mike Kravetz
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2 5/5] mm/hugetlb: avoid calculating fault_mutex_hash in truncate_op case
2021-03-17 0:27 ` Mike Kravetz
@ 2021-03-17 1:44 ` Miaohe Lin
0 siblings, 0 replies; 5+ messages in thread
From: Miaohe Lin @ 2021-03-17 1:44 UTC (permalink / raw)
To: Mike Kravetz, akpm; +Cc: linux-kernel, linux-mm
On 2021/3/17 8:27, Mike Kravetz wrote:
> On 3/15/21 11:49 PM, Miaohe Lin wrote:
>> On 2021/3/16 11:07, Mike Kravetz wrote:
>>> On 3/15/21 7:27 PM, Miaohe Lin wrote:
>>>> The fault_mutex hashing overhead can be avoided in truncate_op case
>>>> because page faults can not race with truncation in this routine. So
>>>> calculate hash for fault_mutex only in !truncate_op case to save some cpu
>>>> cycles.
>>>>
>>>> Reviewed-by: Mike Kravetz <mike.kravetz@oracle.com>
>>>> Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
>>>> Cc: Mike Kravetz <mike.kravetz@oracle.com>
>>>> ---
>>>> v1->v2:
>>>> remove unnecessary initialization for variable hash
>>>> collect Reviewed-by tag from Mike Kravetz
>>>
>>> My apologies for not replying sooner and any misunderstanding from my
>>> previous comments.
>>>
>>
>> That's all right.
>>
>>> If the compiler is going to produce a warning because the variable is
>>> not initialized, then we will need to keep the initialization.
>>> Otherwise, this will show up as a build regression. Ideally, there
>>> would be a modifier which could be used to tell the compiler the
>>> variable will used. I do not know if such a modifier exists.
>>>
>>
>> I do not know if such a modifier exists too. But maybe not all compilers are intelligent
>> enough to not produce a warning. It would be safe to keep the initialization...
>>
>>> The patch can not produce a new warning. So, if you need to initialize
>>
>> So just drop this version of the patch? Or should I send a new version with your Reviewed-by tag and
>> keep the initialization?
>>
>
> Yes, drop this version of the patch. You can add my Reviewed-by to the
> previous version that included the initialization and resend.
>
Will do. Many thanks. :)
> All the cleanup patches in this series should be good to go.
>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2021-03-17 1:45 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-16 2:27 [PATCH v2 5/5] mm/hugetlb: avoid calculating fault_mutex_hash in truncate_op case Miaohe Lin
2021-03-16 3:07 ` Mike Kravetz
2021-03-16 6:49 ` Miaohe Lin
2021-03-17 0:27 ` Mike Kravetz
2021-03-17 1:44 ` Miaohe Lin
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.