Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp19861747rwd; Wed, 28 Jun 2023 15:44:53 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4Qrr5RMo8ehgmflwA13Q5kXoGo014AeEu1IzhhWXqBGOh/unfGnOm3bHrF3bjBn0oPqgLf X-Received: by 2002:a17:90a:8a87:b0:25e:f6c0:8327 with SMTP id x7-20020a17090a8a8700b0025ef6c08327mr31607475pjn.47.1687992292850; Wed, 28 Jun 2023 15:44:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687992292; cv=none; d=google.com; s=arc-20160816; b=0tKOlHt9OXWUyIqmnvVOthGzRyNPubQV1OjN0/jy1voBQH22l36sC+2J1Wsw0BRKgw Kc+9e5k15kq1AmSvo0XiG+5eAR29ky/bP5pB2U8IzGVw7RBTCobRMpwZ1Svr4dQzKZZp 4PS3QcFuHKsM6rjg4Ex8vCONZnzQYQe+WZMVPUpk5ma7Z0QIb8g2k2Mvf2OPfIiesDox Wc1RL2X1pfGyK/m2gqdB50BXlsNUeGgoGBG34eiTnhh1xF0rmktZ7Z9Cbw9gY/ndHcXR o2ASbkY0MsYgQBUu98x9V9TB2l3nOCr2mkwb2+eIfLvF+SV7ZaBSi+AiRR1Om08FbjJS uCTA== 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=C1A4ivN2AFC1lD1f3DRS9KX47rVe/ku79YHFPXkOfKI=; fh=YRm1SqlPzCC/sbB3u8ugRd2MBYnp3vC9/g67nUn+DD4=; b=AmdsXkAI2wv+0qOFIn35uIoAVisVusTUURTPJDkGMg9kVlcCOWmx7OgCRNXZtGRusz ybiv8YIjlCvCH/FxIhckLbTGF++vFni+ZZTJLs14RJKFpdS8ZBqEZ5kCbdmWcCmjgHvw gaRMfOSufWtx6QyDSEvmpmInXFmsdUZIL9aEy8X+0DrCAeDgqAVPggebW/dAfr6z+qIk XsrFaJ3Zhlf1SceAK9MT73mYjM8fjB2bsHHngYNgYeVOYlkjLCSuFat4X81aBxucMTRA m8bTsz8nW8Tpfzaxcku3jCJ1hQMZavFl4KCJRWSMBh2DT8lYzthUR4jpqaonkw+SHWxK jC/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Kt5ZAVDd; 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 oc6-20020a17090b1c0600b00262f798b614si6614906pjb.51.2023.06.28.15.44.40; Wed, 28 Jun 2023 15:44: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=Kt5ZAVDd; 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 S232176AbjF1Vyb (ORCPT + 99 others); Wed, 28 Jun 2023 17:54:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37764 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231636AbjF1VyJ (ORCPT ); Wed, 28 Jun 2023 17:54:09 -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 7B4CC2110 for ; Wed, 28 Jun 2023 14:53:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1687989199; 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=C1A4ivN2AFC1lD1f3DRS9KX47rVe/ku79YHFPXkOfKI=; b=Kt5ZAVDdr/jVhGx1pHDLciGBS5vMnFB4Ut2NcAbS5uYT0z1LRk4hQLNBXKmPIjBybkDoLm AKdANP0+1OwJzS32vBeWGapRVMeCNTZFe2u/R+xtmIllhpxxvhar9qT+8Yz29M2ZzGkLZD yNeKT/bQwUxyPULf8pU1+t2udNgVMzA= Received: from mail-qv1-f71.google.com (mail-qv1-f71.google.com [209.85.219.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-244-Repg9S1sOki2fFtIypOy6g-1; Wed, 28 Jun 2023 17:53:18 -0400 X-MC-Unique: Repg9S1sOki2fFtIypOy6g-1 Received: by mail-qv1-f71.google.com with SMTP id 6a1803df08f44-635df023844so9736d6.1 for ; Wed, 28 Jun 2023 14:53:18 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687989198; x=1690581198; 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=C1A4ivN2AFC1lD1f3DRS9KX47rVe/ku79YHFPXkOfKI=; b=HWx37WgvLrFAFvxRb62f5CdxN3t01hlsq6cxG3AnCyKUUEpok9TcaPw1vwHxZG0R0o 77DjUbORdmvzfWWI2We12w/1k8+s4RDFlnTKf2W8vGrlMwQjx62zem4XoyBJz5Tpwbv7 rn1uWdKAOzxaP1kWMH/tAuKPfi7zX2c1MCiPxJjoeOst2e3xFEgHRf1IcRsZw2O5wi3c sbZBFEubftghBFpdTo2oc4Ub2XZmiZjuYOEr/3oMo36dpn5Pgc1dya/hzVxUrVRr4H2V DTq2XqOxWXDJyM6rI/IcS0Ioz2dfA6JLq7EPnFaq3j/fqoQJNVEvGYMZEVRrjKFug3rJ ltCw== X-Gm-Message-State: AC+VfDyRO6WFc7FoUjC8DN5IyZSrXHH+GuGoKX3yPLZzYGrsNkw/rJXa Dqr0SpJ/O6sZIi9Gp0jjPi9GV6N/UE0ltlTEjT/FqIBgSYipXRhF65K+C1vrri452OcBKvYw1Oi e0Sir6apH8lgLdGocPyuIWGOP X-Received: by 2002:a05:6214:301a:b0:635:da19:a67f with SMTP id ke26-20020a056214301a00b00635da19a67fmr13098204qvb.1.1687989198001; Wed, 28 Jun 2023 14:53:18 -0700 (PDT) X-Received: by 2002:a05:6214:301a:b0:635:da19:a67f with SMTP id ke26-20020a056214301a00b00635da19a67fmr13098180qvb.1.1687989197705; Wed, 28 Jun 2023 14:53:17 -0700 (PDT) Received: from x1n.. (cpe5c7695f3aee0-cm5c7695f3aede.cpe.net.cable.rogers.com. [99.254.144.39]) by smtp.gmail.com with ESMTPSA id p3-20020a0cfac3000000b00631fea4d5bcsm6277797qvo.95.2023.06.28.14.53.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Jun 2023 14:53:17 -0700 (PDT) From: Peter Xu To: linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: David Hildenbrand , "Kirill A . Shutemov" , Andrew Morton , Andrea Arcangeli , Mike Rapoport , John Hubbard , Matthew Wilcox , Mike Kravetz , Vlastimil Babka , Yang Shi , James Houghton , Jason Gunthorpe , Lorenzo Stoakes , Hugh Dickins , peterx@redhat.com Subject: [PATCH v4 4/8] mm/gup: Cleanup next_page handling Date: Wed, 28 Jun 2023 17:53:06 -0400 Message-ID: <20230628215310.73782-5-peterx@redhat.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230628215310.73782-1-peterx@redhat.com> References: <20230628215310.73782-1-peterx@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 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 1e2e23084f3c..5af1be81390b 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; -- 2.41.0