From: Mike Kravetz <mike.kravetz@oracle.com>
To: Mina Almasry <almasrymina@google.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
Qian Cai <cai@lca.pw>
Subject: Re: [PATCH -next] mm/hugetlb: Fix file_region entry allocations
Date: Tue, 18 Feb 2020 15:43:11 -0800 [thread overview]
Message-ID: <67aa82a8-3c8d-d1eb-7e83-4f722b1eeb2a@oracle.com> (raw)
In-Reply-To: <20200218222658.132101-1-almasrymina@google.com>
On 2/18/20 2:26 PM, Mina Almasry wrote:
> Commit a9e443086489e ("hugetlb: disable region_add file_region
> coalescing") introduced a bug with adding file_region entries
> that is fixed here:
>
> 1. Refactor file_region entry allocation logic into 1 function called
> from region_add and region_chg since the code is now identical.
> 2. region_chg only modifies resv->adds_in_progress after the regions
> have been allocated. In the past it used to increment
> adds_in_progress and then drop the lock, which would confuse racing
> region_add calls into thinking they need to allocate entries when
> they are not allowed.
> 3. In region_add, only try to allocate regions when
> actual_regions_needed > in_regions_needed. This is not causing a bug
> but is better for cleanliness and reasoning about the code.
>
> Tested using ltp hugemmap0* tests, and libhugetlbfs tests.
>
> Reported-by: Qian Cai <cai@lca.pw>
> Signed-off-by: Mina Almasry <almasrymina@google.com>
> Fixes: Commit a9e443086489e ("hugetlb: disable region_add file_region
> coalescing")
>
> ---
> mm/hugetlb.c | 149 +++++++++++++++++++++++++--------------------------
> 1 file changed, 74 insertions(+), 75 deletions(-)
>
> diff --git a/mm/hugetlb.c b/mm/hugetlb.c
> index 8171d2211be77..3d5b48ae8971f 100644
> --- a/mm/hugetlb.c
> +++ b/mm/hugetlb.c
> @@ -439,6 +439,66 @@ static long add_reservation_in_range(struct resv_map *resv, long f, long t,
> return add;
> }
>
> +/* Must be called with resv->lock acquired. Will drop lock to allocate entries.
> + */
> +static int allocate_file_region_entries(struct resv_map *resv,
> + int regions_needed)
> +{
I think this is going to need annotation for the lock or sparse is going
throw a warning. See,
https://lore.kernel.org/linux-mm/20200214204741.94112-7-jbi.octave@gmail.com/
Other than that, looks good. Sorry I missed that race in the review.
--
Mike Kravetz
next prev parent reply other threads:[~2020-02-18 23:43 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-18 22:26 [PATCH -next] mm/hugetlb: Fix file_region entry allocations Mina Almasry
2020-02-18 23:43 ` Mike Kravetz [this message]
2020-02-19 1:27 ` [PATCH v2] " Mina Almasry
2020-02-19 14:12 ` Miguel Ojeda
2020-02-19 23:28 ` Mina Almasry
2020-02-20 9:37 ` Miguel Ojeda
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=67aa82a8-3c8d-d1eb-7e83-4f722b1eeb2a@oracle.com \
--to=mike.kravetz@oracle.com \
--cc=akpm@linux-foundation.org \
--cc=almasrymina@google.com \
--cc=cai@lca.pw \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.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;
as well as URLs for NNTP newsgroup(s).