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=-6.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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 C0C69C43461 for ; Wed, 9 Sep 2020 13:46:21 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 18B2720639 for ; Wed, 9 Sep 2020 13:46:21 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=shutemov-name.20150623.gappssmtp.com header.i=@shutemov-name.20150623.gappssmtp.com header.b="snsjbUkl" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 18B2720639 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=shutemov.name Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 872598E0001; Wed, 9 Sep 2020 09:46:20 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 822236B005D; Wed, 9 Sep 2020 09:46:20 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 711008E0001; Wed, 9 Sep 2020 09:46:20 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0100.hostedemail.com [216.40.44.100]) by kanga.kvack.org (Postfix) with ESMTP id 5AA1A6B005C for ; Wed, 9 Sep 2020 09:46:20 -0400 (EDT) Received: from smtpin17.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 1F8B93623 for ; Wed, 9 Sep 2020 13:46:20 +0000 (UTC) X-FDA: 77243647320.17.toe43_15116bc270dd Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin17.hostedemail.com (Postfix) with ESMTP id D9EE3180D0181 for ; Wed, 9 Sep 2020 13:46:19 +0000 (UTC) X-HE-Tag: toe43_15116bc270dd X-Filterd-Recvd-Size: 6374 Received: from mail-lf1-f67.google.com (mail-lf1-f67.google.com [209.85.167.67]) by imf21.hostedemail.com (Postfix) with ESMTP for ; Wed, 9 Sep 2020 13:46:19 +0000 (UTC) Received: by mail-lf1-f67.google.com with SMTP id b12so1598702lfp.9 for ; Wed, 09 Sep 2020 06:46:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=shutemov-name.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to; bh=OFXb0fPeLozHIVk13q+oqzPm3YSyHqohd5OhKkyGBzk=; b=snsjbUklactjQNaOxCa7O3dIYtSGEg2ycGoP/cP0ENJaq6E1pxjSgNYk/K28kQk8wS DmGXJF927zgRygzhmTP2PWZdovyGVz9WpC2ykyIfltp92TUwWpJuAqdX6CSQD5TL1XNp fHOPBouWFy6DN7Q1STE438GKb73xVEyXQMaxopP/cyk3z5T5RhgwljPTCw3v0vgPPwIJ KFqpigwngqqiCjwmCxoNTc6BSnwNvwwQMOjXGB5tW+MWntbgcVer+zwxAGhhFRFfJY2Z Nuygjq+UM+c+nMm0NKfrjQ/TjObKOpgZct0cA3365yaUpMMNRKwk42YUCKvbbI4WkkrL JR/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=OFXb0fPeLozHIVk13q+oqzPm3YSyHqohd5OhKkyGBzk=; b=qtHL69N0akO885CufafB0TR53K33ujq+g4OPMzOzQjw6zIAQqUbvftNd2NdMVmiSW+ M5fGIe+bOvSlPOQ+lQ2wENtv8bMYMy25kLTZUowVPPcSuh0ni5dWzcm2UmuSJf9CQ+D7 LCW1QzYhiVh57/6HPH8jeP+G5V2VIKYWhYfekgvvQW48UiwTQ2UazG3Wko6kMY6amtm4 UevqKKCJS4QjBvnbSPDRtMlA3/70+VVytLpQOF2iQkzzBbe8Fp2/hIKXU5rG+6bKanIC Yurn2gyLaPdy/rBWq/qp3gwgnH58zV/m23aTl5I/+Dd9pknEdU6eHgXoL4gIhUdzozmq ta2w== X-Gm-Message-State: AOAM533dy0YTscIOXfefyGTlWksq24/Pbdj13kCh47yU29VnTbVSh3we m5qW7+Rhzk6uh9iMNs1VerLfCg== X-Google-Smtp-Source: ABdhPJyTk4108hBQZgn/Y4gNdjt/2DgtafCRGGwNLgK9b1ovUuZLK9iu9GKM7+vEJY6b23OBMrgy6Q== X-Received: by 2002:a19:8907:: with SMTP id l7mr1931403lfd.105.1599659177768; Wed, 09 Sep 2020 06:46:17 -0700 (PDT) Received: from box.localdomain ([86.57.175.117]) by smtp.gmail.com with ESMTPSA id w4sm584720lfq.75.2020.09.09.06.46.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Sep 2020 06:46:17 -0700 (PDT) Received: by box.localdomain (Postfix, from userid 1000) id 338DA1036AE; Wed, 9 Sep 2020 16:46:22 +0300 (+03) Date: Wed, 9 Sep 2020 16:46:22 +0300 From: "Kirill A. Shutemov" To: Zi Yan Cc: linux-mm@kvack.org, Roman Gushchin , Rik van Riel , "Kirill A . Shutemov" , Matthew Wilcox , Shakeel Butt , Yang Shi , David Nellans , linux-kernel@vger.kernel.org Subject: Re: [RFC PATCH 01/16] mm: add pagechain container for storing multiple pages. Message-ID: <20200909134622.xkuzx5nf4xq2vudh@box> References: <20200902180628.4052244-1-zi.yan@sent.com> <20200902180628.4052244-2-zi.yan@sent.com> <20200907122228.4zlyfysdul3s62me@box> <50FA95D1-9222-48C0-9223-C1267E8C7A4A@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <50FA95D1-9222-48C0-9223-C1267E8C7A4A@nvidia.com> X-Rspamd-Queue-Id: D9EE3180D0181 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam02 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 Mon, Sep 07, 2020 at 11:11:05AM -0400, Zi Yan wrote: > On 7 Sep 2020, at 8:22, Kirill A. Shutemov wrote: >=20 > > On Wed, Sep 02, 2020 at 02:06:13PM -0400, Zi Yan wrote: > >> From: Zi Yan > >> > >> When depositing page table pages for 1GB THPs, we need 512 PTE pages= + > >> 1 PMD page. Instead of counting and depositing 513 pages, we can use= the > >> PMD page as a leader page and chain the rest 512 PTE pages with ->lr= u. > >> This, however, prevents us depositing PMD pages with ->lru, which is > >> currently used by depositing PTE pages for 2MB THPs. So add a new > >> pagechain container for PMD pages. > >> > >> Signed-off-by: Zi Yan > > > > Just deposit it to a linked list in the mm_struct as we do for PMD if > > split ptl disabled. > > >=20 > Thank you for checking the patches. Since we don=E2=80=99t have PUD spl= it lock > yet, I store the PMD page table pages in a newly added linked list head > in mm_struct like you suggested above. >=20 > I was too vague about my pagechain design for depositing page table pag= es > for PUD THPs. Sorry about the confusion. Let me clarify why > I am doing this pagechain here too. I am sure there would be > some other designs and I am happy to change my code. >=20 > In my design, I did not store all page table pages in a single list. > I first deposit 512 PTE pages in one PMD page table page=E2=80=99s pmd_= huge_pte > using pgtable_trans_huge_depsit(), then deposit the PMD page to > a newly added linked list in mm_struct. Since pmd_huge_pte shares space > with half of lru in struct page, we cannot use lru to link all PMD > pages together. As a result, I added pagechain. Also in this way, > we can avoid these things: >=20 > 1. when we withdraw the PMD page during PUD THP split, we don=E2=80=99t= need > to withdraw 513 page, set up one PMD page, then, deposit 512 PTE pages > in that PMD page. >=20 > 2. we don=E2=80=99t mix PMD page table pages and PTE page table pages i= n a single > list, since they are initialized in different ways. Otherwise, we need > to maintain a subtle rule in the single page table page list that in ev= ery > 513 pages, first one is PMD page table page and the rest are PTE page > table pages. >=20 > As I am typing, I also realize that my current design does not work > when PMD split lock is disabled, so I will fix it. I would store PMD pa= ges > and PTE pages in two separate lists in mm_struct. >=20 >=20 > Any comments? Okay, fair enough. Although, I think you can get away without a new data structure. We don't need double-linked list to deposit page tables. You can rework PTE tables deposit code to have single-linked list and use one pointer of ->lru (wit= h proper name) and make PMD tables deposit to use the other one. This way you can avoid conflict for ->lru. Does it make sense? --=20 Kirill A. Shutemov