From patchwork Sat Feb 8 08:35:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Xinhai X-Patchwork-Id: 11371497 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 D45611398 for ; Sat, 8 Feb 2020 08:37:43 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 96C3521741 for ; Sat, 8 Feb 2020 08:37:43 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="cWjUoJQK" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 96C3521741 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 5788C6B0008; Sat, 8 Feb 2020 03:37:40 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 4FFD96B000A; Sat, 8 Feb 2020 03:37:40 -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 3038B6B000C; Sat, 8 Feb 2020 03:37:40 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0204.hostedemail.com [216.40.44.204]) by kanga.kvack.org (Postfix) with ESMTP id 193916B0008 for ; Sat, 8 Feb 2020 03:37:40 -0500 (EST) Received: from smtpin27.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 9EC26181AEF00 for ; Sat, 8 Feb 2020 08:37:39 +0000 (UTC) X-FDA: 76466306238.27.price09_89b07d9a1f12 X-Spam-Summary: 2,0,0,998a1769d0609b0a,d41d8cd98f00b204,lixinhai.lxh@gmail.com,::akpm@linux-foundation.org:kirill.shutemov@linux.intel.com:willy@infradead.org:hannes@cmpxchg.org,RULES_HIT:41:69:355:379:541:800:960:973:988:989:1260:1345:1359:1437:1534:1541:1711:1730:1747:1777:1792:2393:2559:2562:2693:3138:3139:3140:3141:3142:3353:3865:3866:3868:3870:3871:3874:5007:6261:6653:7514:7903:9413:9592:10004:11026:11658:11914:12043:12296:12297:12438:12517:12519:12555:12679:12895:12986:13069:13311:13357:14096:14181:14384:14394:14687:14721:21080:21222:21365:21444:21451:21627:21666:21740:21789:30012:30054,0,RBL:209.85.208.195:@gmail.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:none,Custom_rules:0:0:0,LFtime:24,LUA_SUMMARY:none X-HE-Tag: price09_89b07d9a1f12 X-Filterd-Recvd-Size: 4829 Received: from mail-lj1-f195.google.com (mail-lj1-f195.google.com [209.85.208.195]) by imf23.hostedemail.com (Postfix) with ESMTP for ; Sat, 8 Feb 2020 08:37:38 +0000 (UTC) Received: by mail-lj1-f195.google.com with SMTP id x14so1738130ljd.13 for ; Sat, 08 Feb 2020 00:37:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=1DOw5CbbkNYP7FwQdD8qSzaPYEShSYioAUQqNAIQfdY=; b=cWjUoJQKmZ8C3F5DtZz0Rl/lsjnzEGM5g7rKcVy06kF3hSdednyyh59sl/SrJv7RBZ pVAUhkA8AJFeSqBc0a5jWbHq0henpKU9WX29p/IMwTRN/LwLLLCoRIeUV4oRHfss/BZz HYiWQ0UkD7i1vGGgbpWaOTmJ6H5Dxi8vDl3zOMv1QaL17ldW+1etB8cPcPlkq++WiZIU T15O41gcrAShIxVyy9oOaGKMuCJPDnWqOcYuSSx8EnAobZe4WOJWL6o0oW+Vj9L+LStL bipK6SPzoFvdP/ygg3kgo+P4rM0eRPDSDwU4wtqBavmjijqDABjb/+udHcy/NpcwbYjo GZPQ== 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; bh=1DOw5CbbkNYP7FwQdD8qSzaPYEShSYioAUQqNAIQfdY=; b=jH8Li90Sna8Z23TBAxJ/GEvWIpCjBjMwbFid3TPBROSkzaGY6QrRl1tQ0c6LuCbjku TvEbubflNExUQWVHLOOU7eexmj1KB+L5CNw7k7GQsno7xhW9nXtDuAl1byxrF+MB//+6 /gfg+GG5GhbWxmmAIBsKu0+O1DlnKRcBpOH6lvmqv4TSUlca0v424fOuMEaZnKbApas4 OkvUtpM6idfoqXiqaW3lQ09lrG4KOYXy2jglxUUiHm1KW+P8fqheUYhbENQPHEMlpXXz Int67nmSsgjOmquLY7H1aa36p8ZOoHhQiQeWl/vBhz8CVPXJIFYg9qOjfcV+Fc7RUtkk FU+A== X-Gm-Message-State: APjAAAVrD+m5qZ8sOTr06KD2G4ED0iCPLIBQmlAj5TWYol3odMW8eZq5 zPMOMqJSrG6J/6M3WhsM+mfv6kBEht8= X-Google-Smtp-Source: APXvYqzwQhZbgdaSQIB6j3niKwDhCjmx+2ZxfM6IA3uZw+QqRwaqq9YsYbv6PD61L7QsopT9Dexgrg== X-Received: by 2002:a2e:884c:: with SMTP id z12mr2162198ljj.55.1581151057670; Sat, 08 Feb 2020 00:37:37 -0800 (PST) Received: from localhost.localdomain.localdomain ([131.228.2.21]) by smtp.gmail.com with ESMTPSA id n11sm2663404ljg.15.2020.02.08.00.37.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 08 Feb 2020 00:37:37 -0800 (PST) From: Li Xinhai To: linux-mm@kvack.org Cc: akpm@linux-foundation.org, "Kirill A. Shutemov" , Matthew Wilcox , Johannes Weiner Subject: [PATCH 2/3] Revert "mm/rmap.c: reuse mergeable anon_vma as parent when fork" Date: Sat, 8 Feb 2020 08:35:27 +0000 Message-Id: <1581150928-3214-3-git-send-email-lixinhai.lxh@gmail.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1581150928-3214-1-git-send-email-lixinhai.lxh@gmail.com> References: <1581150928-3214-1-git-send-email-lixinhai.lxh@gmail.com> 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: This reverts commit 4e4a9eb921332b9d1edd99f76998f99f36b195f7 In dup_mmap(), anon_vma_fork() is called for attaching anon_vma and parameter 'tmp' (i.e., the new vma of child) has same ->vm_next and ->vm_prev as its parent vma. That causes the anon_vma used by parent been mistakenly shared by child (In anon_vma_clone(), the code added by that commit will do this reuse work). Besides this issue, the design of reusing anon_vma from vma which has gone through fork should be avoided ([1]). So, this patch reverts that commit and maintains the consistent logic of reusing anon_vma for fork/split/merge vma. [1] commit d0e9fe1758f2 ("Simplify and comment on anon_vma re-use for anon_vma_prepare()") explains the test of "list_is_singular()". Fixes: 4e4a9eb92133 ("mm/rmap.c: reuse mergeable anon_vma as parent when fork") Signed-off-by: Li Xinhai Cc: Kirill A. Shutemov Cc: Matthew Wilcox Cc: Johannes Weiner --- mm/rmap.c | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/mm/rmap.c b/mm/rmap.c index b3e3819..861435b 100644 --- a/mm/rmap.c +++ b/mm/rmap.c @@ -269,19 +269,6 @@ int anon_vma_clone(struct vm_area_struct *dst, struct vm_area_struct *src) { struct anon_vma_chain *avc, *pavc; struct anon_vma *root = NULL; - struct vm_area_struct *prev = dst->vm_prev, *pprev = src->vm_prev; - - /* - * If parent share anon_vma with its vm_prev, keep this sharing in in - * child. - * - * 1. Parent has vm_prev, which implies we have vm_prev. - * 2. Parent and its vm_prev have the same anon_vma. - */ - if (!dst->anon_vma && src->anon_vma && - pprev && pprev->anon_vma == src->anon_vma) - dst->anon_vma = prev->anon_vma; - list_for_each_entry_reverse(pavc, &src->anon_vma_chain, same_vma) { struct anon_vma *anon_vma;