Received: by 2002:a25:b794:0:0:0:0:0 with SMTP id n20csp5517265ybh; Wed, 7 Aug 2019 07:16:46 -0700 (PDT) X-Google-Smtp-Source: APXvYqzLd63tx5IaRZo6piIlUPr4YrnjI4wF4TlGwz/Oi4BKhevnMjIsTF6lmPm1UFUmr9RP6WIk X-Received: by 2002:a17:90a:372a:: with SMTP id u39mr226753pjb.2.1565187406525; Wed, 07 Aug 2019 07:16:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565187406; cv=none; d=google.com; s=arc-20160816; b=mLtk6TLYQBF1Zj9/QW4VdZLbCHkP5iGYGPcCQKm0s2oOdPt69pxA9O4EofcEpv8/iW 7HTLMsMTl1DEaC0uhQ6whqY647hqHdsWYwwxKYhjCgfXEwpA8LEj8l50OWrd5EQxe37X TnhDraIxpqsblOypa5Xi/Sy7jlavz+2W0BQQMS1hUw+qHJmG8STc6ezA6OBWP4u4JvVA jyWs2hSetE0ARl5B/xeNl1xhc+4/seARs1WSO0Tua1H5QR3wwxsH4+538hY78D5gnNKx nnJY7VA3YEjy/NuWD7IFKmFbQc+dYVg+WTQjUTvPNMHW/tEUIlheQefJ2RmZwSiQrmHH e38w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=hlfBT6TXSUpnllA47N2HUtHetiSK58in3jxlr+iv0pw=; b=cq3bH/RSxBsHI3jIPZhjThPMDKXBg02UQIij+jpjFhM59bhOSjNU9WYYs1Q/zSHpx9 p+Bp01+wE/Z+7MZlekUa1iadAF1Wi9a6Hfk2nXSrjLUImj5D6LXkvpgKCL7o3P0Efvne UqNCCECdTQthImdbvZplGhihDQW0RMOGccgQYb6AI49ISnZGvASdwpXna3f4Ya1r6qpT qShDk1mdquu+GEYis9lR9CpSTp4YSzwIG0RK0aZnq0RfS/2XRXkFDlAiKTelQzdKT8Hf na5OluUNkyCiRicg4+NQvVrDhzccBoGYOhIVGPuMVSvLwjDsFx4NBKgsOczeyFPt9rAO /VTw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=fl04xyXZ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v71si50155774pgd.468.2019.08.07.07.16.30; Wed, 07 Aug 2019 07:16:46 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=fl04xyXZ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729992AbfHGOPW (ORCPT + 99 others); Wed, 7 Aug 2019 10:15:22 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:58940 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729408AbfHGOPW (ORCPT ); Wed, 7 Aug 2019 10:15:22 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=hlfBT6TXSUpnllA47N2HUtHetiSK58in3jxlr+iv0pw=; b=fl04xyXZ1MF4FV7R7c9+2e3mc BnEgn9ziqhqIJRRcqRGXr5xuLz626V4rw1XP31jZzwq1IoksUtAYJUgps0z8pBhH0+FMZFkhISBNx Q5YRJDQd0C6WBWV3zqHiLbtLFAMgbBa3U9JSXYKyw8RJ5M3Pf9JUD8STq452o7t/3toUUCeipkl05 eu2Tihzhn0ue6tHKKThBIn0XkdjBi368CTpA9WdpKwBsxHwpN/izSGN7a10VxkbqlHcs7rNxywvMq PH89XHFpzIT7ys9UqwBp/TiaY+4/2uzjtzf9xtC9fXhtVE6Gk44R+jhXza0R4NTl71C4x7lJJ1jUD VaWCGWKzw==; Received: from willy by bombadil.infradead.org with local (Exim 4.92 #3 (Red Hat Linux)) id 1hvMij-0000L4-QT; Wed, 07 Aug 2019 14:15:17 +0000 Date: Wed, 7 Aug 2019 07:15:17 -0700 From: Matthew Wilcox To: Christoph Hellwig Cc: Linus Torvalds , Thomas =?iso-8859-1?Q?Hellstr=F6m_=28VMware=29?= , Dave Airlie , Thomas Hellstrom , Daniel Vetter , LKML , dri-devel , Jerome Glisse , Jason Gunthorpe , Andrew Morton , Steven Price , Linux-MM Subject: Re: drm pull for v5.3-rc1 Message-ID: <20190807141517.GA5482@bombadil.infradead.org> References: <48890b55-afc5-ced8-5913-5a755ce6c1ab@shipmail.org> <20190806073831.GA26668@infradead.org> <20190806190937.GD30179@bombadil.infradead.org> <20190807064000.GC6002@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190807064000.GC6002@infradead.org> User-Agent: Mutt/1.11.4 (2019-03-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Aug 06, 2019 at 11:40:00PM -0700, Christoph Hellwig wrote: > On Tue, Aug 06, 2019 at 12:09:38PM -0700, Matthew Wilcox wrote: > > Has anyone looked at turning the interface inside-out? ie something like: > > > > struct mm_walk_state state = { .mm = mm, .start = start, .end = end, }; > > > > for_each_page_range(&state, page) { > > ... do something with page ... > > } > > > > with appropriate macrology along the lines of: > > > > #define for_each_page_range(state, page) \ > > while ((page = page_range_walk_next(state))) > > > > Then you don't need to package anything up into structs that are shared > > between the caller and the iterated function. > > I'm not an all that huge fan of super magic macro loops. But in this > case I don't see how it could even work, as we get special callbacks > for huge pages and holes, and people are trying to add a few more ops > as well. We could have bits in the mm_walk_state which indicate what things to return and what things to skip. We could (and probably should) also use different iterator names if people actually want to iterate different things. eg for_each_pte_range(&state, pte) as well as for_each_page_range().