Received: by 10.213.65.68 with SMTP id h4csp787588imn; Tue, 20 Mar 2018 15:37:34 -0700 (PDT) X-Google-Smtp-Source: AG47ELvFLRbCLMivK9C/Y1kRFRCcGXyFGmFalqt2aRoPNrRaqQWJraCB7ZYgUbLxq2Vcv9kNUW4g X-Received: by 10.101.68.82 with SMTP id e18mr13227147pgq.329.1521585454229; Tue, 20 Mar 2018 15:37:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521585454; cv=none; d=google.com; s=arc-20160816; b=R3E4gBW6XD9Z4XQimb7jeKXHH+pmC6kaWFW7fJWFdzmNTT34symnk/e2FCYOfbVkoL y1gicphudLnY9smRYz0lEDXD7bbR5+R5HK0uM7Z/gKLgaP5PpXKtx2z01ZBI2srn/KKp p0zlkaYXNczSHpUKyGvXsESAXCfDBzsEPrZ3KJ0poqyCN7tSdVZEhSWzTQC0EybWOco4 rijsOimRJBvy3Jqhjq0FoxUPCNDYkM4KysIF91iGG3hrE6hvLiVaEQpRhuKOne4bDnvT MvIztlK1DS8AM8qJGdRQM1JK+8hw1rusfEAb6P172Q7gC9RDIxSDk/Lxls8mohNWgLRf iNwg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date :arc-authentication-results; bh=WBB5CmSIVlr1S3++WvpI51ojUx1pOtDrkV1i37tCaRw=; b=PdnSlpBAGo1312nvYLDia+yQxFvCtUY0jfzKzRcqdxo00wXw++1u86VsipbVeynUBb Qt9JxFSx83FqoyavFJPXstp0bLWVSuWyNFH2503qq0hdyNk+WWI8l6NtiDWdpraYc1HT t9FO5xI/362c/nWwty0F2/9uH7T+i1eztG2UymVqx2aT3cs7S8VlXTQ8O70HuiNEBEzz DEdb2spViFuBbQhbnQFcX1whVR+1biExiMseeieWeVLL69GFnOwGd2oNFmA9UNJWSFB1 LUQBLulYMgrE2ZxMKqyTI5CFtaE3s3HVNIZGbWVcZna3A+2Rb+yQOyQbAW143wIhfYG3 R0qQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s14si1990002pfj.131.2018.03.20.15.37.19; Tue, 20 Mar 2018 15:37:34 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751997AbeCTWfj (ORCPT + 99 others); Tue, 20 Mar 2018 18:35:39 -0400 Received: from Galois.linutronix.de ([146.0.238.70]:35745 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751832AbeCTWff (ORCPT ); Tue, 20 Mar 2018 18:35:35 -0400 Received: from p4fea5f09.dip0.t-ipconnect.de ([79.234.95.9] helo=nanos.glx-home) by Galois.linutronix.de with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1eyPqt-00043G-2L; Tue, 20 Mar 2018 23:35:31 +0100 Date: Tue, 20 Mar 2018 23:35:30 +0100 (CET) From: Thomas Gleixner To: Yang Shi cc: akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Ricardo Neri , Ingo Molnar , "H. Peter Anvin" , Borislav Petkov , x86@kernel.org Subject: Re: [RFC PATCH 7/8] x86: mpx: pass atomic parameter to do_munmap() In-Reply-To: <1521581486-99134-8-git-send-email-yang.shi@linux.alibaba.com> Message-ID: References: <1521581486-99134-1-git-send-email-yang.shi@linux.alibaba.com> <1521581486-99134-8-git-send-email-yang.shi@linux.alibaba.com> User-Agent: Alpine 2.21 (DEB 202 2017-01-01) 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 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 21 Mar 2018, Yang Shi wrote: Please CC everyone involved on the full patch set next time. I had to dig the rest out from my lkml archive to get the context. > Pass "true" to do_munmap() to not do unlock/relock to mmap_sem when > manipulating mpx map. > This is API change only. This is wrong. You cannot change the function in one patch and then clean up the users. That breaks bisectability. Depending on the number of callers this wants to be a single patch changing both the function and the callers or you need to create a new function which has the extra argument and switch all users over to it and then remove the old function. > @@ -780,7 +780,7 @@ static int unmap_entire_bt(struct mm_struct *mm, > * avoid recursion, do_munmap() will check whether it comes > * from one bounds table through VM_MPX flag. > */ > - return do_munmap(mm, bt_addr, mpx_bt_size_bytes(mm), NULL); > + return do_munmap(mm, bt_addr, mpx_bt_size_bytes(mm), NULL, true); But looking at the full context this is the wrong approach. First of all the name of that parameter 'atomic' is completely misleading. It suggests that this happens in fully atomic context, which is not the case. Secondly, conditional locking is frowned upon in general and rightfully so. So the right thing to do is to leave do_munmap() alone and add a new function do_munmap_huge() or whatever sensible name you come up with. Then convert the places which are considered to be safe one by one with a proper changelog which explains WHY this is safe. That way you avoid the chasing game of all existing do_munmap() callers and just use the new 'free in chunks' approach where it is appropriate and safe. No suprises, no bisectability issues.... While at it please add proper kernel doc documentation to both do_munmap() and the new function which explains the intricacies. Thanks, tglx