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: 112178 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp5822388vqr; Fri, 23 Jun 2023 07:41:49 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5hIfV0ra1u35T1B5EN99iiP3EVELjo4eGCf7X+w6enCtEJqHrEAC3AmExziocFY49d5ovO X-Received: by 2002:a17:90a:e2c8:b0:25e:b450:c5f1 with SMTP id fr8-20020a17090ae2c800b0025eb450c5f1mr29192069pjb.4.1687531309363; Fri, 23 Jun 2023 07:41:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687531309; cv=none; d=google.com; s=arc-20160816; b=zPlekXO6WVgcu+k46xPxa+NovumJQl/MDBhvM0vbtlwTyZsPs6/PxIjfz1AyNM6S9h jRXWJsRXv0lOU9FVppcT5tqNcRzC/hE0y0X48qU4vWg+H99ll7a4U3EnQ7pfojClXbAO uXzyjfD9QZd3MVOVe04FNHfVnOTDgZn4adfPpHO01DfWdkcMar6Oa6QHuPa97hQLHM79 XvE5/Ys7hicnoqN3X+k3cCLjRDjiyRkC4zLXKM6zSN86/uVNcZ3tAfrP+bb27oY7H73S 3LbiIsCiib2i7dCbQ0+jCiYVHQ/9KAw1eLMhuODGcZjqsj+HB2OuB6DeHIu3WD/fnJGR eXrA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=eaaAtm4E0YzeLzCpC+sle/rLwyV4UWhhjWGc4/kvdNw=; b=SPJoTr0SHI1v5DUDw1y3UQ5+wyBNCbzP6AO4TvkjwHLblAhuXPgROAgWkmaSdWLx5e dknPZjfdAu+FlYCPNNZ/s3YASzW9vZF7D497Z9HZcGhIoh7YnnWFP3HxgQ1u+7zfxt8H xNXOjmGdd3TMc9nhpUtGO/mYpe421cMV+Pt1LHeeTIgOOc2hM+9VytBZ4fUQlyfISffc yV7xP/zevQZGZPh8iQ0kbs8lN6tgQp6AwFfNgoZG1RvUUotTmrT8MkCFH3sdW5PeBnU/ ZpOTNKcSZx9oXfVUK+RrKGLl/RmJL3jQGeF7z/S6JRyk0qo6Cr3X8/O5YP+9ChQxAjC4 +C0Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=LeRVe2Yo; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w191-20020a6382c8000000b00530b3b98fc5si578599pgd.417.2023.06.23.07.41.36; Fri, 23 Jun 2023 07:41:49 -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=LeRVe2Yo; 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 S231970AbjFWOat (ORCPT + 99 others); Fri, 23 Jun 2023 10:30:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58970 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231310AbjFWOab (ORCPT ); Fri, 23 Jun 2023 10:30:31 -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 CBABD1706 for ; Fri, 23 Jun 2023 07:29:47 -0700 (PDT) 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=eaaAtm4E0YzeLzCpC+sle/rLwyV4UWhhjWGc4/kvdNw=; b=LeRVe2YosrM8EFo6DWbVO/StP4LggomZjc2H2pqnTRMLTxU/KPVBk5crAHEy3ic7J63IzP jwsL37jvGaWGCdEyusG7RjAzmxLyjIRDnunrXeQ9y1aNbCvxskBPbIHNcO0OF+6zcVEuXI 1RN68cGB4YSLXpjdv/Btc68UdS5VP5U= Received: from mail-oi1-f198.google.com (mail-oi1-f198.google.com [209.85.167.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-640-eXSct1RDNYqp0SuVv9vN6g-1; Fri, 23 Jun 2023 10:29:46 -0400 X-MC-Unique: eXSct1RDNYqp0SuVv9vN6g-1 Received: by mail-oi1-f198.google.com with SMTP id 5614622812f47-39cabe624deso48380b6e.1 for ; Fri, 23 Jun 2023 07:29:45 -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=gDq/ftp1IK/FhgHav3WPPFUGJa4IDAernAQFeSH6Cnfi/419jzbA2e1OqMRKk/L5lk bGa2XcKKBd/ZRVkaSwNMG0H3Ia6CLwWxy07O4dPnjYkjW/GY9IPqZcBF+QpQWD/TrSwY bJS/QZEiUfvIBHkju8e0zD6hg9DtKczWEMugnLvTF2sTrQcfRWqmAXdstXZSp/QvGPh8 obeLXLAe1/e3ZMk79yjixswi/xhl2+acYTbRWqLEUEbTgJojeIBKzyrUGasC6n9CuEgq 9IRTmry6t+9+gRKw7BX+oL5Mmhh2PMTqIgK9toiNoT3KViFzOhkYhOSNKeRtv6ZG9DKO nltA== X-Gm-Message-State: AC+VfDzakg+vI8ZhpvKeU1979PhKyvoBXaUPtmoRktGL/mKUAQpk0u2G +hXrpzq8vxxqAa8ZdhwIYs5KRup+aGm3rr7SB4jLOdg/kMa3EUyLlFPKNzoomoAf44MWqr1C2j6 J83c17Ip0tjQXBvNMxHp7gv4u X-Received: by 2002:aca:e1c6:0:b0:397:f116:8f67 with SMTP id y189-20020acae1c6000000b00397f1168f67mr15159992oig.0.1687530585229; Fri, 23 Jun 2023 07:29:45 -0700 (PDT) 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-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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1769504830067051860?= X-GMAIL-MSGID: =?utf-8?q?1769504830067051860?= 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;