Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1592329pxb; Thu, 4 Feb 2021 17:55:19 -0800 (PST) X-Google-Smtp-Source: ABdhPJxMEmsI0er13pd1oSPcg1nmqnxhiqugzA0D8Ca8ivT4mVFLk5Ukg11dH0MWbMKZ9waK+PUg X-Received: by 2002:a05:6402:1013:: with SMTP id c19mr1344276edu.298.1612490118985; Thu, 04 Feb 2021 17:55:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612490118; cv=none; d=google.com; s=arc-20160816; b=aCJNQZggJ7Tg1VxZt1NX/7Xnx+jx9gP3SHPUiCCrjh8yS9dflNJKIAGI8SLyfsFye/ eJdvPCe32NXXEaS+axfXkQdzrm6AUQq4ke/RXUXuMltuLDUsXK/XiZMj5LBbBrqbCqZd MVNXhSKuSLoXiTmHhY6onDV/aAVor/KHxAhsx2vxrzVzJmS8xX77dYGsBlOZj04F5H7W Qfd5yksp/Zfuub1zc8r/QHBI/zBPjiAY7E8wxSQy2WCPfHGSiAWb10QBtRuQRIwr0dJm mqUlxvfK6i046wxf6+JSTfucVA5ewA2CeyxfisF4bPejS3encWGwAIepR7xbeltpMi4a ZMSQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:dkim-signature:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=LZBSTf8xjFioVk+xSfpLI1dtz0FjIjVaquLfChu0CyU=; b=Y23TLgAlm+5ouyoOYlpwJfPHTsT+SAu+yzAO0OTldY1dJ/EhfYVrrmMwlM11ajDtaP 7Yam2wOAnGhgeKhF2uoksqr/PjByA3xPpW3gHG152hmGOA6XXHnzjtcDattxMJwwVUCp wiS+gDjH7U/tUeaUfPJlIBjnFLPJ01Xmvb7WMT5FYFlDeP19b6NDXsPiI8pkOF9R1REj 6twUd12xkjaDn6mLCt3Q5lKJpFlGA9AytXrmuuHkJDkXqJarshyms6hmsz7xM1W5poeU 1DhXVUAn3ZtuqJAP3XqreCR9wYGG4Zm7RNqqQXTc3pGpD0OV+g9/lmHXvTA/z0WJzlQu WCXA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b=Oa17G4uC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nvidia.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k17si2494147eji.150.2021.02.04.17.54.55; Thu, 04 Feb 2021 17:55:18 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b=Oa17G4uC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nvidia.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230432AbhBDXlD (ORCPT + 99 others); Thu, 4 Feb 2021 18:41:03 -0500 Received: from hqnvemgate26.nvidia.com ([216.228.121.65]:14950 "EHLO hqnvemgate26.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230469AbhBDXk7 (ORCPT ); Thu, 4 Feb 2021 18:40:59 -0500 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== Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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