From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.2 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9EA34C33CA7 for ; Sat, 11 Jan 2020 22:38:30 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 4E9232084D for ; Sat, 11 Jan 2020 22:38:30 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4E9232084D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id AF08B8E0005; Sat, 11 Jan 2020 17:38:29 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id A77C68E0001; Sat, 11 Jan 2020 17:38:29 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 98DCC8E0005; Sat, 11 Jan 2020 17:38:29 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0044.hostedemail.com [216.40.44.44]) by kanga.kvack.org (Postfix) with ESMTP id 818D98E0001 for ; Sat, 11 Jan 2020 17:38:29 -0500 (EST) Received: from smtpin20.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with SMTP id 2EC7E181AEF00 for ; Sat, 11 Jan 2020 22:38:29 +0000 (UTC) X-FDA: 76366818738.20.bears94_2ce92bc18ad45 X-HE-Tag: bears94_2ce92bc18ad45 X-Filterd-Recvd-Size: 4805 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by imf40.hostedemail.com (Postfix) with ESMTP for ; Sat, 11 Jan 2020 22:38:28 +0000 (UTC) X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga102.jf.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 In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) Content-Transfer-Encoding: quoted-printable 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: On Fri, Jan 10, 2020 at 11:11:23AM +0300, Konstantin Khlebnikov wrote: [...] >> > > >=20 >> > > > series of vma in parent with shared AV: >> > > >=20 >> > > > SRC1 - AV0 >> > > > SRC2 - AV0 >> > > > SRC3 - AV0 >> > > > ... >> > > > SRCn - AV0 >> > > >=20 >> > > > in child after fork >> > > >=20 >> > > > DST1 - AV_OLD_1 (some old vma, picked by anon_vma_clone) plus DS= T1 is attached to same AVs as SRC1 >> > > > DST2 - AV_OLD_2 (other old vma) plus DST1 is attached to same AV= s as SRC2 >> > > > DST2 - AV1 prev AV parent does not match AV0, no old vma found f= or reusing -> allocate new one (child of AV0) >> > > > DST3 - AV1 - DST2->AV->parent =3D=3D SRC3->AV (AV0) -> share AV = with prev >> > > > DST4 - AV1 - same thing >> > > > ... >> > > > DSTn - AV1 >> > > >=20 To focus on the point, I rearranged the order a little. Suppose your foll= owing comments is explaining the above behavior. I've illustrated how two heuristics (reusing-old and sharing-prev) _co= uld_ work together. But they both are optional. =20 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. =20 If there is no old anon-vma which have to be reused then DST1 will all= ocate 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() w= ould 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 paren= t, SRC1 and SRC2 has the same anon_vma, AV0. So in child, DST1 and DST2 coul= d also share the same anon_vma, AV_OLD_1. Sorry for my poor understanding, would you mind giving me more hint on th= is change? >> > >=20 >> > > Yes, your code works for DST3..DSTn. They will pick up AV1 since >> > > (DST2->AV->parent =3D=3D SRC3->AV). >> > >=20 >> > > 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: >> > >=20 >> > > DST1 - AV1 >> > > DST2 - AV1 >> > > DST2 - AV1 >> > > DST3 - AV1 >> > > DST4 - AV1 >> > >=20 >> > > Would you mind putting more words on DST1 and DST2? I didn't fully= understand >> > > the logic here. >> > >=20 >> > > Thanks >> > >=20 >> >=20 >> > I think that the first version is doing the work as you expected, bu= t been >> > revised in second version, to limits the number of users of reused o= ld >> > anon(which=A0is picked=A0in anon_vma_clone() and keep the tree struc= ture. >> >=20 >>=20 >> Any reason to reduce the reuse? Maybe I lost some point. > >>=20 >> > > -- >> > > Wei Yang >> > > Help you, Help me >>=20 --=20 Wei Yang Help you, Help me