[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20161011214817.GB32165@linux.intel.com>
Date: Tue, 11 Oct 2016 15:48:17 -0600
From: Ross Zwisler <ross.zwisler@...ux.intel.com>
To: Christoph Hellwig <hch@....de>
Cc: Ross Zwisler <ross.zwisler@...ux.intel.com>,
linux-kernel@...r.kernel.org, Theodore Ts'o <tytso@....edu>,
Alexander Viro <viro@...iv.linux.org.uk>,
Andreas Dilger <adilger.kernel@...ger.ca>,
Andrew Morton <akpm@...ux-foundation.org>,
Dan Williams <dan.j.williams@...el.com>,
Dave Chinner <david@...morbit.com>, Jan Kara <jack@...e.com>,
Matthew Wilcox <mawilcox@...rosoft.com>,
linux-ext4@...r.kernel.org, linux-fsdevel@...r.kernel.org,
linux-mm@...ck.org, linux-nvdimm@...ts.01.org,
linux-xfs@...r.kernel.org
Subject: Re: [PATCH v5 15/17] dax: add struct iomap based DAX PMD support
On Mon, Oct 10, 2016 at 05:59:17PM +0200, Christoph Hellwig wrote:
> On Fri, Oct 07, 2016 at 03:09:02PM -0600, Ross Zwisler wrote:
> > - if (RADIX_DAX_TYPE(entry) == RADIX_DAX_PMD)
> > + if ((unsigned long)entry & RADIX_DAX_PMD)
>
> Please introduce a proper inline helper that mask all the possible type
> bits out of the radix tree entry, and use them wherever you do the
> open cast.
Yea, this is messy. I tried having temporary flags, but that's basically
where we came from with the old 'type' thing which used to be
RADIX_DAX_PTE|RADIX_DAX_PMD.
After playing with it a bit it seems like the cleanest way is to have a little
flag test helper, like this:
static int dax_flag_test(void *entry, int flags)
{
return (unsigned long)entry & flags;
}
...
/*
* Besides huge zero pages the only other thing that gets
* downgraded are empty entries which don't need to be
* unmapped.
*/
if (pmd_downgrade && dax_flag_test(entry, RADIX_DAX_HZP))
unmap_mapping_range(mapping,
(index << PAGE_SHIFT) & PMD_MASK, PMD_SIZE, 0);
etc. Please let me know if this is undesirable for some reason. Vs keeping
the flags in a local variable, this is good because a) it doesn't require
callers to cast, and b) it makes operator precedence easy because the flags
are a param, so no "flags & (flag1|flag2)" nesting, and c) we don't keep a
local variable that could get out of sync with 'entry'.
> > restart:
> > spin_lock_irq(&mapping->tree_lock);
> > entry = get_unlocked_mapping_entry(mapping, index, &slot);
> > +
> > + if (entry) {
> > + if (size_flag & RADIX_DAX_PMD) {
> > + if (!radix_tree_exceptional_entry(entry) ||
> > + !((unsigned long)entry & RADIX_DAX_PMD)) {
> > + entry = ERR_PTR(-EEXIST);
> > + goto out_unlock;
> > + }
> > + } else { /* trying to grab a PTE entry */
> > + if (radix_tree_exceptional_entry(entry) &&
> > + ((unsigned long)entry & RADIX_DAX_PMD) &&
> > + ((unsigned long)entry &
> > + (RADIX_DAX_HZP|RADIX_DAX_EMPTY))) {
>
> And when we do these cases N times next to each other we should
> have a local variable the valid flag bits of entry.
--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists