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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2E614EB64DA for ; Fri, 14 Jul 2023 03:41:41 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C2229900017; Thu, 13 Jul 2023 23:41:40 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BAB9D900002; Thu, 13 Jul 2023 23:41:40 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A25A6900017; Thu, 13 Jul 2023 23:41:40 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 8DFC4900002 for ; Thu, 13 Jul 2023 23:41:40 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 5E0BB404BB for ; Fri, 14 Jul 2023 03:41:40 +0000 (UTC) X-FDA: 81008817960.07.5C21117 Received: from mail-yw1-f180.google.com (mail-yw1-f180.google.com [209.85.128.180]) by imf02.hostedemail.com (Postfix) with ESMTP id 8C9FE80009 for ; Fri, 14 Jul 2023 03:41:37 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=o3Z1SICc; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf02.hostedemail.com: domain of hughd@google.com designates 209.85.128.180 as permitted sender) smtp.mailfrom=hughd@google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1689306097; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=oq/iXCZ6KBuSs0qXrz+U2H8YMEBCPe12P27Wd/t5wvc=; b=ZQp94A3LAdldh4zzC8QlcguBUFPIrSkjAvpY/MpfgR54c71EEqAbtMlKLULDztD8Uy8SVO K+kcfCM9gLr1ldfsVzXhj8QRYTt8N9nS2oK9vOEUReziL89llzlzBpJOQmEtYXkgkE99xZ p94/Ybn9w6UHxvEnns0O7Qg0CCW04rk= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=o3Z1SICc; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf02.hostedemail.com: domain of hughd@google.com designates 209.85.128.180 as permitted sender) smtp.mailfrom=hughd@google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1689306097; a=rsa-sha256; cv=none; b=s8aKr4pYgDxPpoYBulwlPqE9CSFcdyyupbaWzIarXLEq+LigK8BB9Ii0nUmFZUOPSTCkNL 7dg5hQ/QkNT3Q/IVeCvX1CNhus0nS6GnHbiB60k4GvK9xY9TBpPMYdGF0l5OknNjsHso8B IoEpL6x/k4jkI2fUSUrVMH2Q5g8qXsw= Received: by mail-yw1-f180.google.com with SMTP id 00721157ae682-57a551ce7e9so13189507b3.3 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=ezcsKDqM6DmEssljcr+CglwaMFfSZP0JGVjYHFYOOXnzVMbIPx+pg98+otlZZGd0La IXN5VL4PV2r+EEvXf/5fgjeI2nWA1OmuV40ADI16iTj+19BD5CDQ2Px+cGUltT1NSTEK Oav4AFCSHo0ePevcRTB+dBP2COruLMbxFVwUaq4Vgq+jxrkv151w9akWB2KmkQPYPqQZ NMYMEemu4YE9lCq++neMmQtgTthbJTXuasWiYqMaRjHSVzinXzPjK2RZhvCi7LTdq8pr YL7GoAdI/T393jlv+kDs75wu2NgWWkeIZdKfZzq4/cttcKJZIklxx65QYyN220UBuBQI ogTw== X-Gm-Message-State: ABy/qLa6r0DYpTrnCq3Vf9X28VgrSF+DujBG63N1+pjpy+gnX6dtGO5x 4sKkjQBCaUsK1UaYTXYsPMcrpQ== X-Google-Smtp-Source: APBJJlGaEUzgokNEht6uVJFioRuyVpfaqJG0CEeNs/swISJ3GMh5mJobkuEsIPpFLI6niKKhFr5VhQ== 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-Rspamd-Queue-Id: 8C9FE80009 X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: qrst7ah5or1t98x5o6q4c397yn78kzg7 X-HE-Tag: 1689306097-556934 X-HE-Meta: U2FsdGVkX18JUmfzPshl0HC5S2ErGnriTeeIWAkUbJCTsKGfoIxfbjPimQHRu6n/o2eOrun5OPBpCl98B6LfZux0IbqHRADJLvVsUv5dUxl5rToE/ETVG9IHStsvSKe5zcBaa/rYigRwl+v47Lwn7V1QPqcNh8C54FHgNp5VTorJNFEXMgz1oU3IZV9mUbyILHmgVrql5W64hw73C9pCh6lPjv8CtTjLNCgYX+oZhMsRKkWehx6eC2OT4Ojsir28JqoJWM1TlEKztAKEDs01vR6qDbeff5A/XreG8WpZWbn8ks2Vnce8Z+fdIGbhWG6PyIF00qKQUZdOwtukb08kZgYi/qhQu5L5TuxOUkb+TlG5rl8ANYRC2/0JfphWKriWhYxupU1tPitrcPU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A3Gk4eROLWYvm1oOyA+eoKziZgt 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 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--