Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp5288783yba; Wed, 8 May 2019 10:44:08 -0700 (PDT) X-Google-Smtp-Source: APXvYqxvY5zGwER34j1NBaoo47WbFcirmgCn9+pkHOVT9PihO+6ry5SFZEgozy0bI4rS8oxCVuP5 X-Received: by 2002:a63:5608:: with SMTP id k8mr30055502pgb.393.1557337448562; Wed, 08 May 2019 10:44:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557337448; cv=none; d=google.com; s=arc-20160816; b=H8gd/hLmgneJ1hdLH5fHsu/gaHYMDOxrDSsTYWA44KLaPcCraEQY1KfCkgR6LyVE/H h/y8d0t5evuLwhcrsa2N6gXALmjbuymkmNTKTK4kJuIi1obTLK5JJ/M5Bx667ZBOazs1 I+AwXd1RZifZrUuABxyM8iWndQxw6bb1tcymewr7HO73TDW/+lVNAxU/1YtR8kibkXV6 6BRzClJjBT2ekp5wuBc35TquscMGCF6bWTXdFoG/GWmGUMyAVeVMVSOy8NPewMvW7ho4 RB0qmWERHXjADlEl19XO/KkniXXQ55Vxg1AaBKzjRCPaJYWSRXwquD06JFvbKsfGnSXY NWcA== 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:message-id:date:subject:cc:to:from; bh=aDWClVMg7o0q6W+CS5Ktmi+M2XAVNiQkNlzid5TzL2w=; b=ta400zCo45U3BZ/2fFwdELnLQcLe1d1JjJbq7rco0jXy/pxjC+FscuAOQ9T/OFKcaE +2jj2xMH8yRxLGsvEOuCv5hHmXSl6NeRFvDstdycpXJxH+sDijPuSMUunMz3LUs3amH5 7tM0a6rPcNfNM2DSYgkJvds6UjJ6I9VcYKHtHcPn90S1cx/XXgzKVBqMkool/q+BwPs6 Eh6xd1zGaF4Ip7bzX11Hqdw0Df0PeKoZszm4BpLgPbDgTPAivaJz37+dVPrNLvZ9Vp5b MtTz78wJ7UCzgmp8FxUvdT7TK6eKVIR/hNmAk0q1OeBVbfXbHICGWm4Aujq+QzaDRo9n GOgw== 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 v11si24485087pgh.22.2019.05.08.10.43.52; Wed, 08 May 2019 10:44:08 -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 S1728607AbfEHOpA (ORCPT + 99 others); Wed, 8 May 2019 10:45:00 -0400 Received: from mga11.intel.com ([192.55.52.93]:7358 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728245AbfEHOoo (ORCPT ); Wed, 8 May 2019 10:44:44 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 08 May 2019 07:44:43 -0700 X-ExtLoop1: 1 Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga004.fm.intel.com with ESMTP; 08 May 2019 07:44:39 -0700 Received: by black.fi.intel.com (Postfix, from userid 1000) id B90ABA50; Wed, 8 May 2019 17:44:29 +0300 (EEST) From: "Kirill A. Shutemov" To: Andrew Morton , x86@kernel.org, Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , Borislav Petkov , Peter Zijlstra , Andy Lutomirski , David Howells Cc: Kees Cook , Dave Hansen , Kai Huang , Jacob Pan , Alison Schofield , linux-mm@kvack.org, kvm@vger.kernel.org, keyrings@vger.kernel.org, linux-kernel@vger.kernel.org, "Kirill A. Shutemov" Subject: [PATCH, RFC 21/62] mm/rmap: Clear vma->anon_vma on unlink_anon_vmas() Date: Wed, 8 May 2019 17:43:41 +0300 Message-Id: <20190508144422.13171-22-kirill.shutemov@linux.intel.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190508144422.13171-1-kirill.shutemov@linux.intel.com> References: <20190508144422.13171-1-kirill.shutemov@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If all pages in the VMA got unmapped there's no reason to link it into original anon VMA hierarchy: it cannot possibly share any pages with other VMA. Set vma->anon_vma to NULL on unlink_anon_vmas(). With the change VMA can be reused. The new anon VMA will be allocated on the first fault. Signed-off-by: Kirill A. Shutemov --- mm/rmap.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/mm/rmap.c b/mm/rmap.c index b30c7c71d1d9..4ec2aee7baa3 100644 --- a/mm/rmap.c +++ b/mm/rmap.c @@ -400,8 +400,10 @@ void unlink_anon_vmas(struct vm_area_struct *vma) list_del(&avc->same_vma); anon_vma_chain_free(avc); } - if (vma->anon_vma) + if (vma->anon_vma) { vma->anon_vma->degree--; + vma->anon_vma = NULL; + } unlock_anon_vma_root(root); /* -- 2.20.1