* [PATCH] mm/hugetlb: optimize the surplus state transfer code in move_hugetlb_state()
@ 2021-02-10 7:12 Miaohe Lin
2021-02-13 0:51 ` Mike Kravetz
0 siblings, 1 reply; 2+ messages in thread
From: Miaohe Lin @ 2021-02-10 7:12 UTC (permalink / raw)
To: akpm, mike.kravetz; +Cc: linux-mm, linux-kernel, linmiaohe
We should not transfer the per-node surplus state when we do not cross the
node in order to save some cpu cycles
Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
---
mm/hugetlb.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index da347047ea10..4f2c92ddbca4 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -5632,6 +5632,12 @@ void move_hugetlb_state(struct page *oldpage, struct page *newpage, int reason)
SetHPageTemporary(oldpage);
ClearHPageTemporary(newpage);
+ /*
+ * There is no need to transfer the per-node surplus state
+ * when we do not cross the node.
+ */
+ if (new_nid == old_nid)
+ return;
spin_lock(&hugetlb_lock);
if (h->surplus_huge_pages_node[old_nid]) {
h->surplus_huge_pages_node[old_nid]--;
--
2.19.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] mm/hugetlb: optimize the surplus state transfer code in move_hugetlb_state()
2021-02-10 7:12 [PATCH] mm/hugetlb: optimize the surplus state transfer code in move_hugetlb_state() Miaohe Lin
@ 2021-02-13 0:51 ` Mike Kravetz
0 siblings, 0 replies; 2+ messages in thread
From: Mike Kravetz @ 2021-02-13 0:51 UTC (permalink / raw)
To: Miaohe Lin, akpm; +Cc: linux-mm, linux-kernel
On 2/9/21 11:12 PM, Miaohe Lin wrote:
> We should not transfer the per-node surplus state when we do not cross the
> node in order to save some cpu cycles
>
> Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
> ---
> mm/hugetlb.c | 6 ++++++
> 1 file changed, 6 insertions(+)
Thanks,
I was going to comment that the usual case is migrating to another node
and old_nid != new_nid. However, this really is workload and system
configuration dependent. In any case, the quick check is worth potentially
saving a lock/unlock cycle.
Reviewed-by: Mike Kravetz <mike.kravetz@oracle.com>
--
Mike Kravetz
>
> diff --git a/mm/hugetlb.c b/mm/hugetlb.c
> index da347047ea10..4f2c92ddbca4 100644
> --- a/mm/hugetlb.c
> +++ b/mm/hugetlb.c
> @@ -5632,6 +5632,12 @@ void move_hugetlb_state(struct page *oldpage, struct page *newpage, int reason)
> SetHPageTemporary(oldpage);
> ClearHPageTemporary(newpage);
>
> + /*
> + * There is no need to transfer the per-node surplus state
> + * when we do not cross the node.
> + */
> + if (new_nid == old_nid)
> + return;
> spin_lock(&hugetlb_lock);
> if (h->surplus_huge_pages_node[old_nid]) {
> h->surplus_huge_pages_node[old_nid]--;
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-02-13 0:57 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-10 7:12 [PATCH] mm/hugetlb: optimize the surplus state transfer code in move_hugetlb_state() Miaohe Lin
2021-02-13 0:51 ` Mike Kravetz
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.