Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2903794rwd; Wed, 14 Jun 2023 08:42:23 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7HU6NoD8hYu6HkcL3hGs19sDJDe0GCVHOct4wdJBytbHAQAvnlF1fmwsffLiIFqzRoSlSv X-Received: by 2002:a17:902:f547:b0:1b3:c3ca:1513 with SMTP id h7-20020a170902f54700b001b3c3ca1513mr10586583plf.65.1686757343231; Wed, 14 Jun 2023 08:42:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686757343; cv=none; d=google.com; s=arc-20160816; b=VkcmPvgXQ/2CRKNcU+WnX+8kfBceURlyaUlHGfOhu5EWFjhHg+Jo/5OMmRi2w3H0P5 Ilak0Z20H276nDktvt00zeBB69CHoUbNiV0wsywSWhN51YC3HyWxbuFKKDjepSOzHDpt tvwtgqHNvHbZUTKmql5n5qcbFQ030tFAjq0bjYE3abMvCopC4K0v00S5H72/cpNKs5sz ZupKAvCXxfBgWXfRx+xb54OHV2kIWfNdhbSEG1kWx1Scp+/IdXB5tibyn/K8KIQwy1mp M/O4oov622ujGbgCdd+HpHQ69xYBEPM/JZfu8c5JMWmd27xHVj0jKHMiaBMKJUcWBOnj F1mA== 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=sEIN0Smv09A3v1esQkaZzNJnVZHbG2zMXf43EwatZAA=; b=zmEzLV8E54k9lU5EOkubbLpQxpIQ6mO/qyPwFJP+O+xTa7Bxg2ypmrZRDLmv/cAqLE q5R+siLx8U1W+5CNixk2ht5cxRNl9HrQ5+an9tsfI59M1XBq4iiLxn+lgouaUrVtjh6J J1gcB0LYah5IkZZ6aXr6Q7EdsAQFD2RP/bu3g1HMER3UN4e6fTBson1KWKbLepRnJuQy 0dI0P1XHmlvfLdH91Vk6igIrWy68RSX+diKsk96s17dOs+2oZIGNWspy2LeZ+rvQMNPc TN6DwDUi1lF/2L7ytkb9cDQEnUDB17uAMO1KmfBkcGcVCagX/xkfcfSfAS3nhIogay3U nmZg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Cb9MeLNj; 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=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id lk15-20020a17090308cf00b001a92875cda9si10571392plb.288.2023.06.14.08.42.10; Wed, 14 Jun 2023 08:42:23 -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=@redhat.com header.s=mimecast20190719 header.b=Cb9MeLNj; 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=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343721AbjFNPUm (ORCPT + 99 others); Wed, 14 Jun 2023 11:20:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58394 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343726AbjFNPUh (ORCPT ); Wed, 14 Jun 2023 11:20:37 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E03F51A3 for ; Wed, 14 Jun 2023 08:19:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1686755993; 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=sEIN0Smv09A3v1esQkaZzNJnVZHbG2zMXf43EwatZAA=; b=Cb9MeLNjfiuGSuuWFDIBDZ+/mVXIAXfICw8iPAAiEXiL4ArHsQEM8J6jqyhiSNtwp09vjv 1du8mHe+cmcaw4uan8cDtPYdNd0WkMm/XP3ZFbLIH6qjwT/3u54yhoJozZsSpA2WIImboH iD41sGzylr7lPlkDTygTKEWtLzwxvCQ= Received: from mail-qv1-f69.google.com (mail-qv1-f69.google.com [209.85.219.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-478-mRllwUJgMWOeydXGoMMwCw-1; Wed, 14 Jun 2023 11:19:52 -0400 X-MC-Unique: mRllwUJgMWOeydXGoMMwCw-1 Received: by mail-qv1-f69.google.com with SMTP id 6a1803df08f44-62de85c6862so7838186d6.1 for ; Wed, 14 Jun 2023 08:19:51 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686755991; x=1689347991; 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=sEIN0Smv09A3v1esQkaZzNJnVZHbG2zMXf43EwatZAA=; b=GlYPyp8A3JJ7vp3ZexMWj9E2qMmNZwht+71BV9dYgEReIyLoIvP6fnl1zr1aO5HUlp fYA+dP3YLpbNLOZ4x9cVO0bi+24at3UZHbW6v5M0y2eXpP1ilEv0nb3799cv/6aarm85 8qPsFOKzx0nGU/Y7mRROEL1/cHWPyvVaxLClftjK3Dp/rrZhHZCOyykP5slQr7G/77Uc PmGSWwHFAH8xoBYAES+La6fneRIMQwDxTu0t8m/5D6gdfnsV6JX7n5NzjbJJiE7qaG4U 0gdsCNA70oMAa/dmFmyf7tI9CfZR7dpmckgY59XQQMMrZkskkpbMOswUynDu17eqArEl vrBQ== X-Gm-Message-State: AC+VfDyH0B+T5irUTZ3l+kMOC/MrG5ij5ar8C0Ff8MR8RGDF3Z/J93ii t/ggvD02w/pheBpLKhZD7os3LI93zeNbqMQbMHOMCinsg6Ai+XasPgM5M9IMXMOSaEpuBXTjDH1 DgSUuUfK06cgT60pEUjKLjG/IvHr/BC/D X-Received: by 2002:a05:6214:29ec:b0:62d:fc81:44fc with SMTP id jv12-20020a05621429ec00b0062dfc8144fcmr4517508qvb.6.1686755991025; Wed, 14 Jun 2023 08:19:51 -0700 (PDT) X-Received: by 2002:a05:6214:29ec:b0:62d:fc81:44fc with SMTP id jv12-20020a05621429ec00b0062dfc8144fcmr4517487qvb.6.1686755990729; Wed, 14 Jun 2023 08:19:50 -0700 (PDT) Received: from x1n (cpe5c7695f3aee0-cm5c7695f3aede.cpe.net.cable.rogers.com. [99.254.144.39]) by smtp.gmail.com with ESMTPSA id y13-20020a0cec0d000000b006215d0bdf37sm4768906qvo.16.2023.06.14.08.19.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Jun 2023 08:19:50 -0700 (PDT) Date: Wed, 14 Jun 2023 11:19:48 -0400 From: Peter Xu To: Matthew Wilcox Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, Andrea Arcangeli , John Hubbard , Mike Rapoport , David Hildenbrand , Vlastimil Babka , "Kirill A . Shutemov" , Andrew Morton , Mike Kravetz , James Houghton , Hugh Dickins Subject: Re: [PATCH 6/7] mm/gup: Accelerate thp gup even for "pages != NULL" Message-ID: References: <20230613215346.1022773-1-peterx@redhat.com> <20230613215346.1022773-7-peterx@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE 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 On Wed, Jun 14, 2023 at 03:58:34PM +0100, Matthew Wilcox wrote: > On Tue, Jun 13, 2023 at 05:53:45PM -0400, Peter Xu wrote: > > + if (page_increm > 1) > > + WARN_ON_ONCE( > > + try_grab_folio(compound_head(page), > > You don't need to call compound_head() here; try_grab_folio() works > on tail pages just fine. I did it with caution because two things I'm not sure: either is_pci_p2pdma_page() or is_longterm_pinnable_page() inside, both calls is_zone_device_page() on the page*. But I just noticed try_grab_folio() is also used in gup_pte_range() where the thp can be pte mapped, so I assume we at least need that to handle tail page well. Do we perhaps need the compound_head() in try_grab_folio() as a separate patch? Or maybe I was wrong on is_zone_device_page()? > > > + page_increm - 1, > > + foll_flags) == NULL); > > + > > + for (j = 0; j < page_increm; j++) { > > + subpage = nth_page(page, j); > > + pages[i+j] = subpage; > > + flush_anon_page(vma, subpage, start + j * PAGE_SIZE); > > + flush_dcache_page(subpage); > > You're better off calling flush_dcache_folio() right at the end. Will do. Thanks, -- Peter Xu