From nobody Sun Feb 8 10:48:52 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A45EAEB64DB for ; Mon, 19 Jun 2023 23:11:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229896AbjFSXL4 (ORCPT ); Mon, 19 Jun 2023 19:11:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39850 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229736AbjFSXLn (ORCPT ); Mon, 19 Jun 2023 19:11:43 -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 400FDF9 for ; Mon, 19 Jun 2023 16:10:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1687216254; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=G5PvpMSc9PWeUNzovzE5WASqMyhgs2MBMMaZX0mlkro=; b=HsrfWaFGRNGW7TyqANKJXScYe9zyJOxCR9WJ2uLjTGhDhqAWnatUQY7r1NI3E5AyZZhr0l 3x3Csn0p86ULBAcyHGR1YwyVNu45UN/5trM7b/w/POwyHylavMtMVJwQciwVg6hxa/Ru71 v0exEzuJzbpZ2yI1ce+yxe71MAIgH4M= Received: from mail-qk1-f197.google.com (mail-qk1-f197.google.com [209.85.222.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-367-ADuqldeKOdC8jdP2BC1-Wg-1; Mon, 19 Jun 2023 19:10:53 -0400 X-MC-Unique: ADuqldeKOdC8jdP2BC1-Wg-1 Received: by mail-qk1-f197.google.com with SMTP id af79cd13be357-76077669a5aso105210085a.0 for ; Mon, 19 Jun 2023 16:10:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687216252; x=1689808252; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=G5PvpMSc9PWeUNzovzE5WASqMyhgs2MBMMaZX0mlkro=; b=RF39+mw1lECiHeviN7uE0PT+gnphVOGi182Z5xSfA+KCcVuoCnbin9yzecpBqawujg 1CyKn1G529yVjklqbX+o7KX04WE6HrLCi1gmMXa09esKEcw5AE20nctGqJYUzavBEkYS Yad+9gny8Zqk9xYVFKDkE/ocK3hwyk/DRTxY8a60p4rASuZo8l0P/wJBxqa/cnAlQe9G UHI+az9wzuMV3zfc9vi639V9szqlh7eVk1FXhRxb5QGS6wFU1wwdBg0da3eL2NMLQFxH m88NWspXIc8x/PGDESW4YRd7QheGT056Phsjl5fGVOx9rlTItGXgUAf+ZZt+BwruWtsY +T0A== X-Gm-Message-State: AC+VfDz8GmTaexW9uJ/MPRW5YC5YuLJNvtMVkZt8NOri0rmvlILX/Cd/ SVaJGjX7B8PL7nPT8OUNQmZu0epVBpjiA0GYuaHiJ+MuxZylI+35X5UjCt9t1dCF4WFmwjh3RQI y4OyE6NSN8k4hUocTLaqZwsZq X-Received: by 2002:a05:620a:800e:b0:763:b025:9f40 with SMTP id ee14-20020a05620a800e00b00763b0259f40mr146888qkb.7.1687216252497; Mon, 19 Jun 2023 16:10:52 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5gUaxPapWXj9fyTcJWWnL1Kgv2ncFDRbyXTEYoD6E6DhEtoWY/2AMdIngB3HsMpWlNRnZ+zw== X-Received: by 2002:a05:620a:800e:b0:763:b025:9f40 with SMTP id ee14-20020a05620a800e00b00763b0259f40mr146867qkb.7.1687216252208; Mon, 19 Jun 2023 16:10:52 -0700 (PDT) Received: from x1n.. (cpe5c7695f3aee0-cm5c7695f3aede.cpe.net.cable.rogers.com. [99.254.144.39]) by smtp.gmail.com with ESMTPSA id t15-20020a05620a034f00b007592f2016f4sm405864qkm.110.2023.06.19.16.10.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Jun 2023 16:10:51 -0700 (PDT) From: Peter Xu To: linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: Andrea Arcangeli , Mike Rapoport , David Hildenbrand , Matthew Wilcox , Vlastimil Babka , John Hubbard , "Kirill A . Shutemov" , James Houghton , Andrew Morton , Lorenzo Stoakes , Hugh Dickins , Mike Kravetz , peterx@redhat.com, Jason Gunthorpe Subject: [PATCH v2 4/8] mm/gup: Cleanup next_page handling Date: Mon, 19 Jun 2023 19:10:40 -0400 Message-Id: <20230619231044.112894-5-peterx@redhat.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230619231044.112894-1-peterx@redhat.com> References: <20230619231044.112894-1-peterx@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The only path that doesn't use generic "**pages" handling is the gate vma. Make it use the same path, meanwhile tune the next_page label upper to cover "**pages" handling. This prepares for THP handling for "**pages". Reviewed-by: Lorenzo Stoakes Signed-off-by: Peter Xu Acked-by: David Hildenbrand --- mm/gup.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/mm/gup.c b/mm/gup.c index 9fc9271cba8d..4a00d609033e 100644 --- a/mm/gup.c +++ b/mm/gup.c @@ -1124,7 +1124,7 @@ static long __get_user_pages(struct mm_struct *mm, if (!vma && in_gate_area(mm, start)) { ret =3D get_gate_page(mm, start & PAGE_MASK, gup_flags, &vma, - pages ? &pages[i] : NULL); + pages ? &page : NULL); if (ret) goto out; ctx.page_mask =3D 0; @@ -1194,19 +1194,18 @@ static long __get_user_pages(struct mm_struct *mm, ret =3D PTR_ERR(page); goto out; } - - goto next_page; } else if (IS_ERR(page)) { ret =3D PTR_ERR(page); goto out; } +next_page: if (pages) { pages[i] =3D page; flush_anon_page(vma, page, start); flush_dcache_page(page); ctx.page_mask =3D 0; } -next_page: + page_increm =3D 1 + (~(start >> PAGE_SHIFT) & ctx.page_mask); if (page_increm > nr_pages) page_increm =3D nr_pages; --=20 2.40.1