From patchwork Mon Feb 24 20:30:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michel Lespinasse X-Patchwork-Id: 11401513 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 95BC0924 for ; Mon, 24 Feb 2020 20:31:44 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 625E920675 for ; Mon, 24 Feb 2020 20:31:44 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="rlrokBSk" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 625E920675 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id BD7E56B009B; Mon, 24 Feb 2020 15:31:38 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id BAFBB6B009D; Mon, 24 Feb 2020 15:31:38 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AF0966B009E; Mon, 24 Feb 2020 15:31:38 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 86B926B009B for ; Mon, 24 Feb 2020 15:31:38 -0500 (EST) Received: from smtpin05.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 3F8A549961A for ; Mon, 24 Feb 2020 20:31:38 +0000 (UTC) X-FDA: 76526166276.05.horse87_2b57cb25d7d1f X-Spam-Summary: 2,0,0,fb8e7eec982d5a9f,d41d8cd98f00b204,3qdjuxgykcfclza93c5dd5a3.1dba7cjm-bb9kz19.dg5@flex--walken.bounces.google.com,,RULES_HIT:41:152:355:379:541:800:960:973:988:989:1260:1277:1313:1314:1345:1359:1437:1516:1518:1534:1541:1593:1594:1711:1730:1747:1777:1792:2393:2559:2562:2693:2895:3138:3139:3140:3141:3142:3152:3353:3865:3866:3867:3870:3871:4321:5007:6120:6261:6653:7875:9969:10004:10400:11026:11473:11658:11914:12043:12048:12296:12297:12438:12555:12895:12986:13069:13141:13230:13255:13311:13357:14096:14097:14181:14659:14721:21080:21444:21451:21627:21990:30003:30054:30070:30079,0,RBL:209.85.215.202:@flex--walken.bounces.google.com:.lbl8.mailshell.net-62.18.0.100 66.100.201.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:24,LUA_SUMMARY:none X-HE-Tag: horse87_2b57cb25d7d1f X-Filterd-Recvd-Size: 4597 Received: from mail-pg1-f202.google.com (mail-pg1-f202.google.com [209.85.215.202]) by imf37.hostedemail.com (Postfix) with ESMTP for ; Mon, 24 Feb 2020 20:31:37 +0000 (UTC) Received: by mail-pg1-f202.google.com with SMTP id 37so7377732pgq.0 for ; Mon, 24 Feb 2020 12:31:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=VPI6sUydG2rawPhJIvqJUfBxoqUV2ho2w9ujkWVyI60=; b=rlrokBSkNAY94bAAGiyJZq8ThhSz5INj2exgDAu3C/TyuTfg1uI/Gzw1oLmiNxEScv xdtVagtH8SbKYQ9f84JXq5OsNKFFUNVrY/NUBF2tQOsdxWv5UOdqiNEEaFCl+nmpBvwB LIJEAQQv65R6DUeZxK4YuU7TfWUH5Xg1Dont7tYErVDglD1HVLV4q4XRheMpeH7A03Fk 7xH3UzyxPj+McolsTZ0Mk00+BH1I3p+tNaL3WeyTYSo+I8kdaeGFXn8ZEHqh2yEcrAFr w01Ei/eX8Wvw7Aju11iM36rU+Td921BGcNFgaZGwe/1mMmDbZI9Kx8xzh1SW9lCtJaZV Twxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=VPI6sUydG2rawPhJIvqJUfBxoqUV2ho2w9ujkWVyI60=; b=duCu0sPZM3UlIlv1vRJS0QvJ5BLrj6Um6hUQOI+iyfyjdiCHBJHsGJ6qwYy03T/U7f QKkvYawNaZJf1IBmPOED8S5AIKWFbptd1+agOoo2jkaM1rZIZVeoSkaZmzFgk6vDIw/Y 29U7jfRSHHm9snq0lvhixnxOQ1aqrgTbX9BQdvSjV/31szPJaW7R9SHWsdNXu/7DprQ5 S0wmCRPfVwMSTfui6GbgS/WDnBFNxBdFjWvvfOHkd3ITp/aW0DtVZ3eWb9RLxZDsyWAF dWFMX40Tt483uDs60SQQt28boUCPShBUnziICbJyzT/FME3AjhFkxXSkZ1Yd2g7yk2B6 lYBw== X-Gm-Message-State: APjAAAWNLM1BNmGeHjYtNWtGSb02QA8xJWvmS7OvIXqnvn8KCgCyuNGf LiP1ISAfLNwwuEBJVj47HchSm9uF2pI= X-Google-Smtp-Source: APXvYqwdk3qgU9gzMyXRUkTyjJufA9Oul8am946/pyMlUe3nXfPtahDTmkBwq1094dqkqeblV8//ChDuAxI= X-Received: by 2002:a65:478a:: with SMTP id e10mr52716350pgs.197.1582576296777; Mon, 24 Feb 2020 12:31:36 -0800 (PST) Date: Mon, 24 Feb 2020 12:30:48 -0800 In-Reply-To: <20200224203057.162467-1-walken@google.com> Message-Id: <20200224203057.162467-16-walken@google.com> Mime-Version: 1.0 References: <20200224203057.162467-1-walken@google.com> X-Mailer: git-send-email 2.25.0.265.gbab2e86ba0-goog Subject: [RFC PATCH 15/24] x86 fault handler: use a pseudo-vma when operating on anonymous vmas. From: Michel Lespinasse To: Peter Zijlstra , Andrew Morton , Laurent Dufour , Vlastimil Babka , Matthew Wilcox , "Liam R . Howlett" , Jerome Glisse , Davidlohr Bueso , David Rientjes Cc: linux-mm , Michel Lespinasse X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Update the fault handler to use a pseudo-vma when the original vma is anonymous. This is in preparation to handling such faults with a fine grained range lock in a later change. Signed-off-by: Michel Lespinasse --- arch/x86/mm/fault.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git arch/x86/mm/fault.c arch/x86/mm/fault.c index 700da3cc3db9..52333272e14e 100644 --- arch/x86/mm/fault.c +++ arch/x86/mm/fault.c @@ -1279,7 +1279,7 @@ void do_user_addr_fault(struct pt_regs *regs, unsigned long address) { struct mm_lock_range *range; - struct vm_area_struct *vma; + struct vm_area_struct pvma, *vma; struct task_struct *tsk; struct mm_struct *mm; vm_fault_t fault, major = 0; @@ -1423,6 +1423,23 @@ void do_user_addr_fault(struct pt_regs *regs, return; } + if (vma_is_anonymous(vma)) { + /* + * Allocate anon_vma if needed. + * This needs to operate on the vma of record. + */ + fault = prepare_mm_fault(vma, flags); + if (fault) + goto got_fault; + + /* + * Copy vma attributes into a pseudo-vma. + * This will be required when using fine grained locks. + */ + pvma = *vma; + vma = &pvma; + } + /* * If for any reason at all we couldn't handle the fault, * make sure we exit gracefully rather than endlessly redo @@ -1437,6 +1454,7 @@ void do_user_addr_fault(struct pt_regs *regs, * FAULT_FLAG_USER|FAULT_FLAG_KILLABLE are both set in flags. */ fault = handle_mm_fault_range(vma, address, flags, range); +got_fault: major |= fault & VM_FAULT_MAJOR; /*