Re: [PATCH 17/19] x86, mpx: rewrite unmap code

From: Thomas Gleixner
Date: Mon May 18 2015 - 17:55:19 EST


On Fri, 8 May 2015, Dave Hansen wrote:
> The MPX code needs to clear out bounds tables for memory which
> is no longer in use. We do this when a userspace mapping is
> torn down (unmapped).
>
> There are two modes:
> 1. An entire bounds table becomes unused, and can be freed
> and its pointer removed from the bounds directory. This
> happens either when a large mapping is torn down, or when
> a small mapping is torn down and it is the last mapping
> "covered" by a bounds table.
> 2. Only part of a bounds table becomes unused, in which case
> we free the backing memory as if MADV_DONTNEED was called.
>
> The old code was a spaghetti mess of "edge" bounds tables
> where the edges were handled specially, even if we were
> unmapping an entire one. Non-edge bounds tables are always
> fully unmapped, but share a different code path from the edge
> ones. The old code had a bug where it was unmapping too much
> memory. I worked on fixing it for two days and gave up.
>
> I didn't write the original code. I didn't particularly like
> it, but it worked, so I left it. After my debug session, I
> realized it was undebuggagle *and* buggy, so out it went.
>
> I also wrote a new unmapping test program which uncovers bugs
> pretty nicely.

Very appreciated. This is really readable now.

Reviewed-by: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/