From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,NICE_REPLY_A, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7140FC433DB for ; Fri, 5 Feb 2021 20:07:57 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id CCA9864E2C for ; Fri, 5 Feb 2021 20:07:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CCA9864E2C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=nvidia.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 209456B0006; Fri, 5 Feb 2021 15:07:56 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 1BB4B6B006C; Fri, 5 Feb 2021 15:07:56 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0D10B6B006E; Fri, 5 Feb 2021 15:07:56 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0033.hostedemail.com [216.40.44.33]) by kanga.kvack.org (Postfix) with ESMTP id E71D86B0006 for ; Fri, 5 Feb 2021 15:07:55 -0500 (EST) Received: from smtpin14.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 8EB2A181AEF15 for ; Fri, 5 Feb 2021 20:07:55 +0000 (UTC) X-FDA: 77785300110.14.6EB3F17 Received: from hqnvemgate25.nvidia.com (hqnvemgate25.nvidia.com [216.228.121.64]) by imf01.hostedemail.com (Postfix) with ESMTP id 11B3921EEB10 for ; Fri, 5 Feb 2021 19:54:00 +0000 (UTC) Received: from hqmail.nvidia.com (Not Verified[216.228.121.13]) by hqnvemgate25.nvidia.com (using TLS: TLSv1.2, AES256-SHA) id ; Fri, 05 Feb 2021 11:53:59 -0800 Received: from MacBook-Pro-10.local (172.20.145.6) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Fri, 5 Feb 2021 19:53:58 +0000 Subject: Re: [PATCH v2 1/4] mm/gup: add compound page list iterator To: Joao Martins , CC: , , Andrew Morton , Jason Gunthorpe , Doug Ledford , Matthew Wilcox References: <20210204202500.26474-1-joao.m.martins@oracle.com> <20210204202500.26474-2-joao.m.martins@oracle.com> <74edd971-a80c-78b6-7ab2-5c1f6ba4ade9@nvidia.com> From: John Hubbard Message-ID: <4eececb9-fa0a-eeff-0c1f-79a0afb7da4e@nvidia.com> Date: Fri, 5 Feb 2021 11:53:58 -0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.16; rv:78.0) Gecko/20100101 Thunderbird/78.7.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8"; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [172.20.145.6] X-ClientProxiedBy: HQMAIL107.nvidia.com (172.20.187.13) To HQMAIL107.nvidia.com (172.20.187.13) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1612554839; bh=0h3J4XpgSbnd1qVxTuResEviGJFb7t4ULuzWgVzqm6Y=; h=Subject:To:CC:References:From:Message-ID:Date:User-Agent: MIME-Version:In-Reply-To:Content-Type:Content-Language: Content-Transfer-Encoding:X-Originating-IP:X-ClientProxiedBy; b=J1EL7s+beZe+hOTR8u2crhRqJwPojytXlLfGE4z7O5g60hQTigRJM/n4xeVAszlF2 qUsoIUqGgZ5Q2fhuVsO3JaD3xkvCVpotl0OGxKnwu4EZSMKd0zzyTftg7GDq9sE8HD qmyA2mT+XX9TjJgiSN4nhGM3e+fINEVyMLgZc+WqYNzuSvCUKOl1iZsZuRWRxvUWVm sEDaM3+vicku5i6GBMV03yz2o6gIPds3ZzJYXEc5qEEqj7qM/kaO45ZcA0gsQ7zLlL rYd8UBMVWoAEIHFBYRTlplypwua41+B25dAbNDYhuCO+PjALKdu9EWybriTMviDOv3 sUZr0urn5TA1g== X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 11B3921EEB10 X-Stat-Signature: khg73eg3cr1ftx5fare7jc3o4kfsuxup Received-SPF: none (nvidia.com>: No applicable sender policy available) receiver=imf01; identity=mailfrom; envelope-from=""; helo=hqnvemgate25.nvidia.com; client-ip=216.228.121.64 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1612554840-947956 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: On 2/5/21 2:46 AM, Joao Martins wrote: ...>> If instead you keep npages constant like it naturally wants to be, you could >> just do a "(*ntails)++" in the loop, to take care of *ntails. >> > I didn't do it as such as I would need to deref @ntails per iteration, so > it felt more efficient to do as above. On a second thought, I could alternatively do the > following below, thoughts? > > diff --git a/mm/gup.c b/mm/gup.c > index d68bcb482b11..8defe4f670d5 100644 > --- a/mm/gup.c > +++ b/mm/gup.c > @@ -215,6 +215,32 @@ void unpin_user_page(struct page *page) > } > EXPORT_SYMBOL(unpin_user_page); > > +static inline void compound_next(unsigned long i, unsigned long npages, > + struct page **list, struct page **head, > + unsigned int *ntails) > +{ > + struct page *page; > + unsigned int nr; > + > + if (i >= npages) > + return; > + > + page = compound_head(list[i]); > + for (nr = i + 1; nr < npages; nr++) { > + if (compound_head(list[nr]) != page) > + break; > + } > + > + *head = page; > + *ntails = nr - i; > +} > + Yes, this is cleaner and quite a bit easier to verify that it is correct. > >> However, given that the patch is correct and works as-is, the above is really just >> an optional idea, so please feel free to add: >> >> Reviewed-by: John Hubbard >> >> > Thanks! > > Hopefully I can retain that if the snippet above is preferred? > > Joao > Yes. Still looks good. thanks, -- John Hubbard NVIDIA