From patchwork Fri Jun 23 14:29:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 13290736 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 52D4EEB64D7 for ; Fri, 23 Jun 2023 14:29:54 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7E1598D0007; Fri, 23 Jun 2023 10:29:51 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 76D318D0001; Fri, 23 Jun 2023 10:29:51 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4D4EF8D0007; Fri, 23 Jun 2023 10:29:51 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 2191E8D0001 for ; Fri, 23 Jun 2023 10:29:51 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 5D91BB0773 for ; Fri, 23 Jun 2023 14:29:50 +0000 (UTC) X-FDA: 80934246540.27.1C492A1 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf07.hostedemail.com (Postfix) with ESMTP id 2C97D4000B for ; Fri, 23 Jun 2023 14:29:47 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=X4mGpUJu; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf07.hostedemail.com: domain of peterx@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=peterx@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1687530588; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=eaaAtm4E0YzeLzCpC+sle/rLwyV4UWhhjWGc4/kvdNw=; b=aXmoQyiyCFQ04m5nCCSCzgvhcGTYSavhNQ8OzzVkusxrn3c3aeTKtApKaXJJeGHhVz4pGS VxSXI4LyOX66LGt5g395b4wYylv3DvqvlPrxpnbOQmeMXOS9KHdDgoJv7IHEHzFUeODwQx FBHZa3NQ/MX1ySQ0ZRyGt1EEXpIloNs= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=X4mGpUJu; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf07.hostedemail.com: domain of peterx@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=peterx@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1687530588; a=rsa-sha256; cv=none; b=FpPGYBwYPHxKtl4IlB60hZ+i/Rl9T3eOgG64OY+fBgKyL9NlUNSrRzFaP19wj4yXZzXQ/D YwYJ575O68Q4CEgMfrLhJ4EhtHdRs8KfW6PM4+JewCpTpDKDrKTKbYwn5MLOrOwxGHf8ik mPFbpTNgo8teLjt266EM1zosl4Bs4NA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1687530587; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=eaaAtm4E0YzeLzCpC+sle/rLwyV4UWhhjWGc4/kvdNw=; b=X4mGpUJu0HM6D/wdIQYuxUSGyIomYMKWFN3eXeeKfT4QajP7Y5U3tMc6B4T00EH9+kwAZE S4WX5VXQTJ5AK5sPTRFcro/hknHP5ab/pMYS7wYUAuVGzLA9jDvGAWiolA+kEV+XoD/hVP PBa9z5buZbfxdjyjPs8A+h2ezP1juqU= Received: from mail-oi1-f197.google.com (mail-oi1-f197.google.com [209.85.167.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-500-4kPAkvUWMOCq6zKq1tIVyg-1; Fri, 23 Jun 2023 10:29:46 -0400 X-MC-Unique: 4kPAkvUWMOCq6zKq1tIVyg-1 Received: by mail-oi1-f197.google.com with SMTP id 5614622812f47-39f2b870dd5so48947b6e.0 for ; Fri, 23 Jun 2023 07:29:46 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687530585; x=1690122585; 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=eaaAtm4E0YzeLzCpC+sle/rLwyV4UWhhjWGc4/kvdNw=; b=Akl0GEbCc/f993LjTQ7m79Vyeo7dJzElIx5iFFxwm+NG9cI5gbFWlKSXVuE1kFxeRj dZOO/E50rOGOVFiSSdt35Th/3PO8CmpKdmOs24Dz/V0PPuwQ48PQoi+T6ffxIDdM4qIr H4yipoOTjslGASmLTYbj+y3LJfd3awkXeEyGqtj2+rxcSSghoSXb66D4ttYYRSbPGajY P8BeOVMZX/5i3zkaP4XunJ5Hs5q2k4SVutKbWld3gJzarlNUzqmpf4P2/3cIX6TQE3Zy hFmTIAWqQKxkph369mveEGWbNta6jgzEVnjZ9KXdtX59T90ISYwOTY9y80fjO32Vs0if QGWw== X-Gm-Message-State: AC+VfDzOC1uY/6fAePbAWrf6xJGsLfXwO8jkkyLPcOF3sF2k+uUNm7gI n2BE4owF9tw6IayFnMt9vyvcMDBE2u/awahGbWZ89py5lCk+yV7+34v4Qr33Pue7VWxGRiPKUwf DUvr3rgqk+ufPxTzZrZJuhugYrN9byiQ3jcNgmJ+ImmKjRsNK/PwHSJx2P+QSkmxSVJgJ X-Received: by 2002:aca:e1c6:0:b0:397:f116:8f67 with SMTP id y189-20020acae1c6000000b00397f1168f67mr15159999oig.0.1687530585313; Fri, 23 Jun 2023 07:29:45 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6GO65T8HReZxqXh+dPcy+HPwi177tHnPRkclvjCV4jFXu/xj5JsB/zleCQUHHU+pcmmBAOMw== X-Received: by 2002:aca:e1c6:0:b0:397:f116:8f67 with SMTP id y189-20020acae1c6000000b00397f1168f67mr15159971oig.0.1687530584997; Fri, 23 Jun 2023 07:29:44 -0700 (PDT) Received: from x1n.. (cpe5c7695f3aee0-cm5c7695f3aede.cpe.net.cable.rogers.com. [99.254.144.39]) by smtp.gmail.com with ESMTPSA id b9-20020a0cc989000000b0062821057ac7sm5104827qvk.39.2023.06.23.07.29.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Jun 2023 07:29:44 -0700 (PDT) From: Peter Xu To: linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: Lorenzo Stoakes , John Hubbard , Andrew Morton , Mike Rapoport , David Hildenbrand , peterx@redhat.com, Yang Shi , Andrea Arcangeli , Vlastimil Babka , "Kirill A . Shutemov" , James Houghton , Matthew Wilcox , Mike Kravetz , Hugh Dickins , Jason Gunthorpe Subject: [PATCH v3 4/8] mm/gup: Cleanup next_page handling Date: Fri, 23 Jun 2023 10:29:32 -0400 Message-Id: <20230623142936.268456-5-peterx@redhat.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230623142936.268456-1-peterx@redhat.com> References: <20230623142936.268456-1-peterx@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 2C97D4000B X-Stat-Signature: j7u9xaetaha884xy91uurhij8sfwhk5j X-Rspam-User: X-HE-Tag: 1687530587-173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RSStH/0XQenNeBC/ddruAXnagM6jU19YP+5pJDPFoiz9MpUK1e9Fhfu/GXGG0ERQ3J/lag2tbYt4L2bSBQAhZ6Szx1q/sdrnFZ1sF8YB+/zldbJWCRk+iLkqCZ9f/s/xWoyTFdNjFpVWQjZLxUOtD9UGuqBngFU01kXBCpZTPkPnJ1EAmBNG5DY40xQIEbr4Lt6OpRl+kSiG7KEpNDobuKisLdE6yJ4z6AHlHtwu8TpVXguh0V0t/Jvyzr5ZHiRQaZNjVy5E1V89JStOnR3S9Zgb0kQeb9j9eATS6hp5ytl56Cs1xP8fIuvsZqYC9m1gCnLHiuP4zUtCnhBAlWmi+Gu4Yn4+G0SnJoc9bOXRp7DIcr1MHYWWtEJ2rJLNtjrLsSFC0LbZA= 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: 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 Acked-by: David Hildenbrand Signed-off-by: Peter Xu --- 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 = get_gate_page(mm, start & PAGE_MASK, gup_flags, &vma, - pages ? &pages[i] : NULL); + pages ? &page : NULL); if (ret) goto out; ctx.page_mask = 0; @@ -1194,19 +1194,18 @@ static long __get_user_pages(struct mm_struct *mm, ret = PTR_ERR(page); goto out; } - - goto next_page; } else if (IS_ERR(page)) { ret = PTR_ERR(page); goto out; } +next_page: if (pages) { pages[i] = page; flush_anon_page(vma, page, start); flush_dcache_page(page); ctx.page_mask = 0; } -next_page: + page_increm = 1 + (~(start >> PAGE_SHIFT) & ctx.page_mask); if (page_increm > nr_pages) page_increm = nr_pages;