From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754764AbbERVzQ (ORCPT ); Mon, 18 May 2015 17:55:16 -0400 Received: from www.linutronix.de ([62.245.132.108]:51397 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752057AbbERVzN (ORCPT ); Mon, 18 May 2015 17:55:13 -0400 Date: Mon, 18 May 2015 23:55:24 +0200 (CEST) From: Thomas Gleixner To: Dave Hansen cc: linux-kernel@vger.kernel.org, x86@kernel.org, dave.hansen@linux.intel.com Subject: Re: [PATCH 17/19] x86, mpx: rewrite unmap code In-Reply-To: <20150508185957.C657301B@viggo.jf.intel.com> Message-ID: References: <20150508185948.4C19F4B0@viggo.jf.intel.com> <20150508185957.C657301B@viggo.jf.intel.com> User-Agent: Alpine 2.11 (DEB 23 2013-08-11) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001,URIBL_BLOCKED=0.001 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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