Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp6270004ybi; Wed, 31 Jul 2019 11:15:52 -0700 (PDT) X-Google-Smtp-Source: APXvYqwyw6SGUQY00s5GWwajGl5wH3d6Puv9XysK66MN/8Bbvr/xXv/u1DD/OmXG85n+M4uQHBKo X-Received: by 2002:a63:9e54:: with SMTP id r20mr81423441pgo.64.1564596952470; Wed, 31 Jul 2019 11:15:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564596952; cv=none; d=google.com; s=arc-20160816; b=RYNtVaAEKXO54rYZ8lKJVUviO/l58qZF+hjMFiTBt5p4gyCprUlA1KGMyWogQZVbUb QXItyomQABNKV8sU9IK3IeBJ9G0WFBM3BEOO0kQyQMWoRXDPxE8hf0sUdoksg7KypuoP +b9ScO+cg/6ppoovvpI4xd/Ceh8dFjs6Dco+m5UPjWVMtm37/hd1jQyIWM01jub9hOyE ksUlASWFXLqVXWgPqof1STVMtrDhn9oovNXteTBAi2BdNt5Q3uS+G7xTF5wSuJ2dCKH3 HGYl1O2xB1c4QtiVJE8uJnmKWr3bGFS70n4LxCS5hxelGvLwgHXvhtdWf8wKWCR1zLh7 14/A== 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 :dkim-signature; bh=EvEqqoCYvSiaJViGsfZgvE8wYjGeg4BQWYRIZAIdYOQ=; b=HAAggNf3lRGo2mPYxXkGg47Camghht/3EeeyjRo+3nHQaOgoqhzDVjU2YcxrblnSBw +k+rWMvkbNXmPbmvc0Bk9O8AtW+ot8BsvHyURG3J950xOONThvz/xzg78YlFYA8JxYSd sqtslACBwVDNMDJrpAT337F1yolZWv4A2F8qSwgX53sdY0upP2bCTW05E04ercZHnbUT 9z/ejyK4KX++sjqByJKqs+LXrVHl44EuFA1ss4WgMQ0wbKFSqRBXwrZ9cAUZNNRZm+vB KtYbH0T2ngWsog4m7sBgcFif7HE6nle7c50dH6NUyNpOD5meKCXukjWuYj3dM2ZdMtL1 MDnA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@shutemov-name.20150623.gappssmtp.com header.s=20150623 header.b=bZcGmOHw; 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 o61si32111730plb.0.2019.07.31.11.15.37; Wed, 31 Jul 2019 11:15:52 -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; dkim=pass header.i=@shutemov-name.20150623.gappssmtp.com header.s=20150623 header.b=bZcGmOHw; 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 S1729407AbfGaPTJ (ORCPT + 99 others); Wed, 31 Jul 2019 11:19:09 -0400 Received: from mail-ed1-f68.google.com ([209.85.208.68]:33038 "EHLO mail-ed1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729160AbfGaPTE (ORCPT ); Wed, 31 Jul 2019 11:19:04 -0400 Received: by mail-ed1-f68.google.com with SMTP id i11so2556934edq.0 for ; Wed, 31 Jul 2019 08:19:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=shutemov-name.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=EvEqqoCYvSiaJViGsfZgvE8wYjGeg4BQWYRIZAIdYOQ=; b=bZcGmOHwm0gi6j5t/BbUGsKtOCIZr4doGxyXBg+bAsntyv91YXoAwS8iK8gYH/2Rhd EZoLChmRluivD3XLirlmMT5W1vFicn0Th6yRJbjlvSCthP29u5r3kvQbgKOL0NnWdm5O z6WKnsGxsng9YOVJ6s+hk1x3ysUEVhPOmeDyo07xX324wqjHjFQ9yfcsBJPs6sEkZfG/ j1P95OYBR2KAtJYWJH/9fdcbulUD7i7ZdBv1U7AlRZ5qi7KMU65oMM+umaihE2hREq1N HFgl1iVKn4xa5Uwqe5PFQO1apPGzMbp3tx+aOQoTXOpVFI0CqNnOhoaQyl+Z3LmysdM7 SIkg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=EvEqqoCYvSiaJViGsfZgvE8wYjGeg4BQWYRIZAIdYOQ=; b=UkCg8d7ZijlSYT667GRMK0qD+bBn3GKhAIzoPmcsd3hm5GlWP/h1aCjPam0NH+2i1S 9Pv4Q0FJLINVTKEYQC1heWv05mtxwTAtTpiuW7MEMMUuCsKrRU34h2+fjmWH40stHm4w WmOWBd9TgODNR49s+McV8w6CiD+VtKHJJ0V9Iov+yqBc40ExooMAKdeAXGtfM8KinV+Z 5TmXj8gDYw+MvVfF490fvd0GNj1USyTXhuOX/Z7W9GwqInOchHrHWffht7qOMQVkS7Kp mbrlnWxgowQuJXzu7g/Rfx20b8Dffwra86ByQ/32a7iw16PHfR9Ghyfn0XTgeXm/6WaI 1fRQ== X-Gm-Message-State: APjAAAVLa8YvMLj7JWEOld3Rjo4wa+7qQCYKUOG2Mbgppglx6cUcAwZi xQDu4CH+93NZsDm7fs1Qlzo= X-Received: by 2002:a17:906:4d19:: with SMTP id r25mr94272907eju.125.1564586035045; Wed, 31 Jul 2019 08:13:55 -0700 (PDT) Received: from box.localdomain ([86.57.175.117]) by smtp.gmail.com with ESMTPSA id g7sm16945101eda.52.2019.07.31.08.13.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 31 Jul 2019 08:13:53 -0700 (PDT) From: "Kirill A. Shutemov" X-Google-Original-From: "Kirill A. Shutemov" Received: by box.localdomain (Postfix, from userid 1000) id 874211030BD; Wed, 31 Jul 2019 18:08:16 +0300 (+03) 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: [PATCHv2 22/59] mm/rmap: Clear vma->anon_vma on unlink_anon_vmas() Date: Wed, 31 Jul 2019 18:07:36 +0300 Message-Id: <20190731150813.26289-23-kirill.shutemov@linux.intel.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190731150813.26289-1-kirill.shutemov@linux.intel.com> References: <20190731150813.26289-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 e5dfe2ae6b0d..911367b5fb40 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.21.0