From: Jerome Glisse <jglisse@redhat.com>
To: John Hubbard <jhubbard@nvidia.com>
Cc: linux-mm@kvack.org, Andrew Morton <akpm@linux-foundation.org>,
linux-kernel@vger.kernel.org,
Evgeny Baskakov <ebaskakov@nvidia.com>,
Ralph Campbell <rcampbell@nvidia.com>,
Mark Hairgrove <mhairgrove@nvidia.com>
Subject: Re: [PATCH 09/14] mm/hmm: do not differentiate between empty entry or missing directory
Date: Mon, 19 Mar 2018 22:08:23 -0400 [thread overview]
Message-ID: <20180320020823.GA3436@redhat.com> (raw)
In-Reply-To: <680af8e7-0f6d-85cb-f259-8a6a1d1dc9c3@nvidia.com>
On Mon, Mar 19, 2018 at 04:06:11PM -0700, John Hubbard wrote:
[...]
> > @@ -419,7 +404,7 @@ static int hmm_vma_walk_pmd(pmd_t *pmdp,
> > pfns[i] = 0;
> >
> > if (pte_none(pte)) {
> > - pfns[i] = HMM_PFN_EMPTY;
> > + pfns[i] = 0;
>
> Why is this being set to zero? (0 == HMM_PFN_VALID, btw.)
> I would have expected HMM_PFN_NONE. Actually, looking through the
> larger patchset, I think there are a couple of big questions about
> these HMM_PFN_* flags. Maybe it's just that the comment documentation
> has fallen completely behind, but it looks like there is an actual
> problem in the code:
>
> 1. HMM_PFN_* used to be bit shifts, so setting them directly sometimes
> worked. But now they are enum values, so that doesn't work anymore.
> Yet they are still being set directly in places: the enum is being
> treated as a flag, probably incorrectly.
>
> Previously:
>
> #define HMM_PFN_VALID (1 << 0)
> #define HMM_PFN_WRITE (1 << 1)
> #define HMM_PFN_ERROR (1 << 2)
> #define HMM_PFN_EMPTY (1 << 3)
> ...
>
> New:
>
> enum hmm_pfn_flag_e {
> HMM_PFN_VALID = 0,
> HMM_PFN_WRITE,
> HMM_PFN_ERROR,
> HMM_PFN_NONE,
> ...
>
> Yet we still have, for example:
>
> pfns = HMM_PFN_ERROR;
>
> This might be accidentally working, because HMM_PFN_ERROR
> has a value of 2, so only one bit is set, but...yikes.
>
> 2. The hmm_range.flags variable is a uint64_t* (pointer). And then
> the patchset uses the HMM_PFN_* enum to *index* into that as an
> array. Something is highly suspect here, because...an array that is
> indexed by HMM_PFN_* enums? It's certainly not documented that way.
>
> Examples:
> range->flags[HMM_PFN_ERROR]
>
> range->flags[HMM_PFN_VALID]
>
> I'll go through and try to point these out right next to the relevant
> parts of the patchset, but because I'm taking a little longer than
> I'd hoped to review this, I figured it's best to alert you earlier, as
> soon as I spot something.
>
I added more comments in v3 to explain this in last patch (15), and i
also splited values and flags hoping this make it more clear. Maybe
look at how nouveau use that NV_HMM_PAGE_FLAG* and NV_HMM_PAGE_VALUE*
[1] [2]
It is the same idea as pgprot_t vm_page_prot in vma struct except that
it is per device driver and hence not something i can optimize away at
build time for all possible user of HMM and thus why i use an array
provided by each device driver.
Hope this helps explaining it. Note that this would be best to discuss
as last patch review as this patch has nothing to do with that.
Cheers,
Jerome
[1] https://cgit.freedesktop.org/~glisse/linux/commit/?h=nouveau-hmm&id=b5da479c212d1fe7b6734dd8e69045e23871fdc8
[2] https://cgit.freedesktop.org/~glisse/linux/commit/?h=nouveau-hmm&id=1993d1b09f5941e0fab80c0b485eef296119d393
prev parent reply other threads:[~2018-03-20 2:08 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-16 19:14 [PATCH 0/4] hmm: fixes and documentations v2 jglisse
2018-03-16 19:14 ` [PATCH 01/14] mm/hmm: documentation editorial update to HMM documentation jglisse
2018-03-16 19:14 ` [PATCH 02/14] mm/hmm: fix header file if/else/endif maze jglisse
2018-03-16 21:09 ` Andrew Morton
2018-03-16 21:18 ` Jerome Glisse
2018-03-16 21:35 ` Andrew Morton
2018-03-16 21:40 ` John Hubbard
2018-03-17 1:20 ` [PATCH 02/14] mm/hmm: fix header file if/else/endif maze v2 jglisse
2018-03-16 19:14 ` [PATCH 03/14] mm/hmm: HMM should have a callback before MM is destroyed v2 jglisse
2018-03-16 21:12 ` Andrew Morton
2018-03-16 21:26 ` Jerome Glisse
2018-03-16 21:37 ` John Hubbard
2018-03-17 2:36 ` John Hubbard
2018-03-17 3:47 ` John Hubbard
2018-03-17 4:39 ` John Hubbard
2018-03-16 19:14 ` [PATCH 04/14] mm/hmm: hmm_pfns_bad() was accessing wrong struct jglisse
2018-03-17 2:04 ` John Hubbard
2018-03-16 19:14 ` [PATCH 05/14] mm/hmm: use struct for hmm_vma_fault(), hmm_vma_get_pfns() parameters jglisse
2018-03-17 3:08 ` John Hubbard
2018-03-16 19:14 ` [PATCH 06/14] mm/hmm: remove HMM_PFN_READ flag and ignore peculiar architecture jglisse
2018-03-17 3:30 ` John Hubbard
2018-03-16 19:14 ` [PATCH 07/14] mm/hmm: use uint64_t for HMM pfn instead of defining hmm_pfn_t to ulong jglisse
2018-03-17 3:59 ` John Hubbard
2018-03-16 19:14 ` [PATCH 08/14] mm/hmm: cleanup special vma handling (VM_SPECIAL) jglisse
2018-03-17 4:35 ` John Hubbard
2018-03-16 19:14 ` [PATCH 09/14] mm/hmm: do not differentiate between empty entry or missing directory jglisse
2018-03-19 23:06 ` John Hubbard
2018-03-20 2:08 ` Jerome Glisse [this message]
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=20180320020823.GA3436@redhat.com \
--to=jglisse@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=ebaskakov@nvidia.com \
--cc=jhubbard@nvidia.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mhairgrove@nvidia.com \
--cc=rcampbell@nvidia.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