Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp4266098ybl; Tue, 20 Aug 2019 09:18:46 -0700 (PDT) X-Google-Smtp-Source: APXvYqx3JyV7OFCCgQTD2oJ+qamH87IrWciLWNR1/7XmxhQpwojXh3z+dz7VNwuOV8um6Wr+lc/M X-Received: by 2002:a65:6552:: with SMTP id a18mr26097058pgw.208.1566317925845; Tue, 20 Aug 2019 09:18:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566317925; cv=none; d=google.com; s=arc-20160816; b=ehkg/7Bm2LPN+c1G9LDu7wo9AhteqS4z6fr8GQOgECbB+btQHChP0lSVj5EMAAvcu+ ZtjyyVg1CB1cUtFATtoIebnsiL5R89k+pjdN3c+V0l9OXjXjZYxiZzvNxMAkJH9vS+vV TJXBrvo56JObEA+EIHvmJO/pyTXLCp1BBOCV35kt3zVyuDkEH8wogYo7ut8/RU0NmJY8 4gcU41bcT6px6Q/D9sytgPbB1AfQVZmHkpZxVWJXDUjAb8CGNYkJhc1H5JBILJWvomyq ogwDo57YAxN/pfobGutTEfxzzgqdE7Ku7SjAvzg/TRaMrdBfTV4OpX+Kbw3B6gTfxrzX 6pqw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:date:cc:to:from:subject:message-id; bh=KEluMBF7376n8LPmDEH2+jpvcV515+fN2iWcvBHPHVA=; b=ZqZmx6BqXuBclQAK050dvWnycxejD9+q/pafO6AQUxJtWaxojfKk47uSUaaU0W7kfV FKUPpJnVjtl3yDpoSGWit3n3kbgxkGCZtKUzfIYLFW8A/JJj1VAcvXJON0Nv165r5pQm Sv+YOLoUExEaHGEO9SqAedWa7O/Ax5fU5LPnJWrJSou/Ry/XGlsGR1vN9th1EKWoR7RC Tq26neYBZxxrK6au0zJhLAlp05laWWw8TCxcl4FAmjDuFEfMeE5eXlJSFUBMzQj0AOtq xZknK/v58xfts14fkqTjulFkJQXH9zm2yj1eU0tMO9o0q3mCzQ3uopzR9ITOQHGMRygl j0tA== 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=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d36si7114287pla.286.2019.08.20.09.18.29; Tue, 20 Aug 2019 09:18:45 -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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730184AbfHTQRn (ORCPT + 99 others); Tue, 20 Aug 2019 12:17:43 -0400 Received: from mga07.intel.com ([134.134.136.100]:58739 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725971AbfHTQRm (ORCPT ); Tue, 20 Aug 2019 12:17:42 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 20 Aug 2019 09:17:40 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,408,1559545200"; d="scan'208";a="169130943" Received: from yyu32-desk1.sc.intel.com ([10.144.153.205]) by orsmga007.jf.intel.com with ESMTP; 20 Aug 2019 09:17:39 -0700 Message-ID: Subject: Re: [PATCH v8 18/27] mm: Introduce do_mmap_locked() From: Yu-cheng Yu To: Sean Christopherson Cc: x86@kernel.org, "H. Peter Anvin" , Thomas Gleixner , Ingo Molnar , linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-mm@kvack.org, linux-arch@vger.kernel.org, linux-api@vger.kernel.org, Arnd Bergmann , Andy Lutomirski , Balbir Singh , Borislav Petkov , Cyrill Gorcunov , Dave Hansen , Eugene Syromiatnikov , Florian Weimer , "H.J. Lu" , Jann Horn , Jonathan Corbet , Kees Cook , Mike Kravetz , Nadav Amit , Oleg Nesterov , Pavel Machek , Peter Zijlstra , Randy Dunlap , "Ravi V. Shankar" , Vedvyas Shanbhogue , Dave Martin Date: Tue, 20 Aug 2019 09:08:34 -0700 In-Reply-To: <20190820010200.GI1916@linux.intel.com> References: <20190813205225.12032-1-yu-cheng.yu@intel.com> <20190813205225.12032-19-yu-cheng.yu@intel.com> <20190820010200.GI1916@linux.intel.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.28.1-2 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 2019-08-19 at 18:02 -0700, Sean Christopherson wrote: > On Tue, Aug 13, 2019 at 01:52:16PM -0700, Yu-cheng Yu wrote: > > There are a few places that need do_mmap() with mm->mmap_sem held. > > Create an in-line function for that. > > > > Signed-off-by: Yu-cheng Yu > > --- > > include/linux/mm.h | 18 ++++++++++++++++++ > > 1 file changed, 18 insertions(+) > > > > diff --git a/include/linux/mm.h b/include/linux/mm.h > > index bc58585014c9..275c385f53c6 100644 > > --- a/include/linux/mm.h > > +++ b/include/linux/mm.h > > @@ -2394,6 +2394,24 @@ static inline void mm_populate(unsigned long addr, > > unsigned long len) > > static inline void mm_populate(unsigned long addr, unsigned long len) {} > > #endif > > > > +static inline unsigned long do_mmap_locked(struct file *file, > > + unsigned long addr, unsigned long len, unsigned long prot, > > + unsigned long flags, vm_flags_t vm_flags, struct list_head *uf) > > +{ > > + struct mm_struct *mm = current->mm; > > + unsigned long populate; > > + > > + down_write(&mm->mmap_sem); > > + addr = do_mmap(file, addr, len, prot, flags, vm_flags, 0, > > + &populate, uf); > > + up_write(&mm->mmap_sem); > > + > > + if (populate) > > + mm_populate(addr, populate); > > + > > + return addr; > > +} > > Any reason not to put this in cet.c, as suggested by PeterZ? All of the > calls from CET have identical params except for @len, e.g. you can add > 'static unsigned long cet_mmap(unsigned long len)' and bury most of the > copy-paste code in there. > > https://lkml.kernel.org/r/20190607074707.GD3463@hirez.programming.kicks-ass.ne > t Yes, I will do that. I thought this would be useful in other places, but currently only in mpx.c. Yu-cheng