Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp4427928rwd; Sat, 17 Jun 2023 13:35:43 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5xlfW6juE6lfiVstwlJLfuTSUAZur6cY/22EtCgF+fSsUUCFzHSz8fR4dcoX2OniT0lu1z X-Received: by 2002:a92:c10e:0:b0:340:b1af:bc1b with SMTP id p14-20020a92c10e000000b00340b1afbc1bmr3734655ile.23.1687034142823; Sat, 17 Jun 2023 13:35:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687034142; cv=none; d=google.com; s=arc-20160816; b=p6HH3IrfwtLVCKbQ7f6kheP24UeLyU+U2HACz1R1UoidU7NPjGoaLgfJ1K6Z3+7r/Z jzLd2paxZfYhtztHQVDmQFDZPY1Ml9i/SYkalTYOhPqL2rrX2bq7KwWkr7azZT1Yaxxy G04vFVKL/Is1GryD+6+QPiUaoa0JeNTKPUcjt0VYHFaoZqQ5sz+Jj29sElT8zvIYW6Yh 1a90Izyz0a21E1OE7+zl7BG+bGVCVfKn3+OmwneWWiUeq6VT6D3qCdo3Yfvt8w8MTRp0 N6Nf4kl0nozvncToX0+BUcNuwrqnF6qmIKEl6pnPnUOiiKAf6Re8zALJDwdql0A4z7uW PLNQ== 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=jlLud9fUjWTG1BAYyfaScj42f1iE+kplSpMj/YmXmBc=; b=vBbXKgeD4b2ArcMZe7p3O5pKzdWSv2uWSz7OacRSKdIpnmh/8CrMHvqXpWBqGvtOZE F3GbuyJ2x9R4eojX0Xj0Y3q32qcVGjp0lC5qmXqHRM6Z38UzxKUrivkHob/+vois/k8p 1DJWi+okQMQC9pSnRh5tSwOyeTlhJrPWhHYaDfJfq5DkILxApPawTFR/T1pmxllwKVV1 TKU419ef+elU8CG3qmKjl33Ms2DLXLmHjtOfAO23SdNXnHpSAfvsZu60wUwvEJ1cHHt/ sj508PJ5l2Xal0p1w+1Q/xqUS5NMtAdAUGpqs5AHxzYDX/+4FMvqzsjR8Y3zPQk+ImZ/ W3HQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=KhnI54ST; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n9-20020a170903110900b001b176dc95dbsi12622780plh.593.2023.06.17.13.35.30; Sat, 17 Jun 2023 13:35:42 -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=@gmail.com header.s=20221208 header.b=KhnI54ST; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346328AbjFQTs7 (ORCPT + 99 others); Sat, 17 Jun 2023 15:48:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33748 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235451AbjFQTsu (ORCPT ); Sat, 17 Jun 2023 15:48:50 -0400 Received: from mail-wm1-x332.google.com (mail-wm1-x332.google.com [IPv6:2a00:1450:4864:20::332]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DBEAD1982 for ; Sat, 17 Jun 2023 12:48:42 -0700 (PDT) Received: by mail-wm1-x332.google.com with SMTP id 5b1f17b1804b1-3f906d8fca3so4253035e9.1 for ; Sat, 17 Jun 2023 12:48:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1687031321; x=1689623321; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=jlLud9fUjWTG1BAYyfaScj42f1iE+kplSpMj/YmXmBc=; b=KhnI54STxI15hEJpXsh/ENw0PqfyO9C/kPIsaZXVMi/uN5t5h8CDd00otWlOi74H79 +j3gT+rjwymjKQp4D0lpy8BjV5SwT0r0+HUS8bFwp4NxAD4csfPjvzf4KlDzKdGFG0Mv rkHHtzPBD18oUAEImBCfWOpVEozyCmhs6PuTj7DHo2V12g8/wMTMNdjnkzWQUhtu/3Qw oclL8EqitZdAuYA4a1NrWvt00SmPAs7k7M4lvSrOYeXRkKsYz0oPU1agkKmBrulzgNRY FpweJn3bo1lEr5iMFC89f/2jNNcxCoimEDqL1u8reMUTqsPRJpHocN1NPxVFLK8Q+y2/ kWnw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687031321; x=1689623321; 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=jlLud9fUjWTG1BAYyfaScj42f1iE+kplSpMj/YmXmBc=; b=NvA+PLphki6lU5BiWsm3veki3benBZtiJgy2DPLaMO/3yB1k4E67LQ/0+2hw6bjrNL tWjyfNyBP9oIDlXzLxHwGJiVAZCSZzz681DiGInsGg/0c+PmhAdTPGWPoRACPi5hppjs xxR8pOgKFB3av7gXzK8aqEk2+ml6eOFQYjmKHMnQLdBpu+ke4lKUPdw6aMgJab37lOwR OuUOvgnI5w2iaxA9jiG2sIhGCeS3y4WYxCGSrlA+bFviuZMTzibqyv1SbQ0I1HLS5hGX yI1nL5wmICK7s3RipaBRVP4KouhOnHIpNMsnrsoLvAW8ocPb/1YvEJSsmShHVOSr9T1r Gy3Q== X-Gm-Message-State: AC+VfDwb7jvc73CPoj/03IbzY/iTmwBfgnb7r5jfzLUf1vwv+TQwiS5s 5a83ANQq7ZEvPqLu8r9S0yjjN8xCoiQ= X-Received: by 2002:a1c:7c17:0:b0:3f9:aca:48c3 with SMTP id x23-20020a1c7c17000000b003f90aca48c3mr237960wmc.0.1687031320771; Sat, 17 Jun 2023 12:48:40 -0700 (PDT) Received: from localhost ([2a00:23c5:dc8c:8701:1663:9a35:5a7b:1d76]) by smtp.gmail.com with ESMTPSA id h12-20020adffd4c000000b0031130b9b173sm1675719wrs.34.2023.06.17.12.48.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 17 Jun 2023 12:48:39 -0700 (PDT) Date: Sat, 17 Jun 2023 20:48:38 +0100 From: Lorenzo Stoakes To: Peter Xu 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 5/7] mm/gup: Cleanup next_page handling Message-ID: References: <20230613215346.1022773-1-peterx@redhat.com> <20230613215346.1022773-6-peterx@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230613215346.1022773-6-peterx@redhat.com> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,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 Tue, Jun 13, 2023 at 05:53:44PM -0400, Peter Xu wrote: > 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". > > 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 8d59ae4554e7..a2d1b3c4b104 100644 > --- a/mm/gup.c > +++ b/mm/gup.c > @@ -1135,7 +1135,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); Good spot... ugh that we handled this differently. > if (ret) > goto out; > ctx.page_mask = 0; We can drop this line now right? As the new next_page block will duplicate this. > @@ -1205,19 +1205,18 @@ static long __get_user_pages(struct mm_struct *mm, > ret = PTR_ERR(page); > goto out; > } > - > - goto next_page; This is neat, we've already checked if pages != NULL so the if (pages) block at the new next_page label will not be run. > } 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); I guess there's no harm that we now flush here, though it seems to me to be superfluous, it's not a big deal I don't think. > 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.40.1 > Other than that, LGTM, Reviewed-by: Lorenzo Stoakes