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=-2.1 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,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 0CE27C433FF for ; Wed, 7 Aug 2019 14:15:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D3F7021E6C for ; Wed, 7 Aug 2019 14:15:23 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="fl04xyXZ" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730008AbfHGOPW (ORCPT ); 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().