Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp1953095rwp; Thu, 13 Jul 2023 20:53:37 -0700 (PDT) X-Google-Smtp-Source: APBJJlFb/US2X65yvI/k9GDbIr5KF07JfVmuKaq97093kIVTCjsKIGhr+iDRlOxH7mPu+T6j5uaL X-Received: by 2002:ac2:46f7:0:b0:4f8:6ac1:15a9 with SMTP id q23-20020ac246f7000000b004f86ac115a9mr2384929lfo.31.1689306817449; Thu, 13 Jul 2023 20:53:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689306817; cv=none; d=google.com; s=arc-20160816; b=0g5sB5vefCPJS0fyKlVC2A7jKyp/qcSruZKrEKrP9c/UJu1Jwx8IR2d5RAp+mgY0tj djZgsvMsZ+6Z/PtCckgKr6i+qMxeww4UXWx8YAyrxcTAWjAK52mt9nVFsOIPOCMROrBh dVgZDuc99CE8V6hfeKQCBrdNbhPuQFxcPkiZJLPHEnE2Cv5Ff3xMHIkuyv1dCxOKHT99 04WhBSgYeKQWBySX6MqVCmDYA/V6XUrwJwBOSXBfAcNR1gk52gkxoJBnJGjFokWpm1Vw mTwggW0eecLP8PU/ZZ9KJyCTiAiavx6wRORvqCSzCfaBH5qW8rVrCdvEaMcqnumvL9bY GgIQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:message-id:in-reply-to :subject:cc:to:from:date:dkim-signature; bh=oq/iXCZ6KBuSs0qXrz+U2H8YMEBCPe12P27Wd/t5wvc=; fh=uRK5UwnY06uc39RBj05Nqd+IBJbAThlKGoxTRmo5xbM=; b=KCAZbtC/0ZUyfz/ZV220yFkQwZhWlEQe1ap1ZkjzWp/u6eY178IrXqtJlhRR9KLZpW TkTu7bvNqkT14d/GBheH+oYxRMob0wKhlzL4uGxbGOSBkbuZqunbVI9/JoqfIOd0LiC6 kVjVMEEHxNGfa7jYkm7+MmxdoSZr4fncjnVZpftaOwSUY9j6Y9KzSk3i7CrMKL6Oag2S RB9SJM9t589HWdlxAiaqRje28OMbu3nH4o+xud6MStiAh0tnTy12Edl1anMwBhIaqdho kmG0uaYA7UJr/2mQhC13TGEiI4oIGpISbezv6b9vsMZpRO6aVbSMR6DM0r8vJzUeapua mLPA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=o3Z1SICc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k5-20020aa7c385000000b0051da4f1bea9si2200870edq.383.2023.07.13.20.53.13; Thu, 13 Jul 2023 20:53:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=o3Z1SICc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234868AbjGNDll (ORCPT + 99 others); Thu, 13 Jul 2023 23:41:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49830 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234638AbjGNDli (ORCPT ); Thu, 13 Jul 2023 23:41:38 -0400 Received: from mail-yw1-x1134.google.com (mail-yw1-x1134.google.com [IPv6:2607:f8b0:4864:20::1134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7AF7126B1 for ; Thu, 13 Jul 2023 20:41:37 -0700 (PDT) Received: by mail-yw1-x1134.google.com with SMTP id 00721157ae682-5728df0a7d9so13225067b3.1 for ; Thu, 13 Jul 2023 20:41:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1689306096; x=1691898096; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:from:to:cc:subject:date:message-id:reply-to; bh=oq/iXCZ6KBuSs0qXrz+U2H8YMEBCPe12P27Wd/t5wvc=; b=o3Z1SICcLfLUodojhbg3ISOh4AV/GyLrGNzS8WFcFZFq1OnoCboClgPujTMXC1QJVk vqxB4X6zsRYAfNbjFHnRCL4o8KlZk6pKagsB4qdc2mJWLnSnsGh0/Wo5cOgoB3yA+ct+ 4+bhTMk2x1DESdgo7Mb2v52449B8GyfgHykmJ4siVab/Isy1Qi+QXtqL+0IDiLFjTP+G RESjESxnYIyUua0j0CiARuSjN9Hd5KOhsY1aUV1/lBzQWxnLnxJvugs9RpeacUof642p 3zmlclskYlGaqSVt0vSnDT75PQXZJ6jWqlXwI5lIexSvsNIO7kSGJpfoqGIn01WmW5G4 HEDQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689306096; x=1691898096; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=oq/iXCZ6KBuSs0qXrz+U2H8YMEBCPe12P27Wd/t5wvc=; b=kyZPbRtDJJlEMaAQ9diGvPTlm7UL2dVCpjmtCNTkii0el3gX11V334V8cesGLyi7x+ dS5f5KEXWCnHMxg2lU446HdRRJkmOe+d7rAC5hPOKFjHdI1RSLAjDUWPburvBTWm227a gGZyZzJeYkSUj5hO4aUSBuPIdl+lb/+2IzwX5CbGGK+j5Gs3xtF1WjZ9OHIB44ECp6wb n3P/sX4LRY0HT0AAnAILSwkuLdZh4pxAXbVZc6PjipZgnBoYQpGWucrk3wXO2giNnAte rXucy2b40/iRUlQQzQO7acYbpGUgzSVCTRb49w5xdmgTaw3dKs82P1rJMNSAzflEwU8I wWtQ== X-Gm-Message-State: ABy/qLa4zclg+CQkX+6yV2CmukfY2qioO5+CHTtQTlo1TUQuEcoABq4O n2+OOyH74TdA8yazhPAVyDp4hQ== X-Received: by 2002:a0d:d44c:0:b0:57a:89b1:2c73 with SMTP id w73-20020a0dd44c000000b0057a89b12c73mr3569828ywd.5.1689306096607; Thu, 13 Jul 2023 20:41:36 -0700 (PDT) Received: from ripple.attlocal.net (172-10-233-147.lightspeed.sntcca.sbcglobal.net. [172.10.233.147]) by smtp.gmail.com with ESMTPSA id t81-20020a0dea54000000b0056ffca5fb01sm2124142ywe.117.2023.07.13.20.41.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Jul 2023 20:41:36 -0700 (PDT) Date: Thu, 13 Jul 2023 20:41:26 -0700 (PDT) From: Hugh Dickins X-X-Sender: hugh@ripple.attlocal.net To: "Yin, Fengwei" cc: Hugh Dickins , Yu Zhao , linux-mm@kvack.org, linux-kernel@vger.kernel.org, akpm@linux-foundation.org, willy@infradead.org, david@redhat.com, ryan.roberts@arm.com, shy828301@gmail.com Subject: Re: [RFC PATCH v2 2/3] mm: handle large folio when large folio in VM_LOCKED VMA range In-Reply-To: Message-ID: <7e21e99-8f8a-6f31-601c-a73ad6a0e87f@google.com> References: <20230712060144.3006358-1-fengwei.yin@intel.com> <20230712060144.3006358-3-fengwei.yin@intel.com> <6cc5a915-a28c-983f-9b32-6040f033970b@intel.com> <6573e671-62e-b7b9-1aae-64336c32bf1@google.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="-1463760895-479918679-1689306096=:4447" X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. ---1463760895-479918679-1689306096=:4447 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: QUOTED-PRINTABLE On Fri, 14 Jul 2023, Yin, Fengwei wrote: > On 7/14/2023 10:21 AM, Hugh Dickins wrote: > > On Wed, 12 Jul 2023, Yin Fengwei wrote: > >> On 7/12/23 14:23, Yu Zhao wrote: > >>> On Wed, Jul 12, 2023 at 12:02=E2=80=AFAM Yin Fengwei wrote: > >>>> --- a/ > >>>> +++ b/mm/internal.h > >>>> @@ -643,7 +643,8 @@ static inline void mlock_vma_folio(struct folio = *folio, > >>>> * still be set while VM_SPECIAL bits are added: so ignor= e it then. > >>>> */ > >>>> if (unlikely((vma->vm_flags & (VM_LOCKED|VM_SPECIAL)) =3D=3D= VM_LOCKED) && > >>>> - (compound || !folio_test_large(folio))) > >>>> + (compound || !folio_test_large(folio) || > >>>> + folio_in_range(folio, vma, vma->vm_start, vma->vm_end))) > >>>> mlock_folio(folio); > >>>> } > >>> > >>> This can be simplified: > >>> 1. remove the compound parameter > >> Yes. There is not difference here for pmd mapping of THPs and pte mapp= ings of THPs > >> if the only condition need check is whether the folio is within VMA ra= nge or not. > >> > >> But let me add Huge for confirmation. > >=20 > > I'm not sure what it is that you need me to confirm: if the folio fits > > within the vma, then the folio fits within the vma, pmd-mapped or not. > Sorry. My bad. I should speak it out for what I want your confirmation: > Whether we can remove the compound and use whether folio is within > VMA instead. >=20 > I suppose you answer is Yes. Yes (if it all works out going that way). >=20 > >=20 > > (And I agree with Yu that it's better to drop the folio_test_large() > > check too.) > My argument was folio_test_large() can filter the normal 4K page out so > it doesn't need to call folio_in_range() which looks to me a little bit > heavy for normal 4K page. And the deal was move folio_test_large() > to folio_in_range() like function so simplify the code in caller side. I realized that, but agree with Yu. It looked a little over-engineered to me, but I didn't spend long enough looking to understand why there's folio_within_vma() distinct from folio_in_range(), when everyone(?) calls folio_in_range() with the same arguments vma->vm_start, vma->vm_end. >=20 > >=20 > > This idea, of counting the folio as mlocked according to whether the > > whole folio fits within the vma, does seem a good idea to me: worth > > pursuing. But whether the implementation adds up and works out, I > > have not checked. It was always difficult to arrive at a satisfactory > > compromise in mlocking compound pages: I hope this way does work out. > This is the purpose of this patch. :). Thanks. >=20 >=20 > Regards > Yin, Fengwei >=20 > >=20 > > Hugh ---1463760895-479918679-1689306096=:4447--