From: Hillf Danton <hdanton@sina.com>
To: Waiman Long <longman@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@redhat.com>, Will Deacon <will.deacon@arm.com>,
Alexander Viro <viro@zeniv.linux.org.uk>,
Mike Kravetz <mike.kravetz@oracle.com>,
linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org,
linux-mm@kvack.org, Davidlohr Bueso <dave@stgolabs.net>
Subject: Re: [PATCH 5/5] hugetlbfs: Limit wait time when trying to share huge PMD
Date: Thu, 12 Sep 2019 13:36:21 +0800 [thread overview]
Message-ID: <20190912053621.15456-1-hdanton@sina.com> (raw)
In-Reply-To: <20190911150537.19527-1-longman@redhat.com>
On Wed, 11 Sep 2019 16:05:37 +0100
>
> +#define PMD_SHARE_DISABLE_THRESHOLD (1 << 8)
> +
> /*
> * Search for a shareable pmd page for hugetlb. In any case calls pmd_alloc()
> * and returns the corresponding pte. While this is not necessary for the
> @@ -4770,11 +4772,24 @@ pte_t *huge_pmd_share(struct mm_struct *mm, unsigned long addr, pud_t *pud)
> pte_t *spte = NULL;
> pte_t *pte;
> spinlock_t *ptl;
> + static atomic_t timeout_cnt;
>
> - if (!vma_shareable(vma, addr))
> - return (pte_t *)pmd_alloc(mm, pud, addr);
> + /*
> + * Don't share if it is not sharable or locking attempt timed out
> + * after 10ms. After 256 timeouts, PMD sharing will be permanently
> + * disabled as it is just too slow.
> + */
> + if (!vma_shareable(vma, addr) ||
> + (atomic_read(&timeout_cnt) >= PMD_SHARE_DISABLE_THRESHOLD))
> + goto out_no_share;
> +
> + if (!i_mmap_timedlock_write(mapping, ms_to_ktime(10))) {
> + if (atomic_inc_return(&timeout_cnt) ==
> + PMD_SHARE_DISABLE_THRESHOLD)
> + pr_info("Hugetlbfs PMD sharing disabled because of timeouts!\n");
> + goto out_no_share;
> + }
atomic_dec_if_positive(&timeout_cnt);
The logic to permanently disable pmd sharing does not make much sense
without anything like atomic_dec that would have been in their places,
with 256 timeouts put aside.
>
> - i_mmap_lock_write(mapping);
> vma_interval_tree_foreach(svma, &mapping->i_mmap, idx, idx) {
> if (svma == vma)
> continue;
> @@ -4806,6 +4821,9 @@ pte_t *huge_pmd_share(struct mm_struct *mm, unsigned long addr, pud_t *pud)
> pte = (pte_t *)pmd_alloc(mm, pud, addr);
> i_mmap_unlock_write(mapping);
> return pte;
> +
> +out_no_share:
> + return (pte_t *)pmd_alloc(mm, pud, addr);
> }
next prev parent reply other threads:[~2019-09-12 5:36 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-09-11 15:05 [PATCH 0/5] hugetlbfs: Disable PMD sharing for large systems Waiman Long
2019-09-11 15:05 ` [PATCH 1/5] locking/rwsem: Add down_write_timedlock() Waiman Long
2019-09-11 15:05 ` [PATCH 2/5] locking/rwsem: Enable timeout check when spinning on owner Waiman Long
2019-09-11 15:05 ` [PATCH 3/5] locking/osq: Allow early break from OSQ Waiman Long
2019-09-11 15:05 ` [PATCH 4/5] locking/rwsem: Enable timeout check when staying in the OSQ Waiman Long
2019-09-11 15:05 ` [PATCH 5/5] hugetlbfs: Limit wait time when trying to share huge PMD Waiman Long
2019-09-11 15:14 ` Matthew Wilcox
2019-09-11 15:44 ` Waiman Long
2019-09-11 17:03 ` Mike Kravetz
2019-09-11 17:15 ` Waiman Long
2019-09-11 17:22 ` Qian Cai
2019-09-11 17:28 ` Waiman Long
2019-09-11 16:01 ` Qian Cai
2019-09-11 16:34 ` Waiman Long
2019-09-11 19:42 ` Qian Cai
2019-09-11 20:54 ` Waiman Long
2019-09-11 21:57 ` Qian Cai
2019-09-11 19:57 ` Matthew Wilcox
2019-09-11 20:51 ` Waiman Long
2019-09-12 3:26 ` Mike Kravetz
2019-09-12 3:41 ` Matthew Wilcox
2019-09-12 4:40 ` Davidlohr Bueso
2019-09-16 13:53 ` Waiman Long
2019-09-12 9:06 ` Waiman Long
2019-09-12 16:43 ` Mike Kravetz
2019-09-13 18:23 ` Waiman Long
2019-09-12 5:36 ` Hillf Danton [this message]
2019-09-13 1:50 ` [PATCH 0/5] hugetlbfs: Disable PMD sharing for large systems Dave Chinner
2019-09-25 8:35 ` Peter Zijlstra
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=20190912053621.15456-1-hdanton@sina.com \
--to=hdanton@sina.com \
--cc=dave@stgolabs.net \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=longman@redhat.com \
--cc=mike.kravetz@oracle.com \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=viro@zeniv.linux.org.uk \
--cc=will.deacon@arm.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).