Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp2838447rdb; Mon, 4 Dec 2023 08:49:10 -0800 (PST) X-Google-Smtp-Source: AGHT+IHbK8ZhAa2HDlcIoMMWm5XJOgyvunU5Qb2zfDOH4puDOaJ5mrTuXfh4DUk4DmmxPc7TlqJ6 X-Received: by 2002:a17:902:e802:b0:1d0:acf7:833c with SMTP id u2-20020a170902e80200b001d0acf7833cmr1342025plg.26.1701708549687; Mon, 04 Dec 2023 08:49:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701708549; cv=none; d=google.com; s=arc-20160816; b=DJL0JG2Oc0loJSB7tdOB5519L7J2yTAdIDdv/PSK8nB7Dro0f/82bnrkqGq3cqGBw7 5jrKO++5SHw17E/fOhxJc0sEzTvz5sUjPekJWQeo60Q4l43YZuN5oaXStq3nI82JuIdw nkJ+qZobxKOXsupXtcreRtGWsF/f2V4fYHl+4/VGdHqnvE5iZvL50PnpcEhakSzqt9xQ MuTvuECWFKwRGm5hijGD6KYGNAcL64F5SQUn7d2+kyVypmkSexqKamntYst+RsVAVu0Y Q+W4+vPiQNXEM3GTZ5l3IbVhO9RZnJuSRAOND6G0sWDIut2bp0uWwU80o2hAGKFaJUZI 05aA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=DlFD7GhwLjb9S13yNsgkI3KXvw6iVqGQQvaiU30gBvU=; fh=cOH4/HPCyy2fRPLQ0cSUnpJMjf5GFtISZWiMStWdWuE=; b=iLhIDqgdcL6va8PmLxtfPjuLHPl2tAU+FCmUmkkzoeA77Lw/kky7aAxxZ2S2c2NxT5 shILB3TnKrNe9xEnVeWM56j/0MoRWlMo/T5H33bcu3gden5fkZgPBgSIz73TZzY1PniY LWKrPhu/tgrwi6MfBjes9sYHPNwO8jssaGpt4tWuYXuOSkIdkuCayWYYyuW3uXFVef1E S4yhAkHS5uOBHA9jlFipBPCjp0l5VQSVh98UwZV9iOzraeBfLT+AuZBmZsrMi1Y6tHuN wvqT7Vn+viJImOE9BigVG1quRFAfshm4lXbOOkpnY2LV7DgUK3iaMEP3b11p7JC6OJB7 HODA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Il0kLUyM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id p18-20020a170902ead200b001d06d410ea0si4373614pld.448.2023.12.04.08.49.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Dec 2023 08:49:09 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Il0kLUyM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 4558B80A4A2E; Mon, 4 Dec 2023 08:49:07 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230333AbjLDQsx (ORCPT + 99 others); Mon, 4 Dec 2023 11:48:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51532 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229513AbjLDQsw (ORCPT ); Mon, 4 Dec 2023 11:48:52 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A1153AC for ; Mon, 4 Dec 2023 08:48:58 -0800 (PST) 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-235-yFlc80ULO6GoJA8YRmdZJw-1; Mon, 04 Dec 2023 11:48:56 -0500 X-MC-Unique: yFlc80ULO6GoJA8YRmdZJw-1 Received: by mail-io1-f69.google.com with SMTP id ca18e2360f4ac-7b395875bd0so114632839f.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=XerfXk07deeAwk4eSlc8dKirzrPXUUqV1KydC7omfCMBDuA/yo/yiCvWJ9vDtVJRuC wc1D8kVe+hVtgozWDm+n1HAHNEquNYU9tgOBicKDr51GoIyg786tBPOOgsLZIviT0gLr ota38/0xe4ItAvktra83kH1YuNUftE9wGKykz2RWW1Q1tcmanuPb6C7nvFtVLr1zNPfW k5e0P3dNgyPHRIvLBKILl8F3v43WjeMqH7gsnTdrAD3xgHnGrJut1gGxOp3bRfKtoguz aJWy6glBmwjd5h58wU7kweTj2dEgEOe/XYfgWTS7EQimkzj1tZU8Zjy7RX1dafLMDqlx a0nA== X-Gm-Message-State: AOJu0Yxo8DaOmbARQ+ypd0E3x4MtH0+8XZGsFlbECK9YLJOV5brt8Jjy yyB4VKbu6VjZQlN4R0TdjfAauNI/FvJzn6mU8ntr5cdZ4QQNpFw/+mEM1N5MWOw2ad5o0PwdcNW W7iBS4K/8IxKO6Rd3cQ77LpHw X-Received: by 2002:a05:6602:2245:b0:7b3:5be5:fa55 with SMTP id o5-20020a056602224500b007b35be5fa55mr32630809ioo.2.1701708535613; Mon, 04 Dec 2023 08:48:55 -0800 (PST) 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 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <01aad92f-b1e0-4f31-b905-8b1c2012ebab@arm.com> X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Mon, 04 Dec 2023 08:49:07 -0800 (PST) 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