Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp2332925ybl; Sat, 11 Jan 2020 14:43:39 -0800 (PST) X-Google-Smtp-Source: APXvYqxIrvxkKkjfjlOvCD5RZz5Gcvkhuc5G+UJZCKmZ8UEk0GYd0IaNUVtVOPopUMikIMfETlHU X-Received: by 2002:a9d:7e99:: with SMTP id m25mr7731536otp.212.1578782618949; Sat, 11 Jan 2020 14:43:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578782618; cv=none; d=google.com; s=arc-20160816; b=Aopgarz2ENxYVId71ytT4U6ZVpKThpnSCaQ6uxS45y3A7hNa99oBWQIYC2wY0YVsmE oqE25KhP4fFpTO/vCO4nQDMx/mO7fJPCLLVJM51Y085QEZDwEkVuILd/Lh+79r9JERPn C9VQKQiBMh2xQiYJ9qxuyKb/BeWIhWf4Nnw+zdEPuk0iH9W4z+hAa9wiiMMKCj9TidXQ lvEmCa8/1e8AwB1bWY7ll3qEHWx8FDSavGvvpGHWHBwolev7UtIgK6LciTkU0GoY3oLH TyAWOSxI7AE0vHxSSLqvQTFO2PvJBxUVwqniAJQnd1ONCpouHtvhrF/ejf/tO1wxXObI EmvQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:reply-to:message-id:subject:cc:to:from:date; bh=3dPumPYOvx6eM+329svPtSe+9nWte//uuUZzRd+UUoo=; b=qFe0eqwGabZq28iW0svXidN5KXfC9VdYM5NgCoAWa0eawPIh9ZZ4x9fpiag3ig4MWr 4VdC60KjUZbwggPw5iO7tg9gLSxxQesxd64A6NzJ5KkWz2DgckTe5Zrdd5hgKsndMWxc wcfO2kgWUtzAQlVzjgwXJahTcARoWgjzplIikJpBovKIxQWikEXYA1p52G8dp7DyNQQX BLgiPgFrKxovkvi6VSNTRPdvpv95SQuOO/X4LP2yRM1R32pCmUeEcO67/gmyzf0xMZ6i luQFjz+tSVPfkoVRp4MBqfMse6AZ+H/q8rvU5IvtqPGzQvDcn8brh9OSL5WCWKLbZYPT oYzw== 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 11si4605157otu.301.2020.01.11.14.42.55; Sat, 11 Jan 2020 14:43:38 -0800 (PST) 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 S1731575AbgAKWi1 (ORCPT + 99 others); Sat, 11 Jan 2020 17:38:27 -0500 Received: from mga17.intel.com ([192.55.52.151]:24099 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731372AbgAKWi1 (ORCPT ); Sat, 11 Jan 2020 17:38:27 -0500 X-Amp-Result: UNSCANNABLE X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 11 Jan 2020 14:38:26 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.69,422,1571727600"; d="scan'208";a="224535091" Received: from richard.sh.intel.com (HELO localhost) ([10.239.159.54]) by orsmga003.jf.intel.com with ESMTP; 11 Jan 2020 14:38:24 -0800 Date: Sun, 12 Jan 2020 06:38:20 +0800 From: Wei Yang To: Konstantin Khlebnikov Cc: Wei Yang , Li Xinhai , "linux-mm@kvack.org" , akpm , "linux-kernel@vger.kernel.org" , Rik van Riel , "kirill.shutemov" Subject: Re: [PATCH v2 1/2] mm/rmap: fix and simplify reusing mergeable anon_vma as parent when fork Message-ID: <20200111223820.GA15506@richard> Reply-To: Wei Yang References: <157839239609.694.10268055713935919822.stgit@buzz> <20200108023211.GC13943@richard> <20200109025240.GA2000@richard> <20200110023029.GB16823@richard> <20200110112357351531132@gmail.com> <20200110053442.GA27846@richard> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jan 10, 2020 at 11:11:23AM +0300, Konstantin Khlebnikov wrote: [...] >> > > > >> > > > series of vma in parent with shared AV: >> > > > >> > > > SRC1 - AV0 >> > > > SRC2 - AV0 >> > > > SRC3 - AV0 >> > > > ... >> > > > SRCn - AV0 >> > > > >> > > > in child after fork >> > > > >> > > > DST1 - AV_OLD_1 (some old vma, picked by anon_vma_clone) plus DST1 is attached to same AVs as SRC1 >> > > > DST2 - AV_OLD_2 (other old vma) plus DST1 is attached to same AVs as SRC2 >> > > > DST2 - AV1 prev AV parent does not match AV0, no old vma found for reusing -> allocate new one (child of AV0) >> > > > DST3 - AV1 - DST2->AV->parent == SRC3->AV (AV0) -> share AV with prev >> > > > DST4 - AV1 - same thing >> > > > ... >> > > > DSTn - AV1 >> > > > To focus on the point, I rearranged the order a little. Suppose your following comments is explaining the above behavior. I've illustrated how two heuristics (reusing-old and sharing-prev) _could_ work together. But they both are optional. At cloning first vma SRC1 -> DST1 there is no prev to share anon vma, thus works common code which _could_ reuse old vma because it have to. If there is no old anon-vma which have to be reused then DST1 will allocate new anon-vma (AV1) and it will be used by DST2 and so on like on your picture. I agree with your 3rd paragraph, but confused with 2nd. At cloning first vma SRC1 -> DST1, there is no prev so anon_vma_clone() would pick up a reusable anon_vma. Here you named it AV_OLD_1. This looks good to me. But I am not sure why you would picked up AV_OLD_2 for DST2? In parent, SRC1 and SRC2 has the same anon_vma, AV0. So in child, DST1 and DST2 could also share the same anon_vma, AV_OLD_1. Sorry for my poor understanding, would you mind giving me more hint on this change? >> > > >> > > Yes, your code works for DST3..DSTn. They will pick up AV1 since >> > > (DST2->AV->parent == SRC3->AV). >> > > >> > > My question is why DST1 and DST2 has different AV? The purpose of my patch >> > > tries to make child has the same topology and parent. So the ideal look of >> > > child is: >> > > >> > > DST1 - AV1 >> > > DST2 - AV1 >> > > DST2 - AV1 >> > > DST3 - AV1 >> > > DST4 - AV1 >> > > >> > > Would you mind putting more words on DST1 and DST2? I didn't fully understand >> > > the logic here. >> > > >> > > Thanks >> > > >> > >> > I think that the first version is doing the work as you expected, but been >> > revised in second version, to limits the number of users of reused old >> > anon(which?is picked?in anon_vma_clone() and keep the tree structure. >> > >> >> Any reason to reduce the reuse? Maybe I lost some point. > >> >> > > -- >> > > Wei Yang >> > > Help you, Help me >> -- Wei Yang Help you, Help me