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 79E67C4167B for ; Mon, 4 Dec 2023 16:49:01 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id F3EA86B02D0; Mon, 4 Dec 2023 11:49:00 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id EEE0C6B02D1; Mon, 4 Dec 2023 11:49:00 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D8F016B02D7; Mon, 4 Dec 2023 11:49:00 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id C7E1A6B02D0 for ; Mon, 4 Dec 2023 11:49:00 -0500 (EST) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 892F5A02BC for ; Mon, 4 Dec 2023 16:49:00 +0000 (UTC) X-FDA: 81529720440.17.E79503F Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf16.hostedemail.com (Postfix) with ESMTP id 74080180012 for ; Mon, 4 Dec 2023 16:48:58 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Il0kLUyM; spf=pass (imf16.hostedemail.com: domain of peterx@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=peterx@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1701708538; a=rsa-sha256; cv=none; b=r3b0lGyREZuYrOzkFW18iHbIPOobvNL3jBNUoME0ZAqCNgDSFaQMThJHw5LA6p5pH+7cyr PqfOit2o3OgMu/LZGJjcTUdD+Ms7/Cvkssy5c/2J5FxXTyG7tD/2YOz0RufP4HPhNuFIM/ Cu1jT85vbB3S+tSYDdGb4WIoCWe4RBQ= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Il0kLUyM; spf=pass (imf16.hostedemail.com: domain of peterx@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=peterx@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1701708538; 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=DlFD7GhwLjb9S13yNsgkI3KXvw6iVqGQQvaiU30gBvU=; b=WQ1fAMTkdLmmDappzR/gfof6UzECP6ydEbNTwwG99nPZhqNYezBuSY0W1NJVH289kfDGIQ ztb0bfHtEFHpQNQJrS+EJ3tY4rUNnMfUtBXpeR8JfR/AxH0ieaTsYtwg4cGQPstxY8utpN uRltVofcEYfXCrmd2xaj1yPThdr4EO4= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1701708537; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=DlFD7GhwLjb9S13yNsgkI3KXvw6iVqGQQvaiU30gBvU=; b=Il0kLUyM12rNafdXjZQvm82s/fpgXndxk/nOX7x4wEx9en6Yy9cXcYPsbZcAgj2GJmfJfm UeZFM+x1qbaVjLdye1j5QLqj/uHfmHJyhPi702sod4aWKdDrI8jNK/fp9uFFH+ys2zj1Sy IkjWYy7Gldug/+OOuGYG5CNDhinBAa0= Received: from mail-io1-f69.google.com (mail-io1-f69.google.com [209.85.166.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-245-3DihsqpmOE-2rgTM9xo46A-1; Mon, 04 Dec 2023 11:48:56 -0500 X-MC-Unique: 3DihsqpmOE-2rgTM9xo46A-1 Received: by mail-io1-f69.google.com with SMTP id ca18e2360f4ac-7b395875bd0so114633239f.0 for ; Mon, 04 Dec 2023 08:48:56 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701708535; x=1702313335; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=DlFD7GhwLjb9S13yNsgkI3KXvw6iVqGQQvaiU30gBvU=; b=mNZmEN/BgYNeRJPmTOIKPVzZGY7QlUUsGPGvSvvob8BYJywyYZ07Bguk8x1PNeB/gJ ZJhDHhPsXBPS/bvRs5VMJorUalaOuxFGPAQpnIN4eTgwuq+0GL0BB3NgnGSHGKgpbm9c o3MU/+/2UlIswb1DS//yVn2z/XNhI1sn/WwNgCtiuEDhFiP1hpxYVLewLVmkunqx4iZp NrkgYfUdcNIaTk+FmwRWitWt8e8A4fnTUD3dv0plwRvbDrM4+lw2prybqp024TaM5Iqu p9y+cmvsrKyXDzHpe42FMRK1DCCyRMSvVM5INsQlNjrMRymKDSeOY7rr+5pQ5Assfg52 btYg== X-Gm-Message-State: AOJu0YwlEkFEGPPcZ3HDCrKxmEqShTFrJ5dqz1yY4zgiKuEk8hASHebD aO2f1xbWwuGLpI4FOdhEXhTC/S1XtQlopQW4AShrmXh1GUVr3Z15F6ZBe9LZj2S/Et5iiXCbKMN o7G3wPEeKEC0= X-Received: by 2002:a05:6602:2245:b0:7b3:5be5:fa55 with SMTP id o5-20020a056602224500b007b35be5fa55mr32630812ioo.2.1701708535631; Mon, 04 Dec 2023 08:48:55 -0800 (PST) X-Google-Smtp-Source: AGHT+IHMbZTTWxY8DAhdNOUcz7fb265lA/l2cJEQ3I487U8F0Nm42ahY5dHXJJc8+VpefYo3r7ArvA== X-Received: by 2002:a05:6602:2245:b0:7b3:5be5:fa55 with SMTP id o5-20020a056602224500b007b35be5fa55mr32630779ioo.2.1701708535343; Mon, 04 Dec 2023 08:48:55 -0800 (PST) Received: from x1n (cpe688f2e2cb7c3-cm688f2e2cb7c0.cpe.net.cable.rogers.com. [99.254.121.117]) by smtp.gmail.com with ESMTPSA id b10-20020a02a58a000000b00463fb5dd52dsm2637378jam.57.2023.12.04.08.48.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Dec 2023 08:48:55 -0800 (PST) Date: Mon, 4 Dec 2023 11:48:52 -0500 From: Peter Xu To: Ryan Roberts Cc: Christophe Leroy , Matthew Wilcox , Christoph Hellwig , "linux-kernel@vger.kernel.org" , "linux-mm@kvack.org" , Andrea Arcangeli , James Houghton , Lorenzo Stoakes , David Hildenbrand , Vlastimil Babka , John Hubbard , Yang Shi , Rik van Riel , Hugh Dickins , Jason Gunthorpe , Axel Rasmussen , "Kirill A . Shutemov" , Andrew Morton , "linuxppc-dev@lists.ozlabs.org" , Mike Rapoport , Mike Kravetz Subject: Re: [PATCH RFC 06/12] mm/gup: Drop folio_fast_pin_allowed() in hugepd processing Message-ID: References: <510adc26-9aed-4745-8807-dba071fadbbe@arm.com> <283da12c-14f1-4255-b3c4-ab933f3373c4@csgroup.eu> <01aad92f-b1e0-4f31-b905-8b1c2012ebab@arm.com> MIME-Version: 1.0 In-Reply-To: <01aad92f-b1e0-4f31-b905-8b1c2012ebab@arm.com> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Disposition: inline X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 74080180012 X-Stat-Signature: oeeimhzopbyuny8gf63gn6xwk9hxqwkg X-Rspam-User: X-HE-Tag: 1701708538-921217 X-HE-Meta: U2FsdGVkX1/FEi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pS5no2EvVQepGHXIf9yJr016NFXmPZD2tCBtAYs8jMeUuCgC2JhgMajt58Qk/y6Pbc56WXNzhM0jNIbUxEy0RmI+Mlp0m7u8WHOpyZcrCc1fXgqFpDadMeHJq5n1rPtkYUdRvj0KEuvFRRgQ+efk1C1FlFi5+8Rp7NnRZqSI7fohHZNRjaq9ZXw4Y4acxFq0hJXyqYnThPwJUwkF7U75+QQ5eypVDvcgP8jpckXaH6CrSpd68oKn2hUqY7vBgWOxzYz2vJCwDPN8h2fh0oqqGHGMkeFy49qb8haVWStotCZoTdsUVdS+SL55goAv38ArXxp7TGM7TTltXijKoky9Lct0= 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: List-Subscribe: List-Unsubscribe: On Mon, Dec 04, 2023 at 11:11:26AM +0000, Ryan Roberts wrote: > To be honest, while I understand pte_cont() and friends, I don't understand > their relevance (or at least potential future relevance) to GUP? GUP in general can be smarter to recognize if a pte/pmd is a cont_pte and fetch the whole pte/pmd range if the caller specified. Now it loops over each pte/pmd. Fast-gup is better as it at least doesn't take pgtable lock, for cont_pte it looks inside gup_pte_range() which is good enough, but it'll still do folio checks for each sub-pte, even though the 2nd+ folio checks should be mostly the same (if to ignore races when the folio changed within the time of processing the cont_pte chunk). Slow-gup (as of what this series is about so far) doesn't do that either, for each cont_pte whole entry it'll loop N times, frequently taking and releasing the pgtable lock. A smarter slow-gup can fundamentallly setup follow_page_context.page_mask if it sees a cont_pte. There might be a challenge on whether holding the head page's refcount would stablize the whole folio, but that may be another question to ask. I think I also overlooked that PPC_8XX also has cont_pte support, so we actually have three users indeed, if not counting potential future archs adding support to also get that same tlb benefit. Thanks, -- Peter Xu