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=-7.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=no 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 3B113C433E0 for ; Thu, 4 Feb 2021 23:37:48 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id B9FA664FA8 for ; Thu, 4 Feb 2021 23:37:47 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B9FA664FA8 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 077F26B0006; Thu, 4 Feb 2021 18:37:47 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 029D96B006C; Thu, 4 Feb 2021 18:37:46 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E7F2E6B006E; Thu, 4 Feb 2021 18:37:46 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0079.hostedemail.com [216.40.44.79]) by kanga.kvack.org (Postfix) with ESMTP id D31E76B0006 for ; Thu, 4 Feb 2021 18:37:46 -0500 (EST) Received: from smtpin04.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 9772D1EF1 for ; Thu, 4 Feb 2021 23:37:46 +0000 (UTC) X-FDA: 77782200132.04.order26_1614674275e0 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin04.hostedemail.com (Postfix) with ESMTP id 7E9E9800A332 for ; Thu, 4 Feb 2021 23:37:46 +0000 (UTC) X-HE-Tag: order26_1614674275e0 X-Filterd-Recvd-Size: 3819 Received: from hqnvemgate26.nvidia.com (hqnvemgate26.nvidia.com [216.228.121.65]) by imf46.hostedemail.com (Postfix) with ESMTP for ; Thu, 4 Feb 2021 23:37:45 +0000 (UTC) Received: from hqmail.nvidia.com (Not Verified[216.228.121.13]) by hqnvemgate26.nvidia.com (using TLS: TLSv1.2, AES256-SHA) id ; Thu, 04 Feb 2021 15:37:44 -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; Thu, 4 Feb 2021 23:37:44 +0000 Subject: Re: [PATCH 1/4] mm/gup: add compound page list iterator To: Jason Gunthorpe CC: Joao Martins , , , , Andrew Morton , Doug Ledford , "Matthew Wilcox" References: <20210203220025.8568-1-joao.m.martins@oracle.com> <20210203220025.8568-2-joao.m.martins@oracle.com> <955dbe68-7302-a8bc-f0b5-e9032d7f190e@nvidia.com> <20210204195355.GO4247@nvidia.com> From: John Hubbard Message-ID: <2919605d-f00f-4a07-8420-6b6d0a42081a@nvidia.com> Date: Thu, 4 Feb 2021 15:37:43 -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: <20210204195355.GO4247@nvidia.com> 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: HQMAIL101.nvidia.com (172.20.187.10) To HQMAIL107.nvidia.com (172.20.187.13) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1612481864; bh=LZBSTf8xjFioVk+xSfpLI1dtz0FjIjVaquLfChu0CyU=; 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=Oa17G4uClE/0l17rXVcqb9R0YXdIyNZ6Mbn8DQXHa3eOR3lVtJ5CKZMhg+Nmy9p6Q lKMf0uig/fJ8Hsg9O80poVjSeHBvugVTw+gKnlYoIk7xNVeVcFaKbJ6IKymV3I3KTw h25i1finFISPvrDmje2JnjHU1yBBQhduMygimB4M2ty1j9Y9/BV5CUZ1x6pI+afDR0 Jrv11zMX+So1JSPknhcVjX/7uFSzewiLfvqmYnaHxHSFQ4Zf2pWZDTrBgwkLvGg8ae KCpCJ+UqVpnX2DitbizPmjKKKQ1KXUXY7AI1/gypCzg2TklpkSvx5M+XZs1vIxB9qe DzSwtMC3+lx0Q== 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/4/21 11:53 AM, Jason Gunthorpe wrote: > On Wed, Feb 03, 2021 at 03:00:01PM -0800, John Hubbard wrote: >>> +static inline void compound_next(unsigned long i, unsigned long npages, >>> + struct page **list, struct page **head, >>> + unsigned int *ntails) >>> +{ >>> + if (i >= npages) >>> + return; >>> + >>> + *ntails = count_ntails(list + i, npages - i); >>> + *head = compound_head(list[i]); >>> +} >>> + >>> +#define for_each_compound_head(i, list, npages, head, ntails) \ >> >> When using macros, which are dangerous in general, you have to worry about >> things like name collisions. I really dislike that C has forced this unsafe >> pattern upon us, but of course we are stuck with it, for iterator helpers. >> >> Given that we're stuck, you should probably use names such as __i, __list, etc, >> in the the above #define. Otherwise you could stomp on existing variables. > > Not this macro, it after cpp gets through with it all the macro names > vanish, it can't collide with variables. > Yes, I guess it does just vaporize, because it turns all the args into their substituted values. I was just having flashbacks from similar cases I guess. > The usual worry is you might collide with other #defines, but we don't > seem to worry about that in the kernel > Well, I worry about it a little anyway. haha :) thanks, -- John Hubbard NVIDIA