Received: by 10.213.65.68 with SMTP id h4csp1406714imn; Wed, 21 Mar 2018 09:55:16 -0700 (PDT) X-Google-Smtp-Source: AG47ELvYeSxDlH1+WHDB5qpR5Drl9+meYbGyiiTa6CxR4UuMa3OavIbHDdn85qeFvDuB56u1Z0Mr X-Received: by 2002:a17:902:8349:: with SMTP id z9-v6mr21448242pln.163.1521651316176; Wed, 21 Mar 2018 09:55:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521651316; cv=none; d=google.com; s=arc-20160816; b=TdeAX0F57Kxu5HzVWFfu5rajlD5hXbf5NX36V8tUgInmfBw8EE21bBdi0YHqjD5OZ7 cqiNXAjACMwX1q/bKx+j/Ip9xZMnapWiz6ORRwZmm/39BBXqNKaF5DxKZoWdT2oHU+4f PZGe+snOMcooYHQOjqV7DbD6wCEey/QJAEZ39p69Go5WemNQaFCzDFnhJyIqdwcVMQzo ZrUr+WiLri/3DjGkS4mwg1pqmTFhyjZqSfomMRTz8fXa99OYDK9Eh+cXGFigkk522rIb 5qAVkh4zDsokmv4vLvsdnErg8n9Ds6CJ2CCypIj9Q6BVG12n/gcCrJAnk/Epkcy4nlxZ HoPg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:arc-authentication-results; bh=Ne8H/y/L9umXeZROP3Umj5BRS2mUZDIbdh54trsM95A=; b=qhW7/gH2cHd3Jh/to75Gom7CxNj98mhW+GwvT3Y8F3KlWIa8A8yDFvZJYtNVsOyIas BeABCAQAND898D01X2fIos/r0pPkeSgRoXTUQn5e0kpUTP9xxKMbWtL7FBr0TUD6Clkb YgMYt/mV3bHVm5OeC0pSjY+Yaz5w4ZrxNOh61K0bfNokAkPqxjeGLWMTMLSeh2DDPGeI bi6910PRPY2PJQLOBj44v7w6G9zL3LWCroIkZEEPUQ2qXO9BPyAaS7WbBdcZosFgoayo y6Fdahpl6BuCQ5Y8iYfmU7xSLMNq5pKNXxGsaPDSfxt0Js+TnzIiiC65R9lI4hKSBMnB SH1Q== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e12si2900697pgq.413.2018.03.21.09.55.01; Wed, 21 Mar 2018 09:55:16 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753058AbeCUQyI (ORCPT + 99 others); Wed, 21 Mar 2018 12:54:08 -0400 Received: from out30-130.freemail.mail.aliyun.com ([115.124.30.130]:49988 "EHLO out30-130.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751641AbeCUQyF (ORCPT ); Wed, 21 Mar 2018 12:54:05 -0400 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R171e4;CH=green;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e01422;MF=yang.shi@linux.alibaba.com;NM=1;PH=DS;RN=9;SR=0;TI=SMTPD_---0SzrS.nC_1521651220; Received: from US-143344MP.local(mailfrom:yang.shi@linux.alibaba.com fp:121.0.29.197) by smtp.aliyun-inc.com(127.0.0.1); Thu, 22 Mar 2018 00:53:43 +0800 Subject: Re: [RFC PATCH 7/8] x86: mpx: pass atomic parameter to do_munmap() To: Thomas Gleixner 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 References: <1521581486-99134-1-git-send-email-yang.shi@linux.alibaba.com> <1521581486-99134-8-git-send-email-yang.shi@linux.alibaba.com> From: Yang Shi Message-ID: <8d2b26b6-b40a-cef8-9d67-afb8c12ad359@linux.alibaba.com> Date: Wed, 21 Mar 2018 09:53:36 -0700 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 3/20/18 3:35 PM, Thomas Gleixner wrote: > 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. Sorry for the inconvenience. Will pay attention to it next time. > >> 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 a lot for the suggestion. Absolutely agree. Will fix the problems in newer version. Yang > > Thanks, > > tglx