Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp6852790rwd; Mon, 19 Jun 2023 13:34:52 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ76mQpb7N4hEvc8QpH764+ATqPmvsLY2lb08e2Hizi7uC8Us3VSRJgcFj7SGbGbdOOdFaYF X-Received: by 2002:a05:6a21:9016:b0:117:19d1:8369 with SMTP id tq22-20020a056a21901600b0011719d18369mr9158098pzb.37.1687206892644; Mon, 19 Jun 2023 13:34:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687206892; cv=none; d=google.com; s=arc-20160816; b=g39krRUWoHfC9OgdO5iqUh3ZKmJ1Md+2Jv6qFfiW4pk2NERoM4xyS8Ovr6WBcPvp1y C84AgM3k3STStgzt3Rx25bAahl1Mj7g5ldXZ/Q68O4C4Ie2fk9hvuzhltC++i5NLofmK icSKEkZDls6aS/ZXZI/rle8BJHBrI6QqYQRfvBYt5pQbWhAvLkWAmZs7+dkip32XgU9w 7uSVHX5wj8UGB1rrvPeqa43nvv7LsQD2taO8MyQW6IAwiDGAeUY/DQfhU75j64ooXzQi zY+ogW+nN7OroDxLt+W//5K72KLtPcNdJgHKlVbiATruRLMUwaIsT40ZCLeJEIAvYTJf zc0A== 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=L+7NDxcHQTB4tiGksszjGmWGVz0Hs3EOY3lovbfaDMI=; b=l1zrfPvWBH/Bpi5fvejKMOGs6lQNyYftOUn5IzGcug5aRIwEPN33/EkAJt8P+2Dme/ eJvC/H3YjqBaJG/YAbs7zp6GOsgHCRLbNE4gDpoS32l6o11k7SU/6g4baRdR5igKfxao a7HWcvRQPcH8+8vXr0Jl57Q+CIuJeyNAHiojkiFcpPb8gm7esTi+Jkd2DMwEWTjF2Psj o+TxlEYe+3IW36Q0bVMbV/CLYYw3/4sRcq2grKss/Z6ebyp2GQ9bqCLtxcB7loXSY9of NJhjAS8vZAPCx7+I3tMYTw+bdSPBk7p6iDGaaSDStXpgHfZRaOHDlX+PegvQJ5oXjvKz gxcA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=EJLm31Lq; 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 h2-20020a056a00000200b00643ba887601si165201pfk.307.2023.06.19.13.34.40; Mon, 19 Jun 2023 13:34:52 -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=EJLm31Lq; 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 S229651AbjFSUZW (ORCPT + 99 others); Mon, 19 Jun 2023 16:25:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35020 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229518AbjFSUZU (ORCPT ); Mon, 19 Jun 2023 16:25:20 -0400 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 48485CC for ; Mon, 19 Jun 2023 13:24:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1687206275; 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=L+7NDxcHQTB4tiGksszjGmWGVz0Hs3EOY3lovbfaDMI=; b=EJLm31LqfZLJoQsREcMfryTJw4ELgkTqIgw+Z2w8JEZYjb0Xb49Q+uS5cYFBn8/HWFq1ev Z2KJMXHLWK/CUD8KVEYISVPZ7IJqJJ9zDMi8orXtnQntmCON8idPttQFPLIFCbZotL0VQW vl7bdKLQ7zA2naIeNa5kRe9FyV9gW7I= Received: from mail-qt1-f197.google.com (mail-qt1-f197.google.com [209.85.160.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-497-IaidyvNzPTiD-bAA2DHNSA-1; Mon, 19 Jun 2023 16:24:33 -0400 X-MC-Unique: IaidyvNzPTiD-bAA2DHNSA-1 Received: by mail-qt1-f197.google.com with SMTP id d75a77b69052e-3f8283a3a7aso9957591cf.1 for ; Mon, 19 Jun 2023 13:24:33 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687206273; x=1689798273; 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=L+7NDxcHQTB4tiGksszjGmWGVz0Hs3EOY3lovbfaDMI=; b=AvmQAs37KSRbjAsvnnuo+AMWWUTLAw1395ZWMpmM/EO8JVx/2MvWiY8GEC9fkV+x/7 cPj64orM2zzzykq6/WOay4shI+ujrbLzH5Aj8pMK4be5SR0KRb67bQmfLXaDNe5UcvN1 pkebV0Hsmojy7qHsAfp4OhObV9lxpXdtC3gkT0Uhp5aLWzrxpesbRDHj1yb9tMaJYPbm hCQZDyLfDxVqjsiyE3vJk8v+7ttEVMrFErv7xJo2B7ewYrgrepTcjnMfoBCkHgB389js UpmiVV79FUvMXF7QbLjRqcm5MdMB8WgIZgJwDDHVY22b/c26EaVJ/oLcdKK0NtjZ/oR/ QuUQ== X-Gm-Message-State: AC+VfDxfyiLXCcE/a/JY7EkV+PZq3bFprE/GC+eu3RylwjC30Fc7ELnu r41ivO0a9VgFFWX26ksvoiYS8n6izhP9Q+h/sDqh5oC+tDtFqm6+li2GEtj1lDB9M4+mH9yKMop t/fXjGlOgxPWnZpNkFs89Ce65 X-Received: by 2002:ac8:5842:0:b0:3f9:cb97:f15a with SMTP id h2-20020ac85842000000b003f9cb97f15amr14546253qth.0.1687206273195; Mon, 19 Jun 2023 13:24:33 -0700 (PDT) X-Received: by 2002:ac8:5842:0:b0:3f9:cb97:f15a with SMTP id h2-20020ac85842000000b003f9cb97f15amr14546240qth.0.1687206272971; Mon, 19 Jun 2023 13:24:32 -0700 (PDT) Received: from x1n (cpe5c7695f3aee0-cm5c7695f3aede.cpe.net.cable.rogers.com. [99.254.144.39]) by smtp.gmail.com with ESMTPSA id i10-20020ac860ca000000b003f9cca00552sm238782qtm.93.2023.06.19.13.24.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Jun 2023 13:24:32 -0700 (PDT) Date: Mon, 19 Jun 2023 16:24:31 -0400 From: Peter Xu To: Lorenzo Stoakes Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, Matthew Wilcox , 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, 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 Mon, Jun 19, 2023 at 03:37:30PM -0400, Peter Xu wrote: > Here what I can do is still guard this try_grab_folio() and fail the GUP if > for any reason it failed. Perhaps then it means I'll also keep that one > untouched in hugetlb_follow_page_mask() too. But I suppose keeping the > WARN_ON_ONCE() seems still proper. Here's the outcome that I plan to post in the new version, taking care of try_grab_folio() failures even if it happens, meanwhile remove the compound_head() redundancy on the page. __get_user_pages(): ... ===8<=== /* * This must be a large folio (and doesn't need to * be the whole folio; it can be part of it), do * the refcount work for all the subpages too. * * NOTE: here the page may not be the head page * e.g. when start addr is not thp-size aligned. * try_grab_folio() should have taken care of tail * pages. */ if (page_increm > 1) { struct folio *folio; /* * Since we already hold refcount on the * large folio, this should never fail. */ folio = try_grab_folio(page, page_increm - 1, foll_flags); if (WARN_ON_ONCE(!folio)) { /* * Release the 1st page ref if the * folio is problematic, fail hard. */ gup_put_folio(page_folio(page), 1, foll_flags); ret = -EFAULT; goto out; } } ===8<=== Thanks, -- Peter Xu